Implement Ansel_Style
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 16 Sep 2010 00:00:05 +0000 (20:00 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 16 Sep 2010 00:00:05 +0000 (20:00 -0400)
Style info is always passed around as an Ansel_Style object now, except when
calling via the API...which will take a named style.  Also, now optionally pass the
thumbbnail type and background color to the img/* scripts since each gallery now
has it's own copy of the style information. Some other misc. changes...basically
a touchstone commit.

56 files changed:
ansel/gallery/captions.php
ansel/gallery/sort.php
ansel/img/mini.php
ansel/img/prettythumb.php
ansel/img/screen.php
ansel/img/thumb.php
ansel/lib/Ansel.php
ansel/lib/Api.php
ansel/lib/Block/gallery.php
ansel/lib/Block/my_galleries.php
ansel/lib/Block/recent_comments.php
ansel/lib/Block/recently_added.php
ansel/lib/Block/recently_added_geodata.php
ansel/lib/Gallery.php
ansel/lib/Gallery/Decorator/Date.php
ansel/lib/Image.php
ansel/lib/ImageGenerator/PlainStack.php
ansel/lib/ImageGenerator/PolaroidStack.php
ansel/lib/ImageGenerator/PolaroidThumb.php
ansel/lib/ImageGenerator/PrettyThumb.php
ansel/lib/ImageGenerator/RoundedStack.php
ansel/lib/ImageGenerator/ShadowSharpThumb.php
ansel/lib/Storage.php
ansel/lib/Style.php [new file with mode: 0644]
ansel/lib/Tile/DateGallery.php
ansel/lib/Tile/Gallery.php
ansel/lib/Tile/Image.php
ansel/lib/View/Base.php
ansel/lib/View/EmbeddedRenderer/GalleryLink.php
ansel/lib/View/Gallery.php
ansel/lib/View/GalleryProperties.php
ansel/lib/View/GalleryRenderer/Base.php
ansel/lib/View/Image.php
ansel/lib/View/List.php
ansel/lib/View/Results.php
ansel/lib/Widget/Base.php
ansel/lib/Widget/GalleryFaces.php
ansel/lib/Widget/OtherGalleries.php
ansel/lib/Widget/OwnerFaces.php
ansel/report.php
ansel/rss.php
ansel/templates/faces/face.inc
ansel/templates/gallery/partial/_styles.html.php [new file with mode: 0644]
ansel/templates/gallery/properties.html.php
ansel/templates/group/owner.inc
ansel/templates/image/crop_image.inc
ansel/templates/image/edit_image.inc
ansel/templates/image/resize_image.inc
ansel/templates/list/header.inc
ansel/templates/tile/image.inc
ansel/templates/view/gallery.inc
ansel/templates/view/gallerylightbox.inc
ansel/templates/view/image.inc
ansel/templates/view/list.inc
ansel/templates/view/results.inc
ansel/templates/view/slideshow.inc

index cbf2772..0862dd7 100644 (file)
@@ -48,7 +48,6 @@ case 'save':
     }
 
     $notification->push(_("Captions Saved."), 'horde.success');
-    $style = $gallery->getStyle();
     Ansel::getUrlFor('view', array_merge(array('gallery' => $galleryId,
                                                'slug' => $gallery->get('slug'),
                                                'view' => 'Gallery'),
index 9d455ad..d386cd4 100644 (file)
@@ -86,7 +86,7 @@ $notification->notify(array('listeners' => 'status'));
  </form>
 </div>
 
-<div id="sortContainer" style="background:<?php echo $style['background'] ?>">
+<div id="sortContainer" style="background:<?php echo $style->background ?>">
 
 <?php
 $images = $gallery->getImages();
@@ -94,7 +94,7 @@ foreach ($images as $image) {
     $caption = empty($image->caption) ? htmlspecialchars($image->filename, ENT_COMPAT, $GLOBALS['registry']->getCharset()) : htmlspecialchars($image->caption, ENT_COMPAT, $GLOBALS['registry']->getCharset());
     echo '<div id="o_' . (int)$image->id . '"><a title="'
         . $caption . '" href="#">'
-        . '<img src="' . Ansel::getImageUrl($image->id, 'thumb', false, $style['name']) . '" alt="' . htmlspecialchars($image->filename) . '" />'
+        . '<img src="' . Ansel::getImageUrl($image->id, 'thumb', false, $style) . '" alt="' . htmlspecialchars($image->filename) . '" />'
         . '</a></div>';
 }
 echo '</div>';
index 25f5c2f..38dbd2e 100644 (file)
@@ -21,7 +21,7 @@ if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
 if ($conf['vfs']['src'] == 'sendfile') {
     /* Need to ensure the file exists */
     try {
-        $image->createView('mini', 'ansel_default');
+        $image->createView('mini', Ansel::getStyleDefinition('ansel_default'));
     } catch (Horde_Exception $e) {
         Horde::logMessage($e, 'ERR');
         exit;
index 203e979..d125a10 100644 (file)
 require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('ansel');
 
-$style = Horde_Util::getFormData('style');
+$thumbstyle = Horde_Util::getFormData('t');
+$background = Horde_Util::getFormData('b');
+
+// Create a dummy style object with only what is needed to generate
+if ($thumbstyle && $background) {
+    $style = new Ansel_Style(array('thumbstyle' => $thumbstyle,
+                                   'background' => $background));
+} else {
+    $style = null;
+}
 $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image'));
 $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($image->gallery));
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
index a9ea08a..68af698 100644 (file)
@@ -21,7 +21,7 @@ if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
 if ($conf['vfs']['src'] == 'sendfile') {
     /* Need to ensure the file exists */
     try {
-        $image->createView('screen', 'ansel_default');
+        $image->createView('screen', Ansel::getStyleDefinition('ansel_default'));
     } catch (Horde_Exception $e) {
         Horde::logMessage($result, 'ERR');
         exit;
index 1caea0d..ef6c290 100644 (file)
@@ -21,7 +21,7 @@ if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
 if ($conf['vfs']['src'] == 'sendfile') {
     /* Need to ensure the file exists */
     try {
-        $image->createView('thumb', 'ansel_default');
+        $image->createView('thumb', Ansel::getStyleDefinition('ansel_default'));
     } catch (Horde_Exception $e) {
         Horde::logMessage($result, 'ERR');
         exit;
index 814f5be..ed630bc 100644 (file)
@@ -363,11 +363,11 @@ class Ansel
      * Takes into account $conf['vfs']['direct'] and other
      * factors.
      *
-     * @param string $imageId  The id of the image.
-     * @param string $view     The view ('screen', 'thumb', 'prettythumb' or
-     *                         'full') to show.
-     * @param boolean $full    Return a path that includes the server name?
-     * @param string $style    Use this gallery style
+     * @param string $imageId     The id of the image.
+     * @param string $view        The view ('screen', 'thumb', 'prettythumb' or
+     *                            'full') to show.
+     * @param boolean $full       Return a path that includes the server name?
+     * @param Ansel_Style $style  Use this gallery style
      *
      * @return Horde_Url The image path.
      */
@@ -396,7 +396,7 @@ class Ansel
         // Default to ansel_default since we really only need to know the style
         // if we are requesting a 'prettythumb'
         if (is_null($style)) {
-            $style = 'ansel_default';
+            $style = Ansel::getStyleDefinition('ansel_default');
         }
 
         // Don't load the image if the view exists
@@ -423,8 +423,10 @@ class Ansel
         if ($conf['vfs']['src'] != 'direct') {
             $params = array('image' => $imageId);
             if (!is_null($style)) {
-                $params['style'] = $style;
+                $params['t'] = $style->thumbstyle;
+                $params['b'] = $style->background;
             }
+
             return Horde::url('img/' . $view . '.php', $full)->add($params);
         }
 
@@ -669,8 +671,9 @@ class Ansel
      */
     static public function getStyleSelect($element_name, $selected = '')
     {
-        $styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel');
+        $styles = $GLOBALS['injector']->getInstance('Ansel_Styles');
 
+        // @TODO: Look at this code: probably duplicated in the binder above.
         /* No prettythumbs allowed at all by admin choice */
         if (empty($GLOBALS['conf']['image']['prettythumbs'])) {
             $test = $styles;
@@ -702,52 +705,38 @@ class Ansel
     }
 
     /**
-     * Get a style definition for the requested named style
+     * Get a pre-defined style definition for the requested named style
      *
      * @param string $style  The name of the style to fetch
      *
-     * @return array  The definition of the requested style if it's available
-     *                otherwise, the ansel_default style is returned.
+     * @return Ansel_Style   The definition of the requested style if it's
+     *                       available, otherwise, the ansel_default style is
+     *                       returned.
      */
     static public function getStyleDefinition($style)
     {
         $styles = $GLOBALS['injector']->getInstance('Ansel_Styles');
         if (isset($styles[$style])) {
-            $style_def = $styles[$style];
+            return new Ansel_Style($styles[$style]);
         } else {
-            $style_def = $styles['ansel_default'];
-        }
-
-        /* Fill in defaults */
-        if (empty($style_def['gallery_view'])) {
-            $style_def['gallery_view'] = 'Gallery';
+            return  new Ansel_Style($styles['ansel_default']);
         }
-        if (empty($style_def['default_galleryimage_type'])) {
-            $style_def['default_galleryimage_type'] = 'plain';
-        }
-        if (empty($style_def['requires_png'])) {
-            $style_def['requires_png'] = false;
-        }
-
-        return $style_def;
     }
 
     /**
      * Return a hash key for the given view and style.
      *
-     * @param string $view   The view (thumb, prettythumb etc...)
-     * @param string $style  The named 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)
     {
-        $style = Ansel::getStyleDefinition($style);
-
         if ($view != 'screen' && $view != 'thumb' && $view != 'mini' &&
             $view != 'full') {
 
-            $view = md5($style['thumbstyle'] . '.' . $style['background']);
+            $view = md5($style->thumbstyle . '.' . $style->background);
         }
 
         return $view;
index 4555213..02a87cd 100644 (file)
@@ -641,7 +641,12 @@ class Ansel_Api extends Horde_Registry_Api
                 throw new Ansel_Exception($e->getMessage());
             }
         } else {
-            $result = $image->load($view, $style);
+            if (!empty($params['style'])) {
+                $params['style'] = Ansel::getStyleDefinition($style);
+            } else {
+                $params['style'] = null;
+            }
+            $result = $image->load($view, $params['style']);
             $data = $image->_image->raw();
         }
 
@@ -776,6 +781,7 @@ class Ansel_Api extends Horde_Registry_Api
         if (!is_null($app)) {
             $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
+
         $storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope();
         // Determine the default gallery when none is given. The first gallery
         // in the list is the default gallery.
@@ -794,6 +800,11 @@ class Ansel_Api extends Horde_Registry_Api
         }
 
         $images = $gallery->listImages();
+        if ($style) {
+            $style = Ansel::getStyleDefinition($style);
+        } else {
+            $style = $gallery->getStyle();
+        }
 
         $counter = 0;
         $imagelist = array();
@@ -839,6 +850,9 @@ class Ansel_Api extends Horde_Registry_Api
         }
         $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages($galleries, $limit, $slugs);
         $imagelist = array();
+        if ($style) {
+            $style = Ansel::getStyleDefinition($style);
+        }
         foreach ($images as $image) {
             $id = $image->id;
             $imagelist[$id]['id'] = $id;
@@ -988,7 +1002,7 @@ class Ansel_Api extends Horde_Registry_Api
     }
 
     /**
-     * Get a list of all configured styles.
+     * Get a list of all pre-configured styles.
      *
      * @return hash of style definitions.
      */
index 7c84e9b..9095a0e 100644 (file)
@@ -78,8 +78,6 @@ class Horde_Block_ansel_gallery extends Horde_Block
         } else {
             $name = $gallery->get('name');
         }
-
-        $style = $gallery->getStyle();
         $viewurl = Ansel::getUrlFor('view',
             array('view' => 'Gallery',
                   'gallery' => $gallery->id,
@@ -112,17 +110,16 @@ class Horde_Block_ansel_gallery extends Horde_Block
         $html = Ansel::embedCode($params);
 
         // Be nice to people with <noscript>
-        $style = $gallery->getStyle();
         $viewurl = Ansel::getUrlFor('view', array('view' => 'Gallery',
                                                   'gallery' => $gallery->id,
                                                   'slug' => $gallery->get('slug')),
                                     true);
         $html .= '<noscript>';
         $html .= $viewurl->link(array('title' => sprintf(_("View %s"), $gallery->get('name'))));
-        if ($iid = $gallery->getKeyImage('ansel_default') &&
+        if ($iid = $gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')) &&
             $gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
 
-            $html .= '<img src="' . Ansel::getImageUrl($gallery->getKeyImage('ansel_default'), 'thumb', true) . '" alt="' . htmlspecialchars($gallery->get('name')) . '" />';
+            $html .= '<img src="' . Ansel::getImageUrl($gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')), 'thumb', true) . '" alt="' . htmlspecialchars($gallery->get('name')) . '" />';
         } else {
             $html .= Horde::img('thumb-error.png');
         }
index 447ae46..f154dae 100644 (file)
@@ -91,14 +91,13 @@ function previewImageMg(e, image_id)
 HEADER;
 
         foreach ($galleries as $gallery) {
-            $style = $gallery->getStyle();
             $url = Ansel::getUrlFor('view', array('view' => 'Gallery',
                                                   'slug' => $gallery->get('slug'),
                                                   'gallery' => $gallery->id),
                                     true);
             $html .= '<tr><td>'
                 . $url->link(array('onmouseout' => '$("ansel_preview").hide();$("ansel_preview").update("");',
-                                   'onmouseover' => 'previewImageMg(event, ' . $gallery->getKeyImage('ansel_default') . ');'))
+                                   'onmouseover' => 'previewImageMg(event, ' . $gallery->getKeyImage(Ansel::getStyleDefinition('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 d2812cf..5efb862 100644 (file)
@@ -66,7 +66,6 @@ class Horde_Block_ansel_recent_comments extends Horde_Block
             if (isset($this->_params['gallery'])) {
                 $name = @htmlspecialchars($gallery->get('name'), ENT_COMPAT, $GLOBALS['registry']->getCharset());
             }
-            $style = $gallery->getStyle();
             $viewurl = Ansel::getUrlFor('view',
                                         array('gallery' => $gallery->id,
                                               'view' => 'Gallery',
index 12db5a5..cd20dae 100644 (file)
@@ -160,7 +160,7 @@ HEADER;
                       'slug' => $gallery->get('slug'),
                       'gallery' => $gallery->id,
                       'image' => $image->id,
-                      'gallery_view' => $style['gallery_view']));
+                      'gallery_view' => $style->gallery_view));
             $html .= '<tr><td>' . strftime('%x', $image->uploaded)
                 . '</td><td class="nowrap">'
                 . $url->link(
index 171a33a..941f8ea 100644 (file)
@@ -75,7 +75,7 @@ class Horde_Block_ansel_recently_added_geodata extends Horde_Block
                       'slug' => $gallery->get('slug'),
                       'gallery' => $gallery->id,
                       'image' => $id,
-                      'gallery_view' => $style['gallery_view']), true);
+                      'gallery_view' => $style->gallery_view), true);
             $images[$key]['icon'] = (string)Ansel::getImageUrl($images[$key]['image_id'], 'mini', true);
             $images[$key]['link'] = (string)$url;
         }
index 5454205..0d39221 100644 (file)
@@ -456,7 +456,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
      * Output the HTML for this gallery's tile.
      *
      * @param Ansel_Gallery $parent  The parent Ansel_Gallery object
-     * @param string $style          A named gallery style to use.
+     * @param Ansel_Style $style     A style object to use.
      * @param boolean $mini          Force the use of a mini thumbnail?
      * @param array $params          Any additional parameters the Ansel_Tile
      *                               object may need.
@@ -466,8 +466,6 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
     {
         if (!is_null($parent) && is_null($style)) {
             $style = $parent->getStyle();
-        } else {
-            $style = Ansel::getStyleDefinition($style);
         }
 
         return Ansel_Tile_Gallery::getTile($this, $style, $mini, $params);
@@ -578,33 +576,23 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
     /**
      * 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.
+     * @param Ansel_Style $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 key image or false.
      */
     public function getKeyImage($style = null)
     {
-        /* Get the available styles */
-        $styles = $GLOBALS['injector']->getInstance('Ansel_Styles');
-
-        /* Check for explicitly requested style */
-        if (!is_null($style)) {
-            $gal_style = Ansel::getStyleDefinition($style);
-        } else {
-            $gal_style = $this->getStyle();
-            if (!isset($styles[$gal_style['name']])) {
-                $gal_style = $styles['ansel_default'];
-            }
+        if (is_null($style)) {
+            $style = $this->getStyle();
         }
 
-        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']);
+        if ($style->default_galleryimage_type != 'plain') {
+            $thumbstyle = $style->default_galleryimage_type;
+            $styleHash = $style->getHash($thumbstyle);
 
             /* First check for the existence of a key image in the specified style */
             if (!empty($this->data['attribute_default_prettythumb'])) {
@@ -618,9 +606,10 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
             }
 
             /* Don't already have one, must generate it. */
-            $params = array('gallery' => $this, 'style' => $gal_style);
+            //@TODO: Look at passing style both in params and the property...
+            $params = array('gallery' => $this, 'style' => $style);
             try {
-                $iview = Ansel_ImageGenerator::factory($gal_style['default_galleryimage_type'], $params);
+                $iview = Ansel_ImageGenerator::factory($style->default_galleryimage_type, $params);
                 $img = $iview->create();
 
                 // Note the gallery_id is negative for generated stacks
@@ -639,8 +628,8 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
                 // Might not support the requested style...try ansel_default
                 // but protect against infinite recursion.
                 Horde::logMessage($e->getMessage(), 'DEBUG');
-                if ($style != 'ansel_default') {
-                    return $this->getKeyImage('ansel_default');
+                if ($style->default_galleryimage_type != 'plain') {
+                    return $this->getKeyImage(Ansel::getStyleDefinition('ansel_default'));
                 }
             }
         } else {
@@ -716,6 +705,8 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
      * configured style is not available, use ansel_default.  If nothing has
      * been configured, the user's selected default is attempted.
      *
+     * @TODO: Verify availability of selected style and fallback to ansel_default
+     *
      * @return array  The style definition array.
      */
     public function getStyle()
@@ -733,15 +724,15 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
     /**
      * Return a hash key for the given view and style.
      *
-     * @param string $view   The view (thumb, prettythumb etc...)
-     * @param string $style  The named style.
+     * @param string $view         The view (thumb, prettythumb 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->data['attribute_style'];
+            $style = $this->getStyle();
         }
 
         return Ansel::getViewHash($view, $style);
index d6d6fb9..a058606 100644 (file)
@@ -89,7 +89,7 @@ class Ansel_Gallery_Decorator_Date
      * Output the HTML for this gallery's tile.
      *
      * @param Ansel_Gallery $parent  The parent Ansel_Gallery object
-     * @param string $style          A named gallery style to use.
+     * @param Ansel_Style $style     A gallery style to use.
      * @param boolean $mini          Force the use of a mini thumbnail?
      * @param array $params          Any additional parameters the Ansel_Tile
      *                               object may need.
@@ -98,8 +98,6 @@ class Ansel_Gallery_Decorator_Date
     {
         if (!is_null($parent) && is_null($style)) {
             $style = $parent->getStyle();
-        } else {
-            $style = Ansel::getStyleDefinition($style);
         }
 
         return Ansel_Tile_DateGallery::getTile($this, $style, $mini, $params);
@@ -148,10 +146,7 @@ class Ansel_Gallery_Decorator_Date
     /**
      * 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.
+     * @param Ansel_Style $style  Force the use of this style, if it's available
      *
      * @return mixed  The image_id of the key image or false.
      */
index 817d97b..7c625f1 100644 (file)
@@ -225,8 +225,8 @@ class Ansel_Image Implements Iterator
     /**
      * Return the vfs path for this image.
      *
-     * @param string $view   The view we want.
-     * @param string $style  A named gallery style.
+     * @param string $view        The view we want.
+     * @param Ansel_Style $style  A named gallery style.
      *
      * @return string  The vfs path for this image.
      */
@@ -264,8 +264,8 @@ class Ansel_Image Implements Iterator
     /**
      * Loads the given view into memory.
      *
-     * @param string $view   Which view to load.
-     * @param string $style  The named gallery style.
+     * @param string $view        Which view to load.
+     * @param Ansel_Style $style  The gallery style.
      *
      * @return boolean
      * @throws Ansel_Exception
@@ -317,9 +317,9 @@ class Ansel_Image Implements Iterator
      * Check if an image view exists and returns the vfs name complete with
      * the hash directory name prepended if appropriate.
      *
-     * @param integer $id    Image id to check
-     * @param string $view   Which view to check for
-     * @param string $style  A named gallery style
+     * @param integer $id         Image id to check
+     * @param string $view        Which view to check for
+     * @param Ansel_Style $style  Style object
      *
      * @return mixed  False if image does not exists | string vfs name
      */
@@ -331,7 +331,7 @@ class Ansel_Image Implements Iterator
         }
 
         /* Get the VFS path. */
-        $view = Ansel_Gallery::getViewHash($view, $style);
+        $view = Ansel::getViewHash($view, $style);
 
         /* Can't call the various vfs methods here, since this method needs
         to be called statically */
@@ -355,8 +355,8 @@ class Ansel_Image Implements Iterator
     /**
      * Creates and caches the given view.
      *
-     * @param string $view  Which view to create.
-     * @param string $style  A named gallery style
+     * @param string $view         Which view to create.
+     * @param Ansel_Style  $style  A style object
      *
      * @return boolean
      * @throws Ansel_Exception
@@ -382,9 +382,8 @@ class Ansel_Image Implements Iterator
 
         $vHash = $this->getViewHash($view, $style);
         $this->_image->loadString($data);
-        $styleDef = Ansel::getStyleDefinition($style);
         if ($view == 'prettythumb') {
-            $viewType = $styleDef['thumbstyle'];
+            $viewType = $style->thumbstyle;
         } else {
             // Screen, Mini, Thumb
             $viewType = ucfirst($view);
@@ -396,8 +395,7 @@ class Ansel_Image Implements Iterator
             // It could be we don't support the requested effect, try
             // ansel_default before giving up.
             if ($view == 'prettythumb') {
-                // If we still fail, the exception gets thrown up the chain.
-                $iview = Ansel_ImageGenerator::factory('Thumb', array('image' => $this, 'style' => 'ansel_default'));
+                $iview = Ansel_ImageGenerator::factory('Thumb', array('image' => $this, 'style' => Ansel::getStyleDefinition('ansel_default')));
             } else {
                 // If it wasn't a prettythumb, then something else must be wrong
                 throw $e;
@@ -760,6 +758,9 @@ class Ansel_Image Implements Iterator
                 $deleted = array();
 
                 /* Need to generate hashes for each possible style */
+                // @TODO: Need to save the style hash to the share entry
+                //        since we don't require the use of predefined
+                //        style definitions now.
                 $styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel');
                 foreach ($styles as $style)
                 {
@@ -816,8 +817,8 @@ class Ansel_Image Implements Iterator
     /**
      * Display the requested view.
      *
-     * @param string $view   Which view to display.
-     * @param string $style  Force use of this gallery style.
+     * @param string $view        Which view to display.
+     * @param Ansel_Style $style  Force use of this gallery style.
      *
      * @return void
      * @throws Horde_Exception_PermissionDenied, Ansel_Exception
@@ -1135,7 +1136,7 @@ class Ansel_Image Implements Iterator
      * Get the Ansel_View_Image_Thumb object
      *
      * @param Ansel_Gallery $parent  The parent Ansel_Gallery object.
-     * @param string        $style   A named gallery style to use.
+     * @param Ansel_Style   $style   A gallery definition to use.
      * @param boolean       $mini    Force the use of a mini thumbnail?
      * @param array         $params  Any additional parameters the Ansel_Tile
      *                               object may need.
@@ -1147,8 +1148,6 @@ class Ansel_Image Implements Iterator
     {
         if (!is_null($parent) && is_null($style)) {
             $style = $parent->getStyle();
-        } else {
-            $style = Ansel::getStyleDefinition($style);
         }
 
         return Ansel_Tile_Image::getTile($this, $style, $mini, $params);
@@ -1173,8 +1172,8 @@ class Ansel_Image Implements Iterator
     /**
      * Return a hash key for the given view and style.
      *
-     * @param string $view   The view (thumb, prettythumb etc...)
-     * @param string $style  The named style.
+     * @param string $view        The view (thumb, prettythumb etc...)
+     * @param Ansel_Style $style  The style.
      *
      * @return string  A md5 hash suitable for use as a key.
      */
@@ -1188,10 +1187,8 @@ class Ansel_Image Implements Iterator
         if (is_null($style)) {
             $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($this->gallery));
             $style = $gallery->getStyle();
-        } else {
-            $style = Ansel::getStyleDefinition($style);
         }
-        $view = md5($style['thumbstyle'] . '.' . $style['background']);
+        $view = md5($style->thumbstyle . '.' . $style->background);
 
         return $view;
     }
index 509a036..85d750e 100644 (file)
@@ -19,7 +19,7 @@ class Ansel_ImageGenerator_PlainStack extends Ansel_ImageGenerator
         $style = $this->_params['style'];
         $params = array('width' => 100,
                         'height' => 100,
-                        'background' => $style['background']);
+                        'background' => $style->background);
 
         $baseImg = Ansel::getImageObject($params);
         try {
@@ -28,7 +28,7 @@ class Ansel_ImageGenerator_PlainStack extends Ansel_ImageGenerator
                 array('images' => $imgobjs,
                       'resize_height' => $GLOBALS['conf']['thumbnail']['height'],
                       'padding' => 0,
-                      'background' => $style['background'],
+                      'background' => $style->background,
                       'type' => 'plain'));
 
             $baseImg->applyEffects();
index 4befd69..62507fc 100644 (file)
@@ -19,7 +19,7 @@ class Ansel_ImageGenerator_PolaroidStack extends Ansel_ImageGenerator
         $style = $this->_params['style'];
         $params = array('width' => 100,
                         'height' => 100,
-                        'background' => $style['background']);
+                        'background' => $style->background);
 
         $baseImg = Ansel::getImageObject($params);
         try {
@@ -28,7 +28,7 @@ class Ansel_ImageGenerator_PolaroidStack extends Ansel_ImageGenerator
                 array('images' => $imgobjs,
                       'resize_height' => $GLOBALS['conf']['thumbnail']['height'],
                       'padding' => 10,
-                      'background' => $style['background'],
+                      'background' => $style->background,
                       'type' => 'polaroid'));
             $baseImg->applyEffects();
             $baseImg->resize($GLOBALS['conf']['thumbnail']['width'],
index e7c1342..3b8b5a5 100644 (file)
@@ -26,11 +26,11 @@ class Ansel_ImageGenerator_PolaroidThumb extends Ansel_ImageGenerator
                 $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery);
                 $styleDef = $gal->getStyle();
             } else {
-                $styleDef = Ansel::getStyleDefinition($this->_style);
+                $styleDef = $this->_style;
             }
             try {
                 $this->_image->addEffect('PolaroidImage',
-                                         array('background' => $styleDef['background'],
+                                         array('background' => $styleDef->background,
                                                'padding' => 5));
                 if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
                     $this->_image->addEffect('Unsharpmask',
index 6bca68e..f7de83a 100644 (file)
@@ -26,7 +26,7 @@ class Ansel_ImageGenerator_PrettyThumb extends Ansel_ImageGenerator
                 $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery);
                 $styleDef = $gal->getStyle();
             } else {
-                $styleDef = Ansel::getStyleDefinition($this->_style);
+                $styleDef = $this->_style;
             }
 
             try {
@@ -34,7 +34,7 @@ class Ansel_ImageGenerator_PrettyThumb extends Ansel_ImageGenerator
                 $this->_image->addEffect('RoundCorners', array('border' => 2,
                                                                'bordercolor' => '#333'));
 
-                $this->_image->addEffect('DropShadow', array('background' => $styleDef['background'],
+                $this->_image->addEffect('DropShadow', array('background' => $styleDef->background,
                                                              'padding' => 5,
                                                              'distance' => 5,
                                                              'fade' => 3));
index 0cdf0ce..a79bd24 100644 (file)
@@ -20,7 +20,7 @@ class Ansel_ImageGenerator_RoundedStack extends Ansel_ImageGenerator
         $style = $this->_params['style'];
         $params = array('width' => 100,
                         'height' => 100,
-                        'background' => $style['background']);
+                        'background' => $style->background);
 
         $baseImg = Ansel::getImageObject($params);
 
@@ -30,7 +30,7 @@ class Ansel_ImageGenerator_RoundedStack extends Ansel_ImageGenerator
                 array('images' => $imgobjs,
                       'resize_height' => $GLOBALS['conf']['thumbnail']['height'],
                       'padding' => 0,
-                      'background' => $style['background'],
+                      'background' => $style->background,
                       'type' => 'rounded'));
 
             $baseImg->applyEffects();
index 241c4e2..bc065d8 100644 (file)
@@ -26,13 +26,13 @@ class Ansel_ImageGenerator_ShadowSharpThumb extends Ansel_ImageGenerator
                 $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery);
                 $styleDef = $gal->getStyle();
             } else {
-                $styleDef = Ansel::getStyleDefinition($this->_style);
+                $styleDef = $this->_style;
             }
 
             try {
                 $this->_image->addEffect('Border', array('bordercolor' => '#333', 'borderwidth' => 1));
                 $this->_image->addEffect('DropShadow',
-                                         array('background' => $styleDef['background'],
+                                         array('background' => $styleDef->background,
                                                'padding' => 5,
                                                'distance' => 8,
                                                'fade' => 2));
index 5787eda..e1da9d2 100644 (file)
@@ -861,7 +861,7 @@ class Ansel_Storage
      * from the same gallery.
      *
      * @param array $images        An array of image ids
-     * @param string $style        A named gallery style to force if requesting
+     * @param Ansel_Style $style   A gallery style to force if requesting
      *                             pretty thumbs.
      * @param boolean $full        Generate full urls
      * @param string $image_view   Which image view to use? screen, thumb etc..
@@ -874,7 +874,7 @@ class Ansel_Storage
     {
         $galleries = array();
         if (is_null($style)) {
-            $style = 'ansel_default';
+            $style = Ansel::getStyleDefinition('ansel_default');
         }
 
         $json = array();
diff --git a/ansel/lib/Style.php b/ansel/lib/Style.php
new file mode 100644 (file)
index 0000000..e4e7912
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+/**
+ * The Ansel_Style:: class is responsible for holding information about a
+ * single Ansel style.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Michael J. Rubinsky <mrubinsk@horde.org>
+ *
+ * @package Ansel
+ */
+class Ansel_Style
+{
+    /**
+     * Holds the style definition
+     *
+     * @var array
+     */
+    protected $_properties;
+
+    public function __construct($properties)
+    {
+        $this->_properties = array_merge(array('gallery_view' => 'Gallery',
+                                               'default_galleryimage_type' => 'plain',
+                                               'background' => 'none'),
+                                        $properties);
+    }
+
+    /**
+     * Return if this style requires PNG support in the browser.
+     *
+     * @return boolean
+     */
+    public function requiresPng()
+    {
+        return true;
+    }
+
+    public function getHash($view)
+    {
+        if ($view != 'screen' && $view != 'thumb' && $view != 'mini' &&
+            $view != 'full') {
+
+            $view = md5($this->thumbstyle . '.' . $this->background);
+        }
+
+        return $view;
+    }
+
+    public function &__get($property)
+    {
+        return $this->_properties[$property];
+    }
+
+    public function __isset($property)
+    {
+        return !empty($property);
+    }
+
+}
+
index 88bd367..54a361a 100644 (file)
@@ -15,7 +15,7 @@ class Ansel_Tile_DateGallery
      *
      * @param Ansel_DateGallery $dgallery  The Ansel_Gallery_Date we are
      *                                     displaying.
-     * @param array $style                 A style definition array.
+     * @param Ansel_Style $style           A style object.
      * @param boolean $mini                Force the use of a mini thumbail?
      * @param array $params                An array containing additional
      *                                     parameters. Currently,
@@ -71,13 +71,13 @@ class Ansel_Tile_DateGallery
                 $style = $dgallery->getStyle();
             }
 
-            $thumbstyle = $mini ? 'mini' : $style['thumbstyle'];
+            $thumbstyle = $mini ? 'mini' : $style->thumbstyle;
             $gallery_image = Ansel::getImageUrl(
                 $dgallery->getKeyImage(),
-                $thumbstyle, true, $style['name']);
+                $thumbstyle,
+                true,
+                $style);
 
-            // No need to escape alt here since it's generated enitrely within
-            // horde from Horde_Date
             $gallery_image = '<img src="' . $gallery_image . '" alt="' . $caption . '" />' ;
         } else {
             $gallery_image = Horde::img('thumb-error.png');
@@ -88,7 +88,7 @@ class Ansel_Tile_DateGallery
             if (empty($params['style'])) {
                 $gstyle = $dgallery->getStyle();
             } else {
-                $gstyle = Ansel::getStyleDefinition($params['style']);
+                $gstyle = $params['style'];
             }
             $params = array('gallery' => $dgallery->id,
                             'view' => 'Gallery',
@@ -108,7 +108,7 @@ class Ansel_Tile_DateGallery
         $gallery_count = $dgallery->countImages(true);
 
         /* Background color is needed if displaying a mini tile */
-        $background_color = $style['background'];
+        $background_color = $style->background;
 
         Horde::startBuffer();
         include ANSEL_TEMPLATES . '/tile/dategallery' . ($mini ? 'mini' : '') . '.inc';
index e5365df..ef3188e 100644 (file)
@@ -14,7 +14,7 @@ class Ansel_Tile_Gallery
      * Outputs the html for a gallery tile.
      *
      * @param Ansel_Gallery $gallery  The Ansel_Gallery we are displaying.
-     * @param array $style            A style definition array.
+     * @param Ansel_Style $style      A style object.
      * @param boolean $mini           Force the use of a mini thumbail?
      * @param array $params           An array containing additional parameters.
      *                                Currently, gallery_view_url and
@@ -46,14 +46,15 @@ class Ansel_Tile_Gallery
             if (is_null($style)) {
                 $style = $gallery->getStyle();
             }
-            $thumbstyle = $mini ? 'mini' : $style['thumbstyle'];
-
+            $thumbstyle = $mini ? 'mini' : $style->thumbstyle;
             if ($gallery->hasPasswd()) {
                 $gallery_image = Horde::img('gallery-locked.png');
             } else {
                 $gallery_image = Ansel::getImageUrl(
-                    $gallery->getKeyImage($style['name']),
-                    $thumbstyle, true, $style['name']);
+                    $gallery->getKeyImage($style),
+                    $thumbstyle,
+                    true,
+                    $style);
                 $gallery_image = '<img src="' . $gallery_image . '" alt="' . htmlspecialchars($gallery->get('name')) . '" />';
             }
         } else {
@@ -62,11 +63,6 @@ class Ansel_Tile_Gallery
 
         /* Check for being called via the api and generate correct view links */
         if (!isset($params['gallery_view_url'])) {
-            if (empty($params['style'])) {
-                $gstyle = $gallery->getStyle();
-            } else {
-                $gstyle = Ansel::getStyleDefinition($params['style']);
-            }
             $view_link = Ansel::getUrlFor('view',
                                           array('gallery' => $gallery->id,
                                                 'view' => 'Gallery',
@@ -109,7 +105,7 @@ class Ansel_Tile_Gallery
         }
 
         $gallery_count = $gallery->countImages(true);
-        $background_color = $style['background'];
+        $background_color = $style->background;
 
         $date_format = $GLOBALS['prefs']->getValue('date_format');
         $created = _("Created:") . ' '
index 8bbee90..b71bdb9 100644 (file)
@@ -17,7 +17,7 @@ class Ansel_Tile_Image
      * @param Ansel_Gallery $parent  The parent Ansel_Gallery for this image.
      *                               If null, will create a new instance of
      *                               the Ansel_Gallery
-     * @param array $style           A sytle definiition array.
+     * @param Ansel_Style $style     A sytle definiition array.
      * @param boolean $mini          Force the use of a mini thumbnail?
      * @param string $params         Any other paramaters needed by this tile
      *
@@ -43,7 +43,7 @@ class Ansel_Tile_Image
         }
 
         /* Override the thumbnail to mini or use style default? */
-        $thumbstyle = $mini ? 'mini' : $style['thumbstyle'];
+        $thumbstyle = $mini ? 'mini' : $style->thumbstyle;
 
         /* URL for image properties/actions etc... */
         $image_url = Horde::url('image.php')->add(
@@ -92,7 +92,8 @@ class Ansel_Tile_Image
                 $date));
         }
 
-        $thumb_url = Ansel::getImageUrl($image->id, $thumbstyle, true, $style['name']);
+        $thumb_url = Ansel::getImageUrl($image->id, $thumbstyle, true, $style);
+
         $option_select = $parent->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE);
         $option_edit = $parent->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
         $imgAttributes = (!empty($params['image_view_attributes']) ? $params['image_view_attributes'] : array());
@@ -115,6 +116,7 @@ class Ansel_Tile_Image
         Horde::startBuffer();
         // In-line caption editing if we have Horde_Perms::EDIT
         if ($option_edit) {
+            // @TODO: passing thumbstyle here doesn't look right to me.
             $geometry = $image->getDimensions($thumbstyle);
             $GLOBALS['injector']->createInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'EditCaption'), array(
                 'domid' => $image->id . 'caption',
index ffd88cb..956c2fd 100644 (file)
@@ -256,7 +256,7 @@ abstract class Ansel_View_Base
                 $curimage = 0;
             }
 
-            $data = array((string)Ansel::getImageUrl($image->id, $params['image_view'], $params['full'], $style['name']),
+            $data = array((string)Ansel::getImageUrl($image->id, $params['image_view'], $params['full'], $style),
                           htmlspecialchars($image->filename, ENT_COMPAT, $GLOBALS['registry']->getCharset()),
                           $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($image->caption, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL)),
                           $image->id,
index 4ce6206..3d986f3 100644 (file)
@@ -72,7 +72,7 @@ class Ansel_View_EmbeddedRenderer_GalleryLink extends Ansel_View_Gallery
              * both were not passed in.
              */
             if ($thumbsize == 'thumb') {
-                $images[] = $gallery->getKeyImage('ansel_default');
+                $images[] = $gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default'));
             } else {
                 // Default to gallery's defined style if not provided.
                 $gallery_style = empty($this->_params['style']) ?
index ca45c44..9384761 100644 (file)
@@ -100,7 +100,7 @@ class Ansel_View_Gallery extends Ansel_View_Base
         if (!empty($this->_params['gallery_view'])) {
             $renderer = $this->_params['gallery_view'];
         } else {
-            $renderer = (!empty($style['gallery_view'])) ? $style['gallery_view'] : 'Gallery';
+            $renderer = (!empty($style->gallery_view)) ? $style->gallery_view : 'Gallery';
         }
 
         /* Load the helper */
index 45e6f6a..2d8504b 100644 (file)
@@ -99,7 +99,6 @@ class Ansel_View_GalleryProperties
      */
     private function _output()
     {
-
         $view = new Horde_View(array('templatePath' => array(ANSEL_TEMPLATES . '/gallery',
                                                              ANSEL_TEMPLATES . '/gallery/partial',
                                                              ANSEL_TEMPLATES . '/gallery/layout')));
@@ -234,6 +233,21 @@ class Ansel_View_GalleryProperties
         $gallery_thumbstyle = Horde_Util::getFormData('gallery_style');
         $gallery_parent = Horde_Util::getFormData('gallery_parent');
 
+        // Style
+        $style = new Ansel_Style(array(
+            'thumbstyle' => Horde_Util::getFormData('thumbnail_style'),
+            'default_galleryimage_type' => 'PlainStack',//Horde_Util::getFormData('keyimage_type'),
+            'background' => Horde_Util::getFormData('background_color'),
+            // temporary hack
+            'widgets' => array('Actions' => array(),
+                 'Tags' => array('view' => 'gallery'),
+                 'OtherGalleries' => array(),
+                 'Geotag' => array(),
+                 'Links' => array(),
+                 'GalleryFaces' => array(),
+                 'OwnerFaces' => array())
+        ));
+
         // Double check for an empty string instead of null
         if (empty($gallery_parent)) {
             $gallery_parent = null;
@@ -252,7 +266,7 @@ class Ansel_View_GalleryProperties
                 }
                 $gallery->set('desc', $gallery_desc);
                 $gallery->setTags(!empty($gallery_tags) ? explode(',', $gallery_tags) : '');
-                //$gallery->set('style', $style);
+                $gallery->set('style', $style);
                 $gallery->set('slug', $gallery_slug);
                 $gallery->set('age', $gallery_age);
                 $gallery->set('download', $gallery_download);
@@ -261,7 +275,7 @@ class Ansel_View_GalleryProperties
                     $gallery->get('owner') == $GLOBALS['registry']->getAuth()) {
                     $gallery->set('passwd', $gallery_passwd);
                 }
-
+                
                 // Did the parent change?
                 $old_parent = $gallery->getParent();
                 if (!is_null($old_parent)) {
@@ -328,7 +342,7 @@ class Ansel_View_GalleryProperties
                         array('name' => $gallery_name,
                               'desc' => $gallery_desc,
                               'tags' => explode(',', $gallery_tags),
-                              //'style' => $style,
+                              'style' => $style,
                               'slug' => $gallery_slug,
                               'age' => $gallery_age,
                               'download' => $gallery_download,
index 2e98d87..673ed32 100644 (file)
@@ -53,7 +53,7 @@ abstract class Ansel_View_GalleryRenderer_Base
     /**
      * The style definition array for this gallery.
      *
-     * @var array
+     * @var Ansel_Style
      */
     public $style;
 
@@ -140,15 +140,16 @@ abstract class Ansel_View_GalleryRenderer_Base
 
         /* Do we have an explicit style set? If not, use the gallery's */
         if (!empty($this->view->style)) {
-            $this->style = Ansel::getStyleDefinition($this->view->style);
+            $this->style = $this->view->style;
         } else {
             $this->style = $this->view->gallery->getStyle();
         }
 
         /* Include any widgets */
-        if (!empty($this->style['widgets']) && !$this->view->api) {
+        if (!empty($this->style->widgets) && !$this->view->api) {
+
             /* Special case widgets - these are built in */
-            if (array_key_exists('Actions', $this->style['widgets'])) {
+            if (array_key_exists('Actions', $this->style->widgets)) {
                 /* Don't show action widget if no actions */
                 if ($GLOBALS['registry']->getAuth() ||
                     !empty($conf['report_content']['driver']) &&
@@ -158,13 +159,13 @@ abstract class Ansel_View_GalleryRenderer_Base
 
                     $this->view->addWidget(Ansel_Widget::factory('Actions'));
                 }
-                unset($this->style['widgets']['Actions']);
+                unset($this->style->widgets['Actions']);
             }
 
             // Gallery widgets always receive an array of image ids for
             // the current page.
             $ids = $this->getChildImageIds();
-            foreach ($this->style['widgets'] as $wname => $wparams) {
+            foreach ($this->style->widgets as $wname => $wparams) {
                 $wparams = array_merge($wparams, array('images' => $ids));
                 $this->view->addWidget(Ansel_Widget::factory($wname, $wparams));
             }
index 157e44d..fcd9268 100644 (file)
@@ -140,7 +140,7 @@ class Ansel_View_Image extends Ansel_View_Base
 
         $this->_style = (empty($this->_params['style']) ?
              $this->gallery->getStyle() :
-             Ansel::getStyleDefinition($this->_params['style']));
+             $this->_params['style']);
 
         /* Make sure the screen view is loaded and get the geometry */
         try {
@@ -201,7 +201,7 @@ class Ansel_View_Image extends Ansel_View_Base
         }
 
         /* Get the image src url */
-        $this->_urls['imgsrc'] = Ansel::getImageUrl($this->resource->id, 'screen', true, $this->_style['name']);
+        $this->_urls['imgsrc'] = Ansel::getImageUrl($this->resource->id, 'screen', true, $this->_style);
 
         /* And a self url. Can't use Horde::selfUrl() since that would ignore
          * pretty urls. */
@@ -289,7 +289,7 @@ class Ansel_View_Image extends Ansel_View_Base
                       'page' => $page_prev),
                 $this->_date));
         }
-        $prvImgUrl = Ansel::getImageUrl($prev, 'screen', true, $this->_style['name']);
+        $prvImgUrl = Ansel::getImageUrl($prev, 'screen', true, $this->_style);
 
         /* Next image link */
         if (!empty($this->_params['image_view_url'])) {
@@ -306,7 +306,7 @@ class Ansel_View_Image extends Ansel_View_Base
                       'page' => $page_next),
                 $this->_date));
         }
-        $nextImgUrl = Ansel::getImageUrl($next, 'screen', true, $this->_style['name']);
+        $nextImgUrl = Ansel::getImageUrl($next, 'screen', true, $this->_style);
 
         /* Slideshow link */
         if (!empty($this->_params['slideshow_link'])) {
index 95822f8..665af76 100644 (file)
@@ -237,8 +237,7 @@ class Ansel_View_List extends Ansel_View_Base
 
             // Get top-level / default gallery style.
             if (empty($this->_params['style'])) {
-                $style = Ansel::getStyleDefinition(
-                    $prefs->getValue('default_gallerystyle'));
+                $style = Ansel::getStyleDefinition($prefs->getValue('default_gallerystyle'));
             } else {
                 $style = Ansel::getStyleDefinition($this->_params['style']);
             }
index 3e54d31..f257e53 100644 (file)
@@ -251,10 +251,9 @@ class Ansel_View_Results extends Ansel_View_Base
             }
             $rtaghtml .= '</ul>';
         }
-        $styleDef = Ansel::getStyleDefinition($GLOBALS['prefs']->getValue('default_gallerystyle'));
-        $style = $styleDef['name'];
+        $style = Ansel::getStyleDefinition($GLOBALS['prefs']->getValue('default_gallerystyle'));
         $viewurl = Horde::url('view.php')->add(array('view' => 'Results',
-                                                                'actionID' => 'add'));
+                                                     'actionID' => 'add'));
 
         $vars = Horde_Variables::getDefaultVariables();
         $option_move = $option_copy = $ansel_storage->countGalleries(Horde_Perms::EDIT);
index 902ee7d..4fae1ca 100644 (file)
@@ -75,7 +75,7 @@ abstract class Ansel_Widget_Base
     {
         $this->_view = $view;
         if (!empty($this->_params['style'])) {
-            $this->_style = Ansel::getStyleDefinition($this->_params['style']);
+            $this->_style = $this->_params['style'];
         } else {
             $this->_style = $view->gallery->getStyle();
         }
@@ -103,7 +103,7 @@ abstract class Ansel_Widget_Base
      */
     protected function _htmlBegin()
     {
-        $html = '<div class="anselWidget" style="background-color:' . $this->_style['background'] .   ';">';
+        $html = '<div class="anselWidget" style="background-color:' . $this->_style->background .   ';">';
         $html .= '<h2 class="header tagTitle">' . $this->_title . '</h2>';
         return $html;
     }
index ed1af6e..156fc3b 100644 (file)
@@ -61,7 +61,7 @@ class Ansel_Widget_GalleryFaces extends Ansel_Widget_Base
 
         // Check for existing faces for this gallery.
         $html = '<div style="display: block'
-            . ';background:' . $this->_style['background']
+            . ';background:' . $this->_style->background
             . ';width:100%;max-height:300px;overflow:auto;" id="faces_widget_content" >';
 
         $images = $faces->getGalleryFaces($this->_view->resource->id);
index 2d5e7f9..b9ed5c1 100644 (file)
@@ -77,7 +77,7 @@ class Ansel_Widget_OtherGalleries extends Ansel_Widget_Base
 
         $html = '<div style="display:'
             . (($GLOBALS['prefs']->getValue('show_othergalleries')) ? 'block' : 'none')
-            . ';background:' . $this->_style['background']
+            . ';background:' . $this->_style->background
             . ';width:100%;max-height:300px;overflow:auto;" id="othergalleries" >';
 
         foreach ($galleries as $gallery) {
@@ -89,7 +89,7 @@ class Ansel_Widget_OtherGalleries extends Ansel_Widget_Base
                 $parent = array_pop($parents);
             }
 
-            $img = (string)Ansel::getImageUrl($gallery->getKeyImage('ansel_default'), 'mini', true);
+            $img = (string)Ansel::getImageUrl($gallery->getKeyImage(), 'mini', true);
             $link = Ansel::getUrlFor('view', array('gallery' => $gallery->id,
                                                    'slug' => $gallery->get('slug'),
                                                    'view' => 'Gallery'),
index 148bde5..c7ef4ae 100644 (file)
@@ -43,7 +43,7 @@ class Ansel_Widget_OwnerFaces extends Ansel_Widget_Base
 
         $results = $this->_faces->ownerFaces($this->_owner, 0, 12, true);
         $html .= '<div style="display: block'
-            . ';background:' . $this->_style['background']
+            . ';background:' . $this->_style->background
             . ';width:100%;max-height:300px;overflow:auto;" id="faces_widget_content" >';
         foreach ($results as $face_id => $face) {
             $facename = htmlspecialchars($face['face_name']);
index 2940d34..495dc09 100644 (file)
@@ -32,7 +32,6 @@ if (($image_id = Horde_Util::getFormData('image')) !== null) {
                                          'gallery' => $gallery_id),
                                    true);
 } else {
-    $style = $gallery->getStyle();
     $return_url = Ansel::getUrlFor('view',
                                    array('gallery' => $gallery_id,
                                          'view' => 'Gallery'),
index d0b7019..ae6d828 100644 (file)
@@ -100,20 +100,18 @@ if (empty($rss)) {
         if (!count($images)) {
             $images = array();
         } else {
-            $style = $gallery->getStyle();
             $viewurl = Ansel::getUrlFor('view',
                                         array('view' => 'Gallery',
                                               'gallery' => $id),
                                         true);
-            $img = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($gallery->getKeyImage('ansel_default'));
+            $img = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')));
             $params = array('last_modified' => $gallery->get('last_modified'),
                             'name' => sprintf(_("%s on %s"),
                                               $gallery->get('name'),
                                               $conf['server']['name']),
                             'link' => $viewurl,
                             'desc' => $gallery->get('desc'),
-                            'image_url' => Ansel::getImageUrl($img->id, 'thumb',
-                                                              true, 'ansel_default'),
+                            'image_url' => Ansel::getImageUrl($img->id, 'thumb', true),
                             'image_alt' => $img->caption,
                             'image_link' => Ansel::getUrlFor('view',
                                                              array('image' => $img->id,
@@ -165,9 +163,7 @@ if (empty($rss)) {
                                                            true),
                                 'desc' => sprintf(_("Recently added photos by %s on %s"),
                                                   $name, $conf['server']['name']),
-                                'image_url' => Ansel::getImageUrl($images[0]->id,
-                                                                  'thumb', true,
-                                                                  'ansel_default'),
+                                'image_url' => Ansel::getImageUrl($images[0]->id, 'thumb', true),
                                 'image_alt' => $images[0]->caption,
                                 'image_link' => Ansel::getUrlFor(
                                     'view', array('image' => $images[0]->id,
@@ -200,9 +196,7 @@ if (empty($rss)) {
                                                        true),
                             'desc' => sprintf(_("Photos tagged with %s on %s"),
                                               $id, $conf['server']['name']),
-                            'image_url' => Ansel::getImageUrl($images[0]->id,
-                                                              'thumb', true,
-                                                              'ansel_default'),
+                            'image_url' => Ansel::getImageUrl($images[0]->id, 'thumb', true, 'ansel_default'),
                             'image_alt' => $images[0]->caption,
                             'image_link' => Ansel::getUrlFor('view',
                                                              array('view' => 'Image',
index 9c33bac..88d2560 100755 (executable)
@@ -16,8 +16,7 @@
   </td>
   <td>
    <?php
-    $styleDef = Ansel::getStyleDefinition($prefs->getValue('default_gallerystyle'));
-    $style = $styleDef['name'];
+    $style = Ansel::getStyleDefinition($prefs->getValue('default_gallerystyle'));
     foreach (array_keys($face['galleries']) as $gallery_id) {
         foreach ($face['galleries'][$gallery_id] as $imageId) {
             echo '<div style="float: left; text-align: center;"><img src="' . Ansel::getImageUrl($imageId, 'thumb', false, $style) . '" style="padding: 5px;" alt="' . $imageId . '" /><br />';
diff --git a/ansel/templates/gallery/partial/_styles.html.php b/ansel/templates/gallery/partial/_styles.html.php
new file mode 100644 (file)
index 0000000..c622240
--- /dev/null
@@ -0,0 +1,29 @@
+  <tr>
+   <td align="right" valign="top"><strong><?php echo _("Thumbnail Style"); ?></string></td>
+   <td>
+    <select name="thumbnail_style">
+      <option value="Thumb" selected="selected">Basic Thumbnails</option>
+      <option value="ShadowSharpThumb">Drop Shadows</option>
+      <option value="PrettyThumb">Rounded Corners</option>
+      <option value="PolaroidThumb">Polaroids</option>
+    </select>
+   </td>
+  </tr>
+  <tr>
+   <td align="right" valign="top"><strong><?php echo _("Backgrond Color"); ?></string></td>
+   <td>
+    <select name="background_color">
+      <option value="none" selected="selected">None</option>
+      <option value="white">White</option>
+    </select>
+   </td>
+  </tr>
+  <tr>
+   <td align="right" valign="top"><strong><?php echo _("View Style"); ?></string></td>
+   <td>
+    <select name="gallery_view">
+     <option value="Gallery">Traditional</option>
+     <option value="GalleryLightbox">Lightbox</option>
+    </select>
+   </td>
+  </tr>
\ No newline at end of file
index d6052e6..9102d8f 100644 (file)
 <?php endif; ?>
 
 <!-- Gallery Style -->
-<tr>
-  <?php echo $this->renderPartial('styles'); ?>
-</tr>
+<?php echo $this->renderPartial('styles'); ?>
 
 <!-- Submission -->
 <tr>
index b9454d3..27ae8e4 100644 (file)
@@ -50,7 +50,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]->getKeyImage('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(), 'mini', false) ?>" alt="<?php echo $owner_title?>" /></a>
     <?php else: ?>
       <?php echo $link . Horde::img('gallery-locked-mini.png') ?></a>
     <?php endif; ?>
index 22d60b1..b8cdade 100644 (file)
@@ -86,7 +86,6 @@ function changeRatio()
 <h1 class="header"><?php echo htmlspecialchars($title, ENT_COMPAT, $GLOBALS['registry']->getCharset()) ?></h1>
 <div class="control anselActions" style="text-align: center">
 <?php
-$style = $gallery->getStyle();
 $image_src = Ansel::getImageUrl($image_id, 'full');
 
 echo $galleryurl->link() . Horde::img('galleries.png') . ' ' . _("Back to gallery") . '</a> ';
index dd02ad6..1869993 100644 (file)
@@ -2,7 +2,6 @@
 <div class="control anselActions" style="text-align: center">
 <div id="prevDiv"></div>
 <?php
-$style = $gallery->getStyle();
 $image_src = Ansel::getImageUrl($image_id, 'screen');
 
 echo $galleryurl->link() . Horde::img('galleries.png') . ' ' . _("Back to gallery") . '</a> ';
index 816ab75..bfce02a 100644 (file)
@@ -32,8 +32,6 @@ function resetImage()
 <h1 class="header"><?php echo htmlspecialchars($title, ENT_COMPAT, $GLOBALS['registry']->getCharset()) ?></h1>
 <div class="control anselActions" style="text-align: center">
 <?php
-
-$style = $gallery->getStyle();
 $image_src = Ansel::getImageUrl($image_id, 'full');
 
 echo $galleryurl->link() . Horde::img('galleries.png') . ' ' . _("Back to gallery") . '</a> ';
index 44429e0..ba63c29 100644 (file)
@@ -4,4 +4,4 @@
  </span>
  <?php echo @htmlspecialchars($list_title, ENT_COMPAT, $GLOBALS['registry']->getCharset()) . ' ' . Horde::url($refresh_link)->link(array('title' => _("Refresh List"))) . Horde::img('reload.png', _("Refresh List")) . '</a>' ?>
 </div>
-<table width="100%" style="background:<?php echo $styleDef['background'] ?>;"><tr>
+<table width="100%" style="background:<?php echo $styleDef->background ?>;"><tr>
index 683f95f..11e8219 100644 (file)
@@ -1,4 +1,4 @@
-<?php echo '<div class="image-tile" id="imagetile_' . (int)$image->id . '">' . $view_url->link(array_merge(array('title' => $image->filename, 'onclick.raw' => $imgOnClick)), $imgAttributes) . '<img src="' . $thumb_url  . '" alt="' . htmlspecialchars($image->filename) . '" /></a>'; ?>
+<?php echo '<div class="image-tile" id="imagetile_' . (int)$image->id . '">' . $view_url->link(array_merge(array('title' => $image->filename, 'onclick.raw' => $imgOnClick), $imgAttributes)) . '<img src="' . $thumb_url  . '" alt="' . htmlspecialchars($image->filename) . '" /></a>'; ?>
  <div style="valign: bottom;">
  <div class="image-tile-caption" id="<?php echo (int)$image->id . 'caption'?>"><?php echo $imageCaption ?></div>
 <?php if ($GLOBALS['registry']->getAuth() || $option_select): ?>
index 1027c1d..61c7bcc 100644 (file)
@@ -143,13 +143,13 @@ function downloadSelected()
     <?php if (!$this->numTiles): ?>
       <div class="text"><em><?php echo _("There are no photos in this gallery.") ?></em></div>
     <?php else: ?>
-      <table width="100%" style="background-color:<?php echo $this->style['background'] ?>;">
+      <table width="100%" style="background-color:<?php echo $this->style->background ?>;">
         <tr><td colspan="<?php echo $tilesperrow ?>"><?php echo $pager->render() ?></td></tr>
         <tr>
           <?php
           foreach ($this->children as $child) {
               echo '<td width="' . $cellwidth . '%" class="ansel-tile">'
-                  . $child->getTile($this->view->gallery, $this->style['name'], false, $this->view->getParams()) . '</td>';
+                  . $child->getTile($this->view->gallery, $this->style, false, $this->view->getParams()) . '</td>';
               if (!(++$count % $tilesperrow)) {
                 echo '</tr><tr>';
               }
index b4bcf1e..7812058 100644 (file)
@@ -171,13 +171,13 @@ function downloadSelected()
      <?php if (!$this->numTiles): ?>
       <div class="text"><em><?php echo _("There are no photos in this gallery.") ?></em></div>
      <?php else: ?>
-      <table width="100%" style="background-color:<?php echo $this->style['background'] ?>;">
+      <table width="100%" style="background-color:<?php echo $this->style->background ?>;">
        <tr><td colspan="<?php echo $tilesperrow ?>"><?php echo $pager->render() ?></td></tr>
        <tr>
        <?php
        foreach ($this->children as $child) {
            echo '<td width="' . $cellwidth . '%" class="ansel-tile">'
-               . $child->getTile($this->view->gallery, $this->style['name'], false, $this->view->getParams()) . '</td>';
+               . $child->getTile($this->view->gallery, $this->style, false, $this->view->getParams()) . '</td>';
            if (!(++$count % $tilesperrow)) {
                 echo '</tr><tr>';
            }
index e137027..5a9b33d 100644 (file)
@@ -50,7 +50,7 @@ function arrowHandler(e)
 <h1 class="header" id="PhotoName"><?php echo Ansel::getBreadCrumbs($this->gallery) ?></h1>
 <table style="width: 100%; border-collapse: collapse">
  <tr>
-  <td valign="top" style="background-color:<?php echo $this->_style['background']; ?>;">
+  <td valign="top" style="background-color:<?php echo $this->_style->background; ?>;">
     <?php
         $tempurl = new Horde_Url('#');
         $needSeperator = false;
index b7c5f45..14abb68 100644 (file)
 <div style="float:right:width:73%;">
 <?php endif; ?>
 <?php echo $this->_pager->render() ?>
-<table width="<?php echo ($this->countWidgets() ? 73 : 100) ?>%" style="background-color:<?php echo $style['background'] ?>;">
+<table width="<?php echo ($this->countWidgets() ? 73 : 100) ?>%" style="background-color:<?php echo $style->background ?>;">
  <tr>
  <?php
  $tilesperrow = $prefs->getValue('tilesperrow');
  $cellwidth = round(100 / $tilesperrow);
  $count = 0;
  foreach ($this->_galleryList as $galleryId => $gallery) {
-     echo '<td width="' . $width . '%" class="ansel-tile">' . $gallery->getTile(null, $style['name'], false, $this->_params) . '</td>';
+     echo '<td width="' . $width . '%" class="ansel-tile">' . $gallery->getTile(null, $style, false, $this->_params) . '</td>';
      if (!(++$count % $prefs->getValue('tilesperrow'))) {
          if ($count < $this->_numGalleries) {
              echo '</tr><tr>';
index 2587e06..b967198 100644 (file)
@@ -100,7 +100,7 @@ echo htmlspecialchars($this->getTitle(), ENT_COMPAT, $GLOBALS['registry']->getCh
      <div class="text"><em><?php echo _("There are no photos in this gallery.") ?></em></div>
     <?php else: ?>
      <?php echo $this->_pager->render() ?>
-     <table width="100%" style="background-color:<?php echo $styleDef['background'] ?>;"><tr>
+     <table width="100%" style="background-color:<?php echo $style->background ?>;"><tr>
       <?php
         $cellwidth = round(100 / $tilesperrow);
         $count = 0;
@@ -124,7 +124,7 @@ echo htmlspecialchars($this->getTitle(), ENT_COMPAT, $GLOBALS['registry']->getCh
    <td width="20%" valign="top">
     <div id="anselWidgets">
      <?php if ($conf['tags']['relatedtags']): ?>
-      <div style="background-color:<?php echo $styleDef['background'] ?>;">
+      <div style="background-color:<?php echo $style->background ?>;">
        <h2 class="header tagTitle"><?php echo _("Related Tags") ?></h2>
        <div id="tags"><?php echo $rtaghtml ?></div>
       </div>
index 3c570d7..e24473c 100644 (file)
@@ -29,7 +29,7 @@ function stopSlideShow()
   </td>
  </tr>
 </table>
-<table width="100%" cellpadding="0" cellspacing="0" style="background-color:<?php echo $this->_style['background']; ?>;">
+<table width="100%" cellpadding="0" cellspacing="0" style="background-color:<?php echo $this->_style->background; ?>;">
  <tr>
   <td>
     <div class="slideControls">