From: Michael J. Rubinsky Date: Mon, 19 Jul 2010 17:35:29 +0000 (-0400) Subject: Ansel_ImageView -> Ansel_ImageGenerator X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d293fe9fedf628bfe4bf1743f4d6d9c452011465;p=horde.git Ansel_ImageView -> Ansel_ImageGenerator --- diff --git a/ansel/image.php b/ansel/image.php index 5c55eb849..d87a71c31 100644 --- a/ansel/image.php +++ b/ansel/image.php @@ -277,7 +277,7 @@ case 'save': case 'editimage': case 'cropedit': case 'resizeedit': - $imageview_url = Ansel::getUrlFor('view', array_merge( + $ImageGenerator_url = Ansel::getUrlFor('view', array_merge( array('gallery' => $gallery_id, 'image' => $image_id, 'view' => 'Image', @@ -304,7 +304,7 @@ case 'resizeedit': 'horde.error'); /* Return to the image view. */ - header('Location: ' . $imageview_url); + header('Location: ' . $ImageGenerator_url); exit; } diff --git a/ansel/lib/Gallery.php b/ansel/lib/Gallery.php index cce530664..8c9f87f66 100644 --- a/ansel/lib/Gallery.php +++ b/ansel/lib/Gallery.php @@ -627,7 +627,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical // Don't already have one, must generate it. $params = array('gallery' => $this, 'style' => $gal_style); try { - $iview = Ansel_ImageView::factory($gal_style['default_galleryimage_type'], $params); + $iview = Ansel_ImageGenerator::factory($gal_style['default_galleryimage_type'], $params); $img = $iview->create(); // Note the gallery_id is negative for generated stacks @@ -913,7 +913,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical // Manually convert the charset since we're not going through save() // @TODO: Look at this usage - maybe each app's share object should // have this method or just keep it public? - $data = $this->getshareOb()->toDriverChaset(array($driver_key => $value)); + $data = $this->getshareOb()->toDriverCharset(array($driver_key => $value)); $query = $db->prepare('UPDATE ' . $this->getShareOb()->getTable() . ' SET ' . $driver_key . ' = ? WHERE share_id = ?', null, MDB2_PREPARE_MANIP); if ($GLOBALS['conf']['ansel_cache']['usecache']) { $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $this->id); diff --git a/ansel/lib/Image.php b/ansel/lib/Image.php index f4471a3e8..a5a0c7d82 100644 --- a/ansel/lib/Image.php +++ b/ansel/lib/Image.php @@ -401,23 +401,23 @@ class Ansel_Image Implements Iterator } try { - $iview = Ansel_ImageView::factory($viewType, array('image' => $this, 'style' => $style)); + $iview = Ansel_ImageGenerator::factory($viewType, array('image' => $this, 'style' => $style)); } catch (Ansel_Exception $e) { // 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_ImageView::factory('Thumb', array('image' => $this, 'style' => 'ansel_default')); + $iview = Ansel_ImageGenerator::factory('Thumb', array('image' => $this, 'style' => 'ansel_default')); } else { // If it wasn't a prettythumb, then something else must be wrong throw $e; } } - /* Create the ImageView */ + /* Create the ImageGenerator */ $iview->create(); - /* Cache the data from the new imageview */ + /* Cache the data from the new ImageGenerator */ try { $this->_data[$vHash] = $this->_image->raw(); } catch (Horde_Image_Exception $e) { diff --git a/ansel/lib/ImageGenerator.php b/ansel/lib/ImageGenerator.php new file mode 100644 index 000000000..1d4719204 --- /dev/null +++ b/ansel/lib/ImageGenerator.php @@ -0,0 +1,196 @@ + + * @package Ansel + */ +class Ansel_ImageGenerator +{ + /** + * Ansel_Image object that this view is created from. + * + * @var Ansel_Image + */ + protected $_image = null; + + /** + * Parameters for this view + * + * @var array + */ + protected $_params = array(); + + /** + * Image dimensions + * + * @var array + */ + protected $_dimensions = array(); + + /** + * Cache the style information array + * + * @var array + */ + protected $_style = array(); + + /** + * Array of required, supported features for this ImageGenerator to work + * + * @var array + */ + public $need = array(); + + /** + * Const'r + * + * @return Horde_ImageGenerator + */ + public function __construct($params) + { + $this->_params = $params; + if (!empty($params['image'])) { + $this->_image = $params['image']; + } + $this->_style = $params['style']; + } + + /** + * Create and cache the view. + * + * @return mixed Views used as gallery key images return Horde_Image, + * other views return boolean + */ + public function create() + { + if (!empty($this->_image)) { + // Use Horde_Image since we don't know at this point which + // view we have loaded. + $img = $this->_image->getHordeImage(); + $this->_dimensions = $img->getDimensions(); + } + + return $this->_create(); + } + + /** + * Horde_ImageGenerator factory + * + * @param string $type The type of concrete instance to return. + * @param array $params Additional parameters needed for the instance. + * + * @return Ansel_ImageGenerator + * @throws Ansel_Exception + */ + function factory($type, $params = array()) + { + $type = basename($type); + $class = 'Ansel_ImageGenerator_' . $type; + if (!class_exists($class)) { + include dirname(__FILE__) . '/ImageGenerator/' . $type . '.php'; + } + if (class_exists($class)) { + $view = new $class($params); + // Check that the image object supports what we need for the + // requested effect. + foreach ($view->need as $need) { + if (!Ansel::isAvailable($need)) { + Horde::logMessage($err, 'ERR'); + throw new Ansel_Exception(_("This install does not support the %s feature. Please contact your administrator."), $need); + } + } + return $view; + } else { + Horde::logMessage($err, 'ERR'); + throw new Ansel_Exception(sprintf(_("Unable to load the definition of %s."), $class)); + } + } + + /** + * Utility function to make every effort to find a subgallery that + * contains images. + * + * @param Ansel_Gallery $parent The gallery to start looking in + * + * @return Ansel_Gallery Gallery that has images, or the original $parent + */ + protected function _getGalleryWithImages($parent) + { + $galleries = $GLOBALS['injector'] + ->getInstance('Ansel_Storage') + ->getScope() + ->listGalleries(array('parent' => $parent, 'allLevels' => false)); + + foreach ($galleries as $gallery) { + if ($gallery->countImages()) { + return $gallery; + } + $result = $this->_getGalleryWithImages($gallery); + if ($result->countImages()) { + return $result; + } + } + + return $parent; + } + + /** + * Utility function to return an array of Horde_Images to use in building a + * polaroid stack. Returns a random set of 5 images from the gallery, or the + * explicitly set default image plus 4 others. + * + * @return array of Horde_Images + */ + protected function _getStackImages() + { + $images = array(); + $gallery = $this->_params['gallery']; + + // Make sure we have images. + if (!$gallery->countImages() && $gallery->hasSubGalleries()) { + $gallery = $this->_getGalleryWithImages($gallery); + } + + $cnt = min(5, $gallery->countImages()); + $default = $gallery->get('default'); + if (!empty($default) && $default > 0) { + try { + $img = $gallery->getImage($default); + $img->load('screen'); + $images[] = $img->getHordeImage(); + $cnt--; + } catch (Exception $e) { + Horde::logMessage($e, 'ERR'); + } + } + + for ($i = 0; $i < $cnt; $i++) { + $rnd = mt_rand(0, $cnt); + try { + $temp = $gallery->getImages($rnd, 1); + $aimg = array_shift($temp); + $aimg->load('screen'); + $images[] = $aimg->getHordeImage(); + } catch (Exception $e) { + Horde::logMessage($e, 'ERR'); + } + } + + // Reverse the array to ensure the requested default image + // is the last in the array (so it will appear on the top of + // the stack. + return array_reverse($images); + } + +} diff --git a/ansel/lib/ImageGenerator/Mini.php b/ansel/lib/ImageGenerator/Mini.php new file mode 100755 index 000000000..f00f9d8ae --- /dev/null +++ b/ansel/lib/ImageGenerator/Mini.php @@ -0,0 +1,23 @@ + + * @package Ansel + */ +class Ansel_ImageGenerator_Mini extends Ansel_ImageGenerator +{ + /** + * + * @return Horde_Image + */ + protected function _create() + { + $this->_image->resize(min(50, $this->_dimensions['width']), + min(50, $this->_dimensions['height']), + true); + + return $this->_image->getHordeImage(); + } + +} diff --git a/ansel/lib/ImageGenerator/PlainStack.php b/ansel/lib/ImageGenerator/PlainStack.php new file mode 100644 index 000000000..509a03694 --- /dev/null +++ b/ansel/lib/ImageGenerator/PlainStack.php @@ -0,0 +1,44 @@ + + * @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 new file mode 100644 index 000000000..4befd6921 --- /dev/null +++ b/ansel/lib/ImageGenerator/PolaroidStack.php @@ -0,0 +1,44 @@ + + * @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/PolaroidThumb.php b/ansel/lib/ImageGenerator/PolaroidThumb.php new file mode 100644 index 000000000..fc453d120 --- /dev/null +++ b/ansel/lib/ImageGenerator/PolaroidThumb.php @@ -0,0 +1,45 @@ + + * @package Ansel + */ +class Ansel_ImageGenerator_PolaroidThumb extends Ansel_ImageGenerator +{ + public $need = array('PolaroidImage'); + + /** + * + * @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 custom gallery default 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 = Ansel::getStyleDefinition($this->_style); + } + try { + $this->_image->addEffect('PolaroidImage', + array('background' => $styleDef['background'], + 'padding' => 5)); + + $this->_image->applyEffects(); + } catch (Horde_Image_Exception $e) { + throw new Ansel_Exception($e); + } + + return true; + } + } + +} diff --git a/ansel/lib/ImageGenerator/PrettyThumb.php b/ansel/lib/ImageGenerator/PrettyThumb.php new file mode 100644 index 000000000..5fe9df582 --- /dev/null +++ b/ansel/lib/ImageGenerator/PrettyThumb.php @@ -0,0 +1,50 @@ + + * @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 = Ansel::getStyleDefinition($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)); + } catch (Horde_Image_Exception $e) { + throw new Ansel_Exception($e); + } + $this->_image->applyEffects(); + + return $this->_image->getHordeImage(); + } + } + +} diff --git a/ansel/lib/ImageGenerator/RoundedStack.php b/ansel/lib/ImageGenerator/RoundedStack.php new file mode 100644 index 000000000..0cdf0ce18 --- /dev/null +++ b/ansel/lib/ImageGenerator/RoundedStack.php @@ -0,0 +1,46 @@ + + * @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/Screen.php b/ansel/lib/ImageGenerator/Screen.php new file mode 100755 index 000000000..448978aba --- /dev/null +++ b/ansel/lib/ImageGenerator/Screen.php @@ -0,0 +1,23 @@ + + * @package Ansel + */ +class Ansel_ImageGenerator_Screen extends Ansel_ImageGenerator +{ + /** + * + * @return boolean + */ + protected function _create() + { + $this->_image->resize(min($GLOBALS['conf']['screen']['width'], $this->_dimensions['width']), + min($GLOBALS['conf']['screen']['height'], $this->_dimensions['height']), + true); + + return $this->_image->getHordeImage(); + } + +} diff --git a/ansel/lib/ImageGenerator/ShadowSharpThumb.php b/ansel/lib/ImageGenerator/ShadowSharpThumb.php new file mode 100644 index 000000000..bf9004fd1 --- /dev/null +++ b/ansel/lib/ImageGenerator/ShadowSharpThumb.php @@ -0,0 +1,48 @@ + + * @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 = Ansel::getStyleDefinition($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)); + $this->_image->applyEffects(); + } catch (Horde_Image_Exception $e) { + throw new Ansel_Exception($e); + } + + return $this->_image->getHordeImage(); + } + } + +} diff --git a/ansel/lib/ImageGenerator/Thumb.php b/ansel/lib/ImageGenerator/Thumb.php new file mode 100755 index 000000000..f6203cd08 --- /dev/null +++ b/ansel/lib/ImageGenerator/Thumb.php @@ -0,0 +1,22 @@ + + * @package Ansel + */ +class Ansel_ImageGenerator_Thumb extends Ansel_ImageGenerator +{ + /** + * + * @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); + return $this->_image->getHordeImage(); + } + +} diff --git a/ansel/lib/ImageView.php b/ansel/lib/ImageView.php deleted file mode 100644 index 5f09eeaad..000000000 --- a/ansel/lib/ImageView.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @package Ansel - */ -class Ansel_ImageView -{ - /** - * Ansel_Image object that this view is created from. - * - * @var Ansel_Image - */ - protected $_image = null; - - /** - * Parameters for this view - * - * @var array - */ - protected $_params = array(); - - /** - * Image dimensions - * - * @var array - */ - protected $_dimensions = array(); - - /** - * Cache the style information array - * - * @var array - */ - protected $_style = array(); - - /** - * Array of required, supported features for this ImageView to work - * - * @var array - */ - public $need = array(); - - /** - * Const'r - * - * @return Horde_ImageView - */ - public function __construct($params) - { - $this->_params = $params; - if (!empty($params['image'])) { - $this->_image = $params['image']; - } - $this->_style = $params['style']; - } - - /** - * Create and cache the view. - * - * @return mixed Views used as gallery key images return Horde_Image, - * other views return boolean - */ - public function create() - { - if (!empty($this->_image)) { - // Use Horde_Image since we don't know at this point which - // view we have loaded. - $img = $this->_image->getHordeImage(); - $this->_dimensions = $img->getDimensions(); - } - - return $this->_create(); - } - - /** - * Horde_ImageView factory - * - * @param string $type The type of concrete instance to return. - * @param array $params Additional parameters needed for the instance. - * - * @return Ansel_ImageView - * @throws Ansel_Exception - */ - function factory($type, $params = array()) - { - $type = basename($type); - $class = 'Ansel_ImageView_' . $type; - if (!class_exists($class)) { - include dirname(__FILE__) . '/ImageView/' . $type . '.php'; - } - if (class_exists($class)) { - $view = new $class($params); - // Check that the image object supports what we need for the - // requested effect. - foreach ($view->need as $need) { - if (!Ansel::isAvailable($need)) { - Horde::logMessage($err, 'ERR'); - throw new Ansel_Exception(_("This install does not support the %s feature. Please contact your administrator."), $need); - } - } - return $view; - } else { - Horde::logMessage($err, 'ERR'); - throw new Ansel_Exception(sprintf(_("Unable to load the definition of %s."), $class)); - } - } - - /** - * Utility function to make every effort to find a subgallery that - * contains images. - * - * @param Ansel_Gallery $parent The gallery to start looking in - * - * @return Ansel_Gallery Gallery that has images, or the original $parent - */ - protected function _getGalleryWithImages($parent) - { - $galleries = $GLOBALS['injector'] - ->getInstance('Ansel_Storage') - ->getScope() - ->listGalleries(array('parent' => $parent, 'allLevels' => false)); - - foreach ($galleries as $gallery) { - if ($gallery->countImages()) { - return $gallery; - } - $result = $this->_getGalleryWithImages($gallery); - if ($result->countImages()) { - return $result; - } - } - - return $parent; - } - - /** - * Utility function to return an array of Horde_Images to use in building a - * polaroid stack. Returns a random set of 5 images from the gallery, or the - * explicitly set default image plus 4 others. - * - * @return array of Horde_Images - */ - protected function _getStackImages() - { - $images = array(); - $gallery = $this->_params['gallery']; - - // Make sure we have images. - if (!$gallery->countImages() && $gallery->hasSubGalleries()) { - $gallery = $this->_getGalleryWithImages($gallery); - } - - $cnt = min(5, $gallery->countImages()); - $default = $gallery->get('default'); - if (!empty($default) && $default > 0) { - try { - $img = $gallery->getImage($default); - $img->load('screen'); - $images[] = $img->getHordeImage(); - $cnt--; - } catch (Exception $e) { - Horde::logMessage($e, 'ERR'); - } - } - - for ($i = 0; $i < $cnt; $i++) { - $rnd = mt_rand(0, $cnt); - try { - $temp = $gallery->getImages($rnd, 1); - $aimg = array_shift($temp); - $aimg->load('screen'); - $images[] = $aimg->getHordeImage(); - } catch (Exception $e) { - Horde::logMessage($e, 'ERR'); - } - } - - // Reverse the array to ensure the requested default image - // is the last in the array (so it will appear on the top of - // the stack. - return array_reverse($images); - } - -} diff --git a/ansel/lib/ImageView/Mini.php b/ansel/lib/ImageView/Mini.php deleted file mode 100755 index c09ff570c..000000000 --- a/ansel/lib/ImageView/Mini.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @package Ansel - */ -class Ansel_ImageView_Mini extends Ansel_ImageView -{ - /** - * - * @return Horde_Image - */ - protected function _create() - { - $this->_image->resize(min(50, $this->_dimensions['width']), - min(50, $this->_dimensions['height']), - true); - - return $this->_image->getHordeImage(); - } - -} diff --git a/ansel/lib/ImageView/PlainStack.php b/ansel/lib/ImageView/PlainStack.php deleted file mode 100644 index b251f46f4..000000000 --- a/ansel/lib/ImageView/PlainStack.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @package Ansel - */ -class Ansel_ImageView_PlainStack extends Ansel_ImageView -{ - 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/ImageView/PolaroidStack.php b/ansel/lib/ImageView/PolaroidStack.php deleted file mode 100644 index 34e0501ec..000000000 --- a/ansel/lib/ImageView/PolaroidStack.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @package Ansel - */ -class Ansel_ImageView_PolaroidStack extends Ansel_ImageView -{ - 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/ImageView/PolaroidThumb.php b/ansel/lib/ImageView/PolaroidThumb.php deleted file mode 100644 index 07486ca48..000000000 --- a/ansel/lib/ImageView/PolaroidThumb.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @package Ansel - */ -class Ansel_ImageView_PolaroidThumb extends Ansel_ImageView -{ - public $need = array('PolaroidImage'); - - /** - * - * @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 custom gallery default 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 = Ansel::getStyleDefinition($this->_style); - } - try { - $this->_image->addEffect('PolaroidImage', - array('background' => $styleDef['background'], - 'padding' => 5)); - - $this->_image->applyEffects(); - } catch (Horde_Image_Exception $e) { - throw new Ansel_Exception($e); - } - - return true; - } - } - -} diff --git a/ansel/lib/ImageView/PrettyThumb.php b/ansel/lib/ImageView/PrettyThumb.php deleted file mode 100644 index 58d2bc1f2..000000000 --- a/ansel/lib/ImageView/PrettyThumb.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @package Ansel - */ -class Ansel_ImageView_PrettyThumb extends Ansel_ImageView -{ - 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 = Ansel::getStyleDefinition($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)); - } catch (Horde_Image_Exception $e) { - throw new Ansel_Exception($e); - } - $this->_image->applyEffects(); - - return $this->_image->getHordeImage(); - } - } - -} diff --git a/ansel/lib/ImageView/RoundedStack.php b/ansel/lib/ImageView/RoundedStack.php deleted file mode 100644 index 76319b9a4..000000000 --- a/ansel/lib/ImageView/RoundedStack.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @package Ansel - * - */ -class Ansel_ImageView_RoundedStack extends Ansel_ImageView - { - 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/ImageView/Screen.php b/ansel/lib/ImageView/Screen.php deleted file mode 100755 index d50f11153..000000000 --- a/ansel/lib/ImageView/Screen.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @package Ansel - */ -class Ansel_ImageView_Screen extends Ansel_ImageView -{ - /** - * - * @return boolean - */ - protected function _create() - { - $this->_image->resize(min($GLOBALS['conf']['screen']['width'], $this->_dimensions['width']), - min($GLOBALS['conf']['screen']['height'], $this->_dimensions['height']), - true); - - return $this->_image->getHordeImage(); - } - -} diff --git a/ansel/lib/ImageView/ShadowSharpThumb.php b/ansel/lib/ImageView/ShadowSharpThumb.php deleted file mode 100644 index d5b396b72..000000000 --- a/ansel/lib/ImageView/ShadowSharpThumb.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @package Ansel - */ -class Ansel_ImageView_ShadowSharpThumb extends Ansel_ImageView -{ - 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 = Ansel::getStyleDefinition($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)); - $this->_image->applyEffects(); - } catch (Horde_Image_Exception $e) { - throw new Ansel_Exception($e); - } - - return $this->_image->getHordeImage(); - } - } - -} diff --git a/ansel/lib/ImageView/Thumb.php b/ansel/lib/ImageView/Thumb.php deleted file mode 100755 index 62f381d0d..000000000 --- a/ansel/lib/ImageView/Thumb.php +++ /dev/null @@ -1,22 +0,0 @@ - - * @package Ansel - */ -class Ansel_ImageView_Thumb extends Ansel_ImageView -{ - /** - * - * @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); - return $this->_image->getHordeImage(); - } - -} diff --git a/ansel/lib/View/Base.php b/ansel/lib/View/Base.php index 8b49073eb..2e56cedad 100644 --- a/ansel/lib/View/Base.php +++ b/ansel/lib/View/Base.php @@ -221,7 +221,7 @@ abstract class Ansel_View_Base * full - Should a full URL be generated? [false] * from - Starting image count [0] * count - The number of images to include (starting at from) [0] - * image_view - The type of ImageView to obtain the src url for. [screen] + * image_view - The type of ImageGenerator to obtain the src url for. [screen] * view_links - Should the JSON include links to the Image and/or Gallery View? [false] * perpage - Number of images per page [from user prefs] * diff --git a/ansel/templates/image/crop_image.inc b/ansel/templates/image/crop_image.inc index d303faa0b..83cff1f62 100644 --- a/ansel/templates/image/crop_image.inc +++ b/ansel/templates/image/crop_image.inc @@ -90,7 +90,7 @@ $style = $gallery->getStyle(); $image_src = Ansel::getImageUrl($image_id, 'full'); echo $galleryurl->link() . Horde::img('galleries.png') . ' ' . _("Back to gallery") . ' '; -echo $imageview_url->link() . Horde::img('galleries.png') . ' ' . _("Cancel") . ' '; +echo $ImageGenerator_url->link() . Horde::img('galleries.png') . ' ' . _("Cancel") . ' '; if (Ansel::isAvailable('rotate')) { echo $imageurl->copy()->add('actionID', 'previewrotate270')->link() . Horde::img('image/rotate-270.png') . ' ' . _("Rotate Left") . ' '; diff --git a/ansel/templates/image/edit_image.inc b/ansel/templates/image/edit_image.inc index 704037a21..138878fa7 100644 --- a/ansel/templates/image/edit_image.inc +++ b/ansel/templates/image/edit_image.inc @@ -6,7 +6,7 @@ $style = $gallery->getStyle(); $image_src = Ansel::getImageUrl($image_id, 'screen'); echo $galleryurl->link() . Horde::img('galleries.png') . ' ' . _("Back to gallery") . ' '; -echo $imageview_url->link() . Horde::img('galleries.png') . ' ' . _("Cancel") . ' '; +echo $ImageGenerator_url->link() . Horde::img('galleries.png') . ' ' . _("Cancel") . ' '; if (Ansel::isAvailable('rotate')) { echo $imageurl->copy()->add('actionID', 'previewrotate270')->link() . Horde::img('image/rotate-270.png') . ' ' . _("Rotate Left") . ' '; diff --git a/ansel/templates/image/resize_image.inc b/ansel/templates/image/resize_image.inc index 7e655eb17..2ff1d7211 100644 --- a/ansel/templates/image/resize_image.inc +++ b/ansel/templates/image/resize_image.inc @@ -37,7 +37,7 @@ $style = $gallery->getStyle(); $image_src = Ansel::getImageUrl($image_id, 'full'); echo $galleryurl->link() . Horde::img('galleries.png') . ' ' . _("Back to gallery") . ' '; -echo $imageview_url->link() . Horde::img('galleries.png') . ' ' . _("Cancel") . ' '; +echo $ImageGenerator_url->link() . Horde::img('galleries.png') . ' ' . _("Cancel") . ' '; if (Ansel::isAvailable('rotate')) { echo $imageurl->copy()->add('actionID', 'previewrotate270')->link() . Horde::img('image/rotate-270.png') . ' ' . _("Rotate Left") . ' ';