Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-32417: Fixed pagination bug in Flickr search results, also return…

… thumbnail sizes
  • Loading branch information...
commit 6819c4287d9bdaf99420ddadb94f5038ea47ff46 1 parent ead4f18
@marinaglancy marinaglancy authored
Showing with 9 additions and 18 deletions.
  1. +9 −18 repository/flickr/lib.php
View
27 repository/flickr/lib.php
@@ -154,12 +154,12 @@ public function print_login() {
}
/**
+ * Converts result received from phpFlickr::photo_search to Filepicker/repository format
*
* @param mixed $photos
- * @param int $page
* @return array
*/
- private function build_list($photos, $page = 1) {
+ private function build_list($photos) {
$photos_url = $this->flickr->urls_getUserPhotos($this->nsid);
$ret = array();
$ret['manage'] = $photos_url;
@@ -167,11 +167,7 @@ private function build_list($photos, $page = 1) {
$ret['pages'] = $photos['pages'];
$ret['total'] = $photos['total'];
$ret['perpage'] = $photos['perpage'];
- if($page <= $ret['pages']) {
- $ret['page'] = $page;
- } else {
- $ret['page'] = 1;
- }
+ $ret['page'] = $photos['page'];
if (!empty($photos['photo'])) {
foreach ($photos['photo'] as $p) {
if(empty($p['title'])) {
@@ -189,6 +185,7 @@ private function build_list($photos, $page = 1) {
}
$ret['list'][] = array('title'=>$p['title'],'source'=>$p['id'],
'id'=>$p['id'],'thumbnail'=>$this->flickr->buildPhotoURL($p, 'Square'),
+ 'thumbnail_width'=>75, 'thumbnail_height'=>75,
'date'=>'', 'size'=>'unknown', 'url'=>$photos_url.$p['id']);
}
}
@@ -198,6 +195,7 @@ private function build_list($photos, $page = 1) {
/**
*
* @param string $search_text
+ * @param int $page
* @return array
*/
public function search($search_text, $page = 0) {
@@ -205,10 +203,11 @@ public function search($search_text, $page = 0) {
'user_id'=>$this->nsid,
'per_page'=>24,
'extras'=>'original_format',
+ 'page'=>$page,
'text'=>$search_text
));
$ret = $this->build_list($photos);
- $ret['list'] = array_filter($ret['list'], array($this, 'filter'));
+ $ret['list'] = array_filter($ret['list'], array($this, 'filter')); // TODO this breaks pagination
return $ret;
}
@@ -218,16 +217,8 @@ public function search($search_text, $page = 0) {
* @param int $page
* @return array
*/
- 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'=>$page,
- 'extras'=>'original_format'
- ));
- return $this->build_list($photos, $page);
+ public function get_listing($path = '', $page = '') {
+ return $this->search('', $page);
}
public function get_link($photo_id) {
Please sign in to comment.
Something went wrong with that request. Please try again.