1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12: class Ansel_Block_MyGalleries extends Horde_Core_Block
13: {
14: 15:
16: public function __construct($app, $params = array())
17: {
18: parent::__construct($app, $params);
19: $this->_name = _("My Galleries");
20: }
21:
22: 23:
24: protected function _params()
25: {
26: return array(
27: 'limit' => array(
28: 'name' => _("Maximum number of galleries"),
29: 'type' => 'int',
30: 'default' => 0
31: )
32: );
33: }
34:
35: 36:
37: protected function _title()
38: {
39: return Ansel::getUrlFor(
40: 'view',
41: array(
42: 'groupby' => 'owner',
43: 'owner' => $GLOBALS['registry']->getAuth(),
44: 'view' => 'List'))
45: ->link() . _("My Galleries") . '</a>';
46: }
47:
48: 49:
50: protected function _content()
51: {
52: Horde::addScriptFile('block.js');
53:
54:
55: try {
56: $galleries = $GLOBALS['injector']
57: ->getInstance('Ansel_Storage')
58: ->listGalleries(
59: array(
60: 'perm' => Horde_Perms::EDIT,
61: 'attributes' => $GLOBALS['registry']->getAuth(),
62: 'all_levels' => false,
63: 'count' => empty($this->_params['limit']) ? 0 : $this->_params['limit'],
64: 'sort_by' => 'last_modified',
65: 'direction' => Ansel::SORT_DESCENDING));
66: } catch (Ansel_Exception $e) {
67: return $e->getMessage();
68: }
69:
70: $header = array(_("Gallery Name"), _("Last Modified"), _("Photo Count"));
71: $html = <<<HEADER
72: <table class="linedRow" cellspacing="0" style="width:100%">
73: <thead><tr class="item nowrap">
74: <th class="item leftAlign">$header[0]</th>
75: <th class="item leftAlign">$header[1]</th>
76: <th class="item leftAlign">$header[2]</th>
77: </tr></thead>
78: <tbody>
79: HEADER;
80:
81: foreach ($galleries as $gallery) {
82: $url = Ansel::getUrlFor(
83: 'view',
84: array(
85: 'view' => 'Gallery',
86: 'slug' => $gallery->get('slug'),
87: 'gallery' => $gallery->id),
88: true);
89:
90: $html .= '<tr><td>'
91: . $url->link(array('onmouseout' => '$("ansel_preview").hide();$("ansel_preview").update("");',
92: 'onmouseover' => 'Ansel.previewImage(event, ' . $gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')) . ');'))
93: . htmlspecialchars($gallery->get('name')) . '</a></td><td>'
94: . strftime($GLOBALS['prefs']->getValue('date_format'), $gallery->get('last_modified'))
95: . '</td><td>' . (int)$gallery->countImages(true) . '</td></tr>';
96: }
97: $html .= '</tbody></table>';
98:
99: return $html;
100: }
101:
102: }
103: