~ubuntu-branches/ubuntu/hardy/gallery2/hardy-security

« back to all changes in this revision

Viewing changes to themes/hybrid/theme.inc

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2006-04-16 16:42:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060416164235-8uy0u4bfjdxpge2o
Tags: 2.1.1-1
* New upstream release (Closes: #362936)
  + Bugfixes for Postgres7 (Closes: #359000, #362152)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 * $RCSfile: theme.inc,v $
4
4
 *
5
5
 * Gallery - a web based photo album viewer and editor
6
 
 * Copyright (C) 2000-2005 Bharat Mediratta
 
6
 * Copyright (C) 2000-2006 Bharat Mediratta
7
7
 *
8
8
 * This program is free software; you can redistribute it and/or modify
9
9
 * it under the terms of the GNU General Public License as published by
20
20
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
21
21
 */
22
22
/**
23
 
 * @version $Revision: 1.7 $ $Date: 2005/09/10 20:28:16 $
 
23
 * @version $Revision: 1.12 $ $Date: 2006/03/22 03:52:37 $
24
24
 * @package Gallery
25
25
 * @author Alan Harder <alan.harder@sun.com>
26
26
 */
44
44
        $this->setName($gallery->i18n('Hybrid'));
45
45
        $this->setDescription(
46
46
            $gallery->i18n('Combined album/image/slideshow dynamic view'));
47
 
        $this->setVersion('1.0.0');
48
 
        $this->setRequiredCoreApi(array(6, 0));
49
 
        $this->setRequiredThemeApi(array(2, 0));
 
47
        $this->setVersion('1.1.0');
 
48
        $this->setRequiredCoreApi(array(7, 0));
 
49
        $this->setRequiredThemeApi(array(2, 2));
50
50
        $this->setStandardSettings(array(
51
51
            'rows' => 30, 'columns' => 2,
52
52
            'albumFrame' => '', 'itemFrame' => '', 'colorpack' => '',
60
60
            'photoBlocks' => serialize(array(
61
61
                                array('exif.ExifInfo', array()),
62
62
                                array('comment.ViewComments', array()))),
 
63
            'showText' => 1, 'showAlbumDate' => 1, 'showImageDate' => 1, 'showDateInViewer' => 1,
 
64
            'showSize' => 1, 'showViewCount' => 1, 'showAlbumOwner' => 0, 'showImageOwner' => 0,
 
65
            'thumbTitle' => 'none',
63
66
        ));
64
67
    }
65
68
 
66
69
    /**
 
70
     * @see GalleryTheme::getSettings()
 
71
     */
 
72
    function getSettings($itemId=null) {
 
73
        list ($ret, $settings, $params) = parent::getSettings($itemId);
 
74
        if ($ret) {
 
75
            return array($ret->wrap(__FILE__, __LINE__), null);
 
76
        }
 
77
 
 
78
        /* Add in our custom settings */
 
79
        $settings[] = array('key' => 'showText',
 
80
                            'name' => $this->translate('Show text with thumbnails'),
 
81
                            'type' => 'checkbox',
 
82
                            'value' => $params['showText']);
 
83
        $settings[] = array('key' => 'showAlbumDate',
 
84
                            'name' => $this->translate('Show dates for albums'),
 
85
                            'type' => 'checkbox',
 
86
                            'value' => $params['showAlbumDate']);
 
87
        $settings[] = array('key' => 'showImageDate',
 
88
                            'name' => $this->translate('Show dates with thumbnails'),
 
89
                            'type' => 'checkbox',
 
90
                            'value' => $params['showImageDate']);
 
91
        $settings[] = array('key' => 'showDateInViewer',
 
92
                            'name' => $this->translate('Show dates in image view'),
 
93
                            'type' => 'checkbox',
 
94
                            'value' => $params['showDateInViewer']);
 
95
        $settings[] = array('key' => 'showSize',
 
96
                            'name' => $this->translate('Show album sizes'),
 
97
                            'type' => 'checkbox',
 
98
                            'value' => $params['showSize']);
 
99
        $settings[] = array('key' => 'showViewCount',
 
100
                            'name' => $this->translate('Show view counts'),
 
101
                            'type' => 'checkbox',
 
102
                            'value' => $params['showViewCount']);
 
103
        $settings[] = array('key' => 'thumbTitle',
 
104
                            'name' => $this->translate('Mouseover on thumbnails'),
 
105
                            'type' => 'single-select',
 
106
                            'choices' => array(
 
107
                                'none' => $this->translate('None'),
 
108
                                'title' => $this->translate('Title'),
 
109
                                'date' => $this->translate('Date'),
 
110
                                'datetime' => $this->translate('Date/Time'),
 
111
                                'titledate' => $this->translate('Title (Date)'),
 
112
                                'titledatetime' => $this->translate('Title (Date/Time)')),
 
113
                            'value' => $params['thumbTitle']);
 
114
 
 
115
        return array(null, $settings);
 
116
    }
 
117
 
 
118
    /**
67
119
     * @see GalleryTheme::showAlbumPage
68
120
     */
69
121
    function showAlbumPage(&$template, $item, $params, $childIds) {
70
 
        $ret = $this->loadCommonTemplateData($template, $item, $params,
71
 
            array('owner', 'viewCount', 'parents', 'systemLinks', 'itemLinks',
72
 
                  'childItemLinksDetailed', 'permissions', 'jumpRange'),
73
 
            $childIds);
74
 
        if ($ret->isError()) {
 
122
        global $gallery;
 
123
        $urlGenerator =& $gallery->getUrlGenerator();
 
124
 
 
125
        $data = array('parents', 'systemLinks', 'itemLinks',
 
126
                      'itemSummaries', 'childItemLinksDetailed', 'permissions', 'jumpRange');
 
127
        if ($params['showSize']) {
 
128
            $data[] = 'descendentCount';
 
129
        }
 
130
        if ($params['showViewCount']) {
 
131
            $data[] = 'viewCount';
 
132
        }
 
133
        if ($params['showAlbumOwner'] || $params['showImageOwner']) {
 
134
            $data[] = 'owner';
 
135
        }
 
136
        $ret = $this->loadCommonTemplateData($template, $item, $params, $data, $childIds);
 
137
        if ($ret) {
75
138
            return array($ret->wrap(__FILE__, __LINE__), null);
76
139
        }
77
140
        $theme =& $template->getVariableByReference('theme');
78
141
 
79
142
        list ($ret, $imageWidths, $imageHeights) =
80
143
            $this->_buildItemList($childIds, $theme['children']);
81
 
        if ($ret->isError()) {
 
144
        if ($ret) {
82
145
            return array($ret->wrap(__FILE__, __LINE__), null);
83
146
        }
84
147
 
86
149
        $theme['imageHeights'] = implode(',', $imageHeights);
87
150
        $theme['imageCount'] = count($imageWidths);
88
151
        $theme['columnWidthPct'] = floor(90 / $params['columns']);
 
152
        $theme['cookiePath'] = preg_replace('#^.*?://.*?(/|$)#', '/',
 
153
                                            $urlGenerator->getCurrentUrlDir());
89
154
 
90
155
        $showId = GalleryUtilities::getRequestVariables('showId');
91
156
        if (!empty($showId)) {
103
168
        }
104
169
 
105
170
        $template->head('themes/hybrid/templates/header.tpl');
106
 
        return array(GalleryStatus::success(), 'theme.tpl');
 
171
        return array(null, 'theme.tpl');
107
172
    }
108
173
 
109
174
    /**
114
179
        if (!empty($renderId)) {
115
180
            /* Render this item */
116
181
            list ($ret, $image) = GalleryCoreApi::loadEntitiesById($renderId);
117
 
            if ($ret->isError()) {
 
182
            if ($ret) {
118
183
                return array($ret->wrap(__FILE__, __LINE__), null);
119
184
            }
120
 
            $template->setVariable('theme', array('item' => $item->getMemberData(),
121
 
                                                  'image' => $image->getMemberData()));
122
 
            return array(GalleryStatus::success(), 'render.tpl');
 
185
            $template->setVariable('theme', array('item' => (array)$item,
 
186
                                                  'image' => (array)$image));
 
187
            return array(null, 'render.tpl');
123
188
        }
124
189
 
125
190
        if (!empty($detail)) {
126
191
            /* View item details */
127
192
            $ret = $this->loadCommonTemplateData($template, $item, $params,
128
193
                                                 array('owner', 'viewCount'));
129
 
            if ($ret->isError()) {
 
194
            if ($ret) {
130
195
                return array($ret->wrap(__FILE__, __LINE__), null);
131
196
            }
132
197
            $theme =& $template->getVariableByReference('theme');
133
198
            list ($ret, $thumbnail) =
134
199
                GalleryCoreApi::fetchThumbnailsByItemIds(array($item->getId()));
135
 
            if ($ret->isError()) {
 
200
            if ($ret) {
136
201
                return array($ret->wrap(__FILE__, __LINE__), null);
137
202
            }
138
203
            if (!empty($thumbnail)) {
139
 
                $theme['thumbnail'] = $thumbnail[$item->getId()]->getMemberData();
 
204
                $theme['thumbnail'] = (array)$thumbnail[$item->getId()];
140
205
            }
141
206
            $template->style('themes/hybrid/theme.css');
142
 
            return array(GalleryStatus::success(), 'detail.tpl');
 
207
            return array(null, 'detail.tpl');
143
208
        }
144
209
 
145
210
        /* Otherwise, redirect to parent with initial view of this item  */
146
211
        list ($ret, $parent) = GalleryCoreApi::loadEntitiesById($item->getParentId());
147
 
        if ($ret->isError()) {
 
212
        if ($ret) {
148
213
            return array($ret->wrap(__FILE__, __LINE__), null);
149
214
        }
150
215
        $theme =& $template->getVariableByReference('theme');
151
216
        list ($ret, $childIds) =
152
217
            GalleryCoreApi::fetchChildItemIds($parent, null, null, $theme['actingUserId']);
153
 
        if ($ret->isError()) {
 
218
        if ($ret) {
154
219
            return array($ret->wrap(__FILE__, __LINE__), null);
155
220
        }
156
221
        $perPage = $this->getPageSize($params);
166
231
            $redirect['page'] = $page;
167
232
        }
168
233
        $redirect['showId'] = $item->getId();
169
 
        return array(GalleryStatus::success(), array('redirect' => $redirect));
 
234
        return array(null, array('redirect' => $redirect));
170
235
    }
171
236
 
172
237
    /**
175
240
    function showModulePage(&$template, $item, $params, $templateFile) {
176
241
        $ret = $this->loadCommonTemplateData(
177
242
            $template, $item, $params, array('parents', 'systemLinks'));
178
 
        if ($ret->isError()) {
 
243
        if ($ret) {
179
244
            return array($ret->wrap(__FILE__, __LINE__), null);
180
245
        }
181
246
 
182
 
        return array(GalleryStatus::success(), 'theme.tpl');
 
247
        return array(null, 'theme.tpl');
183
248
    }
184
249
 
185
250
    /**
188
253
    function showAdminPage(&$template, $item, $params, $templateFile) {
189
254
        $ret = $this->loadCommonTemplateData(
190
255
            $template, $item, $params, array('parents', 'systemLinks'));
191
 
        if ($ret->isError()) {
 
256
        if ($ret) {
192
257
            return array($ret->wrap(__FILE__, __LINE__), null);
193
258
        }
194
259
 
195
 
        return array(GalleryStatus::success(), 'theme.tpl');
 
260
        return array(null, 'theme.tpl');
196
261
    }
197
262
 
198
263
    /**
199
264
     * @see GalleryTheme::showErrorPage
200
265
     */
201
266
    function showErrorPage(&$template) {
202
 
        return array(GalleryStatus::success(), 'error.tpl');
 
267
        return array(null, 'error.tpl');
203
268
    }
204
269
 
205
270
    /**
208
273
    function showProgressBarPage(&$template, $item, $params) {
209
274
        $ret = $this->loadCommonTemplateData(
210
275
            $template, $item, $params, array('parents', 'systemLinks'));
211
 
        if ($ret->isError()) {
 
276
        if ($ret) {
212
277
            return array($ret->wrap(__FILE__, __LINE__), null);
213
278
        }
214
279
 
215
 
        return array(GalleryStatus::success(), 'theme.tpl');
 
280
        return array(null, 'theme.tpl');
216
281
    }
217
282
 
218
283
    /**
223
288
        $imageWidths = $imageHeights = $childItems = array();
224
289
        if (!empty($childIds)) {
225
290
            $ret = GalleryCoreApi::studyPermissions($childIds);
226
 
            if ($ret->isError()) {
 
291
            if ($ret) {
227
292
                return array($ret->wrap(__FILE__, __LINE__), null, null);
228
293
            }
229
294
            list ($ret, $childItems) = GalleryCoreApi::loadEntitiesById($childIds);
230
 
            if ($ret->isError()) {
 
295
            if ($ret) {
231
296
                return array($ret->wrap(__FILE__, __LINE__), null, null);
232
297
            }
233
298
            list ($ret, $preferredFullImages) =
234
299
                GalleryCoreApi::fetchPreferredsByItemIds($childIds);
235
 
            if ($ret->isError()) {
 
300
            if ($ret) {
236
301
                return array($ret->wrap(__FILE__, __LINE__), null, null);
237
302
            }
238
303
            list ($ret, $resizedImages) =
239
304
                GalleryCoreApi::fetchResizesByItemIds($childIds);
240
 
            if ($ret->isError()) {
 
305
            if ($ret) {
241
306
                return array($ret->wrap(__FILE__, __LINE__), null, null);
242
307
            }
243
308
            list ($ret, $thumbnails) =
244
309
                GalleryCoreApi::fetchThumbnailsByItemIds($childIds);
245
 
            if ($ret->isError()) {
 
310
            if ($ret) {
246
311
                return array($ret->wrap(__FILE__, __LINE__), null, null);
247
312
            }
248
313
        }
254
319
                if (!($thumbnails[$childId]->getWidth() && $thumbnails[$childId]->getHeight())) {
255
320
                    list ($ret, $thumbnails[$childId]) =
256
321
                        GalleryCoreApi::rebuildDerivativeCache($thumbnails[$childId]->getId());
257
 
                    if ($ret->isError()) {
 
322
                    if ($ret) {
258
323
                        return array($ret->wrap(__FILE__, __LINE__), null, null);
259
324
                    }
260
325
                }
261
 
                $children[$i]['thumbnail'] = $thumbnails[$childId]->getMemberData();
 
326
                $children[$i]['thumbnail'] = (array)$thumbnails[$childId];
262
327
            }
263
328
 
264
329
            if (!GalleryUtilities::isA($child, 'GalleryDataItem')) {
266
331
            }
267
332
 
268
333
            list ($ret, $permissions) = GalleryCoreApi::getPermissions($childId);
269
 
            if ($ret->isError()) {
 
334
            if ($ret) {
270
335
                return array($ret->wrap(__FILE__, __LINE__), null, null);
271
336
            }
272
337
 
296
361
                if (GalleryUtilities::isA($image, 'GalleryDerivativeImage')
297
362
                        && !($image->getWidth() && $image->getHeight())) {
298
363
                    list ($ret, $image) = GalleryCoreApi::rebuildDerivativeCache($image->getId());
299
 
                    if ($ret->isError()) {
 
364
                    if ($ret) {
300
365
                        return array($ret->wrap(__FILE__, __LINE__), null, null);
301
366
                    }
302
367
                }
303
 
                $image = $image->getMemberData();
 
368
                $image = (array)$image;
304
369
                $children[$i]['image'] = $image;
305
370
                $children[$i]['imageIndex'] = count($imageWidths);
306
371
                if (GalleryUtilities::isExactlyA($child, 'GalleryPhotoItem') &&
315
380
                }
316
381
            }
317
382
        }
318
 
        return array(GalleryStatus::success(), $imageWidths, $imageHeights);
 
383
        return array(null, $imageWidths, $imageHeights);
319
384
    }
320
385
}
321
386
?>