Skip to content

Commit

Permalink
"REPOSITORY/MDL-13766, separate page and path in get_listing function"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed Feb 18, 2009
1 parent 2aef1fe commit 5fa358d
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 52 deletions.
2 changes: 1 addition & 1 deletion repository/alfresco/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private function get_url($node) {
return $result;
}

public function get_listing($uuid = '', $search = '') {
public function get_listing($uuid = '', $path = '') {
global $CFG;

$ret = array();
Expand Down
2 changes: 1 addition & 1 deletion repository/boxnet/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function search($search_text) {
* @param <type> $path
* @return <type>
*/
public function get_listing($path = '/'){
public function get_listing($path = '/', $page = ''){
global $CFG;
$list = array();
$ret = array();
Expand Down
17 changes: 9 additions & 8 deletions repository/flickr/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@ public function print_login($ajax = true) {
/**
*
* @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;
}
Expand Down Expand Up @@ -187,19 +187,20 @@ public function search($search_text) {

/**
*
* @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);
}

/**
Expand Down
17 changes: 9 additions & 8 deletions repository/flickr_public/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,33 +183,34 @@ public function search($search_text) {

/**
*
* @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;
}
Expand Down
32 changes: 19 additions & 13 deletions repository/javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function repository_get_client($context, $accepted_filetypes = '*', $returnvalue
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
Expand Down Expand Up @@ -361,7 +361,7 @@ function _client() {
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);
Expand Down Expand Up @@ -556,7 +556,7 @@ function _client() {
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);
}
}
}
Expand Down Expand Up @@ -823,9 +823,9 @@ function _client() {
}
_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;
}
Expand Down Expand Up @@ -869,12 +869,13 @@ function _client() {
}
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';
Expand Down Expand Up @@ -908,7 +909,7 @@ function _client() {
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);
})
});
}
Expand Down Expand Up @@ -972,25 +973,30 @@ function _client() {
_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;
params['action']=action;
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');
Expand Down
2 changes: 1 addition & 1 deletion repository/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,7 @@ public function filter(&$value) {
* 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
Expand Down
4 changes: 2 additions & 2 deletions repository/local/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private function _decode_path($path) {
* @return <type>
*/
public function search($search_text) {
return $this->get_listing('', $search_text);
return $this->get_listing('', '', $search_text);
}

/**
Expand All @@ -75,7 +75,7 @@ public function search($search_text) {
* @param <type> $search
* @return <type>
*/
public function get_listing($encodedpath = '', $search = '') {
public function get_listing($encodedpath = '', $page = '', $search = '') {
global $CFG;

try {
Expand Down
2 changes: 1 addition & 1 deletion repository/picasa/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function print_login($ajax = true){
}
}

public function get_listing($path='') {
public function get_listing($path='', $page = '') {
$picasa = new google_picasa(new google_authsub($this->subauthtoken));

$ret = array();
Expand Down
4 changes: 2 additions & 2 deletions repository/remotemoodle/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function print_login($ajax = true) {
* @return <type>
*/
public function search($search_text) {
return $this->get_listing('', $search_text);
return $this->get_listing('', '', $search_text);
}

/**
Expand All @@ -152,7 +152,7 @@ private function ensure_environment() {
* @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
Expand Down
2 changes: 1 addition & 1 deletion repository/s3/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function __construct($repositoryid, $context = SITEID, $options = array()
}
$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();
Expand Down
2 changes: 1 addition & 1 deletion repository/smb/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function get_file($url, $title) {
public function global_search() {
return false;
}
public function get_listing($path='') {
public function get_listing($path='', $page = '') {
global $CFG;
$list = array();
$ret = array();
Expand Down
2 changes: 1 addition & 1 deletion repository/upload/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function print_login($ajax = true) {
* @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;
Expand Down
2 changes: 1 addition & 1 deletion repository/webdav/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function get_file($url, $title) {
public function global_search() {
return false;
}
public function get_listing($path='') {
public function get_listing($path='', $page = '') {
global $CFG;
$list = array();
$ret = array();
Expand Down
2 changes: 1 addition & 1 deletion repository/wikimedia/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public function __construct($repositoryid, $context = SITEID, $options = array()
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);
Expand Down
15 changes: 6 additions & 9 deletions repository/ws.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -130,11 +131,7 @@
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();
Expand Down
2 changes: 1 addition & 1 deletion repository/youtube/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function get_file($url, $title) {
public function global_search() {
return false;
}
public function get_listing($path='') {
public function get_listing($path='', $page = '') {
global $CFG;
$list = array();
$ret = array();
Expand Down

0 comments on commit 5fa358d

Please sign in to comment.