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_View_GalleryRenderer::  Base class for all gallery renderers.
  4:  *
  5:  * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * See the enclosed file COPYING for license information (GPL). If you
  8:  * did not receive this file, see http://www.horde.org/licenses/gpl.
  9:  *
 10:  * @author  Michael J. Rubinsky <mrubinsk@horde.org>
 11:  * @package Ansel
 12:  */
 13: abstract class Ansel_View_GalleryRenderer_Base
 14: {
 15:     /**
 16:      * The Ansel_View_Gallery object that this Renderer belongs to.
 17:      *
 18:      * @var Ansel_View_Gallery
 19:      */
 20:     public $view;
 21: 
 22:     /**
 23:      * The gallery id for this view's gallery
 24:      * (Convenience instead of $this->view->gallery->id)
 25:      *
 26:      * @var integer
 27:      */
 28:     public $galleryId;
 29: 
 30:     /**
 31:      * Gallery slug for current gallery.
 32:      *
 33:      * @var string
 34:      */
 35:     public $gallerySlug;
 36: 
 37:     /**
 38:      * The current page we are viewing
 39:      *
 40:      * @var integer
 41:      */
 42:     public $page = 0;
 43: 
 44:     /**
 45:      * The display mode of the current gallery.
 46:      * 0 == Normal
 47:      * 1 == Group by date
 48:      *
 49:      * @var integer
 50:      */
 51:     public $mode;
 52: 
 53:     /**
 54:      * The style definition.
 55:      *
 56:      * @var Ansel_Style
 57:      */
 58:     public $style;
 59: 
 60:     /**
 61:      * Holds number of tiles to display per page
 62:      *
 63:      * @var integer
 64:      */
 65:     public $perpage;
 66: 
 67:     /**
 68:      * The tile number we are starting with on the current page.
 69:      *
 70:      * @var integer
 71:      */
 72:     public $pagestart;
 73: 
 74:     /**
 75:      * The last tile number on the current page.
 76:      *
 77:      * @var integer
 78:      */
 79:     public $pageend;
 80: 
 81:     /**
 82:      * The total number of tiles that this view contains
 83:      *
 84:      * @var integer
 85:      */
 86:     public $numTiles;
 87: 
 88:     /**
 89:      * The Ansel_Image or Ansel_DateGallery objects that appear on the current
 90:      * page in the current view.
 91:      *
 92:      * @var array of Ansel_Image or Ansel_DateGallery objects.
 93:      */
 94:     public $children;
 95: 
 96:     /**
 97:      * If we are grouping by date, this holds the currently selected date parts.
 98:      *
 99:      * @var array containing sufficient date parts for the current depth.
100:      */
101:     public $date = array();
102: 
103:     /**
104:      * Human readable title for this view type
105:      *
106:      * @var string
107:      */
108:     public $title;
109: 
110:     /**
111:      * Constructor
112:      *
113:      * @param Ansel_View_Gallery  The view object for this renderer.
114:      */
115:     public function __construct($view)
116:     {
117:         $this->view = $view;
118:     }
119: 
120:     /**
121:      * Initialize the renderer. This *must* be called before any attempt is made
122:      * to display or otherwise interact with the renderer.
123:      *
124:      * @TODO: Not sure why I didn't put this in the const'r - try moving it.
125:      */
126:     public function init()
127:     {
128:         global $prefs, $conf;
129: 
130:         $this->galleryId = $this->view->gallery->id;
131:         $this->gallerySlug = $this->view->gallery->get('slug');
132:         $this->page = $this->view->page;
133: 
134:         // Number perpage from prefs or config
135:         if ($this->view->tilesperpage) {
136:             $this->perpage = $this->view->tilesperpage;
137:         } else {
138:             $this->perpage = min($prefs->getValue('tilesperpage'),
139:                                  $conf['thumbnail']['perpage']);
140:         }
141:         $this->pagestart = ($this->page * $this->perpage) + 1;
142: 
143:         // Fetch the children
144:         $this->fetchChildren($this->view->force_grouping);
145: 
146:         // Do we have an explicit style set from the API?
147:         // If not, use the gallery's
148:         if (!empty($this->view->style)) {
149:             $this->style = Ansel::getStyleDefinition($this->view->style);
150:         } else {
151:             $this->style = $this->view->gallery->getStyle();
152:         }
153: 
154:         // Include any widgets
155:         if (!empty($this->style->widgets) && !$this->view->api) {
156:             // Special case widgets - these are built in
157:             if (array_key_exists('Actions', $this->style->widgets)) {
158:                 // Don't show action widget if no actions
159:                 if ($GLOBALS['registry']->getAuth() ||
160:                     !empty($conf['report_content']['driver']) &&
161:                     (($conf['report_content']['allow'] == 'authenticated' &&
162:                       $GLOBALS['registry']->isAuthenticated()) ||
163:                      $conf['report_content']['allow'] == 'all')) {
164: 
165:                     $this->view->addWidget(Ansel_Widget::factory('Actions'));
166:                 }
167:                 unset($this->style->widgets['Actions']);
168:             }
169: 
170:             // Gallery widgets always receive an array of image ids for
171:             // the current page.
172:             $ids = $this->getChildImageIds();
173:             foreach ($this->style->widgets as $wname => $wparams) {
174:                 $wparams = array_merge($wparams, array('images' => $ids));
175:                 $this->view->addWidget(Ansel_Widget::factory($wname, $wparams));
176:             }
177:         }
178: 
179:         /* See if any renderer specific tasks need to be done as well */
180:         $this->_init();
181:     }
182: 
183:     /**
184:      * Default implementation for fetching children/images for this view.
185:      * Other view classes can override this if they need anything special.
186:      */
187:     public function fetchChildren($noauto)
188:     {
189:         /* Total number of tiles for this gallery view */
190:         $this->numTiles = $this->view->gallery->countGalleryChildren(Horde_Perms::SHOW, false, $noauto);
191: 
192:         /* Children to display on this page */
193:         $this->children = $this->view->gallery->getGalleryChildren(
194:             Horde_Perms::SHOW,
195:             $this->page * $this->perpage,
196:             $this->perpage,
197:             !empty($this->view->force_grouping));
198: 
199:         /* The last tile number to display on the current page */
200:         $this->pageend = min($this->numTiles, $this->pagestart + $this->perpage - 1);
201:     }
202: 
203:     public function getChildImageIds()
204:     {
205:         $ids = array();
206:         foreach ($this->children as $child) {
207:             if ($child instanceof Ansel_Image) {
208:                 $ids[] = $child->id;
209:             }
210:         }
211:         return $ids;
212:     }
213: 
214:     /**
215:      * Return the HTML for this view. Done this way so we can override this in
216:      * subclasses if desired.
217:      *
218:      * @return string
219:      */
220:     abstract public function html();
221:     abstract protected function _init();
222: }
223: 
API documentation generated by ApiGen