}
$notification->push(_("Captions Saved."), 'horde.success');
- $style = $gallery->getStyle();
Ansel::getUrlFor('view', array_merge(array('gallery' => $galleryId,
'slug' => $gallery->get('slug'),
'view' => 'Gallery'),
</form>
</div>
-<div id="sortContainer" style="background:<?php echo $style['background'] ?>">
+<div id="sortContainer" style="background:<?php echo $style->background ?>">
<?php
$images = $gallery->getImages();
$caption = empty($image->caption) ? htmlspecialchars($image->filename, ENT_COMPAT, $GLOBALS['registry']->getCharset()) : htmlspecialchars($image->caption, ENT_COMPAT, $GLOBALS['registry']->getCharset());
echo '<div id="o_' . (int)$image->id . '"><a title="'
. $caption . '" href="#">'
- . '<img src="' . Ansel::getImageUrl($image->id, 'thumb', false, $style['name']) . '" alt="' . htmlspecialchars($image->filename) . '" />'
+ . '<img src="' . Ansel::getImageUrl($image->id, 'thumb', false, $style) . '" alt="' . htmlspecialchars($image->filename) . '" />'
. '</a></div>';
}
echo '</div>';
if ($conf['vfs']['src'] == 'sendfile') {
/* Need to ensure the file exists */
try {
- $image->createView('mini', 'ansel_default');
+ $image->createView('mini', Ansel::getStyleDefinition('ansel_default'));
} catch (Horde_Exception $e) {
Horde::logMessage($e, 'ERR');
exit;
require_once dirname(__FILE__) . '/../lib/Application.php';
Horde_Registry::appInit('ansel');
-$style = Horde_Util::getFormData('style');
+$thumbstyle = Horde_Util::getFormData('t');
+$background = Horde_Util::getFormData('b');
+
+// Create a dummy style object with only what is needed to generate
+if ($thumbstyle && $background) {
+ $style = new Ansel_Style(array('thumbstyle' => $thumbstyle,
+ 'background' => $background));
+} else {
+ $style = null;
+}
$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image'));
$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($image->gallery));
if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
if ($conf['vfs']['src'] == 'sendfile') {
/* Need to ensure the file exists */
try {
- $image->createView('screen', 'ansel_default');
+ $image->createView('screen', Ansel::getStyleDefinition('ansel_default'));
} catch (Horde_Exception $e) {
Horde::logMessage($result, 'ERR');
exit;
if ($conf['vfs']['src'] == 'sendfile') {
/* Need to ensure the file exists */
try {
- $image->createView('thumb', 'ansel_default');
+ $image->createView('thumb', Ansel::getStyleDefinition('ansel_default'));
} catch (Horde_Exception $e) {
Horde::logMessage($result, 'ERR');
exit;
* Takes into account $conf['vfs']['direct'] and other
* factors.
*
- * @param string $imageId The id of the image.
- * @param string $view The view ('screen', 'thumb', 'prettythumb' or
- * 'full') to show.
- * @param boolean $full Return a path that includes the server name?
- * @param string $style Use this gallery style
+ * @param string $imageId The id of the image.
+ * @param string $view The view ('screen', 'thumb', 'prettythumb' or
+ * 'full') to show.
+ * @param boolean $full Return a path that includes the server name?
+ * @param Ansel_Style $style Use this gallery style
*
* @return Horde_Url The image path.
*/
// Default to ansel_default since we really only need to know the style
// if we are requesting a 'prettythumb'
if (is_null($style)) {
- $style = 'ansel_default';
+ $style = Ansel::getStyleDefinition('ansel_default');
}
// Don't load the image if the view exists
if ($conf['vfs']['src'] != 'direct') {
$params = array('image' => $imageId);
if (!is_null($style)) {
- $params['style'] = $style;
+ $params['t'] = $style->thumbstyle;
+ $params['b'] = $style->background;
}
+
return Horde::url('img/' . $view . '.php', $full)->add($params);
}
*/
static public function getStyleSelect($element_name, $selected = '')
{
- $styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel');
+ $styles = $GLOBALS['injector']->getInstance('Ansel_Styles');
+ // @TODO: Look at this code: probably duplicated in the binder above.
/* No prettythumbs allowed at all by admin choice */
if (empty($GLOBALS['conf']['image']['prettythumbs'])) {
$test = $styles;
}
/**
- * Get a style definition for the requested named style
+ * Get a pre-defined style definition for the requested named style
*
* @param string $style The name of the style to fetch
*
- * @return array The definition of the requested style if it's available
- * otherwise, the ansel_default style is returned.
+ * @return Ansel_Style The definition of the requested style if it's
+ * available, otherwise, the ansel_default style is
+ * returned.
*/
static public function getStyleDefinition($style)
{
$styles = $GLOBALS['injector']->getInstance('Ansel_Styles');
if (isset($styles[$style])) {
- $style_def = $styles[$style];
+ return new Ansel_Style($styles[$style]);
} else {
- $style_def = $styles['ansel_default'];
- }
-
- /* Fill in defaults */
- if (empty($style_def['gallery_view'])) {
- $style_def['gallery_view'] = 'Gallery';
+ return new Ansel_Style($styles['ansel_default']);
}
- if (empty($style_def['default_galleryimage_type'])) {
- $style_def['default_galleryimage_type'] = 'plain';
- }
- if (empty($style_def['requires_png'])) {
- $style_def['requires_png'] = false;
- }
-
- return $style_def;
}
/**
* Return a hash key for the given view and style.
*
- * @param string $view The view (thumb, prettythumb etc...)
- * @param string $style The named style.
+ * @param string $view The view (thumb, prettythumb etc...)
+ * @param Ansel_Style $style The style object.
*
* @return string A md5 hash suitable for use as a key.
*/
static public function getViewHash($view, $style)
{
- $style = Ansel::getStyleDefinition($style);
-
if ($view != 'screen' && $view != 'thumb' && $view != 'mini' &&
$view != 'full') {
- $view = md5($style['thumbstyle'] . '.' . $style['background']);
+ $view = md5($style->thumbstyle . '.' . $style->background);
}
return $view;
throw new Ansel_Exception($e->getMessage());
}
} else {
- $result = $image->load($view, $style);
+ if (!empty($params['style'])) {
+ $params['style'] = Ansel::getStyleDefinition($style);
+ } else {
+ $params['style'] = null;
+ }
+ $result = $image->load($view, $params['style']);
$data = $image->_image->raw();
}
if (!is_null($app)) {
$GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
}
+
$storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope();
// Determine the default gallery when none is given. The first gallery
// in the list is the default gallery.
}
$images = $gallery->listImages();
+ if ($style) {
+ $style = Ansel::getStyleDefinition($style);
+ } else {
+ $style = $gallery->getStyle();
+ }
$counter = 0;
$imagelist = array();
}
$images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages($galleries, $limit, $slugs);
$imagelist = array();
+ if ($style) {
+ $style = Ansel::getStyleDefinition($style);
+ }
foreach ($images as $image) {
$id = $image->id;
$imagelist[$id]['id'] = $id;
}
/**
- * Get a list of all configured styles.
+ * Get a list of all pre-configured styles.
*
* @return hash of style definitions.
*/
} else {
$name = $gallery->get('name');
}
-
- $style = $gallery->getStyle();
$viewurl = Ansel::getUrlFor('view',
array('view' => 'Gallery',
'gallery' => $gallery->id,
$html = Ansel::embedCode($params);
// Be nice to people with <noscript>
- $style = $gallery->getStyle();
$viewurl = Ansel::getUrlFor('view', array('view' => 'Gallery',
'gallery' => $gallery->id,
'slug' => $gallery->get('slug')),
true);
$html .= '<noscript>';
$html .= $viewurl->link(array('title' => sprintf(_("View %s"), $gallery->get('name'))));
- if ($iid = $gallery->getKeyImage('ansel_default') &&
+ if ($iid = $gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')) &&
$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
- $html .= '<img src="' . Ansel::getImageUrl($gallery->getKeyImage('ansel_default'), 'thumb', true) . '" alt="' . htmlspecialchars($gallery->get('name')) . '" />';
+ $html .= '<img src="' . Ansel::getImageUrl($gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')), 'thumb', true) . '" alt="' . htmlspecialchars($gallery->get('name')) . '" />';
} else {
$html .= Horde::img('thumb-error.png');
}
HEADER;
foreach ($galleries as $gallery) {
- $style = $gallery->getStyle();
$url = Ansel::getUrlFor('view', array('view' => 'Gallery',
'slug' => $gallery->get('slug'),
'gallery' => $gallery->id),
true);
$html .= '<tr><td>'
. $url->link(array('onmouseout' => '$("ansel_preview").hide();$("ansel_preview").update("");',
- 'onmouseover' => 'previewImageMg(event, ' . $gallery->getKeyImage('ansel_default') . ');'))
+ 'onmouseover' => 'previewImageMg(event, ' . $gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')) . ');'))
. @htmlspecialchars($gallery->get('name'), ENT_COMPAT, $GLOBALS['registry']->getCharset()) . '</a></td><td>'
. strftime($GLOBALS['prefs']->getValue('date_format'), $gallery->get('last_modified'))
. '</td><td>' . (int)$gallery->countImages(true) . '</td></tr>';
if (isset($this->_params['gallery'])) {
$name = @htmlspecialchars($gallery->get('name'), ENT_COMPAT, $GLOBALS['registry']->getCharset());
}
- $style = $gallery->getStyle();
$viewurl = Ansel::getUrlFor('view',
array('gallery' => $gallery->id,
'view' => 'Gallery',
'slug' => $gallery->get('slug'),
'gallery' => $gallery->id,
'image' => $image->id,
- 'gallery_view' => $style['gallery_view']));
+ 'gallery_view' => $style->gallery_view));
$html .= '<tr><td>' . strftime('%x', $image->uploaded)
. '</td><td class="nowrap">'
. $url->link(
'slug' => $gallery->get('slug'),
'gallery' => $gallery->id,
'image' => $id,
- 'gallery_view' => $style['gallery_view']), true);
+ 'gallery_view' => $style->gallery_view), true);
$images[$key]['icon'] = (string)Ansel::getImageUrl($images[$key]['image_id'], 'mini', true);
$images[$key]['link'] = (string)$url;
}
* Output the HTML for this gallery's tile.
*
* @param Ansel_Gallery $parent The parent Ansel_Gallery object
- * @param string $style A named gallery style to use.
+ * @param Ansel_Style $style A style object to use.
* @param boolean $mini Force the use of a mini thumbnail?
* @param array $params Any additional parameters the Ansel_Tile
* object may need.
{
if (!is_null($parent) && is_null($style)) {
$style = $parent->getStyle();
- } else {
- $style = Ansel::getStyleDefinition($style);
}
return Ansel_Tile_Gallery::getTile($this, $style, $mini, $params);
/**
* Returns the key image for this gallery.
*
- * @param string $style Force the use of this style, if it's available
- * otherwise use whatever style is choosen for this
- * gallery. If prettythumbs are not available then
- * we always use ansel_default style.
+ * @param Ansel_Style $style Force the use of this style, if it's available
+ * otherwise use whatever style is choosen for
+ * this gallery. If prettythumbs are not
+ * available then we always use ansel_default
+ * style.
*
* @return mixed The image_id of the key image or false.
*/
public function getKeyImage($style = null)
{
- /* Get the available styles */
- $styles = $GLOBALS['injector']->getInstance('Ansel_Styles');
-
- /* Check for explicitly requested style */
- if (!is_null($style)) {
- $gal_style = Ansel::getStyleDefinition($style);
- } else {
- $gal_style = $this->getStyle();
- if (!isset($styles[$gal_style['name']])) {
- $gal_style = $styles['ansel_default'];
- }
+ if (is_null($style)) {
+ $style = $this->getStyle();
}
- if (!empty($gal_style['default_galleryimage_type']) &&
- $gal_style['default_galleryimage_type'] != 'plain') {
-
- $thumbstyle = $gal_style['default_galleryimage_type'];
- $styleHash = $this->getViewHash($thumbstyle, $gal_style['name']);
+ if ($style->default_galleryimage_type != 'plain') {
+ $thumbstyle = $style->default_galleryimage_type;
+ $styleHash = $style->getHash($thumbstyle);
/* First check for the existence of a key image in the specified style */
if (!empty($this->data['attribute_default_prettythumb'])) {
}
/* Don't already have one, must generate it. */
- $params = array('gallery' => $this, 'style' => $gal_style);
+ //@TODO: Look at passing style both in params and the property...
+ $params = array('gallery' => $this, 'style' => $style);
try {
- $iview = Ansel_ImageGenerator::factory($gal_style['default_galleryimage_type'], $params);
+ $iview = Ansel_ImageGenerator::factory($style->default_galleryimage_type, $params);
$img = $iview->create();
// Note the gallery_id is negative for generated stacks
// Might not support the requested style...try ansel_default
// but protect against infinite recursion.
Horde::logMessage($e->getMessage(), 'DEBUG');
- if ($style != 'ansel_default') {
- return $this->getKeyImage('ansel_default');
+ if ($style->default_galleryimage_type != 'plain') {
+ return $this->getKeyImage(Ansel::getStyleDefinition('ansel_default'));
}
}
} else {
* 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 array The style definition array.
*/
public function getStyle()
/**
* Return a hash key for the given view and style.
*
- * @param string $view The view (thumb, prettythumb etc...)
- * @param string $style The named style.
+ * @param string $view The view (thumb, prettythumb etc...)
+ * @param Ansel_Style $style The style.
*
* @return string A md5 hash suitable for use as a key.
*/
public function getViewHash($view, $style = null)
{
if (empty($style)) {
- $style = $this->data['attribute_style'];
+ $style = $this->getStyle();
}
return Ansel::getViewHash($view, $style);
* Output the HTML for this gallery's tile.
*
* @param Ansel_Gallery $parent The parent Ansel_Gallery object
- * @param string $style A named gallery style to use.
+ * @param Ansel_Style $style A gallery style to use.
* @param boolean $mini Force the use of a mini thumbnail?
* @param array $params Any additional parameters the Ansel_Tile
* object may need.
{
if (!is_null($parent) && is_null($style)) {
$style = $parent->getStyle();
- } else {
- $style = Ansel::getStyleDefinition($style);
}
return Ansel_Tile_DateGallery::getTile($this, $style, $mini, $params);
/**
* Returns the key image for this gallery.
*
- * @param string $style Force the use of this style, if it's available
- * otherwise use whatever style is choosen for this
- * gallery. If prettythumbs are not available then
- * we always use ansel_default style.
+ * @param Ansel_Style $style Force the use of this style, if it's available
*
* @return mixed The image_id of the key image or false.
*/
/**
* Return the vfs path for this image.
*
- * @param string $view The view we want.
- * @param string $style A named gallery style.
+ * @param string $view The view we want.
+ * @param Ansel_Style $style A named gallery style.
*
* @return string The vfs path for this image.
*/
/**
* Loads the given view into memory.
*
- * @param string $view Which view to load.
- * @param string $style The named gallery style.
+ * @param string $view Which view to load.
+ * @param Ansel_Style $style The gallery style.
*
* @return boolean
* @throws Ansel_Exception
* Check if an image view exists and returns the vfs name complete with
* the hash directory name prepended if appropriate.
*
- * @param integer $id Image id to check
- * @param string $view Which view to check for
- * @param string $style A named gallery style
+ * @param integer $id Image id to check
+ * @param string $view Which view to check for
+ * @param Ansel_Style $style Style object
*
* @return mixed False if image does not exists | string vfs name
*/
}
/* Get the VFS path. */
- $view = Ansel_Gallery::getViewHash($view, $style);
+ $view = Ansel::getViewHash($view, $style);
/* Can't call the various vfs methods here, since this method needs
to be called statically */
/**
* Creates and caches the given view.
*
- * @param string $view Which view to create.
- * @param string $style A named gallery style
+ * @param string $view Which view to create.
+ * @param Ansel_Style $style A style object
*
* @return boolean
* @throws Ansel_Exception
$vHash = $this->getViewHash($view, $style);
$this->_image->loadString($data);
- $styleDef = Ansel::getStyleDefinition($style);
if ($view == 'prettythumb') {
- $viewType = $styleDef['thumbstyle'];
+ $viewType = $style->thumbstyle;
} else {
// Screen, Mini, Thumb
$viewType = ucfirst($view);
// 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_ImageGenerator::factory('Thumb', array('image' => $this, 'style' => 'ansel_default'));
+ $iview = Ansel_ImageGenerator::factory('Thumb', array('image' => $this, 'style' => Ansel::getStyleDefinition('ansel_default')));
} else {
// If it wasn't a prettythumb, then something else must be wrong
throw $e;
$deleted = array();
/* Need to generate hashes for each possible style */
+ // @TODO: Need to save the style hash to the share entry
+ // since we don't require the use of predefined
+ // style definitions now.
$styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel');
foreach ($styles as $style)
{
/**
* Display the requested view.
*
- * @param string $view Which view to display.
- * @param string $style Force use of this gallery style.
+ * @param string $view Which view to display.
+ * @param Ansel_Style $style Force use of this gallery style.
*
* @return void
* @throws Horde_Exception_PermissionDenied, Ansel_Exception
* Get the Ansel_View_Image_Thumb object
*
* @param Ansel_Gallery $parent The parent Ansel_Gallery object.
- * @param string $style A named gallery style to use.
+ * @param Ansel_Style $style A gallery definition to use.
* @param boolean $mini Force the use of a mini thumbnail?
* @param array $params Any additional parameters the Ansel_Tile
* object may need.
{
if (!is_null($parent) && is_null($style)) {
$style = $parent->getStyle();
- } else {
- $style = Ansel::getStyleDefinition($style);
}
return Ansel_Tile_Image::getTile($this, $style, $mini, $params);
/**
* Return a hash key for the given view and style.
*
- * @param string $view The view (thumb, prettythumb etc...)
- * @param string $style The named style.
+ * @param string $view The view (thumb, prettythumb etc...)
+ * @param Ansel_Style $style The style.
*
* @return string A md5 hash suitable for use as a key.
*/
if (is_null($style)) {
$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($this->gallery));
$style = $gallery->getStyle();
- } else {
- $style = Ansel::getStyleDefinition($style);
}
- $view = md5($style['thumbstyle'] . '.' . $style['background']);
+ $view = md5($style->thumbstyle . '.' . $style->background);
return $view;
}
$style = $this->_params['style'];
$params = array('width' => 100,
'height' => 100,
- 'background' => $style['background']);
+ 'background' => $style->background);
$baseImg = Ansel::getImageObject($params);
try {
array('images' => $imgobjs,
'resize_height' => $GLOBALS['conf']['thumbnail']['height'],
'padding' => 0,
- 'background' => $style['background'],
+ 'background' => $style->background,
'type' => 'plain'));
$baseImg->applyEffects();
$style = $this->_params['style'];
$params = array('width' => 100,
'height' => 100,
- 'background' => $style['background']);
+ 'background' => $style->background);
$baseImg = Ansel::getImageObject($params);
try {
array('images' => $imgobjs,
'resize_height' => $GLOBALS['conf']['thumbnail']['height'],
'padding' => 10,
- 'background' => $style['background'],
+ 'background' => $style->background,
'type' => 'polaroid'));
$baseImg->applyEffects();
$baseImg->resize($GLOBALS['conf']['thumbnail']['width'],
$gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery);
$styleDef = $gal->getStyle();
} else {
- $styleDef = Ansel::getStyleDefinition($this->_style);
+ $styleDef = $this->_style;
}
try {
$this->_image->addEffect('PolaroidImage',
- array('background' => $styleDef['background'],
+ array('background' => $styleDef->background,
'padding' => 5));
if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
$this->_image->addEffect('Unsharpmask',
$gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery);
$styleDef = $gal->getStyle();
} else {
- $styleDef = Ansel::getStyleDefinition($this->_style);
+ $styleDef = $this->_style;
}
try {
$this->_image->addEffect('RoundCorners', array('border' => 2,
'bordercolor' => '#333'));
- $this->_image->addEffect('DropShadow', array('background' => $styleDef['background'],
+ $this->_image->addEffect('DropShadow', array('background' => $styleDef->background,
'padding' => 5,
'distance' => 5,
'fade' => 3));
$style = $this->_params['style'];
$params = array('width' => 100,
'height' => 100,
- 'background' => $style['background']);
+ 'background' => $style->background);
$baseImg = Ansel::getImageObject($params);
array('images' => $imgobjs,
'resize_height' => $GLOBALS['conf']['thumbnail']['height'],
'padding' => 0,
- 'background' => $style['background'],
+ 'background' => $style->background,
'type' => 'rounded'));
$baseImg->applyEffects();
$gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery);
$styleDef = $gal->getStyle();
} else {
- $styleDef = Ansel::getStyleDefinition($this->_style);
+ $styleDef = $this->_style;
}
try {
$this->_image->addEffect('Border', array('bordercolor' => '#333', 'borderwidth' => 1));
$this->_image->addEffect('DropShadow',
- array('background' => $styleDef['background'],
+ array('background' => $styleDef->background,
'padding' => 5,
'distance' => 8,
'fade' => 2));
* from the same gallery.
*
* @param array $images An array of image ids
- * @param string $style A named gallery style to force if requesting
+ * @param Ansel_Style $style A gallery style to force if requesting
* pretty thumbs.
* @param boolean $full Generate full urls
* @param string $image_view Which image view to use? screen, thumb etc..
{
$galleries = array();
if (is_null($style)) {
- $style = 'ansel_default';
+ $style = Ansel::getStyleDefinition('ansel_default');
}
$json = array();
--- /dev/null
+<?php
+/**
+ * The Ansel_Style:: class is responsible for holding information about a
+ * single Ansel style.
+ *
+ * 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_Style
+{
+ /**
+ * Holds the style definition
+ *
+ * @var array
+ */
+ protected $_properties;
+
+ public function __construct($properties)
+ {
+ $this->_properties = array_merge(array('gallery_view' => 'Gallery',
+ 'default_galleryimage_type' => 'plain',
+ 'background' => 'none'),
+ $properties);
+ }
+
+ /**
+ * Return if this style requires PNG support in the browser.
+ *
+ * @return boolean
+ */
+ public function requiresPng()
+ {
+ return true;
+ }
+
+ public function getHash($view)
+ {
+ if ($view != 'screen' && $view != 'thumb' && $view != 'mini' &&
+ $view != 'full') {
+
+ $view = md5($this->thumbstyle . '.' . $this->background);
+ }
+
+ return $view;
+ }
+
+ public function &__get($property)
+ {
+ return $this->_properties[$property];
+ }
+
+ public function __isset($property)
+ {
+ return !empty($property);
+ }
+
+}
+
*
* @param Ansel_DateGallery $dgallery The Ansel_Gallery_Date we are
* displaying.
- * @param array $style A style definition array.
+ * @param Ansel_Style $style A style object.
* @param boolean $mini Force the use of a mini thumbail?
* @param array $params An array containing additional
* parameters. Currently,
$style = $dgallery->getStyle();
}
- $thumbstyle = $mini ? 'mini' : $style['thumbstyle'];
+ $thumbstyle = $mini ? 'mini' : $style->thumbstyle;
$gallery_image = Ansel::getImageUrl(
$dgallery->getKeyImage(),
- $thumbstyle, true, $style['name']);
+ $thumbstyle,
+ true,
+ $style);
- // No need to escape alt here since it's generated enitrely within
- // horde from Horde_Date
$gallery_image = '<img src="' . $gallery_image . '" alt="' . $caption . '" />' ;
} else {
$gallery_image = Horde::img('thumb-error.png');
if (empty($params['style'])) {
$gstyle = $dgallery->getStyle();
} else {
- $gstyle = Ansel::getStyleDefinition($params['style']);
+ $gstyle = $params['style'];
}
$params = array('gallery' => $dgallery->id,
'view' => 'Gallery',
$gallery_count = $dgallery->countImages(true);
/* Background color is needed if displaying a mini tile */
- $background_color = $style['background'];
+ $background_color = $style->background;
Horde::startBuffer();
include ANSEL_TEMPLATES . '/tile/dategallery' . ($mini ? 'mini' : '') . '.inc';
* Outputs the html for a gallery tile.
*
* @param Ansel_Gallery $gallery The Ansel_Gallery we are displaying.
- * @param array $style A style definition array.
+ * @param Ansel_Style $style A style object.
* @param boolean $mini Force the use of a mini thumbail?
* @param array $params An array containing additional parameters.
* Currently, gallery_view_url and
if (is_null($style)) {
$style = $gallery->getStyle();
}
- $thumbstyle = $mini ? 'mini' : $style['thumbstyle'];
-
+ $thumbstyle = $mini ? 'mini' : $style->thumbstyle;
if ($gallery->hasPasswd()) {
$gallery_image = Horde::img('gallery-locked.png');
} else {
$gallery_image = Ansel::getImageUrl(
- $gallery->getKeyImage($style['name']),
- $thumbstyle, true, $style['name']);
+ $gallery->getKeyImage($style),
+ $thumbstyle,
+ true,
+ $style);
$gallery_image = '<img src="' . $gallery_image . '" alt="' . htmlspecialchars($gallery->get('name')) . '" />';
}
} else {
/* Check for being called via the api and generate correct view links */
if (!isset($params['gallery_view_url'])) {
- if (empty($params['style'])) {
- $gstyle = $gallery->getStyle();
- } else {
- $gstyle = Ansel::getStyleDefinition($params['style']);
- }
$view_link = Ansel::getUrlFor('view',
array('gallery' => $gallery->id,
'view' => 'Gallery',
}
$gallery_count = $gallery->countImages(true);
- $background_color = $style['background'];
+ $background_color = $style->background;
$date_format = $GLOBALS['prefs']->getValue('date_format');
$created = _("Created:") . ' '
* @param Ansel_Gallery $parent The parent Ansel_Gallery for this image.
* If null, will create a new instance of
* the Ansel_Gallery
- * @param array $style A sytle definiition array.
+ * @param Ansel_Style $style A sytle definiition array.
* @param boolean $mini Force the use of a mini thumbnail?
* @param string $params Any other paramaters needed by this tile
*
}
/* Override the thumbnail to mini or use style default? */
- $thumbstyle = $mini ? 'mini' : $style['thumbstyle'];
+ $thumbstyle = $mini ? 'mini' : $style->thumbstyle;
/* URL for image properties/actions etc... */
$image_url = Horde::url('image.php')->add(
$date));
}
- $thumb_url = Ansel::getImageUrl($image->id, $thumbstyle, true, $style['name']);
+ $thumb_url = Ansel::getImageUrl($image->id, $thumbstyle, true, $style);
+
$option_select = $parent->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE);
$option_edit = $parent->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
$imgAttributes = (!empty($params['image_view_attributes']) ? $params['image_view_attributes'] : array());
Horde::startBuffer();
// In-line caption editing if we have Horde_Perms::EDIT
if ($option_edit) {
+ // @TODO: passing thumbstyle here doesn't look right to me.
$geometry = $image->getDimensions($thumbstyle);
$GLOBALS['injector']->createInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'EditCaption'), array(
'domid' => $image->id . 'caption',
$curimage = 0;
}
- $data = array((string)Ansel::getImageUrl($image->id, $params['image_view'], $params['full'], $style['name']),
+ $data = array((string)Ansel::getImageUrl($image->id, $params['image_view'], $params['full'], $style),
htmlspecialchars($image->filename, ENT_COMPAT, $GLOBALS['registry']->getCharset()),
$GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($image->caption, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL)),
$image->id,
* both were not passed in.
*/
if ($thumbsize == 'thumb') {
- $images[] = $gallery->getKeyImage('ansel_default');
+ $images[] = $gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default'));
} else {
// Default to gallery's defined style if not provided.
$gallery_style = empty($this->_params['style']) ?
if (!empty($this->_params['gallery_view'])) {
$renderer = $this->_params['gallery_view'];
} else {
- $renderer = (!empty($style['gallery_view'])) ? $style['gallery_view'] : 'Gallery';
+ $renderer = (!empty($style->gallery_view)) ? $style->gallery_view : 'Gallery';
}
/* Load the helper */
*/
private function _output()
{
-
$view = new Horde_View(array('templatePath' => array(ANSEL_TEMPLATES . '/gallery',
ANSEL_TEMPLATES . '/gallery/partial',
ANSEL_TEMPLATES . '/gallery/layout')));
$gallery_thumbstyle = Horde_Util::getFormData('gallery_style');
$gallery_parent = Horde_Util::getFormData('gallery_parent');
+ // 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(),
+ 'Tags' => array('view' => 'gallery'),
+ 'OtherGalleries' => array(),
+ 'Geotag' => array(),
+ 'Links' => array(),
+ 'GalleryFaces' => array(),
+ 'OwnerFaces' => array())
+ ));
+
// Double check for an empty string instead of null
if (empty($gallery_parent)) {
$gallery_parent = null;
}
$gallery->set('desc', $gallery_desc);
$gallery->setTags(!empty($gallery_tags) ? explode(',', $gallery_tags) : '');
- //$gallery->set('style', $style);
+ $gallery->set('style', $style);
$gallery->set('slug', $gallery_slug);
$gallery->set('age', $gallery_age);
$gallery->set('download', $gallery_download);
$gallery->get('owner') == $GLOBALS['registry']->getAuth()) {
$gallery->set('passwd', $gallery_passwd);
}
-
+
// Did the parent change?
$old_parent = $gallery->getParent();
if (!is_null($old_parent)) {
array('name' => $gallery_name,
'desc' => $gallery_desc,
'tags' => explode(',', $gallery_tags),
- //'style' => $style,
+ 'style' => $style,
'slug' => $gallery_slug,
'age' => $gallery_age,
'download' => $gallery_download,
/**
* The style definition array for this gallery.
*
- * @var array
+ * @var Ansel_Style
*/
public $style;
/* Do we have an explicit style set? If not, use the gallery's */
if (!empty($this->view->style)) {
- $this->style = Ansel::getStyleDefinition($this->view->style);
+ $this->style = $this->view->style;
} else {
$this->style = $this->view->gallery->getStyle();
}
/* Include any widgets */
- if (!empty($this->style['widgets']) && !$this->view->api) {
+ if (!empty($this->style->widgets) && !$this->view->api) {
+
/* Special case widgets - these are built in */
- if (array_key_exists('Actions', $this->style['widgets'])) {
+ if (array_key_exists('Actions', $this->style->widgets)) {
/* Don't show action widget if no actions */
if ($GLOBALS['registry']->getAuth() ||
!empty($conf['report_content']['driver']) &&
$this->view->addWidget(Ansel_Widget::factory('Actions'));
}
- unset($this->style['widgets']['Actions']);
+ unset($this->style->widgets['Actions']);
}
// Gallery widgets always receive an array of image ids for
// the current page.
$ids = $this->getChildImageIds();
- foreach ($this->style['widgets'] as $wname => $wparams) {
+ foreach ($this->style->widgets as $wname => $wparams) {
$wparams = array_merge($wparams, array('images' => $ids));
$this->view->addWidget(Ansel_Widget::factory($wname, $wparams));
}
$this->_style = (empty($this->_params['style']) ?
$this->gallery->getStyle() :
- Ansel::getStyleDefinition($this->_params['style']));
+ $this->_params['style']);
/* Make sure the screen view is loaded and get the geometry */
try {
}
/* Get the image src url */
- $this->_urls['imgsrc'] = Ansel::getImageUrl($this->resource->id, 'screen', true, $this->_style['name']);
+ $this->_urls['imgsrc'] = Ansel::getImageUrl($this->resource->id, 'screen', true, $this->_style);
/* And a self url. Can't use Horde::selfUrl() since that would ignore
* pretty urls. */
'page' => $page_prev),
$this->_date));
}
- $prvImgUrl = Ansel::getImageUrl($prev, 'screen', true, $this->_style['name']);
+ $prvImgUrl = Ansel::getImageUrl($prev, 'screen', true, $this->_style);
/* Next image link */
if (!empty($this->_params['image_view_url'])) {
'page' => $page_next),
$this->_date));
}
- $nextImgUrl = Ansel::getImageUrl($next, 'screen', true, $this->_style['name']);
+ $nextImgUrl = Ansel::getImageUrl($next, 'screen', true, $this->_style);
/* Slideshow link */
if (!empty($this->_params['slideshow_link'])) {
// Get top-level / default gallery style.
if (empty($this->_params['style'])) {
- $style = Ansel::getStyleDefinition(
- $prefs->getValue('default_gallerystyle'));
+ $style = Ansel::getStyleDefinition($prefs->getValue('default_gallerystyle'));
} else {
$style = Ansel::getStyleDefinition($this->_params['style']);
}
}
$rtaghtml .= '</ul>';
}
- $styleDef = Ansel::getStyleDefinition($GLOBALS['prefs']->getValue('default_gallerystyle'));
- $style = $styleDef['name'];
+ $style = Ansel::getStyleDefinition($GLOBALS['prefs']->getValue('default_gallerystyle'));
$viewurl = Horde::url('view.php')->add(array('view' => 'Results',
- 'actionID' => 'add'));
+ 'actionID' => 'add'));
$vars = Horde_Variables::getDefaultVariables();
$option_move = $option_copy = $ansel_storage->countGalleries(Horde_Perms::EDIT);
{
$this->_view = $view;
if (!empty($this->_params['style'])) {
- $this->_style = Ansel::getStyleDefinition($this->_params['style']);
+ $this->_style = $this->_params['style'];
} else {
$this->_style = $view->gallery->getStyle();
}
*/
protected function _htmlBegin()
{
- $html = '<div class="anselWidget" style="background-color:' . $this->_style['background'] . ';">';
+ $html = '<div class="anselWidget" style="background-color:' . $this->_style->background . ';">';
$html .= '<h2 class="header tagTitle">' . $this->_title . '</h2>';
return $html;
}
// Check for existing faces for this gallery.
$html = '<div style="display: block'
- . ';background:' . $this->_style['background']
+ . ';background:' . $this->_style->background
. ';width:100%;max-height:300px;overflow:auto;" id="faces_widget_content" >';
$images = $faces->getGalleryFaces($this->_view->resource->id);
$html = '<div style="display:'
. (($GLOBALS['prefs']->getValue('show_othergalleries')) ? 'block' : 'none')
- . ';background:' . $this->_style['background']
+ . ';background:' . $this->_style->background
. ';width:100%;max-height:300px;overflow:auto;" id="othergalleries" >';
foreach ($galleries as $gallery) {
$parent = array_pop($parents);
}
- $img = (string)Ansel::getImageUrl($gallery->getKeyImage('ansel_default'), 'mini', true);
+ $img = (string)Ansel::getImageUrl($gallery->getKeyImage(), 'mini', true);
$link = Ansel::getUrlFor('view', array('gallery' => $gallery->id,
'slug' => $gallery->get('slug'),
'view' => 'Gallery'),
$results = $this->_faces->ownerFaces($this->_owner, 0, 12, true);
$html .= '<div style="display: block'
- . ';background:' . $this->_style['background']
+ . ';background:' . $this->_style->background
. ';width:100%;max-height:300px;overflow:auto;" id="faces_widget_content" >';
foreach ($results as $face_id => $face) {
$facename = htmlspecialchars($face['face_name']);
'gallery' => $gallery_id),
true);
} else {
- $style = $gallery->getStyle();
$return_url = Ansel::getUrlFor('view',
array('gallery' => $gallery_id,
'view' => 'Gallery'),
if (!count($images)) {
$images = array();
} else {
- $style = $gallery->getStyle();
$viewurl = Ansel::getUrlFor('view',
array('view' => 'Gallery',
'gallery' => $id),
true);
- $img = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($gallery->getKeyImage('ansel_default'));
+ $img = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')));
$params = array('last_modified' => $gallery->get('last_modified'),
'name' => sprintf(_("%s on %s"),
$gallery->get('name'),
$conf['server']['name']),
'link' => $viewurl,
'desc' => $gallery->get('desc'),
- 'image_url' => Ansel::getImageUrl($img->id, 'thumb',
- true, 'ansel_default'),
+ 'image_url' => Ansel::getImageUrl($img->id, 'thumb', true),
'image_alt' => $img->caption,
'image_link' => Ansel::getUrlFor('view',
array('image' => $img->id,
true),
'desc' => sprintf(_("Recently added photos by %s on %s"),
$name, $conf['server']['name']),
- 'image_url' => Ansel::getImageUrl($images[0]->id,
- 'thumb', true,
- 'ansel_default'),
+ 'image_url' => Ansel::getImageUrl($images[0]->id, 'thumb', true),
'image_alt' => $images[0]->caption,
'image_link' => Ansel::getUrlFor(
'view', array('image' => $images[0]->id,
true),
'desc' => sprintf(_("Photos tagged with %s on %s"),
$id, $conf['server']['name']),
- 'image_url' => Ansel::getImageUrl($images[0]->id,
- 'thumb', true,
- 'ansel_default'),
+ 'image_url' => Ansel::getImageUrl($images[0]->id, 'thumb', true, 'ansel_default'),
'image_alt' => $images[0]->caption,
'image_link' => Ansel::getUrlFor('view',
array('view' => 'Image',
</td>
<td>
<?php
- $styleDef = Ansel::getStyleDefinition($prefs->getValue('default_gallerystyle'));
- $style = $styleDef['name'];
+ $style = Ansel::getStyleDefinition($prefs->getValue('default_gallerystyle'));
foreach (array_keys($face['galleries']) as $gallery_id) {
foreach ($face['galleries'][$gallery_id] as $imageId) {
echo '<div style="float: left; text-align: center;"><img src="' . Ansel::getImageUrl($imageId, 'thumb', false, $style) . '" style="padding: 5px;" alt="' . $imageId . '" /><br />';
--- /dev/null
+ <tr>
+ <td align="right" valign="top"><strong><?php echo _("Thumbnail Style"); ?></string></td>
+ <td>
+ <select name="thumbnail_style">
+ <option value="Thumb" selected="selected">Basic Thumbnails</option>
+ <option value="ShadowSharpThumb">Drop Shadows</option>
+ <option value="PrettyThumb">Rounded Corners</option>
+ <option value="PolaroidThumb">Polaroids</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td align="right" valign="top"><strong><?php echo _("Backgrond Color"); ?></string></td>
+ <td>
+ <select name="background_color">
+ <option value="none" selected="selected">None</option>
+ <option value="white">White</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td align="right" valign="top"><strong><?php echo _("View Style"); ?></string></td>
+ <td>
+ <select name="gallery_view">
+ <option value="Gallery">Traditional</option>
+ <option value="GalleryLightbox">Lightbox</option>
+ </select>
+ </td>
+ </tr>
\ No newline at end of file
<?php endif; ?>
<!-- Gallery Style -->
-<tr>
- <?php echo $this->renderPartial('styles'); ?>
-</tr>
+<?php echo $this->renderPartial('styles'); ?>
<!-- Submission -->
<tr>
<?php for ($i = 0; $i < count($mini_galleries); ++$i): ?>
<td align="center">
<?php if ($mini_galleries[$i]->isOldEnough() && !$mini_galleries[$i]->hasPasswd()): ?>
- <?php echo $link ?><img src="<?php echo Ansel::getImageUrl($mini_galleries[$i]->getKeyImage('ansel_default'), 'mini', false, 'ansel_default') ?>" alt="<?php echo $owner_title?>" /></a>
+ <?php echo $link ?><img src="<?php echo Ansel::getImageUrl($mini_galleries[$i]->getKeyImage(), 'mini', false) ?>" alt="<?php echo $owner_title?>" /></a>
<?php else: ?>
<?php echo $link . Horde::img('gallery-locked-mini.png') ?></a>
<?php endif; ?>
<h1 class="header"><?php echo htmlspecialchars($title, ENT_COMPAT, $GLOBALS['registry']->getCharset()) ?></h1>
<div class="control anselActions" style="text-align: center">
<?php
-$style = $gallery->getStyle();
$image_src = Ansel::getImageUrl($image_id, 'full');
echo $galleryurl->link() . Horde::img('galleries.png') . ' ' . _("Back to gallery") . '</a> ';
<div class="control anselActions" style="text-align: center">
<div id="prevDiv"></div>
<?php
-$style = $gallery->getStyle();
$image_src = Ansel::getImageUrl($image_id, 'screen');
echo $galleryurl->link() . Horde::img('galleries.png') . ' ' . _("Back to gallery") . '</a> ';
<h1 class="header"><?php echo htmlspecialchars($title, ENT_COMPAT, $GLOBALS['registry']->getCharset()) ?></h1>
<div class="control anselActions" style="text-align: center">
<?php
-
-$style = $gallery->getStyle();
$image_src = Ansel::getImageUrl($image_id, 'full');
echo $galleryurl->link() . Horde::img('galleries.png') . ' ' . _("Back to gallery") . '</a> ';
</span>
<?php echo @htmlspecialchars($list_title, ENT_COMPAT, $GLOBALS['registry']->getCharset()) . ' ' . Horde::url($refresh_link)->link(array('title' => _("Refresh List"))) . Horde::img('reload.png', _("Refresh List")) . '</a>' ?>
</div>
-<table width="100%" style="background:<?php echo $styleDef['background'] ?>;"><tr>
+<table width="100%" style="background:<?php echo $styleDef->background ?>;"><tr>
-<?php echo '<div class="image-tile" id="imagetile_' . (int)$image->id . '">' . $view_url->link(array_merge(array('title' => $image->filename, 'onclick.raw' => $imgOnClick)), $imgAttributes) . '<img src="' . $thumb_url . '" alt="' . htmlspecialchars($image->filename) . '" /></a>'; ?>
+<?php echo '<div class="image-tile" id="imagetile_' . (int)$image->id . '">' . $view_url->link(array_merge(array('title' => $image->filename, 'onclick.raw' => $imgOnClick), $imgAttributes)) . '<img src="' . $thumb_url . '" alt="' . htmlspecialchars($image->filename) . '" /></a>'; ?>
<div style="valign: bottom;">
<div class="image-tile-caption" id="<?php echo (int)$image->id . 'caption'?>"><?php echo $imageCaption ?></div>
<?php if ($GLOBALS['registry']->getAuth() || $option_select): ?>
<?php if (!$this->numTiles): ?>
<div class="text"><em><?php echo _("There are no photos in this gallery.") ?></em></div>
<?php else: ?>
- <table width="100%" style="background-color:<?php echo $this->style['background'] ?>;">
+ <table width="100%" style="background-color:<?php echo $this->style->background ?>;">
<tr><td colspan="<?php echo $tilesperrow ?>"><?php echo $pager->render() ?></td></tr>
<tr>
<?php
foreach ($this->children as $child) {
echo '<td width="' . $cellwidth . '%" class="ansel-tile">'
- . $child->getTile($this->view->gallery, $this->style['name'], false, $this->view->getParams()) . '</td>';
+ . $child->getTile($this->view->gallery, $this->style, false, $this->view->getParams()) . '</td>';
if (!(++$count % $tilesperrow)) {
echo '</tr><tr>';
}
<?php if (!$this->numTiles): ?>
<div class="text"><em><?php echo _("There are no photos in this gallery.") ?></em></div>
<?php else: ?>
- <table width="100%" style="background-color:<?php echo $this->style['background'] ?>;">
+ <table width="100%" style="background-color:<?php echo $this->style->background ?>;">
<tr><td colspan="<?php echo $tilesperrow ?>"><?php echo $pager->render() ?></td></tr>
<tr>
<?php
foreach ($this->children as $child) {
echo '<td width="' . $cellwidth . '%" class="ansel-tile">'
- . $child->getTile($this->view->gallery, $this->style['name'], false, $this->view->getParams()) . '</td>';
+ . $child->getTile($this->view->gallery, $this->style, false, $this->view->getParams()) . '</td>';
if (!(++$count % $tilesperrow)) {
echo '</tr><tr>';
}
<h1 class="header" id="PhotoName"><?php echo Ansel::getBreadCrumbs($this->gallery) ?></h1>
<table style="width: 100%; border-collapse: collapse">
<tr>
- <td valign="top" style="background-color:<?php echo $this->_style['background']; ?>;">
+ <td valign="top" style="background-color:<?php echo $this->_style->background; ?>;">
<?php
$tempurl = new Horde_Url('#');
$needSeperator = false;
<div style="float:right:width:73%;">
<?php endif; ?>
<?php echo $this->_pager->render() ?>
-<table width="<?php echo ($this->countWidgets() ? 73 : 100) ?>%" style="background-color:<?php echo $style['background'] ?>;">
+<table width="<?php echo ($this->countWidgets() ? 73 : 100) ?>%" style="background-color:<?php echo $style->background ?>;">
<tr>
<?php
$tilesperrow = $prefs->getValue('tilesperrow');
$cellwidth = round(100 / $tilesperrow);
$count = 0;
foreach ($this->_galleryList as $galleryId => $gallery) {
- echo '<td width="' . $width . '%" class="ansel-tile">' . $gallery->getTile(null, $style['name'], false, $this->_params) . '</td>';
+ echo '<td width="' . $width . '%" class="ansel-tile">' . $gallery->getTile(null, $style, false, $this->_params) . '</td>';
if (!(++$count % $prefs->getValue('tilesperrow'))) {
if ($count < $this->_numGalleries) {
echo '</tr><tr>';
<div class="text"><em><?php echo _("There are no photos in this gallery.") ?></em></div>
<?php else: ?>
<?php echo $this->_pager->render() ?>
- <table width="100%" style="background-color:<?php echo $styleDef['background'] ?>;"><tr>
+ <table width="100%" style="background-color:<?php echo $style->background ?>;"><tr>
<?php
$cellwidth = round(100 / $tilesperrow);
$count = 0;
<td width="20%" valign="top">
<div id="anselWidgets">
<?php if ($conf['tags']['relatedtags']): ?>
- <div style="background-color:<?php echo $styleDef['background'] ?>;">
+ <div style="background-color:<?php echo $style->background ?>;">
<h2 class="header tagTitle"><?php echo _("Related Tags") ?></h2>
<div id="tags"><?php echo $rtaghtml ?></div>
</div>
</td>
</tr>
</table>
-<table width="100%" cellpadding="0" cellspacing="0" style="background-color:<?php echo $this->_style['background']; ?>;">
+<table width="100%" cellpadding="0" cellspacing="0" style="background-color:<?php echo $this->_style->background; ?>;">
<tr>
<td>
<div class="slideControls">