From: dongsheng Date: Wed, 18 Feb 2009 06:52:54 +0000 (+0000) Subject: "REPOSITORY/MDL-13766, separate page and path in get_listing function" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5fa358d1cef3320e8ffa8b2093f84fba40fce084;p=moodle.git "REPOSITORY/MDL-13766, separate page and path in get_listing function" --- diff --git a/repository/alfresco/repository.class.php b/repository/alfresco/repository.class.php index 8df2f06b1e..63700e2759 100755 --- a/repository/alfresco/repository.class.php +++ b/repository/alfresco/repository.class.php @@ -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(); diff --git a/repository/boxnet/repository.class.php b/repository/boxnet/repository.class.php index 0c5c3b93ee..428eeb2b2b 100755 --- a/repository/boxnet/repository.class.php +++ b/repository/boxnet/repository.class.php @@ -172,7 +172,7 @@ class repository_boxnet extends repository { * @param $path * @return */ - public function get_listing($path = '/'){ + public function get_listing($path = '/', $page = ''){ global $CFG; $list = array(); $ret = array(); diff --git a/repository/flickr/repository.class.php b/repository/flickr/repository.class.php index 702c50706a..0e1b2f9181 100755 --- a/repository/flickr/repository.class.php +++ b/repository/flickr/repository.class.php @@ -138,17 +138,17 @@ class repository_flickr extends repository { /** * * @param $photos - * @param $path + * @param $page * @return */ - 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 $path + * @param string $path + * @param int $page * @return */ - 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); } /** diff --git a/repository/flickr_public/repository.class.php b/repository/flickr_public/repository.class.php index 5b4efe8cfc..c960ab96bf 100644 --- a/repository/flickr_public/repository.class.php +++ b/repository/flickr_public/repository.class.php @@ -183,33 +183,34 @@ class repository_flickr_public extends repository { /** * - * @param $path + * @param string $path + * @param int $page * @return */ - 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 $photos - * @param $path + * @param $page * @return */ - 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; } diff --git a/repository/javascript.php b/repository/javascript.php index 7dac62d10c..44a598bc12 100644 --- a/repository/javascript.php +++ b/repository/javascript.php @@ -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 = ' $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 = ''; + str = ''; } else { - str = ''; + str = ''; } 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'); diff --git a/repository/lib.php b/repository/lib.php index d5db5033a9..4ab8d8e848 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -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 diff --git a/repository/local/repository.class.php b/repository/local/repository.class.php index bc5c3c95b2..486be34485 100755 --- a/repository/local/repository.class.php +++ b/repository/local/repository.class.php @@ -65,7 +65,7 @@ class repository_local extends repository { * @return */ 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 $search * @return */ - public function get_listing($encodedpath = '', $search = '') { + public function get_listing($encodedpath = '', $page = '', $search = '') { global $CFG; try { diff --git a/repository/picasa/repository.class.php b/repository/picasa/repository.class.php index 06d9f852c4..7a88d87eca 100644 --- a/repository/picasa/repository.class.php +++ b/repository/picasa/repository.class.php @@ -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(); diff --git a/repository/remotemoodle/repository.class.php b/repository/remotemoodle/repository.class.php index 153930b238..19c14cfccf 100644 --- a/repository/remotemoodle/repository.class.php +++ b/repository/remotemoodle/repository.class.php @@ -128,7 +128,7 @@ class repository_remotemoodle extends repository { * @return */ 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 $search * @return */ - 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 diff --git a/repository/s3/repository.class.php b/repository/s3/repository.class.php index 1a17c8abce..c9c5e1658e 100644 --- a/repository/s3/repository.class.php +++ b/repository/s3/repository.class.php @@ -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(); diff --git a/repository/smb/repository.class.php b/repository/smb/repository.class.php index 343c36bef7..f336f6c55b 100755 --- a/repository/smb/repository.class.php +++ b/repository/smb/repository.class.php @@ -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(); diff --git a/repository/upload/repository.class.php b/repository/upload/repository.class.php index 0161cddcfa..1ed3ae4e44 100755 --- a/repository/upload/repository.class.php +++ b/repository/upload/repository.class.php @@ -50,7 +50,7 @@ class repository_upload extends repository { * @param $search * @return */ - public function get_listing($path='', $search='') { + public function get_listing($path='', $page='') { global $CFG, $action; if($action=='upload'){ return $this->info; diff --git a/repository/webdav/repository.class.php b/repository/webdav/repository.class.php index b99f1f8b0d..83f7a50d1d 100644 --- a/repository/webdav/repository.class.php +++ b/repository/webdav/repository.class.php @@ -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(); diff --git a/repository/wikimedia/repository.class.php b/repository/wikimedia/repository.class.php index f25938c222..9b9801a939 100644 --- a/repository/wikimedia/repository.class.php +++ b/repository/wikimedia/repository.class.php @@ -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); diff --git a/repository/ws.php b/repository/ws.php index e4c07f37a9..95c4fc461b 100644 --- a/repository/ws.php +++ b/repository/ws.php @@ -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(); diff --git a/repository/youtube/repository.class.php b/repository/youtube/repository.class.php index efb0c8e338..095d9f4233 100644 --- a/repository/youtube/repository.class.php +++ b/repository/youtube/repository.class.php @@ -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();