]> git.mjollnir.org Git - moodle.git/commitdiff
repository/picasa MDL-17473 Use picasa description as the filename if it exists
authormoodler <moodler>
Mon, 19 Jan 2009 06:19:26 +0000 (06:19 +0000)
committermoodler <moodler>
Mon, 19 Jan 2009 06:19:26 +0000 (06:19 +0000)
lib/googleapi.php
lib/moodlelib.php

index f28e64f9a90b721f6d8063fe5376d63cb48a09cb..f5005be842f84cc4119c6df2e19f929c9f83fda8 100644 (file)
@@ -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']
             );
         }
 
index 3abebbee9248d6907214ff35794d2c1c2f7d3997..d98fbb615b1eae4d44bd36396c93045efe0a463e 100644 (file)
@@ -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) {