MDL-15488, use paging in tag searching

This commit is contained in:
dongsheng 2008-09-19 04:44:37 +00:00
parent 1baac464df
commit 86e68c2dc7
2 changed files with 47 additions and 9 deletions

View File

@ -120,19 +120,39 @@ class repository_flickr_public extends repository {
* @return <type>
*/
public function search($search_text) {
global $SESSION;
$people = $this->flickr->people_findByEmail($this->flickr_account);
$sess_tag = 'flickr_public_'.$this->id.'_tag';
$sess_text = 'flickr_public_'.$this->id.'_text';
$this->nsid = $people['nsid'];
$tag = optional_param('tag', '', PARAM_CLEANHTML);
$is_paging = optional_param('search_paging', '', PARAM_RAW);
$page = 1;
if (!empty($is_paging)) {
$page = optional_param('p', '', PARAM_INT);
if (!empty($SESSION->$sess_tag)) {
$tag = $SESSION->$sess_tag;
}
if (!empty($SESSION->$sess_text)) {
$search_text = $SESSION->$sess_text;
}
}
if (!empty($tag)) {
$photos = $this->flickr->photos_search(array(
'tags'=>$tag
'tags'=>$tag,
'page'=>$page
));
$SESSION->$sess_tag = $tag;
} else {
$photos = $this->flickr->photos_search(array(
'user_id'=>$this->nsid,
'text'=>$search_text));
$SESSION->$sess_text = $search_text;
}
return $this->build_list($photos);
$ret = array();
$ret['search_result'] = true;
return $this->build_list($photos, $page, &$ret);
}
/**
@ -144,8 +164,9 @@ class repository_flickr_public extends repository {
$people = $this->flickr->people_findByEmail($this->flickr_account);
$this->nsid = $people['nsid'];
$photos = $this->flickr->people_getPublicPhotos($people['nsid'], 'original_format', 25, $path);
$ret = array();
return $this->build_list($photos, $path);
return $this->build_list($photos, $path, &$ret);
}
/**
@ -154,9 +175,8 @@ class repository_flickr_public extends repository {
* @param <type> $path
* @return <type>
*/
private function build_list($photos, $path = 1) {
private function build_list($photos, $path = 1, $ret) {
$photos_url = $this->flickr->urls_getUserPhotos($this->nsid);
$ret = array();
$ret['manage'] = $photos_url;
$ret['list'] = array();
$ret['pages'] = $photos['pages'];
@ -284,7 +304,7 @@ class repository_flickr_public extends repository {
*/
public static function plugin_init() {
//here we create a default instance for this type
repository_static_function('flickr_public','create', 'flickr_public', 0, get_system_context(), array('name' => get_string('repositoryname', 'repository_public'),'email_address' => null),1);
repository_static_function('flickr_public','create', 'flickr_public', 0, get_system_context(), array('name' => get_string('repositoryname', 'repository_flickr_public'),'email_address' => null),1);
}
}

View File

@ -407,7 +407,7 @@ _client.print_footer = function() {
search.innerHTML = '<img src="$CFG->pixpath/a/search.png" /> $strsearch';
oDiv.appendChild(search);
search.onclick = function() {
repository_client_$suffix.search(repository_client_$suffix.repositoryid);
repository_client_$suffix.search_form(repository_client_$suffix.repositoryid);
}
}
// weather we use cache for this instance, this button will reload listing anyway
@ -666,7 +666,11 @@ _client.makepage = function() {
if(_client.ds.pages) {
str += '<div class="fp-paging" id="paging-$suffix">';
for(var i = 1; i <= _client.ds.pages; i++) {
str += '<a onclick="repository_client_$suffix.req('+_client.repositoryid+', '+i+', 0)" href="###">';
if(!_client.ds.search_result){
str += '<a onclick="repository_client_$suffix.req('+_client.repositoryid+', '+i+', 0)" href="###">';
} else {
str += '<a onclick="repository_client_$suffix.search_paging('+_client.repositoryid+', '+i+')" href="###">';
}
str += String(i);
str += '</a> ';
}
@ -674,6 +678,20 @@ _client.makepage = function() {
}
return str;
}
_client.search_paging = function(id, path) {
_client.viewbar.set('disabled', false);
_client.loading('load');
_client.repositoryid = id;
var params = [];
params['p'] = path;
params['env']=_client.env;
params['action']='search';
params['search_paging']='true';
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='+action, _client.req_cb, _client.postdata(params));
}
_client.makepath = function() {
if(_client.viewmode == 0) {
return;
@ -823,7 +841,7 @@ success: function(o) {
dlg.show();
}
}
_client.search = function(id) {
_client.search_form = function(id) {
var params = [];
params['env']=_client.env;
params['sesskey']='$sesskey';