1: <?php
2: /**
3: * Abstract Ansel_View class for Ansel UI specific views.
4: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
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: * @package Ansel
11: */
12: abstract class Ansel_View_Ansel extends Ansel_View_Base
13: {
14: /**
15: * The ansel resource this view is for.
16: * @TODO: visibility protected
17: * @var mixed Either an Ansel_Gallery or Ansel_Image
18: */
19: public $resource;
20:
21: /**
22: * The gallery object (will be eq to $resource in a gallery view
23: *
24: * @TODO: visibility protected
25: * @var Ansel_Gallery
26: */
27: public $gallery;
28:
29: /**
30: * Collection of Ansel_Widgets to display in this view.
31: *
32: * @var array
33: */
34: protected $_widgets = array();
35:
36: /**
37: * Add an Ansel_Widget to be displayed in this view.
38: *
39: * @param Ansel_Widget $widget The Ansel_Widget to display
40: */
41: public function addWidget($widget)
42: {
43: $result = $widget->attach($this);
44: if (!empty($result)) {
45: $this->_widgets[] = $widget;
46: }
47: }
48:
49: /**
50: * Output any widgets associated with this view.
51: *
52: */
53: public function renderWidgets()
54: {
55: $this->_renderWidgets();
56: }
57:
58: /**
59: * Count the number of widgets we have attached.
60: *
61: * @return integer The number of widgets attached to this view.
62: */
63: public function countWidgets()
64: {
65: return count($this->_widgets);
66: }
67:
68: /**
69: * Default widget rendering, can be overridden by any subclass.
70: *
71: */
72: protected function _renderWidgets()
73: {
74: echo '<div class="anselWidgets">';
75: foreach ($this->_widgets as $widget) {
76: if ($widget->autoRender) {
77: echo $widget->html();
78: echo '<br />';
79: }
80: }
81: echo '</div>';
82: }
83:
84: abstract public function viewType();
85: abstract public function getGalleryCrumbData();
86: abstract public function getTitle();
87: abstract public function html();
88: }