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:  * Ansel_Widget:: class wraps the display of widgets to be displayed in various
  4:  * Ansel_Views.
  5:  *
  6:  * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
  7:  *
  8:  * See the enclosed file COPYING for license information (GPL). If you
  9:  * did not receive this file, see http://www.horde.org/licenses/gpl.
 10:  *
 11:  * @author Michael J. Rubinsky <mrubinsk@horde.org>
 12:  * @category Horde
 13:  * @license http://www.horde.org/licenses/gpl GPL
 14:  * @package Ansel
 15:  */
 16: abstract class Ansel_Widget_Base
 17: {
 18:     /**
 19:      * Any parameters this widget will need..
 20:      *
 21:      * @var array
 22:      */
 23:     protected $_params = array();
 24: 
 25:     /**
 26:      * Reference to the Ansel_View we are attaching to
 27:      *
 28:      * @var Ansel_View
 29:      */
 30:     protected $_view;
 31: 
 32:     /**
 33:      * Holds the style definition for the gallery this view is for
 34:      * (or the image's parent gallery if this is for an image view).
 35:      *
 36:      * @var array
 37:      */
 38:     protected $_style;
 39: 
 40:     /**
 41:      * Title for this widget.
 42:      *
 43:      * @var string
 44:      */
 45:     protected $_title;
 46: 
 47:     /**
 48:      * Determine if this widget will be automatically rendered, or if it is
 49:      * the calling code's responsibility to render it.
 50:      *
 51:      * @var string
 52:      */
 53:     protected $_autoRender = true;
 54: 
 55:     /**
 56:      * Constructor
 57:      *   render
 58:      *   style
 59:      * @param array $params
 60:      * @return Ansel_Widget
 61:      */
 62:     public function __construct($params)
 63:     {
 64:         $this->_params = $params;
 65:         if (!empty($params['render'])) {
 66:             $this->_autoRender = ($params['render'] == 'auto');
 67:         }
 68:     }
 69: 
 70:     /**
 71:      * Attach this widget to the passed in view. Normally called
 72:      * by the Ansel_View once this widget is added.
 73:      *
 74:      * @param Ansel_View $view  The view to attach to
 75:      *
 76:      * @return boolean.
 77:      * @TODO: Remove return value, throw exception instead.
 78:      */
 79:     public function attach($view)
 80:     {
 81:         $this->_view = $view;
 82:         if (!empty($this->_params['style'])) {
 83:             $this->_style = $this->_params['style'];
 84:         } else {
 85:             $this->_style = $view->gallery->getStyle();
 86:         }
 87: 
 88:         return true;
 89:     }
 90: 
 91:     public function __get($property)
 92:     {
 93:         switch ($property) {
 94:         case 'autoRender':
 95:             return $this->_autoRender;
 96:         }
 97:     }
 98: 
 99:     /**
100:      * Get the HTML for this widget
101:      */
102:     abstract public function html();
103: 
104:     /**
105:      * Default HTML for the beginning of the widget.
106:      *
107:      * @return string
108:      */
109:     protected function _htmlBegin()
110:     {
111:         $html = '<div class="anselWidget" style="background-color:' . $this->_style->background .   ';">';
112:         $html .= '<h2 class="header tagTitle">' . $this->_title . '</h2>';
113:         return $html;
114:     }
115: 
116:     /**
117:      * Default HTML for the end of the widget.
118:      *
119:      * @return string
120:      */
121:     protected function _htmlEnd()
122:     {
123:         return '</div>';
124:     }
125: 
126: 
127:     /**
128:      * Determine if a particular view (Image, Gallery etc..) is supported
129:      * by this widget.
130:      *
131:      * @param string $view  The view to check
132:      *
133:      * @return boolean
134:      */
135:     protected function isSupported($view)
136:     {
137:         return true;
138:     }
139: 
140: }
141: 
API documentation generated by ApiGen