0</configstring>
<configboolean name="prettythumbs" desc="Allow the selection of gallery
themes and generation of 'pretty' thumbnails? This can be a performance
- hit the first time the thumbnails are generated.">false</configboolean>
+ hit on some installations but is required for the generation of all but the
+ most basic image thumbnails." required="false">false</configboolean>
<configstring name="num_uploads" desc="How many photos should a user be
allowed to upload at once?">5</configstring>
<configstring name="font" required="false" desc="What font would you like
<?php
/**
- * Configuration for the available gallery style
+ * Predefined gallery styles. These are used to select a predefined set of
+ * styles on the gallery's property page. Style may then be tweaked by the
+ * gallery owner. The 'name' attribute is the name of they style that should be
+ * used if requesting an explicit style to overide the gallery's existing style
+ * when rendering via the API.
*
* Each entry *must* have:
- *
+ * <pre>
* 'name' = The internal name of the style (this should match the
* hash key).
*
* 'title' = This is the title to be displayed to the users.
*
* 'thumbstyle' = This is the type of thumbnail to use. This must match
- * an available Ansel_ImageView object in lib/ImageView.
+ * an available Ansel_ImageGenerator object.
*
* 'background' = The desired background color of the style. This will
* set the background of both the photo display area inside
*
* The following are optional:
*
- * requires_png = Specifies that the style should only be
- * available if both the Horde install uses PNG
- * photos *and* the currently requesting browser
- * has PNG transparency support.
- *
- * default_galleryimage_type = How to represent each gallery's default photo.
- * This must match an available Ansel_ImageView
- * object in lib/ImageView
- * create_serialized_styles.php
- * gallery_view = The Ansel_View_* subclass to use for gallery
- * views.
+ * gallery_view = The Ansel_View_GalleryRenderer to use for
+ * gallery rendering. [Gallery]
*
* widgets = An array describing any Ansel_Widgets to
* display on this gallery along with any
* parameters the widget may need.
- *
- * hide = Hide this style in the gallery propery page.
- *
- * falback - Fall back to this gallery style if unable to
- * use this style (like if we don't have PNG
- * support)
- *
- * $Id$
+ * </pre>
*/
// Just a time saver...
$styles['ansel_prettythumbs'] = array(
'name' => 'ansel_prettythumbs',
- 'title' => _("Pretty Thumbnails (No Background)"),
- 'thumbstyle' => 'PrettyThumb',
- 'requires_png' => true,
- // This really only looks good with ImageMagick, not GD.
- 'default_galleryimage_type' => 'RoundedStack',
+ 'title' => _("Rounded Thumbnails (No Background)"),
+ 'thumbstyle' => 'RoundedThumb',
'background' => 'none',
'widgets' => $widgets,
);
$styles['ansel_blackonwhite'] = array(
'name' => 'ansel_blackonwhite',
- 'title' => _("Pretty Thumbnails (White Background)"),
- 'default_galleryimage_type' => 'RoundedStack',
- 'thumbstyle' => 'PrettyThumb',
+ 'title' => _("Rounded Thumbnails (White Background)"),
+ 'thumbstyle' => 'RoundedThumb',
'background' => 'white',
'widgets' => $widgets,
);
$styles['ansel_sharpshadowed'] = array(
'name' => 'ansel_sharpshadowed',
'title' => _("Shadowed Thumbnails (White Background)"),
- 'thumbstyle' => 'ShadowSharpThumb',
+ 'thumbstyle' => 'ShadowThumb',
'background' => 'white',
- 'default_galleryimage_type' => 'PlainStack',
'widgets' => $widgets
);
'title' => _("Polaroid Style Thumbnails (White Background)"),
'thumbstyle' => 'PolaroidThumb',
'background' => 'white',
- 'default_galleryimage_type' => 'PolaroidStack',
'widgets' => $widgets,
);
'thumbstyle' => 'Thumb',
'background' => 'white',
'gallery_view' => 'GalleryLightbox',
- 'widgets' => $widgets,
+ 'widgets' => $widgets
);
-
/* Lightbox image views with no background
* (requires PNG) */
$styles['ansel_lightbox_png'] = array(
'title' => _("A Lightbox Inspired Style (No Background)"),
'thumbstyle' => 'Thumb',
'background' => 'none',
- 'requires_png' => true,
'gallery_view' => 'GalleryLightbox',
- 'widgets' => $widgets,
+ 'widgets' => $widgets
);
/* Lightbox image views with no background and shadowed thumbs
$styles['ansel_lightbox_shadowed_png'] = array(
'name' => 'ansel_lightbox_shadowed_png',
'title' => _("A Lightbox Inspired Style (Drop Shadows, No Background)"),
- 'thumbstyle' => 'ShadowSharpThumb',
+ 'thumbstyle' => 'ShadowThumb',
'background' => 'none',
- 'requires_png' => true,
'gallery_view' => 'GalleryLightbox',
'widgets' => $widgets,
'fallback' => 'ansel_lightbox'
);
-
/* Same as above, but with Polaroid thumbnails/stacks
* and no background (so required png support) */
$styles['ansel_lightbox_polaroid'] = array(
'title' => _("Lightbox with Polaroids (No Background)"),
'thumbstyle' => 'PolaroidThumb',
'background' => 'none',
- 'requires_png' => true,
- 'default_galleryimage_type' => 'PolaroidStack',
'gallery_view' => 'GalleryLightbox',
- 'widgets' => $widgets,
+ 'widgets' => $widgets
);
/* Simple styles with no Ansel_Widgets useful for rendering on external sites
'name' => 'ansel_simple',
'title' => _("Simple"),
'thumbstyle' => 'Thumb',
- 'background' => 'none',
- 'hide' => true,
+ 'background' => 'none'
);
/* An API friendly lightbox style */
'title' => _("Simple Lightbox"),
'thumbstyle' => 'Thumb',
'background' => 'none',
- 'requires_png' => true,
- 'gallery_view' => 'GalleryLightbox',
- 'hide' => true,
- 'fallback' => 'ansel_simple'
+ 'gallery_view' => 'GalleryLightbox'
);
/* Same as above, but with polaroid thumbnails */
'title' => _("Lightbox with Polaroids (No Background)"),
'thumbstyle' => 'PolaroidThumb',
'background' => 'none',
- 'requires_png' => true,
- 'default_galleryimage_type' => 'PolaroidStack',
- 'gallery_view' => 'GalleryLightbox',
- 'hide' => true,
- 'fallback' => 'ansel_simple'
+ 'gallery_view' => 'GalleryLightbox'
);
}
/**
- * Return the style definition for this gallery. Returns the first available
- * style in this order: Explicitly configured style if available, if
- * 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 the style definition for this gallery.
*
* @return array The style definition array.
*/
public function getStyle()
{
+ // No styles allowed per admin.
+ if (!$GLOBALS['conf']['image']['prettythumbs']) {
+ return Ansel::getStyleDefinition('ansel_default');
+ }
+
if (empty($this->data['attribute_style'])) {
+ // No style configured, use user's prefered default
$style = Ansel::getStyleDefinition($GLOBALS['prefs']->getValue('default_gallerystyle'));
} else {
+ // Explicitly defined style
$style = unserialize($this->data['attribute_style']);
}
+ // Check browser requirements. If we require PNG support, and do not
+ // have it, revert to the basic ansel_default style.
+ if ($style->requiresPng() &&
+ ($GLOBALS['browser']->hasQuirk('png_transparency') ||
+ $GLOBALS['conf']['image']['type'] != 'png')) {
+
+ return Ansel::getStyleDefinition('ansel_default');
+ }
+
return $style;
}
<?php
/**
- * Class to abstract the creation of various image views.
+ * Base class for the creation of various image views.
+ *
+ * New thumbnail generators can be dropped in and will be made available by
+ * Ansel providing:
+ *
+ * 1. The class name is as: Ansel_ImageGenerator_{type}Thumb and filename
+ * matches, i.e. {type}Thumb.php where {type} is the unique name for your
+ * thumbnail type.
+ *
+ * 2. Implements a _create() method that applies the effects to the image
+ * (see existing generators for how this works).
+ *
+ * 3. If a matching "stack" generator is desired, that should be named
+ * similarly: Ansel_ImageGenerator_{type}ThumbStack with matching filename:
+ * {type}ThumbStack.php
+ *
*
* Copyright 2007-2010 The Horde Project (http://www.horde.org/)
*
}
if (class_exists($class)) {
$view = new $class($params);
- // Check that the image object supports what we need for the
- // requested effect.
+ // Check that the image object supports what we need for the effect.
foreach ($view->need as $need) {
if (!Ansel::isAvailable($need)) {
Horde::logMessage($err, 'ERR');
/**
* 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
+ * stack. Returns a random set of 5 images from the gallery, or the
* explicitly set key image plus 4 others.
*
- * @return array of Horde_Images
+ * @return array An array of Horde_Image objects.
*/
protected function _getStackImages()
{
{
public $need = array('PolaroidImage');
+ public function __construct($params)
+ {
+ parent::__construct($params);
+ $this->title = _("Polaroids");
+ }
+
/**
*
* @return Horde_Image
{
public $need = array('RoundCorners', 'DropShadow');
+ public function __construct($params)
+ {
+ parent::__construct($params);
+ $this->title = _("Rounded Corners");
+ }
+
/**
*
* @return Horde_Image
{
public $need = array('DropShadow');
+ public function __construct($params)
+ {
+ parent::__construct($params);
+ $this->title = _("Drop Shadows");
+ }
+
/**
*
* @return boolean
*/
class Ansel_ImageGenerator_Thumb extends Ansel_ImageGenerator
{
+ public function __construct($params)
+ {
+ parent::__construct($params);
+ $this->title = _("Basic Thumbnails");
+ }
+
/**
*
* @return Horde_Image
<?php
/**
- * Binder for all available Ansel styles
+ * Binder for getting list of all available pre-defined styles.
*
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @category Horde
if (empty($GLOBALS['conf']['image']['prettythumbs'])) {
$test = $styles;
foreach ($test as $key => $style) {
- if ($style['thumbstyle'] != 'thumb') {
+ if ($style['thumbstyle'] != 'Thumb') {
unset($styles[$key]);
}
}
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Ansel
*/
-
-/**
- * Description of GalleryProperties
- *
- * @author mrubinsk
- */
class Ansel_View_GalleryProperties
{
/**
public function __construct($params = array())
{
$this->_params = $params;
-
- /*Gallery properties */
- $this->_properties = array(
- 'name' => '',
- 'desc' => '',
- 'tags' => '',
- 'style' => '',
- 'slug' => '',
- 'age' => 0,
- 'download' => $GLOBALS['prefs']->getValue('default_download'),
- 'parent' => null,
- 'id' => null,
- 'mode' => 'Normal',
- 'passwd' => '',
- 'owner' => ''
- );
}
/**
}
}
+ private function _loadDefaults()
+ {
+ /*Gallery properties */
+ $this->_properties = array(
+ 'name' => '',
+ 'desc' => '',
+ 'tags' => '',
+ 'style' => Ansel::getStyleDefinition($GLOBALS['prefs']->getValue('default_gallerystyle')),
+ 'slug' => '',
+ 'age' => 0,
+ 'download' => $GLOBALS['prefs']->getValue('default_download'),
+ 'parent' => null,
+ 'id' => null,
+ 'mode' => 'Normal',
+ 'passwd' => '',
+ 'owner' => ''
+ );
+ }
+
/**
* Outputs the view to the browser.
*
$view->title = $this->_title;
$view->action = $this->_params['actionID'];
$view->url = $this->_params['url'];
+ $view->availableThumbs = $this->_thumbStyles();
+ $view->galleryViews = $this->_galleryViewStyles();
Horde::addInlineScript(array('$("gallery_name").focus()'), 'dom');
Horde::addScriptFile('stripe.js', 'horde');
*/
private function _runNew()
{
+ $this->_loadDefaults();
$this->_title = _("Adding a New Gallery");
$this->_properties['owner'] = $GLOBALS['registry']->getAuth();
}
*/
private function _runNewChild()
{
+ $this->_loadDefaults();
+
// Get the parent and make sure that it exists and that we have
// permissions to add to it.
$parentId = $this->_params['gallery'];
$style = new Ansel_Style(array(
'thumbstyle' => Horde_Util::getFormData('thumbnail_style'),
'background' => Horde_Util::getFormData('background_color'),
- // temporary hack
+ 'gallery_view' => Horde_Util::getFormData('gallery_view'),
+ // temporary hack until widgets are also configurable.
'widgets' => array(
'Tags' => array('view' => 'gallery'),
'OtherGalleries' => array(),
$gallery->get('owner') == $GLOBALS['registry']->getAuth()) {
$gallery->set('passwd', $gallery_passwd);
}
-
+
// Did the parent change?
$old_parent = $gallery->getParent();
if (!is_null($old_parent)) {
}
$url->redirect();
}
+
+ /**
+ * Get a list of available, currently usable thumbnail styles.
+ *
+ * @return array An array of Classnames => titles
+ */
+ protected function _thumbStyles()
+ {
+ // Iterate all available thumbstyles:
+ $dir = ANSEL_BASE . '/lib/ImageGenerator';
+ $files = scandir($dir);
+ $thumbs = array();
+ foreach ($files as $file) {
+ if (substr($file, -9) == 'Thumb.php') {
+ try {
+ $generator = Ansel_ImageGenerator::factory(substr($file, 0, -4), array('style' => ''));
+ $thumbs[substr($file, 0, -4)] = $generator->title;
+ } catch (Ansel_Exception $e) {}
+ }
+ }
+
+ return $thumbs;
+ }
+
+ /**
+ * Get a list of available Gallery View styles
+ *
+ * @return array
+ */
+ protected function _galleryViewStyles()
+ {
+ // Iterate all available thumbstyles:
+ $dir = ANSEL_BASE . '/lib/View/GalleryRenderer';
+ $files = scandir($dir);
+ $views = array();
+ foreach ($files as $file) {
+ if ($file != 'Base.php' && $file != '.' && $file != '..') {
+ $class = 'Ansel_View_GalleryRenderer_' . substr($file, 0, -4);
+ $view = new $class(null);
+ $views[substr($file, 0, -4)] = $view->title;
+ }
+ }
+
+ return $views;
+ }
}
public $mode;
/**
- * The style definition array for this gallery.
+ * The style definition.
*
* @var Ansel_Style
*/
public $date = array();
/**
+ * Human readable title for this view type
+ *
+ * @var string
+ */
+ public $title;
+
+ /**
* Constructor
*
* @param Ansel_View_Gallery The view object for this renderer.
*/
- public function __construct(Ansel_View_Gallery $view)
+ public function __construct($view)
{
$this->view = $view;
}
*/
class Ansel_View_GalleryRenderer_Gallery extends Ansel_View_GalleryRenderer_Base
{
+
+ public function __construct($view)
+ {
+ parent::__construct($view);
+ $this->title = _("Standard Gallery");
+ }
+
/**
* Perform any tasks that should be performed before the view is rendered.
*
*/
class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRenderer_Base
{
+
+ public function __construct($view)
+ {
+ parent::__construct($view);
+ $this->title = _("Lightbox Gallery");
+ }
+
/**
* Perform any tasks that should be performed before the view is rendered.
*
<tr>
- <td align="right" valign="top"><strong><?php echo _("Thumbnail Style"); ?></string></td>
+ <td align="right" valign="top"><strong><?php echo _("Thumbnail Style"); ?></strong></td>
<td>
<select name="thumbnail_style">
- <option value="Thumb" selected="selected">Basic Thumbnails</option>
- <option value="ShadowThumb">Drop Shadows</option>
- <option value="RoundedThumb">Rounded Corners</option>
- <option value="PolaroidThumb">Polaroids</option>
+ <?php foreach ($this->availableThumbs as $type => $title): ?>
+ <option value="<?php echo $type ?>" <?php if ($this->properties['style']->thumbstyle == $type): ?>selected="selected"<?php endif; ?>><?php echo $title ?></option>
+ <?php endforeach;?>
</select>
</td>
</tr>
-<!-- <tr>
- <td align="right" valign="top"><strong><?php echo _("Key Image Style"); ?></string></td>
- <td>
- <select name="keyimage_type">
- <option value="Thumb">Basic Thumbnail</option>
- <option value="PlainStack">Photo Stack</option>
- <option value-="RoundedStack">Rounded Stack</option>
- <option value="PolaroidStack">Polaroid Stack</option>
- </select>
- </td>
- </tr>-->
<tr>
- <td align="right" valign="top"><strong><?php echo _("Backgrond Color"); ?></string></td>
+ <td align="right" valign="top"><strong><?php echo _("Backgrond Color"); ?></strong></td>
<td>
<select name="background_color">
<option value="none" selected="selected">None</option>
</td>
</tr>
<tr>
- <td align="right" valign="top"><strong><?php echo _("View Style"); ?></string></td>
+ <td align="right" valign="top"><strong><?php echo _("View Style"); ?></strong></td>
<td>
<select name="gallery_view">
- <option value="Gallery">Traditional</option>
- <option value="GalleryLightbox">Lightbox</option>
+ <?php foreach ($this->galleryViews as $type => $title): ?>
+ <option value="<?php echo $type ?>"<?php if ($this->properties['style']->gallery_view == $type): ?>selected="selected"<?php endif; ?>><?php echo $title ?></option>
+ <?php endforeach; ?>
</select>
</td>
</tr>
\ No newline at end of file
<td align="right" valign="top"><strong id="slug_flag"><?php echo _("Gallery Slug") ?></strong> </td>
<td>
<input name="gallery_slug" id="gallery_slug" type="text" value="<?php echo $this->h($this->properties['slug']) ?>" size="50" /><br />
- <?php if ($GLOBALS['conf']['urls']['pretty'] == 'rewrite') echo _("Slugs allows direct access to this gallery by visiting:") . ': ' . Horde::url('gallery/slugname', true) ?><br />
+ <?php if ($GLOBALS['conf']['urls']['pretty'] == 'rewrite'): echo _("Slugs allows direct access to this gallery by visiting:") . ': ' . Horde::url('gallery/slugname', true) ?><br /> <?php endif; ?>
<?php echo _("Slug names may contain only letters, numbers, @, or _ (underscore).") ?>
</td>
</tr>
<?php endif; ?>
<!-- Gallery Style -->
-<?php echo $this->renderPartial('styles'); ?>
+<?php if ($GLOBALS['conf']['image']['prettythumbs']) {echo $this->renderPartial('styles'); }?>
<!-- Submission -->
<tr>