Overview

Packages

  • Ansel
  • None

Classes

  • Ansel
  • Ansel_Ajax_Application
  • Ansel_Ajax_Imple_EditCaption
  • Ansel_Ajax_Imple_EditFaces
  • Ansel_Ajax_Imple_EditGalleryFaces
  • Ansel_Ajax_Imple_Embed
  • Ansel_Ajax_Imple_GallerySlugCheck
  • Ansel_Ajax_Imple_ImageSaveGeotag
  • Ansel_Ajax_Imple_LocationAutoCompleter
  • Ansel_Ajax_Imple_MapLayerSelect
  • Ansel_Ajax_Imple_TagActions
  • Ansel_Ajax_Imple_ToggleGalleryActions
  • Ansel_Ajax_Imple_ToggleOtherGalleries
  • Ansel_Ajax_Imple_UploadNotification
  • Ansel_Api
  • Ansel_Exception
  • Ansel_Faces
  • Ansel_Faces_Base
  • Ansel_Faces_Facedetect
  • Ansel_Faces_User
  • Ansel_Factory_Faces
  • Ansel_Factory_Storage
  • Ansel_Factory_Styles
  • Ansel_Form_Ecard
  • Ansel_Form_Image
  • Ansel_Form_ImageDate
  • Ansel_Form_Upload
  • Ansel_Gallery
  • Ansel_Gallery_Decorator_Date
  • Ansel_GalleryMode_Base
  • Ansel_GalleryMode_Date
  • Ansel_GalleryMode_Normal
  • Ansel_Image
  • Ansel_ImageGenerator
  • Ansel_ImageGenerator_Mini
  • Ansel_ImageGenerator_PolaroidThumb
  • Ansel_ImageGenerator_PolaroidThumbStack
  • Ansel_ImageGenerator_RoundedThumb
  • Ansel_ImageGenerator_RoundedThumbStack
  • Ansel_ImageGenerator_Screen
  • Ansel_ImageGenerator_ShadowThumb
  • Ansel_ImageGenerator_ShadowThumbStack
  • Ansel_ImageGenerator_SquareThumb
  • Ansel_ImageGenerator_Thumb
  • Ansel_LoginTasks_SystemTask_Upgrade
  • Ansel_Report
  • Ansel_Report_letter
  • Ansel_Report_mail
  • Ansel_Report_tickets
  • Ansel_Search
  • Ansel_Search_exif
  • Ansel_Search_Tag
  • Ansel_Storage
  • Ansel_Style
  • Ansel_Tagger
  • Ansel_Test
  • Ansel_Tile_DateGallery
  • Ansel_Tile_Gallery
  • Ansel_Tile_Image
  • Ansel_View_Ansel
  • Ansel_View_Base
  • Ansel_View_EmbeddedRenderer_GalleryLink
  • Ansel_View_EmbeddedRenderer_Mini
  • Ansel_View_EmbeddedRenderer_Slideshow
  • Ansel_View_Gallery
  • Ansel_View_GalleryProperties
  • Ansel_View_GalleryRenderer_Base
  • Ansel_View_GalleryRenderer_Gallery
  • Ansel_View_GalleryRenderer_GalleryLightbox
  • Ansel_View_Image
  • Ansel_View_List
  • Ansel_View_Results
  • Ansel_View_Slideshow
  • Ansel_View_Upload
  • Ansel_Widget
  • Ansel_Widget_Actions
  • Ansel_Widget_Base
  • Ansel_Widget_GalleryFaces
  • Ansel_Widget_Geotag
  • Ansel_Widget_ImageFaces
  • Ansel_Widget_Links
  • Ansel_Widget_OtherGalleries
  • Ansel_Widget_OwnerFaces
  • Ansel_Widget_SimilarPhotos
  • Ansel_Widget_Tags
  • Ansel_XPPublisher
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * The Ansel_Style:: class is responsible for holding information about a
  4:  * single Ansel style.
  5:  *
  6:  * See the enclosed file COPYING for license information (GPL). If you
  7:  * did not receive this file, see http://www.horde.org/licenses/gpl.
  8:  *
  9:  * @author  Michael J. Rubinsky <mrubinsk@horde.org>
 10:  *
 11:  * @package Ansel
 12:  */
 13: class Ansel_Style
 14: {
 15:     /**
 16:      * Holds the style definition. Currently supported properties are:
 17:      * <pre>
 18:      *   'thumbstyle'    -  The ImageGenerator to use for thumbnails,
 19:      *                      e.g. PolaroidThumb or RoundedThumb
 20:      *   'background'    -  The background color of the view area. If needed,
 21:      *                      generated images will contain this as their
 22:      *                      background color.
 23:      *   'gallery_view'  -  The GalleryRenderer type to use for the gallery
 24:      *                      view, e.g. GalleryLightbox or Gallery.
 25:      *   'widgets'       -  An array of widgets and their configuration values
 26:      *                      to display on the gallery view.
 27:      *                      e.g. Array('Geotag' => array(),
 28:      *                                 'Tags' => array('view' => 'gallery'))
 29:      *   'width'         - Optional width of generated thumbnails.
 30:      *   'height'        - Option height of generated thumbnails.
 31:      *   'image_widgets' - @TODO: not yet implemented.
 32:      * </pre>
 33:      *
 34:      * @var array
 35:      */
 36:     protected $_properties;
 37: 
 38:     /**
 39:      * Work around issue with arrays and __get
 40:      */
 41:     public $widgets = array();
 42: 
 43:     public function __construct($properties)
 44:     {
 45:         $widgets = !empty($properties['widgets']) ? $properties['widgets'] : array();
 46:         unset($properties['widgets']);
 47:         $properties['widgets'] = null;
 48:         $this->widgets = array_merge(array('Actions' => array()), $widgets);
 49: 
 50:         $this->_properties = array_merge(
 51:             array(
 52:                 'gallery_view' => 'Gallery',
 53:                 'background' => 'none'),
 54:             $properties);
 55:     }
 56: 
 57:     /**
 58:      * Return if this style requires PNG support in the browser. Assumes that
 59:      * any thumbstyle other than the traditional "Thumb", withOUT a background
 60:      * is considered to requre PNG support in the browser.
 61:      *
 62:      * @return boolean
 63:      */
 64:     public function requiresPng()
 65:     {
 66:         return ($this->_properties['thumbstyle'] != 'Thumb' && $this->_properties['background'] == 'none');
 67:     }
 68: 
 69:     public function getHash($view)
 70:     {
 71:         if ($view != 'screen' && $view != 'mini' && $view != 'full') {
 72:             $view = md5($this->thumbstyle . '.' . $this->background . (!empty($this->width) ? $this->width : '') . (!empty($this->height) ? $this->height : ''));
 73:         }
 74: 
 75:         return $view;
 76:     }
 77: 
 78:     public function __get($property)
 79:     {
 80:         if ($property == 'keyimage_type') {
 81:             // Force the same type of effect for key image/stacks if available
 82:             $class = $this->_properties['thumbstyle'] . 'Stack';
 83:             if (!class_exists('Ansel_ImageGenerator_' . $class)) {
 84:                 $class = 'Thumb';
 85:             }
 86: 
 87:             return $class;
 88:         }
 89: 
 90:         return !empty($this->_properties[$property]) ? $this->_properties[$property] : null;
 91:     }
 92: 
 93:     public function __set($property, $value)
 94:     {
 95:         switch ($property) {
 96:         case 'thumbstyle':
 97:         case 'background':
 98:         case 'width':
 99:         case 'height':
100:             $this->_properties[$property] = $value;
101:             break;
102:         default:
103:             throw new Ansel_Exception('Invalid property');
104:         }
105:     }
106: 
107:     public function __isset($property)
108:     {
109:         return !empty($property);
110:     }
111: 
112:     /**
113:      * HACK - not sure how to upgrade the serialized Ansel_Style objects in the
114:      * stored galleries... the data is protected, so unserializing it wouldn't
115:      * give access to the needed information to move it.
116:      */
117:     public function __wakeup()
118:     {
119:        if (!empty($this->_properties['widgets'])) {
120:            $this->widgets = $this->_properties['widgets'];
121:            unset($this->_properties['widgets']);
122:        }
123:     }
124: 
125: }
126: 
127: 
API documentation generated by ApiGen