--- /dev/null
+<?php
+/**
+ * Abstract Ansel_View class for Ansel UI specific views.
+ * Copyright 2011 The Horde Project (http://www.horde.org/)
+ *
+ * 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
+ */
+abstract class Ansel_View_Ansel extends Ansel_View_Base
+{
+ /**
+ * The ansel resource this view is for.
+ * @TODO: visibility protected
+ * @var mixed Either an Ansel_Gallery or Ansel_Image
+ */
+ public $resource;
+
+ /**
+ * The gallery object (will be eq to $resource in a gallery view
+ *
+ * @TODO: visibility protected
+ * @var Ansel_Gallery
+ */
+ public $gallery;
+
+ /**
+ * Collection of Ansel_Widgets to display in this view.
+ *
+ * @var array
+ */
+ protected $_widgets = array();
+
+ /**
+ * Add an Ansel_Widget to be displayed in this view.
+ *
+ * @param Ansel_Widget $widget The Ansel_Widget to display
+ */
+ public function addWidget($widget)
+ {
+ $result = $widget->attach($this);
+ if (!empty($result)) {
+ $this->_widgets[] = $widget;
+ }
+ }
+
+ /**
+ * Output any widgets associated with this view.
+ *
+ */
+ public function renderWidgets()
+ {
+ $this->_renderWidgets();
+ }
+
+ /**
+ * Count the number of widgets we have attached.
+ *
+ * @return integer The number of widgets attached to this view.
+ */
+ public function countWidgets()
+ {
+ return count($this->_widgets);
+ }
+
+ /**
+ * Default widget rendering, can be overridden by any subclass.
+ *
+ */
+ protected function _renderWidgets()
+ {
+ echo '<div class="anselWidgets">';
+ foreach ($this->_widgets as $widget) {
+ if ($widget->autoRender) {
+ echo $widget->html();
+ echo '<br />';
+ }
+ }
+ echo '</div>';
+ }
+
+ abstract public function viewType();
+ abstract public function getGalleryCrumbData();
+ abstract public function getTitle();
+ abstract public function html();
+}
\ No newline at end of file
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
- */
- public $gallery;
-
- /**
- * Collection of Ansel_Widgets to display in this view.
- *
- * @var array
- */
- protected $_widgets = array();
-
- /**
* Const'r
*
* Any javascript files needed by the (non-api) view should be included
}
/**
+ * Getter for the view parameters.
+ *
+ * @return unknown_type
+ */
+ public function getParams()
+ {
+ return $this->_params;
+ }
+
+ /**
* Todo
*
* @param integer $galleryId The gallery id
return $gallery;
}
- /**
- * Add an Ansel_Widget to be displayed in this view.
- *
- * @param Ansel_Widget $widget The Ansel_Widget to display
- */
- public function addWidget($widget)
- {
- $result = $widget->attach($this);
- if (!empty($result)) {
- $this->_widgets[] = $widget;
- }
- }
-
- /**
- * Output any widgets associated with this view.
- *
- */
- public function renderWidgets()
- {
- $this->_renderWidgets();
- }
-
- /**
- * Count the number of widgets we have attached.
- *
- * @return integer The number of widgets attached to this view.
- */
- public function countWidgets()
- {
- return count($this->_widgets);
- }
-
- /**
- * Default widget rendering, can be overridden by any subclass.
- *
- */
- protected function _renderWidgets()
- {
- echo '<div class="anselWidgets">';
- foreach ($this->_widgets as $widget) {
- if ($widget->autoRender) {
- echo $widget->html();
- echo '<br />';
- }
- }
- echo '</div>';
- }
/**
- * JSON representation of this gallery's images.
+ * JSON representation of this gallery's images. We don't use
+ * Ansel_Gallery::toJson() on purpose since that is a general jsonification
+ * of the gallery data. This method is specific to the view, paging, links
+ * etc...
*
- * @param array $params An array of parameters for this method:
+ * @param Ansel_Gallery $gallery The gallery to represent in this view
+ * @param array $params An array of parameters for this method:
* <pre>
- * images - Array of Ansel_Images to generate JSON for [null]
* full - Should a full URL be generated? [false]
* from - Starting image count [0]
* count - The number of images to include (starting at from) [0]
*
* @return string A serialized JSON array.
*/
- public function json($params = array())
+ static public function json(Ansel_Gallery $gallery, $params = array())
{
global $conf, $prefs;
$curpage = 0;
if (empty($params['images'])) {
- $images = $this->gallery->getImages($params['from'], $params['count']);
+ $images = $gallery->getImages($params['from'], $params['count']);
}
- $style = $this->gallery->getStyle();
+ $style = $gallery->getStyle();
foreach ($images as $image) {
// Calculate the page this image will appear on in the
// gallery view.
$curpage);
if ($params['view_links']) {
$data[] = (string)Ansel::getUrlFor('view',
- array('gallery' => $this->gallery->id,
- 'slug' => $this->gallery->get('slug'),
+ array('gallery' => $gallery->id,
+ 'slug' => $gallery->get('slug'),
'image' => $image->id,
'view' => 'Image',
'page' => $curpage),
true);
$data[] = (string)Ansel::getUrlFor('view',
array('gallery' => $image->gallery,
- 'slug' => $this->gallery->get('slug'),
+ 'slug' => $gallery->get('slug'),
'view' => 'Gallery'),
true);
}
return Horde_Serialize::serialize($json, Horde_Serialize::JSON);
}
- /**
- * Getter for the view parameters.
- *
- * @return unknown_type
- */
- public function getParams()
- {
- return $this->_params;
- }
-
- /**
- * @abstract
- * @return unknown_type
- */
- abstract public function viewType();
-
- abstract public function getGalleryCrumbData();
-
- abstract public function getTitle();
-
- abstract public function html();
-
}
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Ansel
*/
-class Ansel_View_EmbeddedRenderer_Mini extends Ansel_View_Gallery
+class Ansel_View_EmbeddedRenderer_Mini extends Ansel_View_Base
{
+ public function __construct($params = array())
+ {
+ $this->_params = $params;
+ }
+
/**
* Build the javascript that will render the view.
*
}
if (empty($images)) {
- $json = $this->json(array('full' => true,
+ $images =
+ $json = self::json($this->gallery,
+ array('full' => true,
'from' => $start,
'count' => $count,
'image_view' => $thumbsize,
'view_links' => true));
- $json_full = $this->json(array('full' => true,
+ $json_full = self::json($this->gallery,
+ array('full' => true,
'from' => $start,
'count' => $count,
'view_links' => true));
*
* @package Ansel
*/
-class Ansel_View_Gallery extends Ansel_View_Base
+class Ansel_View_Gallery extends Ansel_View_Ansel
{
/**
* Holds the object that does the actual rendering.
/* Get JSON data for view */
// 0 == normal, 1 == by date
if ($this->mode == 0) {
- $json = $this->view->json(array(
- 'full' => !empty($this->view->api),
- 'perpage' => $this->perpage));
+ $json = Ansel_View_Base::json(
+ $this->view->gallery,
+ array(
+ 'full' => !empty($this->view->api),
+ 'perpage' => $this->perpage
+ )
+ );
} else {
if (!empty($this->date['day']) && $this->numTiles) {
- $json = $this->view->json(array(
- 'full' => !empty($this->view->api),
- 'perpage' => $this->perpage));
+ $json = Ansel_View_Base::json(
+ $this->view->gallery,
+ array(
+ 'full' => !empty($this->view->api),
+ 'perpage' => $this->perpage
+ )
+ );
} else {
$json = '[]';
}
*
* @package Ansel
*/
-class Ansel_View_Image extends Ansel_View_Base
+class Ansel_View_Image extends Ansel_View_Ansel
{
protected $_slug;
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*
+ * @TODO: should extend Base, not Ansel
+ *
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Ansel
*/
-class Ansel_View_List extends Ansel_View_Base
+class Ansel_View_List extends Ansel_View_Ansel
{
private $_groupby;
private $_owner;
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*
+ * @TODO: Should extend Base, not Ansel
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @category Horde
* @license http://www.fsf.org/copyleft/gpl.html GPL
* @package Ansel
*/
-class Ansel_View_Results extends Ansel_View_Base
+class Ansel_View_Results extends Ansel_View_Ansel
{
/**
* Instance of our tag search
<script type="text/javascript">
//<![CDATA[
-SlideController.initialize(<?php echo $this->json(array('view_links' => true)) ?>, <?php echo $imageIndex ?>, "<?php echo $GLOBALS['registry']->get('webroot')?>", <?php echo $this->gallery->id ?>, "<?php echo $this->gallery->getName()?>");
+SlideController.initialize(<?php echo self::json($this->view->gallery, array('view_links' => true)) ?>, <?php echo $imageIndex ?>, "<?php echo $GLOBALS['registry']->get('webroot')?>", <?php echo $this->gallery->id ?>, "<?php echo $this->gallery->getName()?>");
//]]>
function stopSlideShow()