From: Michael J. Rubinsky Date: Thu, 16 Sep 2010 16:03:56 +0000 (-0400) Subject: Standardize on ImageGenerator names, fix mini thumbnail display on owner group view. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d5af214e527ee89933a480551646dd0b87b7eb66;p=horde.git Standardize on ImageGenerator names, fix mini thumbnail display on owner group view. To allow for easier theming, ImageGenerator classes for thumbnails are now named as: Ansel_ImageGenerator_{type}Thumb and if there is a matching stack generator, it should be named as: Ansel_ImageGenerator_{type}ThumbStack other types of generators, such as the screen, and mini generators, are named as before: Ansel_ImageGenerator_Screen, Ansel_ImageGenerator_Mini etc... --- diff --git a/ansel/img/mini.php b/ansel/img/mini.php index 38dbd2eeb..a74a41b06 100644 --- a/ansel/img/mini.php +++ b/ansel/img/mini.php @@ -32,4 +32,4 @@ if ($conf['vfs']['src'] == 'sendfile') { header('X-Sendfile: ' . $filename); exit; } -$image->display('mini'); +$image->display('mini', Ansel::getStyleDefinition('ansel_default')); diff --git a/ansel/lib/Gallery.php b/ansel/lib/Gallery.php index 0d3922119..2190adb47 100644 --- a/ansel/lib/Gallery.php +++ b/ansel/lib/Gallery.php @@ -51,6 +51,16 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical } } + public function get($property) + { + $value = parent::get($property); + if ($property == 'style') { + $value = unserialize($value); + } + + return $value; + } + /** * Check for special capabilities of this gallery. * @@ -590,8 +600,8 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical $style = $this->getStyle(); } - if ($style->default_galleryimage_type != 'plain') { - $thumbstyle = $style->default_galleryimage_type; + if ($style->keyimage_type != 'Thumb') { + $thumbstyle = $style->keyimage_type; $styleHash = $style->getHash($thumbstyle); /* First check for the existence of a key image in the specified style */ @@ -609,7 +619,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical //@TODO: Look at passing style both in params and the property... $params = array('gallery' => $this, 'style' => $style); try { - $iview = Ansel_ImageGenerator::factory($style->default_galleryimage_type, $params); + $iview = Ansel_ImageGenerator::factory($style->keyimage_type, $params); $img = $iview->create(); // Note the gallery_id is negative for generated stacks @@ -628,7 +638,7 @@ 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->default_galleryimage_type != 'plain') { + if ($style->keyimage_type != 'plain') { return $this->getKeyImage(Ansel::getStyleDefinition('ansel_default')); } } @@ -895,6 +905,11 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical $this->_setModeHelper($mode); } + /* Need to serialize the style object */ + if ($driver_key == 'attribute_style') { + $value = serialize($value); + } + $this->data[$driver_key] = $value; /* Update the backend, but only this current change */ diff --git a/ansel/lib/ImageGenerator/PlainStack.php b/ansel/lib/ImageGenerator/PlainStack.php deleted file mode 100644 index 85d750eb9..000000000 --- a/ansel/lib/ImageGenerator/PlainStack.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @package Ansel - */ -class Ansel_ImageGenerator_PlainStack extends Ansel_ImageGenerator -{ - public $need = array('PhotoStack'); - - /** - * - * @return Horde_Image - */ - protected function _create() - { - $imgobjs = $this->_getStackImages(); - $style = $this->_params['style']; - $params = array('width' => 100, - 'height' => 100, - 'background' => $style->background); - - $baseImg = Ansel::getImageObject($params); - try { - $baseImg->addEffect( - 'PhotoStack', - array('images' => $imgobjs, - 'resize_height' => $GLOBALS['conf']['thumbnail']['height'], - 'padding' => 0, - 'background' => $style->background, - 'type' => 'plain')); - - $baseImg->applyEffects(); - $baseImg->resize($GLOBALS['conf']['thumbnail']['width'], - $GLOBALS['conf']['thumbnail']['height']); - } catch (Horde_Image_Exception $e) { - throw new Ansel_Exception($e); - } - - return $baseImg; - } - -} diff --git a/ansel/lib/ImageGenerator/PolaroidStack.php b/ansel/lib/ImageGenerator/PolaroidStack.php deleted file mode 100644 index 62507fc5e..000000000 --- a/ansel/lib/ImageGenerator/PolaroidStack.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @package Ansel - */ -class Ansel_ImageGenerator_PolaroidStack extends Ansel_ImageGenerator -{ - public $need = array('PhotoStack'); - - /** - * - * @return Horde_Image - */ - protected function _create() - { - $imgobjs = $this->_getStackImages(); - $style = $this->_params['style']; - $params = array('width' => 100, - 'height' => 100, - 'background' => $style->background); - - $baseImg = Ansel::getImageObject($params); - try { - $baseImg->addEffect( - 'PhotoStack', - array('images' => $imgobjs, - 'resize_height' => $GLOBALS['conf']['thumbnail']['height'], - 'padding' => 10, - 'background' => $style->background, - 'type' => 'polaroid')); - $baseImg->applyEffects(); - $baseImg->resize($GLOBALS['conf']['thumbnail']['width'], - $GLOBALS['conf']['thumbnail']['height']); - - } catch (Horde_Image_Exception $e) { - throw new Ansel_Exception($e); - } - - return $baseImg; - } - -} diff --git a/ansel/lib/ImageGenerator/PolaroidThumbStack.php b/ansel/lib/ImageGenerator/PolaroidThumbStack.php new file mode 100644 index 000000000..be2994721 --- /dev/null +++ b/ansel/lib/ImageGenerator/PolaroidThumbStack.php @@ -0,0 +1,44 @@ + + * @package Ansel + */ +class Ansel_ImageGenerator_PolaroidThumbStack extends Ansel_ImageGenerator +{ + public $need = array('PhotoStack'); + + /** + * + * @return Horde_Image + */ + protected function _create() + { + $imgobjs = $this->_getStackImages(); + $style = $this->_params['style']; + $params = array('width' => 100, + 'height' => 100, + 'background' => $style->background); + + $baseImg = Ansel::getImageObject($params); + try { + $baseImg->addEffect( + 'PhotoStack', + array('images' => $imgobjs, + 'resize_height' => $GLOBALS['conf']['thumbnail']['height'], + 'padding' => 10, + 'background' => $style->background, + 'type' => 'polaroid')); + $baseImg->applyEffects(); + $baseImg->resize($GLOBALS['conf']['thumbnail']['width'], + $GLOBALS['conf']['thumbnail']['height']); + + } catch (Horde_Image_Exception $e) { + throw new Ansel_Exception($e); + } + + return $baseImg; + } + +} diff --git a/ansel/lib/ImageGenerator/PrettyThumb.php b/ansel/lib/ImageGenerator/PrettyThumb.php deleted file mode 100644 index f7de83aaa..000000000 --- a/ansel/lib/ImageGenerator/PrettyThumb.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @package Ansel - */ -class Ansel_ImageGenerator_PrettyThumb extends Ansel_ImageGenerator -{ - public $need = array('RoundCorners', 'DropShadow'); - - /** - * - * @return Horde_Image - */ - protected function _create() - { - $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']), - min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']), - true); - - /* Don't bother with these effects for a stack image - * (which will have a negative gallery_id). */ - if ($this->_image->gallery > 0) { - if (is_null($this->_style)) { - $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery); - $styleDef = $gal->getStyle(); - } else { - $styleDef = $this->_style; - } - - try { - /* Apply the effects - continue on error, but be sure to log */ - $this->_image->addEffect('RoundCorners', array('border' => 2, - 'bordercolor' => '#333')); - - $this->_image->addEffect('DropShadow', array('background' => $styleDef->background, - 'padding' => 5, - 'distance' => 5, - 'fade' => 3)); - if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) { - $this->_image->addEffect('Unsharpmask', - array('radius' => $GLOBALS['conf']['thumbnail']['radius'], - 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'], - 'amount' => $GLOBALS['conf']['thumbnail']['amount'])); - } - - $this->_image->applyEffects(); - } catch (Horde_Image_Exception $e) { - throw new Ansel_Exception($e); - } - - return $this->_image->getHordeImage(); - } - } - -} diff --git a/ansel/lib/ImageGenerator/RoundedStack.php b/ansel/lib/ImageGenerator/RoundedStack.php deleted file mode 100644 index a79bd24c2..000000000 --- a/ansel/lib/ImageGenerator/RoundedStack.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @package Ansel - * - */ -class Ansel_ImageGenerator_RoundedStack extends Ansel_ImageGenerator - { - public $need = array('PhotoStack'); - - /** - * - * @return Horde_Image - */ - protected function _create() - { - $imgobjs = $this->_getStackImages(); - $style = $this->_params['style']; - $params = array('width' => 100, - 'height' => 100, - 'background' => $style->background); - - $baseImg = Ansel::getImageObject($params); - - try { - $baseImg->addEffect( - 'PhotoStack', - array('images' => $imgobjs, - 'resize_height' => $GLOBALS['conf']['thumbnail']['height'], - 'padding' => 0, - 'background' => $style->background, - 'type' => 'rounded')); - - $baseImg->applyEffects(); - $baseImg->resize($GLOBALS['conf']['thumbnail']['width'], - $GLOBALS['conf']['thumbnail']['height']); - } catch (Horde_Image_Exception $e) { - throw new Ansel_Exception($e); - } - - return $baseImg; - } - -} diff --git a/ansel/lib/ImageGenerator/RoundedThumb.php b/ansel/lib/ImageGenerator/RoundedThumb.php new file mode 100644 index 000000000..72f08ab48 --- /dev/null +++ b/ansel/lib/ImageGenerator/RoundedThumb.php @@ -0,0 +1,57 @@ + + * @package Ansel + */ +class Ansel_ImageGenerator_RoundedThumb extends Ansel_ImageGenerator +{ + public $need = array('RoundCorners', 'DropShadow'); + + /** + * + * @return Horde_Image + */ + protected function _create() + { + $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']), + min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']), + true); + + /* Don't bother with these effects for a stack image + * (which will have a negative gallery_id). */ + if ($this->_image->gallery > 0) { + if (is_null($this->_style)) { + $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery); + $styleDef = $gal->getStyle(); + } else { + $styleDef = $this->_style; + } + + try { + /* Apply the effects - continue on error, but be sure to log */ + $this->_image->addEffect('RoundCorners', array('border' => 2, + 'bordercolor' => '#333')); + + $this->_image->addEffect('DropShadow', array('background' => $styleDef->background, + 'padding' => 5, + 'distance' => 5, + 'fade' => 3)); + if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) { + $this->_image->addEffect('Unsharpmask', + array('radius' => $GLOBALS['conf']['thumbnail']['radius'], + 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'], + 'amount' => $GLOBALS['conf']['thumbnail']['amount'])); + } + + $this->_image->applyEffects(); + } catch (Horde_Image_Exception $e) { + throw new Ansel_Exception($e); + } + + return $this->_image->getHordeImage(); + } + } + +} diff --git a/ansel/lib/ImageGenerator/RoundedThumbStack.php b/ansel/lib/ImageGenerator/RoundedThumbStack.php new file mode 100644 index 000000000..df5483fba --- /dev/null +++ b/ansel/lib/ImageGenerator/RoundedThumbStack.php @@ -0,0 +1,46 @@ + + * @package Ansel + * + */ +class Ansel_ImageGenerator_RoundedThumbStack extends Ansel_ImageGenerator + { + public $need = array('PhotoStack'); + + /** + * + * @return Horde_Image + */ + protected function _create() + { + $imgobjs = $this->_getStackImages(); + $style = $this->_params['style']; + $params = array('width' => 100, + 'height' => 100, + 'background' => $style->background); + + $baseImg = Ansel::getImageObject($params); + + try { + $baseImg->addEffect( + 'PhotoStack', + array('images' => $imgobjs, + 'resize_height' => $GLOBALS['conf']['thumbnail']['height'], + 'padding' => 0, + 'background' => $style->background, + 'type' => 'rounded')); + + $baseImg->applyEffects(); + $baseImg->resize($GLOBALS['conf']['thumbnail']['width'], + $GLOBALS['conf']['thumbnail']['height']); + } catch (Horde_Image_Exception $e) { + throw new Ansel_Exception($e); + } + + return $baseImg; + } + +} diff --git a/ansel/lib/ImageGenerator/ShadowSharpThumb.php b/ansel/lib/ImageGenerator/ShadowSharpThumb.php deleted file mode 100644 index bc065d897..000000000 --- a/ansel/lib/ImageGenerator/ShadowSharpThumb.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @package Ansel - */ -class Ansel_ImageGenerator_ShadowSharpThumb extends Ansel_ImageGenerator -{ - public $need = array('DropShadow'); - - /** - * - * @return boolean - */ - protected function _create() - { - $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']), - min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']), - true); - - /* Don't bother with these effects for a stack image - * (which will have a negative gallery_id). */ - if ($this->_image->gallery > 0) { - if (is_null($this->_style)) { - $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery); - $styleDef = $gal->getStyle(); - } else { - $styleDef = $this->_style; - } - - try { - $this->_image->addEffect('Border', array('bordercolor' => '#333', 'borderwidth' => 1)); - $this->_image->addEffect('DropShadow', - array('background' => $styleDef->background, - 'padding' => 5, - 'distance' => 8, - 'fade' => 2)); - - if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) { - $this->_image->addEffect('Unsharpmask', - array('radius' => $GLOBALS['conf']['thumbnail']['radius'], - 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'], - 'amount' => $GLOBALS['conf']['thumbnail']['amount'])); - $this->_image->applyEffects(); - } - - $this->_image->applyEffects(); - } catch (Horde_Image_Exception $e) { - throw new Ansel_Exception($e); - } - - return $this->_image->getHordeImage(); - } - } - -} diff --git a/ansel/lib/ImageGenerator/ShadowThumb.php b/ansel/lib/ImageGenerator/ShadowThumb.php new file mode 100644 index 000000000..98ce8abab --- /dev/null +++ b/ansel/lib/ImageGenerator/ShadowThumb.php @@ -0,0 +1,57 @@ + + * @package Ansel + */ +class Ansel_ImageGenerator_ShadowThumb extends Ansel_ImageGenerator +{ + public $need = array('DropShadow'); + + /** + * + * @return boolean + */ + protected function _create() + { + $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']), + min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']), + true); + + /* Don't bother with these effects for a stack image + * (which will have a negative gallery_id). */ + if ($this->_image->gallery > 0) { + if (is_null($this->_style)) { + $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery); + $styleDef = $gal->getStyle(); + } else { + $styleDef = $this->_style; + } + + try { + $this->_image->addEffect('Border', array('bordercolor' => '#333', 'borderwidth' => 1)); + $this->_image->addEffect('DropShadow', + array('background' => $styleDef->background, + 'padding' => 5, + 'distance' => 8, + 'fade' => 2)); + + if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) { + $this->_image->addEffect('Unsharpmask', + array('radius' => $GLOBALS['conf']['thumbnail']['radius'], + 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'], + 'amount' => $GLOBALS['conf']['thumbnail']['amount'])); + $this->_image->applyEffects(); + } + + $this->_image->applyEffects(); + } catch (Horde_Image_Exception $e) { + throw new Ansel_Exception($e); + } + + return $this->_image->getHordeImage(); + } + } + +} diff --git a/ansel/lib/ImageGenerator/ShadowThumbStack.php b/ansel/lib/ImageGenerator/ShadowThumbStack.php new file mode 100644 index 000000000..0aa148b69 --- /dev/null +++ b/ansel/lib/ImageGenerator/ShadowThumbStack.php @@ -0,0 +1,44 @@ + + * @package Ansel + */ +class Ansel_ImageGenerator_ShadowThumbStack extends Ansel_ImageGenerator +{ + public $need = array('PhotoStack'); + + /** + * + * @return Horde_Image + */ + protected function _create() + { + $imgobjs = $this->_getStackImages(); + $style = $this->_params['style']; + $params = array('width' => 100, + 'height' => 100, + 'background' => $style->background); + + $baseImg = Ansel::getImageObject($params); + try { + $baseImg->addEffect( + 'PhotoStack', + array('images' => $imgobjs, + 'resize_height' => $GLOBALS['conf']['thumbnail']['height'], + 'padding' => 0, + 'background' => $style->background, + 'type' => 'plain')); + + $baseImg->applyEffects(); + $baseImg->resize($GLOBALS['conf']['thumbnail']['width'], + $GLOBALS['conf']['thumbnail']['height']); + } catch (Horde_Image_Exception $e) { + throw new Ansel_Exception($e); + } + + return $baseImg; + } + +} diff --git a/ansel/lib/Style.php b/ansel/lib/Style.php index e4e791215..162aceb2b 100644 --- a/ansel/lib/Style.php +++ b/ansel/lib/Style.php @@ -22,7 +22,6 @@ class Ansel_Style public function __construct($properties) { $this->_properties = array_merge(array('gallery_view' => 'Gallery', - 'default_galleryimage_type' => 'plain', 'background' => 'none'), $properties); } @@ -50,6 +49,16 @@ class Ansel_Style public function &__get($property) { + if ($property == 'keyimage_type') { + // Force the same type of effect for key image/stacks if available + $class = $this->_properties['thumbstyle'] . 'Stack'; + if (!class_exists('Ansel_ImageGenerator_' . $class)) { + $class = 'Thumb'; + } + + return $class; + } + return $this->_properties[$property]; } diff --git a/ansel/lib/View/GalleryProperties.php b/ansel/lib/View/GalleryProperties.php index 2d8504b3b..d75bbec3f 100644 --- a/ansel/lib/View/GalleryProperties.php +++ b/ansel/lib/View/GalleryProperties.php @@ -236,7 +236,6 @@ class Ansel_View_GalleryProperties // 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(), diff --git a/ansel/templates/gallery/partial/_styles.html.php b/ansel/templates/gallery/partial/_styles.html.php index c62224017..17161eb01 100644 --- a/ansel/templates/gallery/partial/_styles.html.php +++ b/ansel/templates/gallery/partial/_styles.html.php @@ -3,12 +3,23 @@ + diff --git a/ansel/templates/group/owner.inc b/ansel/templates/group/owner.inc index 27ae8e453..6dc8b885a 100644 --- a/ansel/templates/group/owner.inc +++ b/ansel/templates/group/owner.inc @@ -50,7 +50,7 @@ $mini_galleries = array_values($mini_galleries); isOldEnough() && !$mini_galleries[$i]->hasPasswd()): ?> - <?php echo $owner_title?> + <?php echo $owner_title?>