]> git.mjollnir.org Git - moodle.git/commitdiff
"REPOSITORY/MDL-13766, separate page and path in get_listing function"
authordongsheng <dongsheng>
Wed, 18 Feb 2009 06:52:54 +0000 (06:52 +0000)
committerdongsheng <dongsheng>
Wed, 18 Feb 2009 06:52:54 +0000 (06:52 +0000)
16 files changed:
repository/alfresco/repository.class.php
repository/boxnet/repository.class.php
repository/flickr/repository.class.php
repository/flickr_public/repository.class.php
repository/javascript.php
repository/lib.php
repository/local/repository.class.php
repository/picasa/repository.class.php
repository/remotemoodle/repository.class.php
repository/s3/repository.class.php
repository/smb/repository.class.php
repository/upload/repository.class.php
repository/webdav/repository.class.php
repository/wikimedia/repository.class.php
repository/ws.php
repository/youtube/repository.class.php

index 8df2f06b1e32abfb5464efd2cf8134bcd67ba437..63700e2759e297957b8d04fa8e492c248f48d7f4 100755 (executable)
@@ -87,7 +87,7 @@ class repository_alfresco extends repository {
         return $result;
     }
 
-    public function get_listing($uuid = '', $search = '') {
+    public function get_listing($uuid = '', $path = '') {
         global $CFG;
 
         $ret = array();
index 0c5c3b93ee1465c53ea4cdfca3956b93ca739df5..428eeb2b2ba177fccb36c8177d53f56a8ee3e579 100755 (executable)
@@ -172,7 +172,7 @@ class repository_boxnet extends repository {
      * @param <type> $path
      * @return <type>
      */
-    public function get_listing($path = '/'){
+    public function get_listing($path = '/', $page = ''){
         global $CFG;
         $list = array();
         $ret  = array();
index 702c50706afe85487ede8661114d588f8ac973ba..0e1b2f9181df9e4f933fb8ff95cc78b4847eb4d5 100755 (executable)
@@ -138,17 +138,17 @@ class repository_flickr extends repository {
     /**
      *
      * @param <type> $photos
-     * @param <type> $path
+     * @param <type> $page
      * @return <type>
      */
-    private function build_list($photos, $path = 1) {
+    private function build_list($photos, $page = 1) {
         $photos_url = $this->flickr->urls_getUserPhotos($this->nsid);
         $ret = array();
         $ret['manage'] = $photos_url;
         $ret['list']  = array();
         $ret['pages'] = $photos['pages'];
-        if($path <= $ret['pages']) {
-            $ret['page'] = $path;
+        if($page <= $ret['pages']) {
+            $ret['page'] = $page;
         } else {
             $ret['page'] = 1;
         }
@@ -187,19 +187,20 @@ class repository_flickr extends repository {
 
     /**
      *
-     * @param <type> $path
+     * @param string $path
+     * @param int $page
      * @return <type>
      */
-    public function get_listing($path = '1') {
+    public function get_listing($path = '', $page = '1') {
         $photos_url = $this->flickr->urls_getUserPhotos($this->nsid);
 
         $photos = $this->flickr->photos_search(array(
             'user_id'=>$this->nsid,
             'per_page'=>24,
-            'page'=>$path,
+            'page'=>$page,
             'extras'=>'original_format'
             ));
-        return $this->build_list($photos, $path);
+        return $this->build_list($photos, $page);
     }
 
     /**
index 5b4efe8cfc1ff68c0b241f08fcdf9bf58f30d532..c960ab96bf93b6abc2df567d655c8a1c8ad1f43a 100644 (file)
@@ -183,33 +183,34 @@ class repository_flickr_public extends repository {
 
     /**
      *
-     * @param <type> $path
+     * @param string $path
+     * @param int $page
      * @return <type>
      */
-    public function get_listing($path = '1') {
+    public function get_listing($path = '', $page = 1) {
         $people = $this->flickr->people_findByEmail($this->flickr_account);
         $this->nsid = $people['nsid'];
-        $photos = $this->flickr->people_getPublicPhotos($people['nsid'], 'original_format', 24, $path);
+        $photos = $this->flickr->people_getPublicPhotos($people['nsid'], 'original_format', 24, $page);
         $ret = array();
 
-        return $this->build_list($photos, $path, $ret);
+        return $this->build_list($photos, $page, $ret);
     }
 
     /**
      *
      * @param <type> $photos
-     * @param <type> $path
+     * @param <type> $page
      * @return <type>
      */
-    private function build_list($photos, $path = 1, &$ret) {
+    private function build_list($photos, $page = 1, &$ret) {
         if (!empty($this->nsid)) {
             $photos_url = $this->flickr->urls_getUserPhotos($this->nsid);
             $ret['manage'] = $photos_url;
         }
         $ret['list']  = array();
         $ret['pages'] = $photos['pages'];
-        if (is_int($path) && $path <= $ret['pages']) {
-            $ret['page'] = $path;
+        if (is_int($page) && $page <= $ret['pages']) {
+            $ret['page'] = $page;
         } else {
             $ret['page'] = 1;
         }
index 7dac62d10c2a8813fc95cf0c4a41cb23c740c7b4..44a598bc1248d04979ef168d5849f08b7739b56e 100644 (file)
@@ -161,7 +161,7 @@ var mdl_in_array = function(el, arr) {
 
 var active_instance = null;
 function repository_callback(id) {
-    active_instance.req(id, '', 0);
+    active_instance.req(id, '');
 }
 var repository_client_$suffix = (function() {
 // private static field
@@ -361,7 +361,7 @@ _client.print_instances = function() {
             link.onclick = function() {
                 var re = /repo-call-$suffix-(\d+)/i;
                 var id = this.id.match(re);
-                repository_client_$suffix.req(id[1], '', 0);
+                repository_client_$suffix.req(id[1], '');
             }
             link.innerHTML += ' '+repo.name;
             li.appendChild(link);
@@ -556,7 +556,7 @@ _client.print_footer = function() {
         logout.innerHTML = '<img src="$CFG->pixpath/a/logout.png" /> $strlogout';
         oDiv.appendChild(logout);
         logout.onclick = function() {
-            repository_client_$suffix.req(repository_client_$suffix.repositoryid, 1, 1);
+            repository_client_$suffix.logout(repository_client_$suffix.repositoryid, 1);
         }
     }
 }
@@ -823,9 +823,9 @@ _client.uploadcontrol = function() {
 }
 _client.paging_node = function(type, page) {
     if (page == _client.ds.page) {
-        str = '<a class="cur_page" onclick="repository_client_$suffix.'+type+'('+_client.repositoryid+', '+page+', 0)" href="###">';
+        str = '<a class="cur_page" onclick="repository_client_$suffix.'+type+'('+_client.repositoryid+', '+page+', '+page+')" href="###">';
     } else {
-        str = '<a onclick="repository_client_$suffix.'+type+'('+_client.repositoryid+', '+page+', 0)" href="###">';
+        str = '<a onclick="repository_client_$suffix.'+type+'('+_client.repositoryid+', '+page+', '+page+')" href="###">';
     }
     return str;
 }
@@ -869,12 +869,13 @@ _client.makepage = function(id) {
     }
     return str;
 }
-_client.search_paging = function(id, path) {
+_client.search_paging = function(id, path, page) {
     _client.viewbar.set('disabled', false);
     _client.loading('load');
     _client.repositoryid = id;
     var params = [];
     params['p'] = path;
+    params['page'] = page;
     params['env']=_client.env;
     params['action']='search';
     params['search_paging']='true';
@@ -908,7 +909,7 @@ _client.makepath = function() {
             el.path = _client.ds.path[i].path;
             el.on('contentReady', function() {
                 this.on('click', function() {
-                    repository_client_$suffix.req(this.id, this.path, 0);
+                    repository_client_$suffix.req(this.id, this.path);
                 })
             });
         }
@@ -972,15 +973,11 @@ _client.hide = function() {
     _client.viewfiles();
 }
 // request file list or login
-_client.req = function(id, path, logout) {
+_client.req = function(id, path, page) {
     _client.viewbar.set('disabled', false);
     _client.loading('load');
     _client.repositoryid = id;
-    if (logout == 1) {
-        action = 'logout';
-    } else {
-        action = 'list';
-    }
+    action = 'list';
     var params = [];
     params['p'] = path;
     params['env']=_client.env;
@@ -988,9 +985,18 @@ _client.req = function(id, path, logout) {
     params['sesskey']='$sesskey';
     params['ctx_id']=$context->id;
     params['repo_id']=id;
+    if (page) {
+        params['page']=page;
+    }
     params['accepted_types'] = _client.accepted_types;
     var trans = YAHOO.util.Connect.asyncRequest('POST', '$CFG->httpswwwroot/repository/ws.php?action='+action, _client.req_cb, _client.postdata(params));
 }
+_client.logout = function(id) {
+    _client.repositoryid = id;
+    var params = [];
+    params['repo_id'] = id;
+    var trans = YAHOO.util.Connect.asyncRequest('POST', '$CFG->httpswwwroot/repository/ws.php?action=logout', _client.req_cb, _client.postdata(params));
+}
 _client.search_form_cb = {
 success: function(o) {
      var el = document.getElementById('fp-search-dlg');
index d5db5033a9fa023690f91bd8b68551c533eba612..4ab8d8e848999493877ba41e3b70ceda09563e4a 100644 (file)
@@ -1535,7 +1535,7 @@ abstract class repository {
      * a folder name, or a identification of folder
      * @return array the list of files, including meta infomation
      */
-    abstract public function get_listing($parent = '/');
+    abstract public function get_listing($path = '/', $page='');
 
     /**
      * Search files in repository
index bc5c3c95b23cd7faa1c36de3e405759e893b5e8a..486be34485ac90ca7ca00d810face6c762b9211f 100755 (executable)
@@ -65,7 +65,7 @@ class repository_local extends repository {
      * @return <type>
      */
     public function search($search_text) {
-        return $this->get_listing('', $search_text);
+        return $this->get_listing('', '', $search_text);
     }
 
     /**
@@ -75,7 +75,7 @@ class repository_local extends repository {
      * @param <type> $search
      * @return <type>
      */
-    public function get_listing($encodedpath = '', $search = '') {
+    public function get_listing($encodedpath = '', $page = '', $search = '') {
         global $CFG;
 
         try {
index 06d9f852c4e820f6e32fb292e95b23792fdd904f..7a88d87eca98c4e1278e09e62fb3e9d7c9748e6e 100644 (file)
@@ -60,7 +60,7 @@ class repository_picasa extends repository {
         }
     }
 
-    public function get_listing($path='') {
+    public function get_listing($path='', $page = '') {
         $picasa = new google_picasa(new google_authsub($this->subauthtoken));
 
         $ret = array();
index 153930b2381a24f45dd8a41df66d88642c151439..19c14cfccf981c0f6fcc91f57ddcd855855bbe1f 100644 (file)
@@ -128,7 +128,7 @@ class repository_remotemoodle extends repository {
      * @return <type>
      */
     public function search($search_text) {
-        return $this->get_listing('', $search_text);
+        return $this->get_listing('', '', $search_text);
     }
 
     /**
@@ -152,7 +152,7 @@ class repository_remotemoodle extends repository {
      * @param <type> $search
      * @return <type>
      */
-    public function get_listing($encodedpath = '', $search = '') {
+    public function get_listing($encodedpath = '', $page = '', $search = '') {
         global $CFG, $DB, $USER;
 
         ///check that the host has a version >2.0
index 1a17c8abce8f45dc2431e0eac7ba7924c7237bdd..c9c5e1658e9d1bd9a564ce21772dd8862970a6dc 100644 (file)
@@ -11,7 +11,7 @@ class repository_s3 extends repository {
         }
         $this->s = new S3($this->access_key, $this->secret_key);
     }
-    public function get_listing($path = '') {
+    public function get_listing($path = '', $page = '') {
         global $CFG;
         $list = array();
         $list['list'] = array();
index 343c36bef7f712625785d6f90db6833d7b47cb84..f336f6c55bae3f22eabcff658a978454607256fd 100755 (executable)
@@ -44,7 +44,7 @@ class repository_smb extends repository {
     public function global_search() {
         return false;
     }
-    public function get_listing($path='') {
+    public function get_listing($path='', $page = '') {
         global $CFG;
         $list = array();
         $ret  = array();
index 0161cddcfaa6bf7394f16d59e1e6875652fbe01e..1ed3ae4e4453c6e46126ccb8e736846660661f1f 100755 (executable)
@@ -50,7 +50,7 @@ class repository_upload extends repository {
      * @param <type> $search
      * @return <type>
      */
-    public function get_listing($path='', $search='') {
+    public function get_listing($path='', $page='') {
         global $CFG, $action;
         if($action=='upload'){
             return $this->info;
index b99f1f8b0d7527ae8ecf6a26d5c6fc876b83c94e..83f7a50d1d9756d14dcb0a5a2b7f3fc78a60d51a 100644 (file)
@@ -57,7 +57,7 @@ class repository_webdav extends repository {
     public function global_search() {
         return false;
     }
-    public function get_listing($path='') {
+    public function get_listing($path='', $page = '') {
         global $CFG;
         $list = array();
         $ret  = array();
index f25938c222b13c54e270daebb6481ef20475e9ad..9b9801a939ff714dd76b26c7b3130a2c1ca289de 100644 (file)
@@ -6,7 +6,7 @@ class repository_wikimedia extends repository {
         parent::__construct($repositoryid, $context, $options);
         $this->keyword = optional_param('wikimedia_keyword', '', PARAM_RAW);
     }
-    public function get_listing($path = '') {
+    public function get_listing($path = '', $page = '') {
         global $CFG;
         $client = new wikimedia; 
         $result = $client->search_images($this->keyword);
index e4c07f37a94b019d46bbd932a425cf9c682b2175..95c4fc461b9f79b612cadc112b33b0f89f4ce55b 100644 (file)
@@ -7,15 +7,16 @@
     require_once('lib.php');
 
 /// Parameters
-    $p     = optional_param('p', '', PARAM_RAW);              // page or path
+    $page  = optional_param('page', '', PARAM_RAW);           // page
     $env   = optional_param('env', 'filepicker', PARAM_ALPHA);// opened in editor or moodleform
     $file  = optional_param('file', '', PARAM_RAW);           // file to download
     $title = optional_param('title', '', PARAM_FILE);         // new file name
     $itemid = optional_param('itemid', '', PARAM_INT);
     $action = optional_param('action', '', PARAM_ALPHA);
-    $ctx_id  = optional_param('ctx_id', SITEID, PARAM_INT);   // context ID
-    $repo_id = optional_param('repo_id', 1, PARAM_INT);       // repository ID
-    $callback = optional_param('callback', '', PARAM_CLEANHTML);
+    $ctx_id = optional_param('ctx_id', SITEID, PARAM_INT);    // context ID
+    $repo_id   = optional_param('repo_id', 1, PARAM_INT);     // repository ID
+    $req_path  = optional_param('p', '', PARAM_RAW);          // path
+    $callback  = optional_param('callback', '', PARAM_CLEANHTML);
     $search_text = optional_param('s', '', PARAM_CLEANHTML);
 
 /// Headers to make it not cacheable
@@ -130,11 +131,7 @@ EOD;
         case 'list':
             if ($repo->check_login()) {
                 try {
-                    if (!empty($p)) {
-                        echo json_encode($repo->get_listing($p));
-                    } else {
-                        echo json_encode($repo->get_listing());
-                    }
+                    echo json_encode($repo->get_listing($req_path, $page));
                 } catch (repository_exception $e) {
                     $err = new stdclass;
                     $err->e = $e->getMessage();
index efb0c8e338be5592d2ebcca8ddd3cc1c65bebac1..095d9f42332606a77cfc08a688f4b7d971cc9784 100644 (file)
@@ -61,7 +61,7 @@ class repository_youtube extends repository {
     public function global_search() {
         return false;
     }
-    public function get_listing($path='') {
+    public function get_listing($path='', $page = '') {
         global $CFG;
         $list = array();
         $ret  = array();