1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
<?php /** * provides the Themes tab of admin * @package admin */
// force UTF-8 Ø
define('OFFSET_PATH', 1); require_once(dirname(__FILE__).'/admin-globals.php');
admin_securityChecks(THEMES_RIGHTS, currentRelativeURL());
$_GET['page'] = 'themes';
/* handle posts */ $message = null; // will hold error/success message displayed in a fading box if (isset($_GET['action'])) { XSRFdefender('admin-themes'); switch ($_GET['action']) { case 'settheme': if (isset($_GET['theme'])) { $alb = sanitize_path($_GET['themealbum']); $newtheme = sanitize($_GET['theme']); if (empty($alb)) { $_zp_gallery->setCurrentTheme($newtheme); $_zp_gallery->save(); $_set_theme_album = NULL; } else { $_set_theme_album = newAlbum($alb); $oldtheme = $_set_theme_album->getAlbumTheme(); $_set_theme_album->setAlbumTheme($newtheme); $_set_theme_album->save(); } $opthandler = SERVERPATH.'/'.THEMEFOLDER.'/'.$newtheme.'/themeoptions.php'; if (file_exists($opthandler)) { require_once($opthandler); $opt = new ThemeOptions(); // prime the default options! } /* set any "standard" options that may not have been covered by the theme */ standardThemeOptions($newtheme, $_set_theme_album); header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin-themes.php?themealbum=".sanitize($_GET['themealbum'])); exitZP(); } break; // Duplicate a theme case 'copytheme': if (isset($_GET['source']) && isset($_GET['target']) && isset($_GET['name'])) { $message = copyThemeDirectory(sanitize($_GET['source'],3), sanitize($_GET['target'],3), sanitize($_GET['name'],3)); } $_zp_gallery = new Gallery(); // flush out remembered themes break; case 'deletetheme': if (isset($_GET['theme'])) { if (deleteThemeDirectory(SERVERPATH . '/themes/'.internalToFilesystem($theme = sanitize($_GET['theme'],3)))) { $message = sprintf(gettext("Theme <em>%s</em> removed."),html_encode($theme)); } else { $message = sprintf(gettext('Error removing theme <em>%s</em>'),html_encode($theme)); } $_zp_gallery = new Gallery(); // flush out remembered themes break; } } }
printAdminHeader('themes');
// Script for the "Duplicate theme" feature ?>
<script type="text/javascript" src="<?php echo WEBPATH.'/'.ZENFOLDER;?>/js/sprintf.js"></script> <script type="text/javascript"> //<!-- <![CDATA[ function copyClick(source) { var targetname = prompt('<?php echo gettext('New theme name?'); ?>', sprintf('<?php echo gettext('Copy of %s');?>',source)); if (targetname) { var targetdir = prompt('<?php echo gettext('Theme folder name?'); ?>', targetname.toLowerCase().replace(/ /g,'_').replace(/[^A-Za-z0-9_]/g,'') ); if (targetdir) { launchScript('',['action=copytheme','XSRFToken=<?php echo getXSRFToken('admin-themes')?>','source='+encodeURIComponent(source),'target='+encodeURIComponent(targetdir),'name='+encodeURIComponent(targetname)]); return false; } } return false; } // ]]> --> </script>
<?php echo "\n</head>"; echo "\n<body>"; printLogoAndLinks(); echo "\n" . '<div id="main">'; printTabs(); echo "\n" . '<div id="content">';
$galleryTheme = $_zp_gallery->getCurrentTheme(); $themelist = array(); if (zp_loggedin(ADMIN_RIGHTS)) { $gallery_title = $_zp_gallery->getTitle(); if ($gallery_title != gettext("Gallery")) { $gallery_title .= ' ('.gettext("Gallery").')'; } $themelist[$gallery_title] = ''; } $albums = $_zp_gallery->getAlbums(0); foreach ($albums as $alb) { $album = newAlbum($alb); if ($album->isMyItem(THEMES_RIGHTS)) { $key = $album->getTitle(); if ($key != $alb) { $key .= " ($alb)"; } $themelist[$key] = $alb; } } if (!empty($_REQUEST['themealbum'])) { $alb = sanitize_path($_REQUEST['themealbum']); $album = newAlbum($alb); $albumtitle = $album->getTitle(); $themename = $album->getAlbumTheme(); $current_theme = $themename; } else { $current_theme = $galleryTheme; foreach ($themelist as $albumtitle=>$alb) break; if (empty($alb)) { $themename = $_zp_gallery->getCurrentTheme(); } else { $alb = sanitize_path($alb); $album = newAlbum($alb); $albumtitle = $album->getTitle(); $themename = $album->getAlbumTheme(); } } $themes = $_zp_gallery->getThemes(); if (empty($themename)) { $current_theme = $galleryTheme; $theme = $themes[$galleryTheme]; $themenamedisplay = '</em><small>'.gettext("no theme assigned, defaulting to Gallery theme").'</small><em>'; $gallerydefault = true; } else { $theme = $themes[$themename]; $themenamedisplay = $theme['name']; $gallerydefault = false; }
if (count($themelist) > 1) { echo '<form action="#" method="post">'; echo gettext("Show theme for: "); echo '<select id="themealbum" name="themealbum" onchange="this.form.submit()">'; generateListFromArray(array(pathurlencode($alb)), $themelist, false, true); echo '</select>'; echo '</form>'; } if (count($themelist) == 0) { echo '<div class="errorbox" id="no_themes">'; echo "<h2>".gettext("There are no themes for which you have rights to administer.")."</h2>"; echo '</div>'; } else {
echo "<h1>".sprintf(gettext('Current theme for <code><strong>%1$s</strong></code>: <em>%2$s</em>'),$albumtitle,$themenamedisplay); if (!empty($alb) && !empty($themename)) { ?> <a class="reset" onclick="launchScript('',['action=settheme','themealbum=<?php echo pathurlencode($album->name); ?>','theme=','XSRFToken=<?php echo getXSRFToken('admin-themes'); ?>']);" title="<?php printf(gettext('Clear theme assignment for %s'),$album->name); ?>"> <img src="images/fail.png" style="border: 0px;" alt="<?php echo gettext('Clear theme assignment'); ?>" /> </a> <?php } echo "</h1>\n"; ?>
<?php if ($message) { echo '<div class="messagebox fade-message">'; echo "<h2>$message</h2>"; echo '</div>'; } ?>
<p> <?php echo gettext('Themes allow you to visually change the entire look and feel of your gallery. Theme files are located in your Zenphoto <code>/themes</code> folder.'); ?> <?php echo gettext('You can download more themes from the <a href="http://www.zenphoto.org/theme/">zenphoto themes page</a>.'); ?> <?php echo gettext('Place the downloaded themes in the <code>/themes</code> folder and they will be available for your use.') ?> </p>
<p> <?php echo gettext("You can edit files from custom themes. Official themes shipped with Zenphoto are not editable, since your changes would be lost on next update."); ?> <?php echo gettext("If you want to customize an official theme, please first <em>duplicate</em> it. This will place a copy in your <code>/themes</code> folder for you to edit."); ?> </p> <table class="bordered"> <tr> <th colspan="2"><b><?php echo gettext('Installed themes'); ?></b></th> <th><b><?php echo gettext('Action'); ?></b></th> </tr> <?php $zenphoto_date = date('Y-m-d H:i:s',filemtime(SERVERPATH.'/'.ZENFOLDER.'/version.php')); $current_theme_style = 'class="currentselection"'; foreach($themes as $theme => $themeinfo) { $style = ($theme == $current_theme) ? ' '.$current_theme_style : ''; $themedir = SERVERPATH . '/themes/'.internalToFilesystem($theme); $themeweb = WEBPATH . "/themes/$theme"; if (zenPhotoTheme($theme)) { $whose = 'Zenphoto official theme'; $ico = 'images/zp_gold.png'; } else { $whose = gettext('third party theme'); $path = $themedir.'/logo.png'; if (file_exists($path)) { $ico = $themeweb.'/logo.png'; } else { $ico = 'images/place_holder_icon.png'; } } ?> <tr> <td style="margin: 0px; padding: 0px;"> <?php if (file_exists("$themedir/theme.png")) { $themeimage = "$themeweb/theme.png"; } else if (file_exists("$themedir/theme.gif")) { $themeimage = "$themeweb/theme.gif"; } else if (file_exists("$themedir/theme.jpg")) { $themeimage = "$themeweb/theme.jpg"; } else { $themeimage = false; } if ($themeimage) { ?> <img height="150" width="150" src="<?php echo $themeimage; ?>" alt="Theme Screenshot" /> <?php } ?> </td> <td <?php echo $style; ?>> <img class="zp_logoicon" src="<?php echo $ico; ?>" alt="<?php echo gettext('logo'); ?>" title="<?php echo $whose; ?>" /> <strong><?php echo $themeinfo['name']; ?></strong> <br /> <?php echo $themeinfo['author']; ?> <br /> <?php if ($ico == 'images/zp_gold.png') { $version = ZENPHOTO_VERSION; $date = $zenphoto_date; } else { $version = $themeinfo['version']; $date = $themeinfo['date']; } echo gettext('Version').' '. $version.', '.$date; ?> <br /> <?php echo $themeinfo['desc']; ?> <br /><br /> <a href="<?php echo WEBPATH.'/'.ZENFOLDER; ?>/admin-options.php?page=options&tab=theme&optiontheme=<?php echo $theme; if ($alb) { echo '&themealbum='.$alb; } ?>" ><?php echo sprintf(gettext('Set <em>%s</em> theme options'),$themeinfo['name']); ?></a> </td> <td width="20%" <?php echo $style; ?>> <ul class="theme_links"> <?php if ($theme != $current_theme) { ?> <li> <p class="buttons"> <a onclick="launchScript('admin-themes.php',['action=settheme','themealbum=<?php echo pathurlencode($alb); ?>','theme=<?php echo $theme; ?>','XSRFToken=<?php echo getXSRFToken('admin-themes')?>']);"> <img src="images/pass.png" alt="" /><?php echo gettext("Activate"); ?> </a> </p> <br /> </li> <?php } else { if ($gallerydefault) { ?> <li> <p class="buttons"> <a onclick="launchScript('admin-themes.php',['action=settheme','themealbum=<?php echo pathurlencode($alb); ?>','theme=<?php echo $theme; ?>','XSRFToken=<?php echo getXSRFToken('admin-themes')?>']);"> <img src="images/pass.png" alt="" /><?php echo gettext("Assign"); ?> </a> </p> </li> <?php } else { echo "<li><strong>".gettext("Current Theme")."</strong></li>"; } }
if (themeIsEditable($theme)) { ?> <li> <p class="buttons"> <a onclick="launchScript('admin-themes-editor.php',['theme=<?php echo $theme; ?>']);"> <img src="images/pencil.png" alt="" /><?php echo gettext("Edit"); ?> </a> </p><br /> </li> <?php if ($theme != $current_theme) { ?> <li> <p class="buttons"> <a onclick="launchScript('admin-themes.php',['action=deletetheme','themealbum=<?php echo pathurlencode($alb); ?>','theme=<?php echo $theme; ?>','XSRFToken=<?php echo getXSRFToken('admin-themes')?>']);"> <img src="images/edit-delete.png" alt="" /><?php echo gettext("Delete"); ?> </a> </p> </li> <?php } } else { ?> <li class="zp_copy_theme"> <p class="buttons"> <a onclick="copyClick('<?php echo $theme; ?>');"> <img src="images/page_white_copy.png" alt="" /><?php echo gettext("Duplicate"); ?> </a> </p> </li> <?php } zp_apply_filter('admin_theme_buttons', $theme, $alb); ?> </ul> </td> </tr>
<?php } ?> </table>
<?php }
echo "\n" . '</div>'; //content printAdminFooter(); echo "\n" . '</div>'; //main
echo "\n</body>"; echo "\n</html>"; ?>
|