Mercurial > hg > mgallery
annotate mgallery.php @ 34:e786771dfaa5
Add seconds to outputted timestamps.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 23 Apr 2016 20:14:23 +0300 |
parents | 953b0f7636f4 |
children | 985596db0f01 |
rev | line source |
---|---|
0 | 1 <?php |
2 // | |
3 // Yet Another Image Gallery | |
32 | 4 // (C) Copyright 2015-2016 Tecnic Software productions (TNSP) |
0 | 5 // |
27 | 6 require "mgeneric.inc.php"; |
0 | 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) |
20
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
141 echo "<table class=\"galleryTable ".$class."\">\n"; |
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
142 else |
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
143 echo "<div class=\"galleryTable ".$class."\">\n"; |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
144 |
0 | 145 for ($index = $start; $index < $end; $index++) |
146 { | |
147 $filename = &$galIndex[$index]; | |
148 $data = &$galEntries[$filename]; | |
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 && $n == 0) echo " <tr>\n"; |
0 | 151 |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
152 if ($galUseTables) |
20
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
153 echo " <td class=\"galleryEntry\" id=\"cd".$data["base"]."\">\n"; |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
154 else |
20
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
155 echo " <div class=\"galleryEntry\">\n"; |
0 | 156 |
157 if ($data["type"] == 0) | |
158 { | |
159 echo | |
24 | 160 " <div class=\"imageBox\"><a href=\"".mgGetURL($galPath, $filename)."\">". |
0 | 161 "<img src=\"".mgGetImageURL($galTNPath, $filename)."\" alt=\"". |
24 | 162 chentities($filename)."\"></a></div>\n". |
163 mgGetArr($data, "caption", " <div class=\"imageCaption\">%1</div>\n", "", "chentities"); | |
0 | 164 /* |
165 if ($mode == "") | |
166 { | |
167 echo | |
168 " <select class=\"dropdown\" id=\"dd".$data["base"]."\" name=\"dd".$data["base"]. | |
169 "\" onchange=\"galPhotoDataChanged('".$data["base"]."');\">\n"; | |
170 | |
171 foreach ($picChoices as $name => $value) | |
172 { | |
173 echo " <option value=\"$value\"".($value == $data["id"] ? " selected=\"selected\"" : "").">".chentities($name)."</option>\n"; | |
174 } | |
175 echo | |
176 " </select>\n"; | |
177 } | |
178 */ | |
179 } | |
180 else | |
181 { | |
17
3f7bc4202df3
Add new configuration setting 'cover_images' to disable/enable sub-album
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
182 $atmp = ($galUseCoverImages && isset($data["image"])) ? $galImageURL.mgCleanPath(TRUE, $galPath, $filename, $galTNPath, $data["image"]) : $galAlbumIcon; |
0 | 183 echo |
24 | 184 " <a href=\"".mgGetURL(mgCleanPath(TRUE, $galPath, $filename), FALSE)."\">". |
17
3f7bc4202df3
Add new configuration setting 'cover_images' to disable/enable sub-album
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
185 "<img class=\"albumIcon\" src=\"".$atmp."\" alt=\"".chentities($data["caption"])."\" />\n". |
24 | 186 " <div class=\"albumTitle\">".chentities($data["caption"])."</div></a>\n"; |
0 | 187 } |
188 | |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
189 if ($galUseTables) |
0 | 190 { |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
191 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
|
192 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
|
193 { |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
194 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
|
195 $n = 0; |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
196 } |
0 | 197 } |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
198 else |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
199 echo " </div>\n"; |
0 | 200 } |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
201 |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
202 if ($galUseTables) |
0 | 203 { |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
204 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
|
205 { |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
206 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
|
207 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
|
208 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
|
209 } |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
210 echo "</table>\n"; |
0 | 211 } |
20
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
212 else |
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
213 echo "</div>\n"; |
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
214 |
0 | 215 return $index; |
216 } | |
217 | |
218 | |
219 function mgTimeStr($str) | |
220 { | |
221 $tmp = date_create_from_format("Y:m:d H:i:s", $str); | |
34
e786771dfaa5
Add seconds to outputted timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents:
32
diff
changeset
|
222 return date_format($tmp, "d M Y (H:i:s)"); |
0 | 223 } |
224 | |
225 | |
226 function mgPrintPageInfoFooter() | |
227 { | |
228 if (($str = mgGetSetting("page_info")) !== FALSE) | |
229 echo "<div class=\"pageInfoFooter\">".$str."</div>"; | |
230 } | |
231 | |
232 | |
31
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
233 function mgGetBreadCrump($class, &$pdata) |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
234 { |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
235 return |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
236 "<a class=\"".$class."\" href=\"".mgGetURL($pdata["path"], FALSE)."\">". |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
237 chentities($pdata["caption"])."</a>"; |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
238 } |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
239 |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
240 |
0 | 241 function mgPrintBreadCrumbs($galData) |
242 { | |
243 $res = array(); | |
244 if ($galData["caption"]) | |
31
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
245 $res[] = mgGetBreadCrump("naviBreadCrumbCurr", $galData); |
0 | 246 |
247 $tmp = $galData; | |
248 while (isset($tmp["parent"])) | |
249 { | |
250 $pdata = $tmp["parent"]; | |
31
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
251 $res[] = mgGetBreadCrump("naviBreadCrumbItem", $pdata); |
0 | 252 $tmp = $tmp["parent"]; |
253 } | |
254 | |
255 if (count($res) > 1) | |
256 { | |
257 echo | |
258 "<div class=\"naviBreadCrumbs\">". | |
259 implode("<span class=\"naviBreadCrumbSep\"></span>", array_reverse($res)). | |
260 "</div>\n"; | |
261 } | |
262 } | |
263 | |
264 | |
265 // | |
266 // Get gallery settings | |
267 // | |
268 mgReadSettings(); | |
269 | |
270 $pageCSS = mgGetSetting("css"); | |
271 $pageCSSSelect = mgGetSetting("css_select"); | |
272 $galBasePath = mgGetSetting("base_path"); | |
273 $galBaseURL = mgGetSetting("base_url"); | |
274 $galImageURL = mgGetSetting("image_url", mgGetSetting("base_url")); | |
275 | |
17
3f7bc4202df3
Add new configuration setting 'cover_images' to disable/enable sub-album
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
276 $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
|
277 $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
|
278 |
0 | 279 $galAlbumIcon = mgGetSetting("album_icon"); |
280 $galCleanURLS = mgGetSetting("clean_urls"); | |
281 $galTNPath = mgGetSetting("tn_path"); | |
282 $galMedSuffix = mgGetSetting("med_suffix"); | |
283 $galTitlePrefix = mgGetSetting("title_prefix"); | |
284 $galTitleSep = mgGetSetting("title_sep"); | |
285 | |
286 $galMode = stGetRequestItem("mode", "view", TRUE); | |
287 $galPath = stGetRequestItem("path", ".", TRUE); | |
288 $galPageIndex = intval(stGetRequestItem("index", 0, TRUE)); | |
289 $galImage = stGetRequestItem("image", FALSE, TRUE); | |
290 | |
291 if (is_string($galImage)) | |
292 $galImage = basename($galImage); | |
293 | |
294 | |
295 // | |
296 // Attempt to read the data cache file | |
297 // | |
298 $filename = mgGetPath(mgCleanPath(TRUE, $galBasePath, $galPath), "cache_file"); | |
299 $filename2 = mgGetPath(mgCleanPath(FALSE, $galBasePath, $galPath), "cache_file"); | |
300 if ($filename == $filename2 && file_exists($filename) && ($fp = @fopen($filename, "rb")) !== FALSE) | |
301 { | |
302 if (flock($fp, LOCK_SH)) | |
303 { | |
304 require($filename); | |
305 flock($fp, LOCK_UN); | |
306 } | |
307 fclose($fp); | |
308 } | |
309 | |
310 | |
311 // If no data available, show an error page | |
312 if (!isset($galData) || !isset($galEntries) || | |
313 !isset($galAlbumsIndex) || !isset($galImagesIndex)) | |
314 { | |
315 cmPrintPageHeader(mgGetVal(array("title_prefix", "title_sep"), "%1%2")."ERROR!"); | |
316 | |
317 echo | |
318 "<h1>Gallery error</h1>\n". | |
319 "<p>Gallery path <b>".chentities($galPath)."</b> does not exist or is invalid.</p>\n"; | |
320 | |
12
79987aa7ee9a
Change some debugging (commented out).
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
321 //echo "<p>filename=: '".$filename."', X: galData=".intval(isset($galData)).", galEntries=".intval(isset($galEntries))."\n"; |
0 | 322 |
323 mgPrintPageInfoFooter(); | |
324 cmPrintPageFooter(TRUE); | |
325 exit; | |
326 } | |
327 | |
328 | |
329 // | |
330 // Print page header, etc. | |
331 // | |
332 if (($index = array_search($galImage, $galImagesIndex)) !== FALSE) | |
333 { | |
334 // | |
335 // Single image mode | |
336 // | |
337 $naviFlags = mgGetSetting("image_navigation"); | |
338 $data = $galEntries[$galImage]; | |
339 | |
340 $pageTitle = $galTitlePrefix.$galTitleSep.$galData["caption"]." - ".$galImage; | |
341 cmPrintPageHeader($pageTitle); | |
342 echo "<h1>".chentities($pageTitle)."</h1>\n"; | |
343 | |
344 if ($naviFlags & GNAV_BREADCRUMBS) | |
345 mgPrintBreadCrumbs($galData); | |
346 | |
347 if ($naviFlags & GNAV_TOP) | |
348 echo mgGetNaviControls($galImagesIndex, $index, $naviFlags); | |
349 | |
350 echo | |
351 "<div class=\"imageCBox\">\n". | |
352 mgGetNaviControlImageBox($galImagesIndex, $index, "prev", -1). | |
353 "<div class=\"imageBox\">\n". | |
354 "<a target=\"_blank\" href=\"".$galImageURL.$galPath."/".$galImage."\">". | |
355 "<img src=\"".mgGetImageURL($galTNPath, $data["base"].$galMedSuffix.$data["ext"])."\" alt=\"". | |
356 chentities($data["base"].$galMedSuffix.$data["ext"])."\"></a>\n". | |
357 "</div>\n". | |
358 mgGetNaviControlImageBox($galImagesIndex, $index, "next", 1). | |
359 "</div>\n". | |
360 "<div class=\"imageCaption\">".mgGetArr($data, "caption", "%1", "")."</div>\n"; | |
361 | |
362 $list = array( | |
363 mgGetArr($data, array("width", "height"), "<span class=\"infoDimensions\"><b>%1</b> x <b>%2</b> px</span>", NULL), | |
364 mgGetArr($data, "model", "<span class=\"infoModel\"><b>%1</b></span>", NULL), | |
365 mgGetArr($data, "fnumber", "<span class=\"infoFNumber\"><b>f/%1</b></span>", NULL), | |
366 mgGetArr($data, "exposure", "<span class=\"infoExposure\"><b>%1</b> sec</span>", NULL, NULL), | |
367 mgGetArr($data, "iso", "<span class=\"infoISO\">ISO <b>%1</b></span>", NULL), | |
29
8cf743c7ea23
Add focal length and lens model display.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
368 mgGetArr($data, "focallength", "<span class=\"infoFocalLength\">F-L <b>%1</b>mm</span>", NULL), |
8cf743c7ea23
Add focal length and lens model display.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
369 mgGetArr($data, "lensmodel", "<span class=\"infoLensModel\"><i>%1</i></span>", NULL), |
0 | 370 ); |
371 | |
372 echo | |
373 "<div class=\"infoBox\">\n". | |
374 mgGetArr($data, "datetime", "<span class=\"infoDateTime\">%1</span>", "", "mgTimeStr"). | |
375 implode(", ", array_filter($list, function($a) { return $a !== NULL; })). | |
376 "</div>\n"; | |
377 | |
378 if ($naviFlags & GNAV_BOTTOM) | |
379 echo mgGetNaviControls($galImagesIndex, $index, $naviFlags); | |
380 | |
381 // Javascript navigation | |
382 if ($naviFlags & GNAV_JAVASCRIPT) | |
383 { | |
384 $prevActive = mgGetNaviActive($galImagesIndex, $index, -1, $res, $prevURL, FALSE); | |
385 $nextActive = mgGetNaviActive($galImagesIndex, $index, 1, $res, $nextURL, FALSE); | |
386 echo | |
387 "<script type=\"text/javascript\">\n". | |
388 "var mgalPrevURL = \"".($prevActive ? $prevURL : "")."\";\n". | |
389 "var mgalNextURL = \"".($nextActive ? $nextURL : "")."\";\n". | |
390 "\n"; | |
391 ?> | |
392 function mgalNavigateTo(url) | |
393 { | |
394 if (url != "") | |
395 window.location = url; | |
396 } | |
397 | |
398 | |
399 function mgalProcessKeyPress(ev) | |
400 { | |
401 ev = ev || window.event; | |
402 var key = ev.keyCode ? ev.keyCode : ev.which; | |
403 switch (key) | |
404 { | |
405 case 37: | |
406 case 65: | |
407 // left | |
408 mgalNavigateTo(mgalPrevURL); | |
409 break; | |
410 | |
411 case 39: | |
412 case 68: | |
413 // right | |
414 mgalNavigateTo(mgalNextURL); | |
415 break; | |
416 } | |
417 } | |
418 | |
419 document.onkeypress = mgalProcessKeyPress; | |
420 <? | |
421 echo | |
422 "</script>\n"; | |
423 } | |
424 } | |
425 else | |
426 { | |
427 // | |
428 // Gallery mode | |
429 // | |
430 // - needs sub-modes / handling of order shit | |
431 // - Javascript stuff for picture data updates | |
432 // | |
433 $pageTitle = $galTitlePrefix.mgGetArr($galData, "caption", " - %1", "", "chentities"); | |
434 cmPrintPageHeader($pageTitle); | |
435 echo "<h1>".$pageTitle."</h1>\n"; | |
436 | |
437 $naviFlags = mgGetSetting("album_navigation"); | |
438 if ($naviFlags & GNAV_BREADCRUMBS) | |
439 mgPrintBreadCrumbs($galData); | |
440 | |
441 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
|
442 { |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
443 // 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
|
444 $baseURL = mgGetSetting("image_url"); |
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 $headerText = preg_replace_callback( |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
447 "@href\s*=\s*\"([^\"]+)\"@i", |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
448 function ($matches) use($galPath, $baseURL) |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
449 { |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
450 $mstmp = $matches[1]; |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
451 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
|
452 { |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
453 if ($mstmp[0] != "/") |
28
2d8112d6c3bc
Fix relative links re-parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
454 $mstmp = $baseURL."/".$galPath."/".str_replace("//", "/", $mstmp); |
13
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
455 } |
28
2d8112d6c3bc
Fix relative links re-parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
456 return "href=\"".$mstmp."\""; |
13
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
457 }, |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
458 $galData["header"]); |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
459 |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
460 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
|
461 } |
0 | 462 |
463 mgPrintTable("albumTable", $galEntries, $galAlbumsIndex, 0, FALSE); | |
464 mgPrintTable("imageTable", $galEntries, $galImagesIndex, 0, FALSE); | |
465 } | |
466 | |
467 mgPrintPageInfoFooter(); | |
468 cmPrintPageFooter(TRUE); | |
469 ?> |