Mercurial > hg > mgallery
annotate mgallery.php @ 19:59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 14 Sep 2015 12:49:56 +0300 |
parents | 3f7bc4202df3 |
children | 12916fcdb8b8 |
rev | line source |
---|---|
0 | 1 <?php |
2 // | |
3 // Yet Another Image Gallery | |
4 // (C) Copyright 2015 Tecnic Software productions (TNSP) | |
5 // | |
6 require "msitegen.inc.php"; | |
7 require "mgallery.inc.php"; | |
8 | |
9 | |
10 // | |
11 // Various utility functions | |
12 // | |
13 function mgGetImageURL() | |
14 { | |
15 global $galImageURL, $galPath; | |
5
1bf73b49fc91
Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
16 return str_replace("//", "/", $galImageURL.$galPath."/".implode("", func_get_args())); |
0 | 17 } |
18 | |
19 | |
20 function mgGetURL($path, $image, $entities = TRUE) | |
21 { | |
22 global $galBaseURL, $galCleanURLS; | |
23 $amp = $entities ? "&" : "&"; | |
24 | |
25 if ($galCleanURLS) | |
26 { | |
5
1bf73b49fc91
Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
27 $url = $galBaseURL.$path."/".($image !== FALSE ? $image : ""); |
0 | 28 } |
29 else | |
30 { | |
5
1bf73b49fc91
Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
31 $url = |
0 | 32 $galBaseURL.mgGetSetting("mgallery_php")."?path=". |
33 $path.($image !== FALSE ? $amp."image=".$image : ""); | |
34 } | |
5
1bf73b49fc91
Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
35 |
1bf73b49fc91
Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
36 return str_replace("//", "/", $url); |
0 | 37 } |
38 | |
39 | |
40 function mgGetNaviActive(&$galIndex, $index, $delta, &$res, &$url, $entities) | |
41 { | |
42 global $galPath; | |
43 $res = $index + $delta; | |
44 if ($res >= 0 && $res <= sizeof($galIndex) - 1) | |
45 { | |
46 $url = mgGetURL($galPath, $galIndex[$res], $entities); | |
47 return TRUE; | |
48 } | |
49 else | |
50 return FALSE; | |
51 } | |
52 | |
53 | |
54 function mgGetNaviControlImage(&$galIndex, $index, $class, $url) | |
55 { | |
56 global $galTNPath; | |
57 | |
58 $img = "<div class=\"imageCtrl ".$class."\">"; | |
59 | |
60 if ($url !== FALSE) | |
61 { | |
62 $img .= | |
63 "<a href=\"".$url."\"><img src=\"". | |
64 mgGetImageURL($galTNPath, $galIndex[$index]). | |
65 "\" alt=\"".$galIndex[$index]."\" /></a>"; | |
66 } | |
67 | |
68 return $img."</div>\n"; | |
69 } | |
70 | |
71 | |
72 function mgGetNaviControlImageBox(&$galIndex, $index, $class, $delta) | |
73 { | |
74 if (!mgGetNaviActive($galIndex, $index, $delta, $res, $url, TRUE)) | |
75 $url = FALSE; | |
76 | |
77 return mgGetNaviControlImage($galIndex, $res, $class, $url); | |
78 } | |
79 | |
80 | |
7
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
81 function mgGetControlText($id, $active, $url, $naviFlags) |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
82 { |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
83 if ($naviFlags & GNAV_TEXT) |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
84 { |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
85 $str = chentities(mgGetSetting("navi_ctrl_".$id)); |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
86 return |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
87 "<span class=\"naviControl ".$id."\">[". |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
88 ($active ? "<a href=\"".$url."\">".$str."</a>" : $str). |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
89 "]</span>"; |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
90 } |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
91 else |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
92 return ""; |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
93 } |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
94 |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
95 |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
96 function mgGetControl($id, &$galIndex, $index, $delta, $naviFlags) |
0 | 97 { |
98 $active = mgGetNaviActive($galIndex, $index, $delta, $res, $url, TRUE); | |
99 if ($active && ($naviFlags & GNAV_IMG)) | |
7
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
100 $img = mgGetNaviControlImage($galIndex, $res, $id, $url); |
0 | 101 else |
102 $img = ""; | |
103 | |
7
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
104 $text = mgGetControlText($id, $active, $url, $naviFlags); |
0 | 105 |
106 if ($delta < 0) | |
7
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
107 return $img.$text; |
0 | 108 else |
7
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
109 return $text.$img; |
0 | 110 } |
111 | |
112 | |
113 function mgGetNaviControls(&$galIndex, $index, $naviFlags) | |
114 { | |
115 global $galPath; | |
116 | |
117 return | |
118 "<div class=\"naviControls\">". | |
7
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
119 mgGetControl("prev", $galIndex, $index, -1, $naviFlags). |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
120 mgGetControlText("up", TRUE, mgGetURL($galPath, FALSE), $naviFlags). |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
121 mgGetControl("next", $galIndex, $index, 1, $naviFlags). |
0 | 122 "</div>\n"; |
123 } | |
124 | |
125 | |
126 function mgPrintTable($class, &$galEntries, &$galIndex, $start, $limit) | |
127 { | |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
128 global $galAlbumIcon, $galPath, $galTNPath, $galImageURL, $galUseCoverImages, $galUseTables; |
0 | 129 |
130 $galCount = count($galIndex); | |
131 if ($start >= $galCount) | |
132 return $start; | |
133 | |
134 $end = ($limit === FALSE) ? $galCount : $start + $limit; | |
135 if ($end > $galCount) $end = $galCount; | |
136 | |
137 $rowLimit = mgGetSetting("album_row_limit"); | |
138 $n = 0; | |
139 | |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
140 if ($galUseTables) |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
141 echo "<table class=\"".$class."\">\n"; |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
142 |
0 | 143 for ($index = $start; $index < $end; $index++) |
144 { | |
145 $filename = &$galIndex[$index]; | |
146 $data = &$galEntries[$filename]; | |
147 | |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
148 if ($galUseTables && $n == 0) echo " <tr>\n"; |
0 | 149 |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
150 if ($galUseTables) |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
151 echo " <td id=\"cd".$data["base"]."\">\n"; |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
152 else |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
153 echo " <div class=\"albumEntry\">\n"; |
0 | 154 |
155 if ($data["type"] == 0) | |
156 { | |
157 echo | |
158 "<div class=\"imageBox\"><a href=\"".mgGetURL($galPath, $filename)."\">". | |
159 "<img src=\"".mgGetImageURL($galTNPath, $filename)."\" alt=\"". | |
160 chentities($filename)."\"></a>". | |
161 "</div>". | |
162 mgGetArr($data, "caption", "<div class=\"imageCaption\">%1</div>", "", "chentities"); | |
163 /* | |
164 if ($mode == "") | |
165 { | |
166 echo | |
167 " <select class=\"dropdown\" id=\"dd".$data["base"]."\" name=\"dd".$data["base"]. | |
168 "\" onchange=\"galPhotoDataChanged('".$data["base"]."');\">\n"; | |
169 | |
170 foreach ($picChoices as $name => $value) | |
171 { | |
172 echo " <option value=\"$value\"".($value == $data["id"] ? " selected=\"selected\"" : "").">".chentities($name)."</option>\n"; | |
173 } | |
174 echo | |
175 " </select>\n"; | |
176 } | |
177 */ | |
178 } | |
179 else | |
180 { | |
17
3f7bc4202df3
Add new configuration setting 'cover_images' to disable/enable sub-album
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
181 $atmp = ($galUseCoverImages && isset($data["image"])) ? $galImageURL.mgCleanPath(TRUE, $galPath, $filename, $galTNPath, $data["image"]) : $galAlbumIcon; |
0 | 182 echo |
17
3f7bc4202df3
Add new configuration setting 'cover_images' to disable/enable sub-album
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
183 " <a href=\"".mgGetURL(mgCleanPath(TRUE, $galPath, $filename), FALSE)."\">". |
3f7bc4202df3
Add new configuration setting 'cover_images' to disable/enable sub-album
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
184 "<img class=\"albumIcon\" src=\"".$atmp."\" alt=\"".chentities($data["caption"])."\" />\n". |
0 | 185 "<div class=\"albumTitle\">".chentities($data["caption"])."</div></a>\n"; |
186 } | |
187 | |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
188 if ($galUseTables) |
0 | 189 { |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
190 echo " </td>\n"; |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
191 if (++$n >= $rowLimit) |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
192 { |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
193 echo " </tr>\n"; |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
194 $n = 0; |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
195 } |
0 | 196 } |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
197 else |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
198 echo " </div>\n"; |
0 | 199 } |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
200 |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
201 if ($galUseTables) |
0 | 202 { |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
203 if ($n > 0) |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
204 { |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
205 while ($n++ < $rowLimit) |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
206 echo " <td></td>\n"; |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
207 echo " </tr>\n"; |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
208 } |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
209 echo "</table>\n"; |
0 | 210 } |
211 return $index; | |
212 } | |
213 | |
214 | |
215 function mgTimeStr($str) | |
216 { | |
217 $tmp = date_create_from_format("Y:m:d H:i:s", $str); | |
218 return date_format($tmp, "d M Y (H:i)"); | |
219 } | |
220 | |
221 | |
222 function mgPrintPageInfoFooter() | |
223 { | |
224 if (($str = mgGetSetting("page_info")) !== FALSE) | |
225 echo "<div class=\"pageInfoFooter\">".$str."</div>"; | |
226 } | |
227 | |
228 | |
229 function mgPrintBreadCrumbs($galData) | |
230 { | |
231 $res = array(); | |
232 if ($galData["caption"]) | |
4
014e1d6991a3
Oops, fix the last breadcrumb.
Matti Hamalainen <ccr@tnsp.org>
parents:
3
diff
changeset
|
233 $res[] = "<a class=\"naviBreadCrumbCurr\" href=\"".mgGetURL($galData["path"], FALSE)."\">".chentities($galData["caption"])."</a>"; |
0 | 234 |
235 $tmp = $galData; | |
236 while (isset($tmp["parent"])) | |
237 { | |
238 $pdata = $tmp["parent"]; | |
3
c85f630a4198
Improve bread crumb navigation by making the current album a link as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
239 $res[] = "<a class=\"naviBreadCrumbItem\" href=\"".mgGetURL($pdata["path"], FALSE)."\">".chentities($pdata["caption"])."</a>"; |
0 | 240 $tmp = $tmp["parent"]; |
241 } | |
242 | |
243 if (count($res) > 1) | |
244 { | |
245 echo | |
246 "<div class=\"naviBreadCrumbs\">". | |
247 implode("<span class=\"naviBreadCrumbSep\"></span>", array_reverse($res)). | |
248 "</div>\n"; | |
249 } | |
250 } | |
251 | |
252 | |
253 // | |
254 // Get gallery settings | |
255 // | |
256 mgReadSettings(); | |
257 | |
258 $pageCSS = mgGetSetting("css"); | |
259 $pageCSSSelect = mgGetSetting("css_select"); | |
260 $galBasePath = mgGetSetting("base_path"); | |
261 $galBaseURL = mgGetSetting("base_url"); | |
262 $galImageURL = mgGetSetting("image_url", mgGetSetting("base_url")); | |
263 | |
17
3f7bc4202df3
Add new configuration setting 'cover_images' to disable/enable sub-album
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
264 $galUseCoverImages = mgGetSetting("cover_images"); |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
265 $galUseTables = mgGetSetting("use_tables"); |
17
3f7bc4202df3
Add new configuration setting 'cover_images' to disable/enable sub-album
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
266 |
0 | 267 $galAlbumIcon = mgGetSetting("album_icon"); |
268 $galCleanURLS = mgGetSetting("clean_urls"); | |
269 $galTNPath = mgGetSetting("tn_path"); | |
270 $galMedSuffix = mgGetSetting("med_suffix"); | |
271 $galTitlePrefix = mgGetSetting("title_prefix"); | |
272 $galTitleSep = mgGetSetting("title_sep"); | |
273 | |
274 $galMode = stGetRequestItem("mode", "view", TRUE); | |
275 $galPath = stGetRequestItem("path", ".", TRUE); | |
276 $galPageIndex = intval(stGetRequestItem("index", 0, TRUE)); | |
277 $galImage = stGetRequestItem("image", FALSE, TRUE); | |
278 | |
279 if (is_string($galImage)) | |
280 $galImage = basename($galImage); | |
281 | |
282 | |
283 // | |
284 // Attempt to read the data cache file | |
285 // | |
286 $filename = mgGetPath(mgCleanPath(TRUE, $galBasePath, $galPath), "cache_file"); | |
287 $filename2 = mgGetPath(mgCleanPath(FALSE, $galBasePath, $galPath), "cache_file"); | |
288 if ($filename == $filename2 && file_exists($filename) && ($fp = @fopen($filename, "rb")) !== FALSE) | |
289 { | |
290 if (flock($fp, LOCK_SH)) | |
291 { | |
292 require($filename); | |
293 flock($fp, LOCK_UN); | |
294 } | |
295 fclose($fp); | |
296 } | |
297 | |
298 | |
299 // If no data available, show an error page | |
300 if (!isset($galData) || !isset($galEntries) || | |
301 !isset($galAlbumsIndex) || !isset($galImagesIndex)) | |
302 { | |
303 cmPrintPageHeader(mgGetVal(array("title_prefix", "title_sep"), "%1%2")."ERROR!"); | |
304 | |
305 echo | |
306 "<h1>Gallery error</h1>\n". | |
307 "<p>Gallery path <b>".chentities($galPath)."</b> does not exist or is invalid.</p>\n"; | |
308 | |
12
79987aa7ee9a
Change some debugging (commented out).
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
309 //echo "<p>filename=: '".$filename."', X: galData=".intval(isset($galData)).", galEntries=".intval(isset($galEntries))."\n"; |
0 | 310 |
311 mgPrintPageInfoFooter(); | |
312 cmPrintPageFooter(TRUE); | |
313 exit; | |
314 } | |
315 | |
316 | |
317 // | |
318 // Print page header, etc. | |
319 // | |
320 if (($index = array_search($galImage, $galImagesIndex)) !== FALSE) | |
321 { | |
322 // | |
323 // Single image mode | |
324 // | |
325 $naviFlags = mgGetSetting("image_navigation"); | |
326 $data = $galEntries[$galImage]; | |
327 | |
328 $pageTitle = $galTitlePrefix.$galTitleSep.$galData["caption"]." - ".$galImage; | |
329 cmPrintPageHeader($pageTitle); | |
330 echo "<h1>".chentities($pageTitle)."</h1>\n"; | |
331 | |
332 if ($naviFlags & GNAV_BREADCRUMBS) | |
333 mgPrintBreadCrumbs($galData); | |
334 | |
335 if ($naviFlags & GNAV_TOP) | |
336 echo mgGetNaviControls($galImagesIndex, $index, $naviFlags); | |
337 | |
338 echo | |
339 "<div class=\"imageCBox\">\n". | |
340 mgGetNaviControlImageBox($galImagesIndex, $index, "prev", -1). | |
341 "<div class=\"imageBox\">\n". | |
342 "<a target=\"_blank\" href=\"".$galImageURL.$galPath."/".$galImage."\">". | |
343 "<img src=\"".mgGetImageURL($galTNPath, $data["base"].$galMedSuffix.$data["ext"])."\" alt=\"". | |
344 chentities($data["base"].$galMedSuffix.$data["ext"])."\"></a>\n". | |
345 "</div>\n". | |
346 mgGetNaviControlImageBox($galImagesIndex, $index, "next", 1). | |
347 "</div>\n". | |
348 "<div class=\"imageCaption\">".mgGetArr($data, "caption", "%1", "")."</div>\n"; | |
349 | |
350 $list = array( | |
351 mgGetArr($data, array("width", "height"), "<span class=\"infoDimensions\"><b>%1</b> x <b>%2</b> px</span>", NULL), | |
352 mgGetArr($data, "model", "<span class=\"infoModel\"><b>%1</b></span>", NULL), | |
353 mgGetArr($data, "fnumber", "<span class=\"infoFNumber\"><b>f/%1</b></span>", NULL), | |
354 mgGetArr($data, "exposure", "<span class=\"infoExposure\"><b>%1</b> sec</span>", NULL, NULL), | |
355 mgGetArr($data, "iso", "<span class=\"infoISO\">ISO <b>%1</b></span>", NULL), | |
356 ); | |
357 | |
358 echo | |
359 "<div class=\"infoBox\">\n". | |
360 mgGetArr($data, "datetime", "<span class=\"infoDateTime\">%1</span>", "", "mgTimeStr"). | |
361 implode(", ", array_filter($list, function($a) { return $a !== NULL; })). | |
362 "</div>\n"; | |
363 | |
364 if ($naviFlags & GNAV_BOTTOM) | |
365 echo mgGetNaviControls($galImagesIndex, $index, $naviFlags); | |
366 | |
367 // Javascript navigation | |
368 if ($naviFlags & GNAV_JAVASCRIPT) | |
369 { | |
370 $prevActive = mgGetNaviActive($galImagesIndex, $index, -1, $res, $prevURL, FALSE); | |
371 $nextActive = mgGetNaviActive($galImagesIndex, $index, 1, $res, $nextURL, FALSE); | |
372 echo | |
373 "<script type=\"text/javascript\">\n". | |
374 "var mgalPrevURL = \"".($prevActive ? $prevURL : "")."\";\n". | |
375 "var mgalNextURL = \"".($nextActive ? $nextURL : "")."\";\n". | |
376 "\n"; | |
377 ?> | |
378 function mgalNavigateTo(url) | |
379 { | |
380 if (url != "") | |
381 window.location = url; | |
382 } | |
383 | |
384 | |
385 function mgalProcessKeyPress(ev) | |
386 { | |
387 ev = ev || window.event; | |
388 var key = ev.keyCode ? ev.keyCode : ev.which; | |
389 switch (key) | |
390 { | |
391 case 37: | |
392 case 65: | |
393 // left | |
394 mgalNavigateTo(mgalPrevURL); | |
395 break; | |
396 | |
397 case 39: | |
398 case 68: | |
399 // right | |
400 mgalNavigateTo(mgalNextURL); | |
401 break; | |
402 } | |
403 } | |
404 | |
405 document.onkeypress = mgalProcessKeyPress; | |
406 <? | |
407 echo | |
408 "</script>\n"; | |
409 } | |
410 } | |
411 else | |
412 { | |
413 // | |
414 // Gallery mode | |
415 // | |
416 // - needs sub-modes / handling of order shit | |
417 // - Javascript stuff for picture data updates | |
418 // | |
419 $pageTitle = $galTitlePrefix.mgGetArr($galData, "caption", " - %1", "", "chentities"); | |
420 cmPrintPageHeader($pageTitle); | |
421 echo "<h1>".$pageTitle."</h1>\n"; | |
422 | |
423 $naviFlags = mgGetSetting("album_navigation"); | |
424 if ($naviFlags & GNAV_BREADCRUMBS) | |
425 mgPrintBreadCrumbs($galData); | |
426 | |
427 if (isset($galData["header"]) && strlen($galData["header"]) > 0) | |
13
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
428 { |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
429 // Translate relative URLs in header, if needed |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
430 $baseURL = mgGetSetting("image_url"); |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
431 |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
432 $headerText = preg_replace_callback( |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
433 "@href\s*=\s*\"([^\"]+)\"@i", |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
434 function ($matches) use($galPath, $baseURL) |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
435 { |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
436 $mstmp = $matches[1]; |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
437 if (preg_match("@^[a-z]+://@i", $mstmp) === 0) |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
438 { |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
439 if ($mstmp[0] != "/") |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
440 $mstmp = $baseURL."/".$galPath."/".$mstmp; |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
441 } |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
442 return "href=\"".str_replace("//", "/", $mstmp)."\""; |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
443 }, |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
444 $galData["header"]); |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
445 |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
446 echo "<div class=\"albumHeaderText\">".$headerText."</div>\n"; |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
447 } |
0 | 448 |
449 mgPrintTable("albumTable", $galEntries, $galAlbumsIndex, 0, FALSE); | |
450 mgPrintTable("imageTable", $galEntries, $galImagesIndex, 0, FALSE); | |
451 } | |
452 | |
453 mgPrintPageInfoFooter(); | |
454 cmPrintPageFooter(TRUE); | |
455 ?> |