From 1db64436e1aed8c867d6170075b7329d9ff9ad3b Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Fri, 31 Jul 2009 12:20:15 -0400 Subject: [PATCH] rename lib/GalleryRenderers -> lib/GalleryRenderer --- ansel/lib/View/Abstract.php | 188 --------------------- .../Gallery.php | 2 - .../GalleryLightbox.php | 3 - .../GalleryVimeo.php | 0 4 files changed, 193 deletions(-) delete mode 100644 ansel/lib/View/Abstract.php rename ansel/lib/View/{GalleryRenderers => GalleryRenderer}/Gallery.php (98%) rename ansel/lib/View/{GalleryRenderers => GalleryRenderer}/GalleryLightbox.php (99%) rename ansel/lib/View/{GalleryRenderers => GalleryRenderer}/GalleryVimeo.php (100%) diff --git a/ansel/lib/View/Abstract.php b/ansel/lib/View/Abstract.php deleted file mode 100644 index bcd1bb751..000000000 --- a/ansel/lib/View/Abstract.php +++ /dev/null @@ -1,188 +0,0 @@ - - * @author Michael J. Rubinsky - * @package Ansel - */ -class Ansel_View_Base -{ - protected $_params = array(); - - /** - * The ansel resource this view is for. - * - * @var mixed Either an Ansel_Gallery or Ansel_Image - */ - public $resource; - - /** - * The gallery object (will be eq to $resource in a gallery view - * - * @var Ansel_Gallery - */ - var $gallery; - - /** - * Collection of Ansel_Widgets to display in this view. - * - * @var array - */ - var $_widgets = array(); - - function &getGallery($galleryId = null, $slug = '') - { - if (is_null($galleryId) && empty($slug)) { - $galleryId = !empty($this->_params['gallery_id']) ? $this->_params['gallery_id'] : null; - $slug = !empty($this->_params['gallery_slug']) ? $this->_params['gallery_slug'] : null; - } - - if (empty($galleryId) && empty($slug)) { - return PEAR::raiseError(_("No gallery specified")); - } - - // If we have a slug, use it. - if (!empty($slug)) { - $gallery = &$GLOBALS['ansel_storage']->getGalleryBySlug($slug); - } else { - $gallery = &$GLOBALS['ansel_storage']->getGallery($galleryId); - } - if (is_a($gallery, 'PEAR_Error')) { - return $gallery; - } elseif (!$gallery->hasPermission(Horde_Auth::getAuth(), PERMS_READ)) { - return PEAR::raiseError(sprintf(_("Access denied to gallery \"%s\"."), $gallery->get('name'))); - } - - /* Set any date info we might have */ - if (!empty($this->_params['year'])) { - $date = Ansel::getDateParameter( - array('year' => $this->_params['year'], - 'month' => $this->_params['month'], - 'day' => $this->_params['day'])); - } else { - $date = array(); - } - $gallery->setDate($date); - - return $gallery; - } - - /** - * Add an Ansel_Widget to be displayed in this view. - * - * @param Ansel_Widget $widget The Ansel_Widget to display - */ - function addWidget($widget) - { - $result = $widget->attach($this); - if (!empty($result)) { - $this->_widgets[] = $widget; - } - } - - - /** - * Output any widgets associated with this view. - * - */ - function renderWidgets() - { - $this->_renderWidgets(); - } - - /** - * Count the number of widgets we have attached. - * - * @return integer The number of widgets attached to this view. - */ - function countWidgets() - { - return count($this->_widgets); - } - - /** - * Default widget rendering, can be overridden by any subclass. - * - */ - function _renderWidgets() - { - echo '
'; - foreach ($this->_widgets as $widget) { - if ($widget->autoRender) { - echo $widget->html(); - echo '
'; - } - } - echo '
'; - } - - /** - * JSON representation of this gallery's images. - * - * @param array $images An array of Ansel_Image objects. If this is null - * the images are fetched based on $from and $count. - * - * @param integer $from Image to start at. - * @param integer $count Number of images to get. - * - * @return string A serialized JSON array. - */ - function json($images = null, $full = false, $from = 0, $count = 0, - $image_view = 'screen', $view_links = false) - { - global $conf, $prefs; - - $json = array(); - $perpage = $prefs->getValue('tilesperpage', $conf['thumbnail']['perpage']); - $curimage = 0; - $curpage = 0; - - if (is_null($images)) { - $images = $this->gallery->getImages($from, $count); - } - - $style = $this->gallery->getStyle(); - - foreach ($images as $image) { - // Calculate the page this image will appear on in the - // gallery view. - if (++$curimage > $perpage) { - ++$curpage; - $curimage = 0; - } - - $data = array(Ansel::getImageUrl($image->id, $image_view, $full, $style['name']), - htmlspecialchars($image->filename, ENT_COMPAT, Horde_Nls::getCharset()), - Horde_Text_Filter::filter($image->caption, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL)), - $image->id, - $curpage); - if ($view_links) { - $data[] = Ansel::getUrlFor('view', - array('gallery' => $this->gallery->id, - 'slug' => $this->gallery->get('slug'), - 'image' => $image->id, - 'view' => 'Image'), - true); - $data[] = Ansel::getUrlFor('view', - array('gallery' => $image->gallery, - 'slug' => $this->gallery->get('slug'), - 'view' => 'Gallery'), - true); - } - // Source, Width, Height, Name, Caption, Image Id, Gallery Page - $json[] = $data; - } - - return Horde_Serialize::serialize($json, Horde_Serialize::JSON, Horde_Nls::getCharset()); - } - - /** - * @abstract - * @return unknown_type - */ - function viewType() - { - } - -} diff --git a/ansel/lib/View/GalleryRenderers/Gallery.php b/ansel/lib/View/GalleryRenderer/Gallery.php similarity index 98% rename from ansel/lib/View/GalleryRenderers/Gallery.php rename to ansel/lib/View/GalleryRenderer/Gallery.php index af87d8206..f806a4b20 100644 --- a/ansel/lib/View/GalleryRenderers/Gallery.php +++ b/ansel/lib/View/GalleryRenderer/Gallery.php @@ -11,8 +11,6 @@ * @author Michael J. Rubinsky * @package Ansel */ -require_once ANSEL_BASE . '/lib/Views/GalleryRenderer.php'; - class Ansel_View_GalleryRenderer_Gallery extends Ansel_View_GalleryRenderer { /** diff --git a/ansel/lib/View/GalleryRenderers/GalleryLightbox.php b/ansel/lib/View/GalleryRenderer/GalleryLightbox.php similarity index 99% rename from ansel/lib/View/GalleryRenderers/GalleryLightbox.php rename to ansel/lib/View/GalleryRenderer/GalleryLightbox.php index 3e8e8559a..d70051b4b 100644 --- a/ansel/lib/View/GalleryRenderers/GalleryLightbox.php +++ b/ansel/lib/View/GalleryRenderer/GalleryLightbox.php @@ -11,9 +11,6 @@ * @author Michael J. Rubinsky * @package Ansel */ - -require_once ANSEL_BASE . '/lib/Views/GalleryRenderer.php'; - class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRenderer { /** diff --git a/ansel/lib/View/GalleryRenderers/GalleryVimeo.php b/ansel/lib/View/GalleryRenderer/GalleryVimeo.php similarity index 100% rename from ansel/lib/View/GalleryRenderers/GalleryVimeo.php rename to ansel/lib/View/GalleryRenderer/GalleryVimeo.php -- 2.11.0