]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15488, use paging in tag searching
authordongsheng <dongsheng>
Fri, 19 Sep 2008 04:44:37 +0000 (04:44 +0000)
committerdongsheng <dongsheng>
Fri, 19 Sep 2008 04:44:37 +0000 (04:44 +0000)
repository/flickr_public/repository.class.php
repository/javascript.php

index 9552347043f21d6c33dd9c84a307f0a47491d222..57c8530250dd5d6fd8c8e677b5220a7e7ac1189c 100644 (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);
     }
 
 }
index 8b03fa645c4a9c09627801ba3b191f80ecf5c262..d6005e5295fb692461aa70437451882eaa3f6e03 100644 (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';