Mercurial > hg > mgallery
annotate mgallery.php @ 65:7019d87bc479
Improve/fix language selection support to store language cookie better.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 14 Sep 2016 12:57:28 +0300 |
parents | 1c32ece9acde |
children | be68b2d06674 |
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 | |
48
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
9 $pageLang = "fi"; |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
10 $pageLanguages = |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
11 [ |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
12 "fi" => "Finnish", |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
13 "en" => "English", |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
14 ]; |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
15 |
0 | 16 |
17 // | |
18 // Various utility functions | |
19 // | |
38
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
20 function mgGetImageTitleStr($filename, &$data) |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
21 { |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
22 return |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
23 chentities($filename). |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
24 mgGetArr($data, "datetime", " - %1", "", "mgTimeStr"); |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
25 } |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
26 |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
27 |
0 | 28 function mgGetImageURL() |
29 { | |
30 global $galImageURL, $galPath; | |
5
1bf73b49fc91
Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
31 return str_replace("//", "/", $galImageURL.$galPath."/".implode("", func_get_args())); |
0 | 32 } |
33 | |
34 | |
35 function mgGetURL($path, $image, $entities = TRUE) | |
36 { | |
37 global $galBaseURL, $galCleanURLS; | |
38 $amp = $entities ? "&" : "&"; | |
39 | |
40 if ($galCleanURLS) | |
41 { | |
5
1bf73b49fc91
Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
42 $url = $galBaseURL.$path."/".($image !== FALSE ? $image : ""); |
0 | 43 } |
44 else | |
45 { | |
5
1bf73b49fc91
Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
46 $url = |
0 | 47 $galBaseURL.mgGetSetting("mgallery_php")."?path=". |
48 $path.($image !== FALSE ? $amp."image=".$image : ""); | |
49 } | |
5
1bf73b49fc91
Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
50 |
1bf73b49fc91
Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
51 return str_replace("//", "/", $url); |
0 | 52 } |
53 | |
54 | |
48
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
55 function mgGetLanguageSelector() |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
56 { |
65
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
57 global $pageLang, $pageLanguages, $galBaseURL; |
48
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
58 if (isset($pageLanguages) && count($pageLanguages) > 0) |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
59 { |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
60 $str = "<div id=\"languages\">"; |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
61 foreach ($pageLanguages as $id => $lang) |
65
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
62 $str .= "<a href=\"".$galBaseURL."?from=".urlencode($_SERVER["REQUEST_URI"])."&lang=".$id."\">".$lang."</a> "; |
48
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
63 return $str."</div>\n"; |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
64 } |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
65 else |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
66 return ""; |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
67 } |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
68 |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
69 |
0 | 70 function mgGetNaviActive(&$galIndex, $index, $delta, &$res, &$url, $entities) |
71 { | |
72 global $galPath; | |
73 $res = $index + $delta; | |
74 if ($res >= 0 && $res <= sizeof($galIndex) - 1) | |
75 { | |
76 $url = mgGetURL($galPath, $galIndex[$res], $entities); | |
77 return TRUE; | |
78 } | |
79 else | |
80 return FALSE; | |
81 } | |
82 | |
83 | |
84 function mgGetNaviControlImage(&$galIndex, $index, $class, $url) | |
85 { | |
86 global $galTNPath; | |
87 | |
88 $img = "<div class=\"imageCtrl ".$class."\">"; | |
89 | |
90 if ($url !== FALSE) | |
91 { | |
92 $img .= | |
93 "<a href=\"".$url."\"><img src=\"". | |
94 mgGetImageURL($galTNPath, $galIndex[$index]). | |
95 "\" alt=\"".$galIndex[$index]."\" /></a>"; | |
96 } | |
97 | |
98 return $img."</div>\n"; | |
99 } | |
100 | |
101 | |
102 function mgGetNaviControlImageBox(&$galIndex, $index, $class, $delta) | |
103 { | |
104 if (!mgGetNaviActive($galIndex, $index, $delta, $res, $url, TRUE)) | |
105 $url = FALSE; | |
106 | |
107 return mgGetNaviControlImage($galIndex, $res, $class, $url); | |
108 } | |
109 | |
110 | |
7
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
111 function mgGetControlText($id, $active, $url, $naviFlags) |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
112 { |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
113 if ($naviFlags & GNAV_TEXT) |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
114 { |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
115 $str = chentities(mgGetSetting("navi_ctrl_".$id)); |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
116 return |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
117 "<span class=\"naviControl ".$id."\">[". |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
118 ($active ? "<a href=\"".$url."\">".$str."</a>" : $str). |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
119 "]</span>"; |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
120 } |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
121 else |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
122 return ""; |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
123 } |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
124 |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
125 |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
126 function mgGetControl($id, &$galIndex, $index, $delta, $naviFlags) |
0 | 127 { |
128 $active = mgGetNaviActive($galIndex, $index, $delta, $res, $url, TRUE); | |
129 if ($active && ($naviFlags & GNAV_IMG)) | |
7
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
130 $img = mgGetNaviControlImage($galIndex, $res, $id, $url); |
0 | 131 else |
132 $img = ""; | |
133 | |
7
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
134 $text = mgGetControlText($id, $active, $url, $naviFlags); |
0 | 135 |
136 if ($delta < 0) | |
7
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
137 return $img.$text; |
0 | 138 else |
7
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
139 return $text.$img; |
0 | 140 } |
141 | |
142 | |
143 function mgGetNaviControls(&$galIndex, $index, $naviFlags) | |
144 { | |
145 global $galPath; | |
146 | |
147 return | |
148 "<div class=\"naviControls\">". | |
7
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
149 mgGetControl("prev", $galIndex, $index, -1, $naviFlags). |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
150 mgGetControlText("up", TRUE, mgGetURL($galPath, FALSE), $naviFlags). |
dec931d9e860
Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
151 mgGetControl("next", $galIndex, $index, 1, $naviFlags). |
0 | 152 "</div>\n"; |
153 } | |
154 | |
155 | |
156 function mgPrintTable($class, &$galEntries, &$galIndex, $start, $limit) | |
157 { | |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
158 global $galAlbumIcon, $galPath, $galTNPath, $galImageURL, $galUseCoverImages, $galUseTables; |
0 | 159 |
160 $galCount = count($galIndex); | |
161 if ($start >= $galCount) | |
162 return $start; | |
163 | |
164 $end = ($limit === FALSE) ? $galCount : $start + $limit; | |
165 if ($end > $galCount) $end = $galCount; | |
166 | |
167 $rowLimit = mgGetSetting("album_row_limit"); | |
168 $n = 0; | |
169 | |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
170 if ($galUseTables) |
20
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
171 echo "<table class=\"galleryTable ".$class."\">\n"; |
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
172 else |
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
173 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
|
174 |
0 | 175 for ($index = $start; $index < $end; $index++) |
176 { | |
177 $filename = &$galIndex[$index]; | |
178 $data = &$galEntries[$filename]; | |
179 | |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
180 if ($galUseTables && $n == 0) echo " <tr>\n"; |
0 | 181 |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
182 if ($galUseTables) |
20
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
183 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
|
184 else |
20
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
185 echo " <div class=\"galleryEntry\">\n"; |
0 | 186 |
187 if ($data["type"] == 0) | |
188 { | |
189 echo | |
38
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
190 " <div class=\"imageBox\" title=\"".mgGetImageTitleStr($filename, $data). |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
191 "\"><a href=\"".mgGetURL($galPath, $filename)."\">". |
0 | 192 "<img src=\"".mgGetImageURL($galTNPath, $filename)."\" alt=\"". |
24 | 193 chentities($filename)."\"></a></div>\n". |
194 mgGetArr($data, "caption", " <div class=\"imageCaption\">%1</div>\n", "", "chentities"); | |
0 | 195 /* |
196 if ($mode == "") | |
197 { | |
198 echo | |
199 " <select class=\"dropdown\" id=\"dd".$data["base"]."\" name=\"dd".$data["base"]. | |
200 "\" onchange=\"galPhotoDataChanged('".$data["base"]."');\">\n"; | |
201 | |
202 foreach ($picChoices as $name => $value) | |
203 { | |
204 echo " <option value=\"$value\"".($value == $data["id"] ? " selected=\"selected\"" : "").">".chentities($name)."</option>\n"; | |
205 } | |
206 echo | |
207 " </select>\n"; | |
208 } | |
209 */ | |
210 } | |
211 else | |
212 { | |
35
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
213 if ($galUseCoverImages && isset($data["image"])) |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
214 { |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
215 // Recursively determine the album cover image |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
216 $ptmp = [$galPath, $filename]; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
217 $curr = &$data; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
218 while (is_array($curr["image"])) |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
219 { |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
220 $curr = &$curr["image"]; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
221 $ptmp[] = $curr["base"]; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
222 } |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
223 |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
224 $ptmp[] = $galTNPath; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
225 $ptmp[] = $curr["image"]; |
39 | 226 |
35
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
227 $atmp = $galImageURL.implode("/", mgCleanPathArray(TRUE, 0, count($ptmp), $ptmp)); |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
228 } |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
229 else |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
230 // No album cover, use default |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
231 $atmp = $galAlbumIcon; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
232 |
0 | 233 echo |
24 | 234 " <a href=\"".mgGetURL(mgCleanPath(TRUE, $galPath, $filename), FALSE)."\">". |
47
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
235 "<img class=\"albumIcon\" src=\"".$atmp."\" alt=\"". |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
236 mgGetTrans($data["caption"], TRUE). |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
237 "\" />\n". |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
238 " <div class=\"albumTitle\">".mgGetTrans($data["caption"], TRUE)."</div></a>\n"; |
0 | 239 } |
240 | |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
241 if ($galUseTables) |
0 | 242 { |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
243 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
|
244 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
|
245 { |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
246 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
|
247 $n = 0; |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
248 } |
0 | 249 } |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
250 else |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
251 echo " </div>\n"; |
0 | 252 } |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
253 |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
254 if ($galUseTables) |
0 | 255 { |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
256 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
|
257 { |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
258 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
|
259 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
|
260 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
|
261 } |
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
262 echo "</table>\n"; |
0 | 263 } |
20
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
264 else |
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
265 echo "</div>\n"; |
12916fcdb8b8
Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
266 |
0 | 267 return $index; |
268 } | |
269 | |
270 | |
271 function mgTimeStr($str) | |
272 { | |
273 $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
|
274 return date_format($tmp, "d M Y (H:i:s)"); |
0 | 275 } |
276 | |
277 | |
278 function mgPrintPageInfoFooter() | |
279 { | |
280 if (($str = mgGetSetting("page_info")) !== FALSE) | |
281 echo "<div class=\"pageInfoFooter\">".$str."</div>"; | |
282 } | |
283 | |
284 | |
31
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
285 function mgGetBreadCrump($class, &$pdata) |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
286 { |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
287 return |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
288 "<a class=\"".$class."\" href=\"".mgGetURL($pdata["path"], FALSE)."\">". |
47
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
289 mgGetTrans($pdata["caption"], TRUE). |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
290 "</a>"; |
31
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
291 } |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
292 |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
293 |
0 | 294 function mgPrintBreadCrumbs($galData) |
295 { | |
63
1c32ece9acde
Some residual array() => [] conversions.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
296 $res = []; |
0 | 297 if ($galData["caption"]) |
31
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
298 $res[] = mgGetBreadCrump("naviBreadCrumbCurr", $galData); |
0 | 299 |
300 $tmp = $galData; | |
301 while (isset($tmp["parent"])) | |
302 { | |
303 $pdata = $tmp["parent"]; | |
31
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
304 $res[] = mgGetBreadCrump("naviBreadCrumbItem", $pdata); |
0 | 305 $tmp = $tmp["parent"]; |
306 } | |
307 | |
308 if (count($res) > 1) | |
309 { | |
310 echo | |
311 "<div class=\"naviBreadCrumbs\">". | |
312 implode("<span class=\"naviBreadCrumbSep\"></span>", array_reverse($res)). | |
313 "</div>\n"; | |
314 } | |
315 } | |
316 | |
317 | |
318 // | |
65
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
319 // Check language |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
320 // |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
321 if (($tmp = stGetRequestItem("lang", FALSE, TRUE)) !== FALSE) |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
322 { |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
323 $tmp = strtolower($tmp); |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
324 if (array_key_exists($tmp, $pageLanguages)) |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
325 { |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
326 $pageLang = $tmp; |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
327 setcookie("mglang", $tmp, time() + 365*24*60*60); // expire in a year |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
328 } |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
329 } |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
330 else |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
331 if (isset($_COOKIE["mglang"])) |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
332 { |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
333 $tmp = strtolower($_COOKIE["mglang"]); |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
334 if (array_key_exists($tmp, $pageLanguages)) |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
335 $pageLang = $tmp; |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
336 } |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
337 |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
338 |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
339 // |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
340 // Check for "from" redirection |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
341 // |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
342 if (($from = stGetRequestItem("from", FALSE, TRUE)) !== FALSE && |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
343 preg_match("@^[a-z0-9/_.]+\$@i", $from)) |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
344 { |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
345 header("Location: ".$from); |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
346 exit; |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
347 } |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
348 |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
349 |
7019d87bc479
Improve/fix language selection support to store language cookie better.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
350 // |
0 | 351 // Get gallery settings |
352 // | |
353 mgReadSettings(); | |
354 | |
355 $pageCSS = mgGetSetting("css"); | |
356 $pageCSSSelect = mgGetSetting("css_select"); | |
357 $galBasePath = mgGetSetting("base_path"); | |
358 $galBaseURL = mgGetSetting("base_url"); | |
359 $galImageURL = mgGetSetting("image_url", mgGetSetting("base_url")); | |
360 | |
17
3f7bc4202df3
Add new configuration setting 'cover_images' to disable/enable sub-album
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
361 $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
|
362 $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
|
363 |
0 | 364 $galAlbumIcon = mgGetSetting("album_icon"); |
365 $galCleanURLS = mgGetSetting("clean_urls"); | |
366 $galTNPath = mgGetSetting("tn_path"); | |
367 $galMedSuffix = mgGetSetting("med_suffix"); | |
368 $galTitlePrefix = mgGetSetting("title_prefix"); | |
369 $galTitleSep = mgGetSetting("title_sep"); | |
370 | |
371 $galMode = stGetRequestItem("mode", "view", TRUE); | |
372 $galPath = stGetRequestItem("path", ".", TRUE); | |
373 $galPageIndex = intval(stGetRequestItem("index", 0, TRUE)); | |
374 $galImage = stGetRequestItem("image", FALSE, TRUE); | |
375 | |
376 if (is_string($galImage)) | |
377 $galImage = basename($galImage); | |
378 | |
379 | |
380 // | |
381 // Attempt to read the data cache file | |
382 // | |
383 $filename = mgGetPath(mgCleanPath(TRUE, $galBasePath, $galPath), "cache_file"); | |
384 $filename2 = mgGetPath(mgCleanPath(FALSE, $galBasePath, $galPath), "cache_file"); | |
385 if ($filename == $filename2 && file_exists($filename) && ($fp = @fopen($filename, "rb")) !== FALSE) | |
386 { | |
387 if (flock($fp, LOCK_SH)) | |
388 { | |
389 require($filename); | |
390 flock($fp, LOCK_UN); | |
391 } | |
392 fclose($fp); | |
393 } | |
394 | |
395 | |
396 // If no data available, show an error page | |
397 if (!isset($galData) || !isset($galEntries) || | |
398 !isset($galAlbumsIndex) || !isset($galImagesIndex)) | |
399 { | |
63
1c32ece9acde
Some residual array() => [] conversions.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
400 cmPrintPageHeader(mgGetVal(["title_prefix", "title_sep"], "%1%2")."ERROR!"); |
0 | 401 |
402 echo | |
403 "<h1>Gallery error</h1>\n". | |
404 "<p>Gallery path <b>".chentities($galPath)."</b> does not exist or is invalid.</p>\n"; | |
405 | |
12
79987aa7ee9a
Change some debugging (commented out).
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
406 //echo "<p>filename=: '".$filename."', X: galData=".intval(isset($galData)).", galEntries=".intval(isset($galEntries))."\n"; |
0 | 407 |
408 mgPrintPageInfoFooter(); | |
409 cmPrintPageFooter(TRUE); | |
410 exit; | |
411 } | |
412 | |
413 | |
414 // | |
415 // Print page header, etc. | |
416 // | |
417 if (($index = array_search($galImage, $galImagesIndex)) !== FALSE) | |
418 { | |
419 // | |
420 // Single image mode | |
421 // | |
422 $naviFlags = mgGetSetting("image_navigation"); | |
423 $data = $galEntries[$galImage]; | |
424 | |
47
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
425 $pageTitle = $galTitlePrefix.$galTitleSep.mgGetTrans($galData["caption"])." - ".$galImage; |
0 | 426 cmPrintPageHeader($pageTitle); |
44
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
427 echo |
48
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
428 mgGetLanguageSelector(). |
44
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
429 "<div id=\"imageLarge\"><img src=\"". |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
430 $galImageURL.$galPath."/".$galImage."\" alt=\"". |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
431 chentities($data["base"].$galMedSuffix.$data["ext"])."\" /></div>\n". |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
432 "<h1>".chentities($pageTitle)."</h1>\n"; |
0 | 433 |
434 if ($naviFlags & GNAV_BREADCRUMBS) | |
435 mgPrintBreadCrumbs($galData); | |
436 | |
437 if ($naviFlags & GNAV_TOP) | |
438 echo mgGetNaviControls($galImagesIndex, $index, $naviFlags); | |
439 | |
440 echo | |
441 "<div class=\"imageCBox\">\n". | |
442 mgGetNaviControlImageBox($galImagesIndex, $index, "prev", -1). | |
443 "<div class=\"imageBox\">\n". | |
44
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
444 "<a id=\"imageLink\" target=\"_blank\" href=\"".$galImageURL.$galPath."/".$galImage."\">". |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
445 "<img id=\"imageImage\" src=\"".mgGetImageURL($galTNPath, $data["base"].$galMedSuffix.$data["ext"])."\" alt=\"". |
0 | 446 chentities($data["base"].$galMedSuffix.$data["ext"])."\"></a>\n". |
447 "</div>\n". | |
448 mgGetNaviControlImageBox($galImagesIndex, $index, "next", 1). | |
449 "</div>\n". | |
450 "<div class=\"imageCaption\">".mgGetArr($data, "caption", "%1", "")."</div>\n"; | |
451 | |
63
1c32ece9acde
Some residual array() => [] conversions.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
452 $list = [ |
1c32ece9acde
Some residual array() => [] conversions.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
453 mgGetArr($data, ["width", "height"], "<span class=\"infoDimensions\"><b>%1</b> x <b>%2</b> px</span>", NULL), |
0 | 454 mgGetArr($data, "model", "<span class=\"infoModel\"><b>%1</b></span>", NULL), |
455 mgGetArr($data, "fnumber", "<span class=\"infoFNumber\"><b>f/%1</b></span>", NULL), | |
456 mgGetArr($data, "exposure", "<span class=\"infoExposure\"><b>%1</b> sec</span>", NULL, NULL), | |
457 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
|
458 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
|
459 mgGetArr($data, "lensmodel", "<span class=\"infoLensModel\"><i>%1</i></span>", NULL), |
63
1c32ece9acde
Some residual array() => [] conversions.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
460 ]; |
0 | 461 |
462 echo | |
463 "<div class=\"infoBox\">\n". | |
464 mgGetArr($data, "datetime", "<span class=\"infoDateTime\">%1</span>", "", "mgTimeStr"). | |
465 implode(", ", array_filter($list, function($a) { return $a !== NULL; })). | |
466 "</div>\n"; | |
467 | |
468 if ($naviFlags & GNAV_BOTTOM) | |
469 echo mgGetNaviControls($galImagesIndex, $index, $naviFlags); | |
470 | |
471 // Javascript navigation | |
472 if ($naviFlags & GNAV_JAVASCRIPT) | |
473 { | |
474 $prevActive = mgGetNaviActive($galImagesIndex, $index, -1, $res, $prevURL, FALSE); | |
475 $nextActive = mgGetNaviActive($galImagesIndex, $index, 1, $res, $nextURL, FALSE); | |
476 echo | |
477 "<script type=\"text/javascript\">\n". | |
478 "var mgalPrevURL = \"".($prevActive ? $prevURL : "")."\";\n". | |
479 "var mgalNextURL = \"".($nextActive ? $nextURL : "")."\";\n". | |
44
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
480 "var mgalExpanded = false;\n". |
0 | 481 "\n"; |
482 ?> | |
44
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
483 function mgalExpandClose(force) |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
484 { |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
485 mgalExpanded = !mgalExpanded; |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
486 if (!force) |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
487 mgalExpanded = false; |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
488 |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
489 var mlink = document.getElementById("imageLink"); |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
490 var mlarge = document.getElementById("imageLarge"); |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
491 if (mlink && mlarge) |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
492 { |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
493 mlink.style.visibility = mgalExpanded ? "hidden" : "visible"; |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
494 mlarge.style.display = mgalExpanded ? "block" : "none"; |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
495 } |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
496 return false; |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
497 } |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
498 |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
499 |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
500 function mgalMouseExpandClose(event, force) |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
501 { |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
502 if (!event.ctrlKey) |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
503 return mgalExpandClose(force); |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
504 else |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
505 return true; |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
506 } |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
507 |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
508 |
0 | 509 function mgalNavigateTo(url) |
510 { | |
43 | 511 if (url != "") |
512 window.location = url; | |
0 | 513 } |
514 | |
515 | |
516 function mgalProcessKeyPress(ev) | |
517 { | |
43 | 518 ev = ev || window.event; |
519 var key = ev.keyCode ? ev.keyCode : ev.which; | |
520 switch (key) | |
521 { | |
522 case 37: | |
523 case 65: | |
44
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
524 case 52: |
43 | 525 // left |
526 mgalNavigateTo(mgalPrevURL); | |
527 break; | |
0 | 528 |
43 | 529 case 39: |
530 case 68: | |
44
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
531 case 54: |
43 | 532 // right |
533 mgalNavigateTo(mgalNextURL); | |
534 break; | |
44
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
535 |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
536 case 13: |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
537 case 48: |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
538 mgalExpandClose(true); |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
539 break; |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
540 |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
541 case 27: |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
542 mgalExpandClose(false); |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
543 break; |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
544 |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
545 default: |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
546 return true; |
43 | 547 } |
44
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
548 |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
549 ev.preventDefault(); |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
550 return false; |
0 | 551 } |
552 | |
44
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
553 |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
554 document.getElementById("imageLarge").onclick = function(event) { return mgalMouseExpandClose(event, false); } |
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
555 document.getElementById("imageLink").onclick = function(event) { return mgalMouseExpandClose(event, true); } |
0 | 556 document.onkeypress = mgalProcessKeyPress; |
44
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
557 |
0 | 558 <? |
559 echo | |
560 "</script>\n"; | |
561 } | |
562 } | |
563 else | |
564 { | |
565 // | |
566 // Gallery mode | |
567 // | |
568 // - needs sub-modes / handling of order shit | |
569 // - Javascript stuff for picture data updates | |
570 // | |
571 $pageTitle = $galTitlePrefix.mgGetArr($galData, "caption", " - %1", "", "chentities"); | |
572 cmPrintPageHeader($pageTitle); | |
48
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
573 echo |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
574 mgGetLanguageSelector(). |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
575 "<h1>".$pageTitle."</h1>\n"; |
0 | 576 |
577 $naviFlags = mgGetSetting("album_navigation"); | |
578 if ($naviFlags & GNAV_BREADCRUMBS) | |
579 mgPrintBreadCrumbs($galData); | |
580 | |
47
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
581 if (isset($galData["header"]) && strlen($gheader = mgGetTrans($galData["header"])) > 0) |
13
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
582 { |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
583 // 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
|
584 $baseURL = mgGetSetting("image_url"); |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
585 |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
586 $headerText = preg_replace_callback( |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
587 "@href\s*=\s*\"([^\"]+)\"@i", |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
588 function ($matches) use($galPath, $baseURL) |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
589 { |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
590 $mstmp = $matches[1]; |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
591 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
|
592 { |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
593 if ($mstmp[0] != "/") |
28
2d8112d6c3bc
Fix relative links re-parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
594 $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
|
595 } |
28
2d8112d6c3bc
Fix relative links re-parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
596 return "href=\"".$mstmp."\""; |
13
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
597 }, |
47
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
598 $gheader); |
13
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
599 |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
600 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
|
601 } |
0 | 602 |
603 mgPrintTable("albumTable", $galEntries, $galAlbumsIndex, 0, FALSE); | |
604 mgPrintTable("imageTable", $galEntries, $galImagesIndex, 0, FALSE); | |
605 } | |
606 | |
607 mgPrintPageInfoFooter(); | |
608 cmPrintPageFooter(TRUE); | |
609 ?> |