1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14: class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRenderer_Base
15: {
16: public function __construct($view)
17: {
18: parent::__construct($view);
19: $this->title = _("Lightbox Gallery");
20: }
21:
22: 23: 24: 25: 26:
27: protected function _init()
28: {
29: if (empty($this->view->image_onclick)) {
30: $this->view->image_onclick = 'return lb.start(%i);';
31: }
32:
33:
34: if (empty($this->view->api)) {
35: $GLOBALS['injector']->getInstance('Horde_Themes_Css')->addThemeStylesheet('lightbox.css');
36: Horde::addScriptFile('effects.js', 'horde');
37: Horde::addScriptFile('lightbox.js', 'ansel');
38: Horde::addScriptFile('popup.js', 'horde');
39: }
40: }
41:
42: 43: 44: 45: 46:
47: public function html()
48: {
49: global $conf, $prefs, $registry;
50:
51: $galleryOwner = $this->view->gallery->get('owner');
52: $id = $this->view->gallery->getIdentity();
53: $owner = $id->getValue('fullname');
54: if (!$owner) {
55: $owner = $galleryOwner;
56: }
57:
58:
59:
60: if ($this->mode == 0) {
61: $json = Ansel_View_Base::json(
62: $this->view->gallery,
63: array(
64: 'full' => !empty($this->view->api),
65: 'perpage' => $this->perpage
66: )
67: );
68: } else {
69: if (!empty($this->date['day']) && $this->numTiles) {
70: $json = Ansel_View_Base::json(
71: $this->view->gallery,
72: array(
73: 'full' => !empty($this->view->api),
74: 'perpage' => $this->perpage
75: )
76: );
77: } else {
78: $json = '[]';
79: }
80: }
81:
82:
83: if (!$this->view->api) {
84: $option_edit = $this->view->gallery->hasPermission(
85: $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
86:
87: $option_select = $option_delete = $this->view->gallery->hasPermission(
88: $GLOBALS['registry']->getAuth(), Horde_Perms::DELETE);
89:
90: $option_move = ($option_delete && $GLOBALS['injector']
91: ->getInstance('Ansel_Storage')
92: ->countGalleries($GLOBALS['registry']->getAuth(), array('perm' => Horde_Perms::EDIT)));
93:
94: $option_copy = ($option_edit && $GLOBALS['injector']
95: ->getInstance('Ansel_Storage')
96: ->countGalleries($GLOBALS['registry']->getAuth(), array('perm' => Horde_Perms::EDIT)));
97:
98: if (Horde_Util::getFormData('actionID', '') == 'show_actions') {
99: $prefs->setValue('show_actions', (int)!$prefs->getValue('show_actions'));
100: }
101: }
102:
103:
104: $date_params = Ansel::getDateParameter(array(
105: 'year' => !empty($this->view->year) ? $this->view->year : 0,
106: 'month' => !empty($this->view->month) ? $this->view->month : 0,
107: 'day' => !empty($this->view->day) ? $this->view->day : 0));
108:
109: $vars = Horde_Variables::getDefaultVariables();
110: if (!empty($this->view->page)) {
111: $vars->add('page', $this->view->page);
112: $page = $this->view->page;
113: } else {
114: $page = 0;
115: }
116: if (!empty($this->view->gallery_view_url)) {
117: $pagerurl = new Horde_Url(str_replace(array('%g', '%s'), array($this->galleryId, $this->gallerySlug), urldecode($this->view->gallery_view_url)));
118: $pagerurl->add($date_params)->setRaw(true);
119: } else {
120:
121:
122:
123: $pager_params = array_merge(
124: array('gallery' => $this->galleryId,
125: 'view' => 'Gallery',
126: 'slug' => $this->view->gallery->get('slug')),
127: $date_params);
128: $pagerurl = Ansel::getUrlfor('view', $pager_params, true);
129: }
130:
131: if (!empty($this->view->urlCallback)) {
132: $callback = $this->view->urlCallback;
133: } else {
134: $callback = null;
135: }
136: $params = array('num' => $this->numTiles,
137: 'url' => $pagerurl,
138: 'perpage' => $this->perpage,
139: 'url_callback' => $callback);
140: $pager = new Horde_Core_Ui_Pager('page', $vars, $params);
141:
142: Horde::startBuffer();
143:
144:
145: $jsvars = array('graphics_dir' => Horde::url(Horde_Themes::img(), true, -1),
146: 'image_text' => _("Photo"),
147: 'of_text' => _("of"),
148: 'start_page' => $page);
149: $flipped = array_flip($date_params);
150: if (count($flipped) == 1 && !empty($flipped[0])) {
151: $jsvars['gallery_url'] = $pagerurl . '?';
152: } else {
153: $jsvars['gallery_url'] = $pagerurl . '&';
154: }
155:
156:
157: if ($this->view->api) {
158: $GLOBALS['injector']->getInstance('Horde_Themes_Css')->addThemeStylesheet('lightbox.css');
159: Horde::includeStylesheetFiles(array('nobase' => true), true);
160: $includes = $GLOBALS['injector']->createInstance('Horde_Script_Files');
161: $includes->add('accesskeys.js', 'horde', true);
162: $includes->add('effects.js', 'horde', true);
163: $includes->add('lightbox.js', 'ansel', true);
164: $includes->includeFiles();
165: }
166:
167:
168:
169: $tilesperrow = $this->view->tilesperrow ? $this->view->tilesperrow : $prefs->getValue('tilesperrow');
170: $cellwidth = round(100 / $tilesperrow);
171: $count = 0;
172:
173: include ANSEL_TEMPLATES . '/view/gallerylightbox.inc';
174:
175: return Horde::endBuffer();
176: }
177: }
178: