mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'MDL-68954-master' of git://github.com/mihailges/moodle
This commit is contained in:
commit
39885e35f4
1 changed files with 39 additions and 22 deletions
|
@ -296,13 +296,15 @@ class repository_flickr_public extends repository {
|
||||||
$text = !empty($SESSION->{$this->sess_text}) ? $SESSION->{$this->sess_text} : null;
|
$text = !empty($SESSION->{$this->sess_text}) ? $SESSION->{$this->sess_text} : null;
|
||||||
$nsid = !empty($this->nsid) ? $this->nsid : null;
|
$nsid = !empty($this->nsid) ? $this->nsid : null;
|
||||||
|
|
||||||
$photos = $this->flickr->photos_search(array(
|
$photos = $this->flickr->photos_search(
|
||||||
'tags'=>$tag,
|
array(
|
||||||
'page'=>$page,
|
'tags' => $tag,
|
||||||
'per_page'=>24,
|
'page' => $page,
|
||||||
'user_id'=>$nsid,
|
'per_page' => 24,
|
||||||
'license'=>$licenses,
|
'user_id' => $nsid,
|
||||||
'text'=>$text
|
'license' => $licenses,
|
||||||
|
'text' => $text,
|
||||||
|
'media' => 'photos'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$ret['total'] = $photos['total'];
|
$ret['total'] = $photos['total'];
|
||||||
|
@ -340,6 +342,8 @@ class repository_flickr_public extends repository {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function build_list($photos, $page = 1, &$ret) {
|
private function build_list($photos, $page = 1, &$ret) {
|
||||||
|
global $OUTPUT;
|
||||||
|
|
||||||
if (!empty($this->nsid)) {
|
if (!empty($this->nsid)) {
|
||||||
$photos_url = $this->flickr->urls_getUserPhotos($this->nsid);
|
$photos_url = $this->flickr->urls_getUserPhotos($this->nsid);
|
||||||
$ret['manage'] = $photos_url;
|
$ret['manage'] = $photos_url;
|
||||||
|
@ -371,16 +375,23 @@ class repository_flickr_public extends repository {
|
||||||
// append file extension
|
// append file extension
|
||||||
$p['title'] .= $format;
|
$p['title'] .= $format;
|
||||||
}
|
}
|
||||||
|
// Get the thumbnail source URL.
|
||||||
|
$thumbnailsource = $this->flickr->buildPhotoURL($p, 'Square');
|
||||||
|
if (!@getimagesize($thumbnailsource)) {
|
||||||
|
// Use the file extension icon as a thumbnail if the original thumbnail does not exist to avoid
|
||||||
|
// displaying broken thumbnails in the repository.
|
||||||
|
$thumbnailsource = $OUTPUT->image_url(file_extension_icon($p['title'], 90))->out(false);
|
||||||
|
}
|
||||||
$ret['list'][] = array(
|
$ret['list'][] = array(
|
||||||
'title'=>$p['title'],
|
'title' => $p['title'],
|
||||||
'source'=>$p['id'],
|
'source' => $p['id'],
|
||||||
'id'=>$p['id'],
|
'id' => $p['id'],
|
||||||
'thumbnail'=>$this->flickr->buildPhotoURL($p, 'Square'),
|
'thumbnail' => $thumbnailsource,
|
||||||
'date'=>'',
|
'date' => '',
|
||||||
'size'=>'unknown',
|
'size' => 'unknown',
|
||||||
'url'=>'http://www.flickr.com/photos/'.$p['owner'].'/'.$p['id'],
|
'url' => 'http://www.flickr.com/photos/' . $p['owner'] . '/' . $p['id'],
|
||||||
'haslicense'=>true,
|
'haslicense' => true,
|
||||||
'hasauthor'=>true
|
'hasauthor' => true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -452,13 +463,8 @@ class repository_flickr_public extends repository {
|
||||||
*/
|
*/
|
||||||
public function get_file($photoid, $file = '') {
|
public function get_file($photoid, $file = '') {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
$info = $this->flickr->photos_getInfo($photoid);
|
$info = $this->flickr->photos_getInfo($photoid);
|
||||||
if ($info['owner']['realname']) {
|
|
||||||
$author = $info['owner']['realname'];
|
|
||||||
} else {
|
|
||||||
$author = $info['owner']['username'];
|
|
||||||
}
|
|
||||||
$copyright = get_string('author', 'repository') . ': ' . $author;
|
|
||||||
|
|
||||||
// If we can read the original secret, it means that we have access to the original picture.
|
// If we can read the original secret, it means that we have access to the original picture.
|
||||||
if (isset($info['originalsecret'])) {
|
if (isset($info['originalsecret'])) {
|
||||||
|
@ -466,6 +472,17 @@ class repository_flickr_public extends repository {
|
||||||
} else {
|
} else {
|
||||||
$source = $this->build_photo_url($photoid);
|
$source = $this->build_photo_url($photoid);
|
||||||
}
|
}
|
||||||
|
// Make sure the source image exists.
|
||||||
|
if (!@getimagesize($source)) {
|
||||||
|
throw new moodle_exception('cannotdownload', 'repository');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($info['owner']['realname']) {
|
||||||
|
$author = $info['owner']['realname'];
|
||||||
|
} else {
|
||||||
|
$author = $info['owner']['username'];
|
||||||
|
}
|
||||||
|
$copyright = get_string('author', 'repository') . ': ' . $author;
|
||||||
|
|
||||||
$result = parent::get_file($source, $file);
|
$result = parent::get_file($source, $file);
|
||||||
$path = $result['path'];
|
$path = $result['path'];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue