always use Ansel_Style::getHash(), remove duplicate code
authorMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 31 Dec 2010 16:02:39 +0000 (11:02 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 31 Dec 2010 16:02:39 +0000 (11:02 -0500)
ansel/lib/Ansel.php
ansel/lib/Gallery.php
ansel/lib/Image.php
ansel/lib/View/GalleryProperties.php

index 5faabf0..0c7dc0b 100644 (file)
@@ -677,25 +677,6 @@ class Ansel
     }
 
     /**
-     * Return a hash key for the given view and style.
-     *
-     * @param string $view        The view (thumb, prettythumb etc...)
-     * @param Ansel_Style $style  The style object.
-     *
-     * @return string  A md5 hash suitable for use as a key.
-     */
-    static public function getViewHash($view, $style)
-    {
-        if ($view != 'screen' && $view != 'thumb' && $view != 'mini' &&
-            $view != 'full') {
-
-            $view = md5($style->thumbstyle . '.' . $style->background);
-        }
-
-        return $view;
-    }
-
-    /**
      * Get a date parts array containing only enough date parts for the depth
      * we are at. If an empty array is passed, attempt to get the parts from
      * url parametrs. Any missing date parts must be set to 0.
index 7e812db..af1118e 100644 (file)
@@ -753,23 +753,6 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical implements Seria
     }
 
     /**
-     * Return a hash key for the given view and style.
-     *
-     * @param string $view         The view (thumb, etc...)
-     * @param Ansel_Style $style   The style.
-     *
-     * @return string  A md5 hash suitable for use as a key.
-     */
-    public function getViewHash($view, $style = null)
-    {
-        if (empty($style)) {
-            $style = $this->getStyle();
-        }
-
-        return Ansel::getViewHash($view, $style);
-    }
-
-    /**
      * Checks to see if a user has a given permission.
      *
      * @param string $userid       The userid of the user.
index 8505cb9..f851b7a 100644 (file)
@@ -1197,13 +1197,7 @@ class Ansel_Image Implements Iterator
             $style = $gallery->getStyle();
         }
 
-        if ($view == 'thumb' && $style->thumbstyle == 'Thumb') {
-            return $view;
-        }
-
-        $view = md5($style->thumbstyle . '.' . $style->background);
-
-        return $view;
+        return $style->getHash($view);
     }
 
     /**
index d2a3d00..890f487 100644 (file)
@@ -369,7 +369,7 @@ class Ansel_View_GalleryProperties
 
         // Make sure that the style hash is recorded, ignoring non-styled thumbs
         if ($style->thumbstyle != 'Thumb') {
-            $GLOBALS['injector']->getInstance('Ansel_Storage')->ensureHash($gallery->getViewHash('thumb'));
+            $GLOBALS['injector']->getInstance('Ansel_Storage')->ensureHash($gallery->getStyle()->getHash('thumb'));
         }
 
         // Clear the OtherGalleries widget cache