mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-13766, improve repository search, search interface can be defined
in print_search function now!
This commit is contained in:
parent
81de8d8e64
commit
2b9feb5f0e
@ -113,11 +113,12 @@ class repository_flickr extends repository{
|
||||
}
|
||||
public function get_listing($path = '1', $search = ''){
|
||||
global $SESSION;
|
||||
$nsid = get_user_preferences($this->setting.'_nsid', '');
|
||||
$nsid = get_user_preferences($this->setting.'_nsid');
|
||||
$photos_url = $this->flickr->urls_getUserPhotos($nsid);
|
||||
|
||||
if(!empty($search)) {
|
||||
$photos = $this->flickr->photos_search(array(
|
||||
'user_id'=>$nsid,
|
||||
'per_page'=>25,
|
||||
'page'=>$path,
|
||||
'extras'=>'original_format',
|
||||
@ -164,7 +165,9 @@ class repository_flickr extends repository{
|
||||
return false;
|
||||
}
|
||||
public function print_search(){
|
||||
return false;
|
||||
echo '<input name="s" value="" />';
|
||||
parent::print_search();
|
||||
return true;
|
||||
}
|
||||
public function get_file($photo_id, $file = ''){
|
||||
global $CFG;
|
||||
|
@ -54,7 +54,9 @@ class repository_flickr_public extends repository{
|
||||
$this->flickr_account = $this->get_option('public_account');
|
||||
|
||||
if(!empty($this->flickr_account)) {
|
||||
$action = 'list';
|
||||
if(empty($action)){
|
||||
$action = 'list';
|
||||
}
|
||||
} else {
|
||||
$account = optional_param('flickr_account', '', PARAM_RAW);
|
||||
if(!empty($account)) {
|
||||
@ -136,7 +138,9 @@ class repository_flickr_public extends repository{
|
||||
return false;
|
||||
}
|
||||
public function print_search(){
|
||||
return false;
|
||||
parent::print_search();
|
||||
echo '<input type="text" name="s" />';
|
||||
return true;
|
||||
}
|
||||
public function get_file($photo_id, $file = ''){
|
||||
global $CFG;
|
||||
|
@ -840,7 +840,12 @@ abstract class repository {
|
||||
* Show the search screen, if required
|
||||
* @return null
|
||||
*/
|
||||
abstract public function print_search();
|
||||
public function print_search() {
|
||||
echo '<input type="hidden" name="repo_id" value="'.$this->id.'" />';
|
||||
echo '<input type="hidden" name="ctx_id" value="'.$this->context->id.'" />';
|
||||
echo '<input type="hidden" name="seekey" value="'.sesskey().'" />';
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* is it possible to do glboal search?
|
||||
@ -1929,23 +1934,57 @@ _client.req = function(id, path, reset) {
|
||||
params['repo_id']=id;
|
||||
var trans = YAHOO.util.Connect.asyncRequest('POST', '$CFG->httpswwwroot/repository/ws.php?action='+action, _client.req_cb, _client.postdata(params));
|
||||
}
|
||||
_client.search = function(id){
|
||||
var data = window.prompt("$strsearching");
|
||||
if(data == '') {
|
||||
alert('$strnoenter');
|
||||
return;
|
||||
}else if(data == null){
|
||||
return;
|
||||
_client.search_form_cb = {
|
||||
success: function(o) {
|
||||
var el = document.getElementById('fp-search-dlg');
|
||||
if(el){
|
||||
el.innerHTML = '';
|
||||
} else {
|
||||
var el = document.createElement('DIV');
|
||||
el.id = 'fp-search-dlg';
|
||||
}
|
||||
var div1 = document.createElement('DIV');
|
||||
div1.className = 'hd';
|
||||
div1.innerHTML = "$strsearching";
|
||||
var div2 = document.createElement('DIV');
|
||||
div2.className = 'bd';
|
||||
var sform = document.createElement('FORM');
|
||||
sform.method = 'POST';
|
||||
sform.id = "fp-search-form";
|
||||
sform.action = '$CFG->wwwroot/repository/ws.php?action=search';
|
||||
sform.innerHTML = o.responseText;
|
||||
div2.appendChild(sform);
|
||||
el.appendChild(div1);
|
||||
el.appendChild(div2);
|
||||
document.body.appendChild(el);
|
||||
var dlg = new YAHOO.widget.Dialog("fp-search-dlg",{
|
||||
postmethod: 'async',
|
||||
width : "30em",
|
||||
fixedcenter : true,
|
||||
zindex: 666667,
|
||||
visible : false,
|
||||
constraintoviewport : true,
|
||||
buttons : [ { text:"Submit",handler: function(){
|
||||
_client.viewbar.set('disabled', false);
|
||||
_client.loading('load');
|
||||
YAHOO.util.Connect.setForm('fp-search-form', false, false);
|
||||
this.cancel();
|
||||
var trans = YAHOO.util.Connect.asyncRequest('POST',
|
||||
'$CFG->httpswwwroot/repository/ws.php?action=search&env='+_client.env, _client.req_cb);
|
||||
},isDefault:true },
|
||||
{text:"Cancel",handler:function(){this.cancel()}}]
|
||||
});
|
||||
dlg.render();
|
||||
dlg.show();
|
||||
}
|
||||
_client.viewbar.set('disabled', false);
|
||||
_client.loading('load');
|
||||
}
|
||||
_client.search = function(id){
|
||||
var params = [];
|
||||
params['s']=data;
|
||||
params['env']=_client.env;
|
||||
params['sesskey']='$sesskey';
|
||||
params['ctx_id']=$context->id;
|
||||
params['repo_id']=id;
|
||||
var trans = YAHOO.util.Connect.asyncRequest('POST', '$CFG->httpswwwroot/repository/ws.php?action=search', _client.req_cb, _client.postdata(params));
|
||||
var trans = YAHOO.util.Connect.asyncRequest('POST', '$CFG->httpswwwroot/repository/ws.php?action=searchform', _client.search_form_cb, _client.postdata(params));
|
||||
}
|
||||
_client.req_cb = {
|
||||
success: function(o) {
|
||||
|
@ -112,6 +112,9 @@ EOD;
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'searchform':
|
||||
$repo->print_search();
|
||||
break;
|
||||
case 'login':
|
||||
try {
|
||||
echo json_encode($repo->print_login());
|
||||
|
Loading…
x
Reference in New Issue
Block a user