$styles['ansel_default'] = array(
'name' => 'ansel_default',
'title' => _("Default"),
- 'thumbstyle' => 'thumb',
+ 'thumbstyle' => 'Thumb',
'background' => 'none',
'widgets' => $widgets,
);
$styles['ansel_prettythumbs'] = array(
'name' => 'ansel_prettythumbs',
'title' => _("Pretty Thumbnails (No Background)"),
- 'thumbstyle' => 'prettythumb',
+ 'thumbstyle' => 'PrettyThumb',
'requires_png' => true,
// This really only looks good with ImageMagick, not GD.
'default_galleryimage_type' => 'roundedstack',
'name' => 'ansel_blackonwhite',
'title' => _("Pretty Thumbnails (White Background)"),
'default_galleryimage_type' => 'roundedstack',
- 'thumbstyle' => 'prettythumb',
+ 'thumbstyle' => 'PrettyThumb',
'background' => 'white',
'widgets' => $widgets,
);
$styles['ansel_sharpshadowed'] = array(
'name' => 'ansel_sharpshadowed',
'title' => _("Shadowed Thumbnails (White Background)"),
- 'thumbstyle' => 'shadowsharpthumb',
+ 'thumbstyle' => 'ShadowSharpThumb',
'background' => 'white',
'default_galleryimage_type' => 'plainstack',
'widgets' => $widgets
$styles['ansel_polaroid'] = array(
'name' => 'ansel_polaroid',
'title' => _("Polaroid Style Thumbnails (White Background)"),
- 'thumbstyle' => 'polaroidthumb',
+ 'thumbstyle' => 'PolaroidThumb',
'background' => 'white',
'default_galleryimage_type' => 'polaroidstack',
'widgets' => $widgets,
$styles['ansel_lightbox'] = array(
'name' => 'ansel_lightbox',
'title' => _("A Lightbox Inspired Style (White Background)"),
- 'thumbstyle' => 'thumb',
+ 'thumbstyle' => 'Thumb',
'background' => 'white',
'gallery_view' => 'GalleryLightbox',
'widgets' => $widgets,
$styles['ansel_lightbox_png'] = array(
'name' => 'ansel_lightbox_png',
'title' => _("A Lightbox Inspired Style (No Background)"),
- 'thumbstyle' => 'thumb',
+ 'thumbstyle' => 'Thumb',
'background' => 'none',
'requires_png' => true,
'gallery_view' => 'GalleryLightbox',
$styles['ansel_lightbox_shadowed_png'] = array(
'name' => 'ansel_lightbox_shadowed_png',
'title' => _("A Lightbox Inspired Style (Drop Shadows, No Background)"),
- 'thumbstyle' => 'shadowsharpthumb',
+ 'thumbstyle' => 'ShadowSharpThumb',
'background' => 'none',
'requires_png' => true,
'gallery_view' => 'GalleryLightbox',
$styles['ansel_lightbox_polaroid'] = array(
'name' => 'ansel_lightbox_polaroid',
'title' => _("Lightbox with Polaroids (No Background)"),
- 'thumbstyle' => 'polaroidthumb',
+ 'thumbstyle' => 'PolaroidThumb',
'background' => 'none',
'requires_png' => true,
'default_galleryimage_type' => 'polaroidstack',
$styles['ansel_simple'] = array(
'name' => 'ansel_simple',
'title' => _("Simple"),
- 'thumbstyle' => 'thumb',
+ 'thumbstyle' => 'Thumb',
'background' => 'none',
'hide' => true,
);
$styles['ansel_lightbox_simple'] = array(
'name' => 'ansel_lightbox_simple',
'title' => _("Simple Lightbox"),
- 'thumbstyle' => 'thumb',
+ 'thumbstyle' => 'Thumb',
'background' => 'none',
'requires_png' => true,
'gallery_view' => 'GalleryLightbox',
$styles['ansel_lightbox_simple_polaroid'] = array(
'name' => 'ansel_lightbox_polaroid',
'title' => _("Lightbox with Polaroids (No Background)"),
- 'thumbstyle' => 'polaroidthumb',
+ 'thumbstyle' => 'PolaroidThumb',
'background' => 'none',
'requires_png' => true,
'default_galleryimage_type' => 'polaroidstack',
--- /dev/null
+<?php
+/**
+ * Base exception class for Ansel.
+ *
+ * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
+ *
+ * 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_Exception extends Horde_Exception_Prior
+{
+}
'gallery_id' => -$this->id);
$newImg = new Ansel_Image($iparams);
$newImg->save();
- $prettyData = serialize(
- array_merge($thumbs,
- array($styleHash => $newImg->id)));
-
+ $prettyData = serialize(array_merge($thumbs, array($styleHash => $newImg->id)));
$this->set('default_prettythumb', $prettyData, true);
return $newImg->id;
} else {
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Ansel
*/
-class Ansel_ImageView {
-
+class Ansel_ImageView
+{
/**
* Ansel_Image object that this view is created from.
*
* @var Ansel_Image
*/
- var $_image = null;
+ protected $_image = null;
/**
* Parameters for this view
*
* @var array
*/
- var $_params = array();
+ protected $_params = array();
/**
* Image dimensions
*
* @var array
*/
- var $_dimensions = array();
+ protected $_dimensions = array();
- var $_style = array();
+ /**
+ * Cache the style information array
+ *
+ * @var array
+ */
+ protected $_style = array();
- var $need = array();
+ /**
+ * Array of required, supported features for this ImageView to work
+ *
+ * @var array
+ */
+ public $need = array();
/**
- * Constructor
+ * Const'r
+ *
+ * @return Horde_ImageView
*/
- function Ansel_ImageView($params)
+ public function __construct($params)
{
$this->_params = $params;
if (!empty($params['image'])) {
}
/**
- * Function to actually create and cache the view.
+ * Create and cache the view.
+ *
+ * @return mixed Views used as gallery key images return Horde_Image,
+ * other views return boolean
*/
- function create()
+ public function create()
{
if (!empty($this->_image)) {
// Use Horde_Image since we don't know at this point which
}
/**
+ * 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 Horde_Exception
+ * @throws Ansel_Exception
*/
function factory($type, $params = array())
{
foreach ($view->need as $need) {
if (!Ansel::isAvailable($need)) {
Horde::logMessage($err, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Horde_Exception(_("This install does not support the %s feature. Please contact your administrator."), $need);
+ throw new Ansel_Exception(_("This install does not support the %s feature. Please contact your administrator."), $need);
}
}
return $view;
} else {
Horde::logMessage($err, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Horde_Exception(sprintf(_("Unable to load the definition of %s."), $class));
+ throw new Ansel_Exception(sprintf(_("Unable to load the definition of %s."), $class));
}
-
}
/**
*
* @param Ansel_Gallery $parent The gallery to start looking in
*
- * @return An Ansel_Gallery object that has images, or the original $parent
+ * @return Ansel_Gallery Gallery that has images, or the original $parent
*/
- function _getGalleryWithImages($parent)
+ protected function _getGalleryWithImages($parent)
{
- $galleries = $GLOBALS['ansel_storage']->listGalleries(
- Horde_Perms::SHOW,
- null,
- $parent,
- false);
+ $galleries = $GLOBALS['ansel_storage']->listGalleries(
+ Horde_Perms::SHOW, null, $parent, false);
foreach ($galleries as $gallery) {
if ($gallery->countImages()) {
}
/**
- * Utility function to return an array of Ansel_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.
+ * 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
*/
- function _getStackImages()
+ protected function _getStackImages()
{
$images = array();
$gallery = $this->_params['gallery'];
try {
$img = $gallery->getImage($default);
$img->load('screen');
- $images[] = $img->getHordeImage();//&$gallery->getImage($default);
+ $images[] = $img->getHordeImage();
$cnt--;
} catch (Horde_Exception $e) {}
}
--- /dev/null
+<?php
+/**
+ * ImageView to create the mini view.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Ansel
+ */
+class Ansel_ImageView_Mini extends Ansel_ImageView
+{
+ protected function _create()
+ {
+ $this->_image->resize(min(50, $this->_dimensions['width']),
+ min(50, $this->_dimensions['height']),
+ true);
+
+ return true;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * ImageView to create the gallery image stacks.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @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) {
+ return false;
+ }
+
+ return $baseImg;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * ImageView to create the gallery polaroid stacks.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @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) {
+ return false;
+ }
+
+ return $baseImg;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * ImageView to create the shadowsharpthumb view (sharp corners, shadowed)
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Ansel
+ */
+class Ansel_ImageView_PolaroidThumb extends Ansel_ImageView
+{
+ public $need = array('PolaroidImage');
+
+ /**
+ *
+ * @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 custom gallery default image
+ (which will have a negative gallery_id). */
+ if ($this->_image->gallery > 0) {
+ if (is_null($this->_style)) {
+ $gal = $GLOBALS['ansel_storage']->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) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * ImageView to create the prettythumb view (rounded, shadowed thumbnails).
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Ansel
+ */
+class Ansel_ImageView_PrettyThumb extends Ansel_ImageView
+{
+ public $need = array('RoundCorners', '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['ansel_storage']->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) {
+ return false;
+ }
+ $this->_image->applyEffects();
+
+ return true;
+ }
+ }
+
+}
--- /dev/null
+ <?php
+/**
+ * ImageView to create the gallery image stacks.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @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) {
+ return false;
+ }
+
+ return $baseImg;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * ImageView to create the screen view - image sized for slideshow view.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @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 true;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * ImageView to create the shadowsharpthumb view (sharp corners, shadowed)
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @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['ansel_storage']->getGallery($this->_image->gallery);
+ $styleDef = $gal->getStyle();
+ } else {
+ $styleDef = Ansel::getStyleDefinition($this->_style);
+ }
+
+ try {
+ $this->_image->addEffect('border', array('bordercolor' => '#333'));
+ $this->_image->addEffect('DropShadow',
+ array('background' => $styleDef['background'],
+ 'padding' => 5,
+ 'distance' => '8',
+ 'fade' => 2));
+ $this->_image->applyEffects();
+ } catch (Horde_Image_Exception $e) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * ImageView to create the thumb view (plain, resized thumbnails).
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Ansel
+ */
+class Ansel_ImageView_Thumb extends Ansel_ImageView
+{
+ /**
+ *
+ * @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);
+ return true;
+ }
+
+}