From: moodler Date: Mon, 19 Jan 2009 06:19:26 +0000 (+0000) Subject: repository/picasa MDL-17473 Use picasa description as the filename if it exists X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=d44cee76fa8b67356f38e7ea9341873913423720;p=moodle.git repository/picasa MDL-17473 Use picasa description as the filename if it exists --- diff --git a/lib/googleapi.php b/lib/googleapi.php index f28e64f9a9..f5005be842 100644 --- a/lib/googleapi.php +++ b/lib/googleapi.php @@ -432,14 +432,23 @@ class google_picasa { //hacky... $thumbnailinfo = $mediainfo->group->thumbnail[0]->attributes(); - $files[] = array('title' => (string) $mediainfo->group->title, + // Derive the nicest file name we can + if (!empty($mediainfo->group->description)) { + $title = shorten_text((string)$mediainfo->group->description, 20, false, ''); + $title = clean_filename($title).'.jpg'; + } else { + $title = (string)$mediainfo->group->title; + } + + $files[] = array( + 'title' => $title, 'date' => userdate($gphoto->timestamp), 'size' => (int) $gphoto->size, 'path' => $gphoto->albumid.'/'.$gphoto->id, 'thumbnail' => (string) $thumbnailinfo['url'], 'thumbnail_width' => 72, // 72 is the native maximum dimension 'thumbnail_height' => 72, - 'source' => (string) $fullinfo['url'], + 'source' => (string) $fullinfo['url'] ); } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 3abebbee92..d98fbb615b 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -6842,10 +6842,9 @@ function random_string ($length=15) { * @return string $truncate - shortened string */ -function shorten_text($text, $ideal=30, $exact = false) { +function shorten_text($text, $ideal=30, $exact = false, $ending='...') { global $CFG; - $ending = '...'; // if the plain text is shorter than the maximum length, return the whole text if (strlen(preg_replace('/<.*?>/', '', $text)) <= $ideal) {