"REPOSITORY/MDL-13766, separate page and path in get_listing function"

This commit is contained in:
dongsheng
2009-02-18 06:52:54 +00:00
parent 2aef1fe52f
commit 5fa358d1ce
16 changed files with 57 additions and 52 deletions
+1 -1
View File
@@ -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();
+1 -1
View File
@@ -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();
+9 -8
View File
@@ -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);
}
/**
@@ -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;
}
+19 -13
View 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');
+1 -1
View 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
+2 -2
View File
@@ -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 {
+1 -1
View 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();
+2 -2
View 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
+1 -1
View 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();
+1 -1
View File
@@ -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();
+1 -1
View File
@@ -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;
+1 -1
View 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();
+1 -1
View 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);
+6 -9
View 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();
+1 -1
View 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();