From d5af214e527ee89933a480551646dd0b87b7eb66 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Thu, 16 Sep 2010 12:03:56 -0400 Subject: [PATCH] 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... --- ansel/img/mini.php | 2 +- ansel/lib/Gallery.php | 23 ++++++++++++++++++---- .../{PolaroidStack.php => PolaroidThumbStack.php} | 2 +- .../{PrettyThumb.php => RoundedThumb.php} | 2 +- .../{RoundedStack.php => RoundedThumbStack.php} | 2 +- .../{ShadowSharpThumb.php => ShadowThumb.php} | 2 +- .../{PlainStack.php => ShadowThumbStack.php} | 2 +- ansel/lib/Style.php | 11 ++++++++++- ansel/lib/View/GalleryProperties.php | 1 - ansel/templates/gallery/partial/_styles.html.php | 15 ++++++++++++-- ansel/templates/group/owner.inc | 2 +- 11 files changed, 49 insertions(+), 15 deletions(-) rename ansel/lib/ImageGenerator/{PolaroidStack.php => PolaroidThumbStack.php} (94%) rename ansel/lib/ImageGenerator/{PrettyThumb.php => RoundedThumb.php} (97%) rename ansel/lib/ImageGenerator/{RoundedStack.php => RoundedThumbStack.php} (94%) rename ansel/lib/ImageGenerator/{ShadowSharpThumb.php => ShadowThumb.php} (96%) rename ansel/lib/ImageGenerator/{PlainStack.php => ShadowThumbStack.php} (94%) 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/PolaroidStack.php b/ansel/lib/ImageGenerator/PolaroidThumbStack.php similarity index 94% rename from ansel/lib/ImageGenerator/PolaroidStack.php rename to ansel/lib/ImageGenerator/PolaroidThumbStack.php index 62507fc5e..be2994721 100644 --- a/ansel/lib/ImageGenerator/PolaroidStack.php +++ b/ansel/lib/ImageGenerator/PolaroidThumbStack.php @@ -5,7 +5,7 @@ * @author Michael J. Rubinsky * @package Ansel */ -class Ansel_ImageGenerator_PolaroidStack extends Ansel_ImageGenerator +class Ansel_ImageGenerator_PolaroidThumbStack extends Ansel_ImageGenerator { public $need = array('PhotoStack'); diff --git a/ansel/lib/ImageGenerator/PrettyThumb.php b/ansel/lib/ImageGenerator/RoundedThumb.php similarity index 97% rename from ansel/lib/ImageGenerator/PrettyThumb.php rename to ansel/lib/ImageGenerator/RoundedThumb.php index f7de83aaa..72f08ab48 100644 --- a/ansel/lib/ImageGenerator/PrettyThumb.php +++ b/ansel/lib/ImageGenerator/RoundedThumb.php @@ -5,7 +5,7 @@ * @author Michael J. Rubinsky * @package Ansel */ -class Ansel_ImageGenerator_PrettyThumb extends Ansel_ImageGenerator +class Ansel_ImageGenerator_RoundedThumb extends Ansel_ImageGenerator { public $need = array('RoundCorners', 'DropShadow'); diff --git a/ansel/lib/ImageGenerator/RoundedStack.php b/ansel/lib/ImageGenerator/RoundedThumbStack.php similarity index 94% rename from ansel/lib/ImageGenerator/RoundedStack.php rename to ansel/lib/ImageGenerator/RoundedThumbStack.php index a79bd24c2..df5483fba 100644 --- a/ansel/lib/ImageGenerator/RoundedStack.php +++ b/ansel/lib/ImageGenerator/RoundedThumbStack.php @@ -6,7 +6,7 @@ * @package Ansel * */ -class Ansel_ImageGenerator_RoundedStack extends Ansel_ImageGenerator +class Ansel_ImageGenerator_RoundedThumbStack extends Ansel_ImageGenerator { public $need = array('PhotoStack'); diff --git a/ansel/lib/ImageGenerator/ShadowSharpThumb.php b/ansel/lib/ImageGenerator/ShadowThumb.php similarity index 96% rename from ansel/lib/ImageGenerator/ShadowSharpThumb.php rename to ansel/lib/ImageGenerator/ShadowThumb.php index bc065d897..98ce8abab 100644 --- a/ansel/lib/ImageGenerator/ShadowSharpThumb.php +++ b/ansel/lib/ImageGenerator/ShadowThumb.php @@ -5,7 +5,7 @@ * @author Michael J. Rubinsky * @package Ansel */ -class Ansel_ImageGenerator_ShadowSharpThumb extends Ansel_ImageGenerator +class Ansel_ImageGenerator_ShadowThumb extends Ansel_ImageGenerator { public $need = array('DropShadow'); diff --git a/ansel/lib/ImageGenerator/PlainStack.php b/ansel/lib/ImageGenerator/ShadowThumbStack.php similarity index 94% rename from ansel/lib/ImageGenerator/PlainStack.php rename to ansel/lib/ImageGenerator/ShadowThumbStack.php index 85d750eb9..0aa148b69 100644 --- a/ansel/lib/ImageGenerator/PlainStack.php +++ b/ansel/lib/ImageGenerator/ShadowThumbStack.php @@ -5,7 +5,7 @@ * @author Michael J. Rubinsky * @package Ansel */ -class Ansel_ImageGenerator_PlainStack extends Ansel_ImageGenerator +class Ansel_ImageGenerator_ShadowThumbStack extends Ansel_ImageGenerator { public $need = array('PhotoStack'); 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?> -- 2.11.0