Various renaming and code organization changes:
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 24 Jul 2010 18:59:24 +0000 (14:59 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 24 Jul 2010 18:59:24 +0000 (14:59 -0400)
Rename ansel gallery's "default" image to "key" image - it's not a
default for anything, name it appropriately in the code

Move all sql storage related code to Ansel_Storage.

Don't use the share's database to manipulate non-share tables.

18 files changed:
ansel/lib/Api.php
ansel/lib/Block/gallery.php
ansel/lib/Block/my_galleries.php
ansel/lib/Gallery.php
ansel/lib/Gallery/Decorator/Date.php
ansel/lib/GalleryMode/Date.php
ansel/lib/GalleryMode/Normal.php
ansel/lib/ImageGenerator.php
ansel/lib/ImageGenerator/PolaroidThumb.php
ansel/lib/Storage.php
ansel/lib/Tile/DateGallery.php
ansel/lib/Tile/Gallery.php
ansel/lib/View/EmbeddedRenderer/GalleryLink.php
ansel/lib/View/Results.php
ansel/lib/Widget/OtherGalleries.php
ansel/rss.php
ansel/templates/group/category.inc
ansel/templates/group/owner.inc

index fba4852..08ad760 100644 (file)
@@ -550,7 +550,7 @@ class Ansel_Api extends Horde_Registry_Api
      *     (string)slug    Ignore gallery_id, and use this as the slug
      *   </pre>
      *
-     * @return integer  The default image id.
+     * @return integer  The key image id.
      */
     public function getGalleryKeyImage($gallery_id, $params = array())
     {
@@ -564,7 +564,7 @@ class Ansel_Api extends Horde_Registry_Api
             $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
         }
 
-        return $gallery->getDefaultImage(empty($params['style']) ? 'ansel_default' : $params['style']);
+        return $gallery->getKeyImage(empty($params['style']) ? 'ansel_default' : $params['style']);
     }
 
     /**
index 7294f69..7c84e9b 100644 (file)
@@ -119,10 +119,10 @@ class Horde_Block_ansel_gallery extends Horde_Block
                                     true);
         $html .= '<noscript>';
         $html .= $viewurl->link(array('title' => sprintf(_("View %s"), $gallery->get('name'))));
-        if ($iid = $gallery->getDefaultImage('ansel_default') &&
+        if ($iid = $gallery->getKeyImage('ansel_default') &&
             $gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
 
-            $html .= '<img src="' . Ansel::getImageUrl($gallery->getDefaultImage('ansel_default'), 'thumb', true) . '" alt="' . htmlspecialchars($gallery->get('name')) . '" />';
+            $html .= '<img src="' . Ansel::getImageUrl($gallery->getKeyImage('ansel_default'), 'thumb', true) . '" alt="' . htmlspecialchars($gallery->get('name')) . '" />';
         } else {
             $html .= Horde::img('thumb-error.png');
         }
index be3e6e7..aa662d7 100644 (file)
@@ -98,7 +98,7 @@ HEADER;
                                     true);
             $html .= '<tr><td>'
                 . $url->link(array('onmouseout' => '$("ansel_preview").hide();$("ansel_preview").update("");',
-                                   'onmouseover' => 'previewImageMg(event, ' . $gallery->getDefaultImage('ansel_default') . ');'))
+                                   'onmouseover' => 'previewImageMg(event, ' . $gallery->getKeyImage('ansel_default') . ');'))
                 . @htmlspecialchars($gallery->get('name'), ENT_COMPAT, $GLOBALS['registry']->getCharset()) . '</a></td><td>'
                 . strftime($GLOBALS['prefs']->getValue('date_format'), $gallery->get('last_modified'))
                 . '</td><td>' . (int)$gallery->countImages(true) . '</td></tr>';
index 99f6578..0252bba 100644 (file)
@@ -190,7 +190,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
         $image->save();
         $this->updateImageCount(1);
 
-        /* Should this be the default image? */
+        /* Should this be the key image? */
         if ($default) {
             $this->data['attribute_default'] = $image->id;
             $this->clearStacks();
@@ -217,7 +217,6 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
     {
         global $conf;
 
-        //@TODO: Maybe addImage() gets moved to the modeHelper delegate?
         /* Normal is the only view mode that can accurately update gallery counts */
         $vMode = $this->get('view_mode');
         if ($vMode != 'Normal') {
@@ -257,7 +256,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
             }
         }
 
-        /* Should this be the default image? */
+        /* Should this be the key image? */
         if (!$default && $this->data['attribute_default_type'] == 'auto') {
             $this->data['attribute_default'] = $image->id;
             $resetStack = true;
@@ -266,7 +265,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
             $this->data['default_type'] = 'manual';
         }
 
-        /* Reset the gallery default image stacks if needed. */
+        /* Reset the gallery key image stacks if needed. */
         if ($resetStack) {
             $this->clearStacks();
         }
@@ -287,7 +286,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
     }
 
     /**
-     * Clear all of this gallery's default image stacks from the VFS and the
+     * Clear all of this gallery's key image stacks from the VFS and the
      * gallery's data store.
      *
      * @return void
@@ -362,7 +361,6 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
             throw new Horde_Exception_PermissionDenied(sprintf(_("Access denied copying photos to \"%s\"."), $gallery->get('name')));
         }
 
-        $db = $this->getShareOb()->getWriteDb();
         $imgCnt = 0;
         foreach ($images as $imageId) {
             $img = $this->getImage($imageId);
@@ -378,7 +376,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
             // go through Ansel_Tags::writeTags() - this saves us a SELECT query
             // for each tag - just write the data into the DB ourselves.
             $tags = $img->getTags();
-            $query = $this->getShareOb()->getWriteDb()->prepare('INSERT INTO ansel_images_tags (image_id, tag_id) VALUES(' . $newId . ',?);');
+            $query = $GLOBALS['ansel_db']->prepare('INSERT INTO ansel_images_tags (image_id, tag_id) VALUES(' . $newId . ',?);');
             if ($query instanceof PEAR_Error) {
                 throw new Ansel_Exception($query);
             }
@@ -392,11 +390,11 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
 
             /* exif data */
             // First check to see if the exif data was present in the raw data.
-            $count = $db->queryOne('SELECT COUNT(image_id) FROM ansel_image_attributes WHERE image_id = ' . (int) $newId . ';');
+            $count = $GLOBALS['ansel_db']->queryOne('SELECT COUNT(image_id) FROM ansel_image_attributes WHERE image_id = ' . (int) $newId . ';');
             if ($count == 0) {
-                $exif = $db->queryAll('SELECT attr_name, attr_value FROM ansel_image_attributes WHERE image_id = ' . (int) $imageId . ';',null, MDB2_FETCHMODE_ASSOC);
+                $exif = $GLOBALS['ansel_db']->queryAll('SELECT attr_name, attr_value FROM ansel_image_attributes WHERE image_id = ' . (int) $imageId . ';',null, MDB2_FETCHMODE_ASSOC);
                 if (is_array($exif) && count($exif) > 0) {
-                    $insert = $db->prepare('INSERT INTO ansel_image_attributes (image_id, attr_name, attr_value) VALUES (?, ?, ?)');
+                    $insert = $GLOBALS['ansel_db']->prepare('INSERT INTO ansel_image_attributes (image_id, attr_name, attr_value) VALUES (?, ?, ?)');
                     if ($insert instanceof PEAR_Error) {
                         throw new Horde_Exception($insert->getMessage());
                     }
@@ -423,7 +421,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
      */
     public function setImageOrder($imageId, $pos)
     {
-        return $this->getShareOb()->getWriteDb()->exec('UPDATE ansel_images SET image_sort = ' . (int)$pos . ' WHERE image_id = ' . (int)$imageId);
+        return $GLOBALS['ansel_db']->exec('UPDATE ansel_images SET image_sort = ' . (int)$pos . ' WHERE image_id = ' . (int)$imageId);
     }
 
     /**
@@ -574,54 +572,48 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
     }
 
     /**
-     * Returns the default image for this gallery.
-     *
-     * @TODO: Rename default images to 'key' images - they really are not
-     *        'default' in any sense.
+     * Returns the key image for this gallery.
      *
      * @param string $style  Force the use of this style, if it's available
      *                       otherwise use whatever style is choosen for this
      *                       gallery. If prettythumbs are not available then
      *                       we always use ansel_default style.
      *
-     * @return mixed  The image_id of the default image or false.
+     * @return mixed  The image_id of the key image or false.
      */
-    public function getDefaultImage($style = null)
+    public function getKeyImage($style = null)
     {
         /* Get the available styles */
         $styles = $GLOBALS['injector']->getInstance('Ansel_Styles');
 
-       // Check for explicitly requested style
+       /* Check for explicitly requested style */
         if (!is_null($style)) {
             $gal_style = Ansel::getStyleDefinition($style);
         } else {
-            // Use gallery's default.
             $gal_style = $this->getStyle();
             if (!isset($styles[$gal_style['name']])) {
                 $gal_style = $styles['ansel_default'];
             }
         }
-        Horde::logMessage(sprintf("using gallery style: %s in Ansel::getDefaultImage()", $gal_style['name']), 'DEBUG');
+
         if (!empty($gal_style['default_galleryimage_type']) &&
             $gal_style['default_galleryimage_type'] != 'plain') {
 
             $thumbstyle = $gal_style['default_galleryimage_type'];
             $styleHash = $this->getViewHash($thumbstyle, $gal_style['name']);
 
-            // First check for the existence of a default image in the style
-            // we are looking for.
+            /* First check for the existence of a key image in the specified style */
             if (!empty($this->data['attribute_default_prettythumb'])) {
                 $thumbs = @unserialize($this->data['attribute_default_prettythumb']);
             }
             if (!isset($thumbs) || !is_array($thumbs)) {
                 $thumbs = array();
             }
-
             if (!empty($thumbs[$styleHash])) {
                 return $thumbs[$styleHash];
             }
 
-            // Don't already have one, must generate it.
+            /* Don't already have one, must generate it. */
             $params = array('gallery' => $this, 'style' => $gal_style);
             try {
                 $iview = Ansel_ImageGenerator::factory($gal_style['default_galleryimage_type'], $params);
@@ -645,13 +637,12 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
                 // but protect against infinite recursion.
                 Horde::logMessage($e->getMessage(), 'DEBUG');
                 if ($style != 'ansel_default') {
-                    return $this->getDefaultImage('ansel_default');
+                    return $this->getKeyImage('ansel_default');
                 }
-                Horde::logMessage($e->getMessage(), 'ERR');
             }
 
         } else {
-            // We are just using an image thumbnail for the gallery default.
+            /* We are just using an image thumbnail. */
             if ($this->countImages()) {
                 if (!empty($this->data['attribute_default']) &&
                     $this->data['attribute_default'] > 0) {
@@ -666,7 +657,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
             }
 
             if ($this->hasSubGalleries()) {
-                // Fall through to a default image of a sub gallery.
+                /* Fall through to a key image of a sub gallery. */
                 try {
                     $galleries = $GLOBALS['injector']
                         ->getInstance('Ansel_Storage')
@@ -677,7 +668,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
                 }
                 if ($galleries) {
                     foreach ($galleries as $galleryId => $gallery) {
-                        if ($default_img = $gallery->getDefaultImage($style)) {
+                        if ($default_img = $gallery->getKeyImage($style)) {
                             return $default_img;
                         }
                     }
@@ -685,6 +676,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
             }
         }
 
+        /* Could not find a key image */
         return false;
     }
 
@@ -908,8 +900,6 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
         if ($update) {
             $db = $this->getShareOb()->getWriteDb();
             // Manually convert the charset since we're not going through save()
-            // @TODO: Look at this usage - maybe each app's share object should
-            //  have this method or just keep it public?
             $data = $this->getshareOb()->toDriverCharset(array($driver_key => $value));
             $query = $db->prepare('UPDATE ' . $this->getShareOb()->getTable() . ' SET ' . $driver_key . ' = ? WHERE share_id = ?', null, MDB2_PREPARE_MANIP);
             if ($GLOBALS['conf']['ansel_cache']['usecache']) {
index 7c733b1..08612db 100644 (file)
@@ -142,16 +142,16 @@ class Ansel_Gallery_Decorator_Date
     }
 
     /**
-     * Returns the default image for this gallery.
+     * Returns the key image for this gallery.
      *
      * @param string $style  Force the use of this style, if it's available
      *                       otherwise use whatever style is choosen for this
      *                       gallery. If prettythumbs are not available then
      *                       we always use ansel_default style.
      *
-     * @return mixed  The image_id of the default image or false.
+     * @return mixed  The image_id of the key image or false.
      */
-    public function getDefaultImage($style = null)
+    public function getKeyImage($style = null)
     {
         if (count($this->_images)) {
             return reset($this->_images);
index 15187f5..297858e 100644 (file)
@@ -405,7 +405,7 @@ class Ansel_GalleryMode_Date extends Ansel_GalleryMode_Base
             throw new Horde_Exception_PermissionDenied(sprintf(_("Access denied removing photos from \"%s\"."), $gallery->get('name')));
         }
 
-        /* Sanitize image ids, and see if we're removing our default image. */
+        /* Sanitize image ids, and see if we're removing our key image. */
         $ids = array();
         foreach ($images as $imageId) {
             $ids[] = (int)$imageId;
@@ -431,12 +431,7 @@ class Ansel_GalleryMode_Date extends Ansel_GalleryMode_Base
         }
 
         /* Bulk update the images to their new gallery_id */
-        // @TODO: Move this to Ansel_Storage::
-        $result = $this->_gallery->getShareOb()->getWriteDb()->exec('UPDATE ansel_images SET gallery_id = ' . $gallery->id . ' WHERE image_id IN (' . implode(',', $ids) . ')');
-        if ($result instanceof PEAR_Error) {
-            Horde::logMessage($result, 'ERR');
-            throw new Ansel_Exception($result);
-        }
+        $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->setImagesGallery($ids, $gallery->id);
 
         /* Update the gallery counts for each affected gallery */
         if ($this->_gallery->get('has_subgalleries')) {
@@ -503,12 +498,9 @@ class Ansel_GalleryMode_Date extends Ansel_GalleryMode_Base
                                               $image->getVFSName('full'));
         } catch (VFS_Exception $e) {}
 
-        /* Delete from SQL. */
-        // @TODO: Move to Horde_Storage
-        $this->_gallery->getShareOb()->getWriteDb()->exec('DELETE FROM ansel_images WHERE image_id = ' . (int)$image->id);
-
-        /* Remove any attributes */
-        $this->_gallery->getShareOb()->getWriteDb()->exec('DELETE FROM ansel_image_attributes WHERE image_id = ' . (int)$image->id);
+        /* Delete from storage */
+        $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()
+                ->deleteImage($image->id);
 
         if (!$isStack) {
             $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()
index ed4fce2..0f16194 100644 (file)
@@ -158,7 +158,7 @@ class Ansel_GalleryMode_Normal extends Ansel_GalleryMode_Base
             throw new Horde_Exception_PermissionDenied(sprintf(_("Access denied removing photos from \"%s\"."), $gallery->get('name')));
         }
 
-        /* Sanitize image ids, and see if we're removing our default image. */
+        /* Sanitize image ids, and see if we're removing our key image. */
         $ids = array();
         foreach ($images as $imageId) {
             $ids[] = (int)$imageId;
@@ -167,11 +167,7 @@ class Ansel_GalleryMode_Normal extends Ansel_GalleryMode_Base
             }
         }
 
-        $result = $this->_gallery->getShareOb()->getWriteDb()->exec('UPDATE ansel_images SET gallery_id = ' . $gallery->id . ' WHERE image_id IN (' . implode(',', $ids) . ')');
-        if ($result instanceof PEAR_Error) {
-            throw new Ansel_Exception($result->getMessage());
-        }
-
+        $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->setImagesGallery($ids, $gallery->id);
         $this->_gallery->updateImageCount(count($ids), false);
         $gallery->updateImageCount(count($ids), true);
 
@@ -219,12 +215,8 @@ class Ansel_GalleryMode_Normal extends Ansel_GalleryMode_Base
             $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('images')->deleteFile($image->getVFSPath('full'), $image->getVFSName('full'));
         } catch (VFS_Exception $e) {}
 
-        /* Delete from SQL. */
-        $this->_gallery->getShareOb()->getWriteDb()->exec('DELETE FROM ansel_images WHERE image_id = ' . (int)$image->id);
-
-        /* Remove any attributes */
-        $this->_gallery->getShareOb()->getWriteDb()->exec('DELETE FROM ansel_image_attributes WHERE image_id = ' . (int)$image->id);
-
+        /* Delete from storage */
+        $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->deleteImage($image->id);
         if (!$isStack) {
             $this->_gallery->updateImageCount(1, false);
         }
index 1d47192..15a9ff1 100644 (file)
@@ -148,7 +148,7 @@ class Ansel_ImageGenerator
    /**
      * Utility function to return an array of Horde_Images to use in building a
     *  polaroid stack. Returns a random set of 5 images from the gallery, or the
-    *  explicitly set default image plus 4 others.
+    *  explicitly set key image plus 4 others.
      *
      * @return array of Horde_Images
      */
@@ -187,7 +187,7 @@ class Ansel_ImageGenerator
             }
         }
 
-        // Reverse the array to ensure the requested default image
+        // Reverse the array to ensure the requested key image
         // is the last in the array (so it will appear on the top of
         // the stack.
         return array_reverse($images);
index fc453d1..b0bf83f 100644 (file)
@@ -19,7 +19,7 @@ class Ansel_ImageGenerator_PolaroidThumb extends Ansel_ImageGenerator
                               min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']),
                               true);
 
-        /* Don't bother with these effects for a custom gallery default image
+        /* Don't bother with these effects for a custom gallery key image
            (which will have a negative gallery_id). */
         if ($this->_image->gallery > 0) {
             if (is_null($this->_style)) {
index 5b9b5ec..7feca5a 100644 (file)
@@ -1164,6 +1164,39 @@ class Ansel_Storage
     }
 
     /**
+     * Set the gallery id for a set of images. Useful for bulk updating images
+     * when moving from one gallery to another.
+     * 
+     * @param array $image_ids     An array of image ids
+     * @param integer $gallery_id  The gallery id to move the images to.
+     *
+     * @return void
+     * @throws Ansel_Exception
+     */
+    public function setImagesGallery($image_ids, $gallery_id)
+    {
+        $result = $this->_db->exec('UPDATE ansel_images SET gallery_id = ' . $gallery_id . ' WHERE image_id IN (' . implode(',', $image_ids) . ')');
+        if ($result instanceof PEAR_Error) {
+            Horde::logMessage($result, 'ERR');
+            throw new Ansel_Exception($result);
+        }
+    }
+
+    /**
+     * Deletes an Ansel_Image from data storage.
+     *
+     * @param integer $image_id  The image id(s) to remove.
+     *
+     * @return void
+     * @throws Ansel_Exception
+     */
+    public function removeImage($image_id)
+    {
+        $this->_db->exec('DELETE FROM ansel_images WHERE image_id = ' . (int)$image_id);
+        $this->_db->exec('DELETE FROM ansel_image_attributes WHERE image_id = ' . (int)$imageid);
+    }
+    
+    /**
      * Helper function to get a string of field names
      *
      * @return string
index 385cdce..5467508 100644 (file)
@@ -74,7 +74,7 @@ class Ansel_Tile_DateGallery
 
             $thumbstyle = $mini ? 'mini' : $style['thumbstyle'];
             $gallery_image = Ansel::getImageUrl(
-                $dgallery->getDefaultImage(),
+                $dgallery->getKeyImage(),
                 $thumbstyle, true, $style['name']);
 
             // No need to escape alt here since it's generated enitrely within
index d297855..287e231 100644 (file)
@@ -52,7 +52,7 @@ class Ansel_Tile_Gallery
                 $gallery_image = Horde::img('gallery-locked.png');
             } else {
                 $gallery_image = Ansel::getImageUrl(
-                    $gallery->getDefaultImage($style['name']),
+                    $gallery->getKeyImage($style['name']),
                     $thumbstyle, true, $style['name']);
                 $gallery_image = '<img src="' . $gallery_image . '" alt="' . htmlspecialchars($gallery->get('name')) . '" />';
             }
index f1ef3be..4ce6206 100644 (file)
@@ -65,20 +65,20 @@ class Ansel_View_EmbeddedRenderer_GalleryLink extends Ansel_View_Gallery
                 return '';
             }
 
-            /* Ideally, since gallery default images are unique in that each style
+            /* Ideally, since gallery key images are unique in that each style
              * needs it's own unique image_id, the thumbsize and style parameters
              * are mutually exclusive - specifying a specific gallery style is only
              * needed if requesting the prettythumb thumbsize value. Make sure that
              * both were not passed in.
              */
             if ($thumbsize == 'thumb') {
-                $images[] = $gallery->getDefaultImage('ansel_default');
+                $images[] = $gallery->getKeyImage('ansel_default');
             } else {
                 // Default to gallery's defined style if not provided.
                 $gallery_style = empty($this->_params['style']) ?
                 $gallery->get('style') :
                 $this->_params['style'];
-                $images[] = $gallery->getDefaultImage($gallery_style);
+                $images[] = $gallery->getKeyImage($gallery_style);
             }
         }
         $json = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImageJson($images, null, true, $thumbsize, true);
index ea13917..3b00675 100644 (file)
@@ -28,8 +28,7 @@ class Ansel_View_Results extends Ansel_View_Base
     /**
      * Contructor.
      *
-     * Also handles any actions from the view. TODO: These should be done with
-     * an init() or handle() method instead.
+     * Also handles any actions from the view.
      *
      * @return Ansel_View_Results
      */
index c719c69..2b84514 100644 (file)
@@ -90,7 +90,7 @@ class Ansel_Widget_OtherGalleries extends Ansel_Widget_Base
                 $parent = array_pop($parents);
             }
 
-            $img = (string)Ansel::getImageUrl($gal->getDefaultImage('ansel_default'), 'mini', true);
+            $img = (string)Ansel::getImageUrl($gal->getKeyImage('ansel_default'), 'mini', true);
             $link = Ansel::getUrlFor('view', array('gallery' => $gal->id,
                                                    'slug' => $gal->get('slug'),
                                                    'view' => 'Gallery'),
index f5fad6d..43abc55 100644 (file)
@@ -92,7 +92,7 @@ if (empty($rss)) {
                 $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages($subs);
             } else {
                 $images = $gallery->getRecentImages();
-                $owner = &$gallery->getOwner();
+                $owner = $gallery->getIdentity();
                 $author = $owner->getValue('from_addr');
             }
         }
@@ -105,7 +105,7 @@ if (empty($rss)) {
                                         array('view' => 'Gallery',
                                               'gallery' => $id),
                                         true);
-            $img = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($gallery->getDefaultImage('ansel_default'));
+            $img = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($gallery->getKeyImage('ansel_default'));
             $params = array('last_modified' => $gallery->get('last_modified'),
                             'name' => sprintf(_("%s on %s"),
                                               $gallery->get('name'),
index a0c622b..66b14f6 100644 (file)
@@ -42,7 +42,7 @@ $mini_count = 0;
 <?php foreach ($preview_gallery as $galleryId => $gallery): ?>
    <td align="center">
     <?php if ($gallery->isOldEnough() && !$gallery->hasPasswd()): ?>
-     <?php echo $link ?><img src="<?php echo Ansel::getImageUrl($gallery->getDefaultImage('ansel_default'), 'mini', false, 'ansel_default'); ?>" alt="<?php echo htmlspecialchars($gallery->get('name'))?>" /></a>
+     <?php echo $link ?><img src="<?php echo Ansel::getImageUrl($gallery->getKeyImage('ansel_default'), 'mini', false, 'ansel_default'); ?>" alt="<?php echo htmlspecialchars($gallery->get('name'))?>" /></a>
     <?php else: ?>
      <?php echo $link . Horde::img('gallery-locked-mini.png') ?></a>
     <?php endif; ?>
index 9b577c6..610cbff 100644 (file)
@@ -48,7 +48,7 @@ $mini_galleries = array_values($mini_galleries);
 <?php for ($i = 0; $i < count($mini_galleries); ++$i): ?>
    <td align="center">
     <?php if ($mini_galleries[$i]->isOldEnough() && !$mini_galleries[$i]->hasPasswd()): ?>
-     <?php echo $link ?><img src="<?php echo Ansel::getImageUrl($mini_galleries[$i]->getDefaultImage('ansel_default'), 'mini', false, 'ansel_default') ?>" alt="<?php echo $owner_title?>" /></a>
+     <?php echo $link ?><img src="<?php echo Ansel::getImageUrl($mini_galleries[$i]->getKeyImage('ansel_default'), 'mini', false, 'ansel_default') ?>" alt="<?php echo $owner_title?>" /></a>
     <?php else: ?>
       <?php echo $link . Horde::img('gallery-locked-mini.png') ?></a>
     <?php endif; ?>