Mercurial > hg > mgallery
annotate mgallery.php @ 348:596196f2b0c5 default tip
Improve relative URL translation in header text blobs.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 20 Dec 2023 09:17:55 +0200 |
parents | 7da360685721 |
children |
rev | line source |
---|---|
0 | 1 <?php |
2 // | |
3 // Yet Another Image Gallery | |
69
7777887bc515
Update header/copyright blurbs.
Matti Hamalainen <ccr@tnsp.org>
parents:
68
diff
changeset
|
4 // -- Main PHP file |
7777887bc515
Update header/copyright blurbs.
Matti Hamalainen <ccr@tnsp.org>
parents:
68
diff
changeset
|
5 // Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org> |
345 | 6 // (C) Copyright 2015-2023 Tecnic Software productions (TNSP) |
0 | 7 // |
8 require "mgallery.inc.php"; | |
9 | |
48
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
10 $pageLang = "fi"; |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
11 $pageLanguages = |
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
12 [ |
333 | 13 "fi" => "FI", |
14 "en" => "EN", | |
92
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
15 ]; |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
16 |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
17 |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
18 $pageTranslations = |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
19 [ |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
20 "gallery_error" => [ |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
21 "fi" => "Tapahtui virhe", |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
22 "en" => "An error occured", |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
23 ], |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
24 |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
25 "invalid_gallery_path" => [ |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
26 "fi" => "Gallerian tiedostopolkua <b>%1</b> ei ole olemassa.", |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
27 "en" => "Gallery path <b>%1</b> does not exist or is invalid.", |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
28 ], |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
29 |
93 | 30 "view_best_quality" => [ |
163
59b06be3f355
Improve one message and translation.
Matti Hamalainen <ccr@tnsp.org>
parents:
161
diff
changeset
|
31 "fi" => "Näytä paremmalla laadulla", |
59b06be3f355
Improve one message and translation.
Matti Hamalainen <ccr@tnsp.org>
parents:
161
diff
changeset
|
32 "en" => "View better quality version", |
92
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
33 ], |
126
e14605c7aea0
Add translations for image/sub-album counts.
Matti Hamalainen <ccr@tnsp.org>
parents:
125
diff
changeset
|
34 |
e14605c7aea0
Add translations for image/sub-album counts.
Matti Hamalainen <ccr@tnsp.org>
parents:
125
diff
changeset
|
35 "gallery_nimages" => [ |
e14605c7aea0
Add translations for image/sub-album counts.
Matti Hamalainen <ccr@tnsp.org>
parents:
125
diff
changeset
|
36 "fi" => "kuvaa", |
e14605c7aea0
Add translations for image/sub-album counts.
Matti Hamalainen <ccr@tnsp.org>
parents:
125
diff
changeset
|
37 "en" => "images", |
e14605c7aea0
Add translations for image/sub-album counts.
Matti Hamalainen <ccr@tnsp.org>
parents:
125
diff
changeset
|
38 ], |
e14605c7aea0
Add translations for image/sub-album counts.
Matti Hamalainen <ccr@tnsp.org>
parents:
125
diff
changeset
|
39 |
e14605c7aea0
Add translations for image/sub-album counts.
Matti Hamalainen <ccr@tnsp.org>
parents:
125
diff
changeset
|
40 "gallery_nsubalbums" => [ |
e14605c7aea0
Add translations for image/sub-album counts.
Matti Hamalainen <ccr@tnsp.org>
parents:
125
diff
changeset
|
41 "fi" => "albumia", |
e14605c7aea0
Add translations for image/sub-album counts.
Matti Hamalainen <ccr@tnsp.org>
parents:
125
diff
changeset
|
42 "en" => "albums", |
e14605c7aea0
Add translations for image/sub-album counts.
Matti Hamalainen <ccr@tnsp.org>
parents:
125
diff
changeset
|
43 ], |
193
96f5cdc71af5
Add translatable titles to navigation button elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
44 |
96f5cdc71af5
Add translatable titles to navigation button elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
45 "page_info_button_title" => [ |
96f5cdc71af5
Add translatable titles to navigation button elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
46 "fi" => "Näytä gallerian navigointi.", |
96f5cdc71af5
Add translatable titles to navigation button elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
47 "en" => "Show gallery navigation.", |
96f5cdc71af5
Add translatable titles to navigation button elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
48 ], |
96f5cdc71af5
Add translatable titles to navigation button elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
49 |
96f5cdc71af5
Add translatable titles to navigation button elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
50 "page_up_navi_button_title" => [ |
202
c8b69b6bb692
Improve button descriptions.
Matti Hamalainen <ccr@tnsp.org>
parents:
200
diff
changeset
|
51 "fi" => "Takaisin galleriasivulle.", |
c8b69b6bb692
Improve button descriptions.
Matti Hamalainen <ccr@tnsp.org>
parents:
200
diff
changeset
|
52 "en" => "Back to gallery page.", |
193
96f5cdc71af5
Add translatable titles to navigation button elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
53 ], |
347
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
54 |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
55 "image_keywords_prefix" => [ |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
56 "fi" => "Avainsanat: ", |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
57 "en" => "Keywords: ", |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
58 ], |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
59 |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
60 "image_keywords_suffix" => [ |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
61 "fi" => "", |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
62 "en" => "", |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
63 ], |
48
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 |
0 | 66 |
67 // | |
68 // Various utility functions | |
69 // | |
89
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
70 function mgSetCookie($name, $value) |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
71 { |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
72 global $galBaseURL; |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
73 setcookie($name, $value, time() + 365*24*60*60, $galBaseURL); // expire in a year |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
74 } |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
75 |
92
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
76 |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
77 function mgQM($msg) |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
78 { |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
79 global $pageTranslations, $pageLang; |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
80 |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
81 if (isset($pageTranslations[$msg]) && isset($pageTranslations[$msg][$pageLang])) |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
82 $str = $pageTranslations[$msg][$pageLang]; |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
83 else |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
84 $str = $msg; |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
85 |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
86 foreach (func_get_args() as $argn => $argv) |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
87 $str = preg_replace("/\%".$argn."/", $argv, $str); |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
88 return $str; |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
89 } |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
90 |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
91 |
68
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
92 function mgTrimIfString($val) |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
93 { |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
94 if (is_string($val)) |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
95 return trim($val); |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
96 else |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
97 return $val; |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
98 } |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
99 |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
100 |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
101 function mgGetRequestItem($name, $default = "", $allowGet = FALSE) |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
102 { |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
103 if ($allowGet) |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
104 return isset($_REQUEST[$name]) ? mgTrimIfString($_REQUEST[$name]) : $default; |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
105 else |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
106 return isset($_POST[$name]) ? mgTrimIfString($_POST[$name]) : $default; |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
107 } |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
108 |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
109 |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
110 function chentities($str) |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
111 { |
240
dee1a11e71e9
Use htmlspecialchars() instead of htmlentities().
Matti Hamalainen <ccr@tnsp.org>
parents:
239
diff
changeset
|
112 return htmlspecialchars($str, ENT_NOQUOTES, "UTF-8"); |
68
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
113 } |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
114 |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
115 |
200
39f50d08ec50
Fix quoting of image element alt texts.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
116 function dhentities($str) |
39f50d08ec50
Fix quoting of image element alt texts.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
117 { |
240
dee1a11e71e9
Use htmlspecialchars() instead of htmlentities().
Matti Hamalainen <ccr@tnsp.org>
parents:
239
diff
changeset
|
118 return htmlspecialchars($str, ENT_COMPAT, "UTF-8"); |
200
39f50d08ec50
Fix quoting of image element alt texts.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
119 } |
39f50d08ec50
Fix quoting of image element alt texts.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
120 |
39f50d08ec50
Fix quoting of image element alt texts.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
121 |
232
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
122 function mgGetTrans($val, $filter = NULL) |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
123 { |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
124 global $pageLang; |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
125 |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
126 if (is_array($val)) |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
127 $str = array_key_exists($pageLang, $val) ? $val[$pageLang] : reset($val); |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
128 else |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
129 $str = $val; |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
130 |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
131 if (is_callable($filter)) |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
132 return call_user_func($filter, $str); |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
133 else |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
134 return $str; |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
135 } |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
136 |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
137 |
191
11aae39833cb
Add mgMangleURI() for optionally adding random SHA hash to CSS and javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
138 function mgMangleURI($filename) |
11aae39833cb
Add mgMangleURI() for optionally adding random SHA hash to CSS and javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
139 { |
274
b1d004a6d3f1
Remove obsolete debug setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
272
diff
changeset
|
140 global $mgalDebug; |
b1d004a6d3f1
Remove obsolete debug setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
272
diff
changeset
|
141 return $filename.($mgalDebug ? "?".sha1(time()) : ""); |
191
11aae39833cb
Add mgMangleURI() for optionally adding random SHA hash to CSS and javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
142 } |
11aae39833cb
Add mgMangleURI() for optionally adding random SHA hash to CSS and javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
143 |
11aae39833cb
Add mgMangleURI() for optionally adding random SHA hash to CSS and javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
144 |
167 | 145 function mgGetCSSLine($filename, $media = FALSE) |
68
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
146 { |
167 | 147 return |
191
11aae39833cb
Add mgMangleURI() for optionally adding random SHA hash to CSS and javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
148 " <link rel=\"stylesheet\" href=\"".mgMangleURI($filename). |
68
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
149 "\" type=\"text/css\" ".($media !== FALSE ? "media=\"".$media."\"": "")." />\n"; |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
150 } |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
151 |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
152 |
322
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
153 function mgGetJSLine($filename) |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
154 { |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
155 return |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
156 " <script src=\"".mgMangleURI($filename)."\"></script>\n"; |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
157 } |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
158 |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
159 |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
160 function mgIncludeUrchin($filename) |
68
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
161 { |
322
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
162 if (file_exists($filename)) |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
163 require_once $filename; |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
164 } |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
165 |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
166 |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
167 function mgPrintPageHeader($pageTitle, $pageDivID) |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
168 { |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
169 global $pageCSS, $pageCharset, $pageUrchin, $pageJS, $pageLang; |
68
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
170 |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
171 echo |
167 | 172 "<!DOCTYPE html>\n". |
238
80cbbdc3f14d
Add lang="xx" attribute to HTML tag.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
173 "<html lang=\"".$pageLang."\">\n". |
167 | 174 "<head>\n". |
175 " <meta charset=\"".$pageCharset."\">\n". | |
231
2731d2d8400e
Set meta viewport tag and initial scale, and try to "fix" things for some
Matti Hamalainen <ccr@tnsp.org>
parents:
222
diff
changeset
|
176 // Setting the viewport makes things break especially with the |
2731d2d8400e
Set meta viewport tag and initial scale, and try to "fix" things for some
Matti Hamalainen <ccr@tnsp.org>
parents:
222
diff
changeset
|
177 // text-size-adjust CSS settings... so we don't use it. |
322
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
178 // XXX: We do now. For now. |
231
2731d2d8400e
Set meta viewport tag and initial scale, and try to "fix" things for some
Matti Hamalainen <ccr@tnsp.org>
parents:
222
diff
changeset
|
179 " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n". |
167 | 180 " <title>".strip_tags($pageTitle)."</title>\n". |
323
23625c53e62d
Fix CSS/JS config item array handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
322
diff
changeset
|
181 (is_array($pageJS) ? implode("", array_map('mgGetJSLine', $pageJS)) : mgGetJSLine($pageJS)). |
23625c53e62d
Fix CSS/JS config item array handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
322
diff
changeset
|
182 (is_array($pageCSS) ? implode("", array_map('mgGetCSSLine', $pageCSS)) : mgGetCSSLine($pageCSS, FALSE)). |
167 | 183 "</head>\n". |
184 "<body>\n"; | |
68
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
185 |
322
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
186 if ($pageUrchin !== NULL) |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
187 { |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
188 if (is_array($pageUrchin)) |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
189 { |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
190 foreach ($pageUrchin as $filename) |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
191 mgIncludeUrchin($filename); |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
192 } |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
193 else |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
194 mgIncludeUrchin($pageUrchin); |
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
195 } |
68
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
196 |
107
71de97240799
Add support for urchin file.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
197 echo |
322
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
198 "<div id=\"".$pageDivID."\">\n"; |
68
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
199 } |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
200 |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
201 |
101
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
202 function mgPrintPageFooter() |
68
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
203 { |
190
718f4c504662
Remove function that was used only once, merge it to parent.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
204 if (($str = mgGetSetting("page_info")) !== FALSE) |
192 | 205 echo "<div id=\"pageInfoFooter\">".$str."</div>"; |
190
718f4c504662
Remove function that was used only once, merge it to parent.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
206 |
101
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
207 echo |
192 | 208 "\n</div>\n</body>\n</html>\n"; |
68
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
209 } |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
210 |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
211 |
348
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
212 function mgTranslateRelativeURLs($text, $path, $base) |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
213 { |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
214 // Translate / transform relative href="" URLs in given text |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
215 // XXX TODO: Perhaps use regexp backreferences instead of loop |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
216 $quoteList = ["'", "\""]; |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
217 foreach ($quoteList as $quote) |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
218 { |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
219 $text = preg_replace_callback( |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
220 "@href\s*=\s*".$quote."([^\"]+)".$quote."@i", |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
221 function ($matches) use($path, $base) |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
222 { |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
223 $mstmp = $matches[1]; |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
224 if (preg_match("@^[a-z]+://@i", $mstmp) === 0) |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
225 { |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
226 if ($mstmp[0] != "/") |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
227 $mstmp = $base."/".$path."/".str_replace("//", "/", $mstmp); |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
228 } |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
229 return "href=\"".$mstmp."\""; |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
230 }, $text); |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
231 } |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
232 return $text; |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
233 } |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
234 |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
235 |
302
f8d812d3194f
Swap argument order of mgGetImageTitleStr().
Matti Hamalainen <ccr@tnsp.org>
parents:
297
diff
changeset
|
236 function mgGetImageTitleStr(&$data, $filename) |
38
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
237 { |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
238 return |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
239 chentities($filename). |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
240 mgGetArr($data, "datetime", " - %1", "", "mgTimeStr"); |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
241 } |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
242 |
3f16beb79f9e
Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
243 |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
244 function mgGetImageURL($galPath, $fpath, $filename, $ffmt) |
0 | 245 { |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
246 global $galImageURL; |
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
247 return mgCleanPathStr($galImageURL.$galPath."/".$fpath.$filename.".".$ffmt); |
0 | 248 } |
249 | |
250 | |
251 function mgGetURL($path, $image, $entities = TRUE) | |
252 { | |
253 global $galBaseURL, $galCleanURLS; | |
254 $amp = $entities ? "&" : "&"; | |
255 | |
256 if ($galCleanURLS) | |
257 { | |
5
1bf73b49fc91
Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
258 $url = $galBaseURL.$path."/".($image !== FALSE ? $image : ""); |
0 | 259 } |
260 else | |
261 { | |
5
1bf73b49fc91
Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
262 $url = |
0 | 263 $galBaseURL.mgGetSetting("mgallery_php")."?path=". |
264 $path.($image !== FALSE ? $amp."image=".$image : ""); | |
265 } | |
5
1bf73b49fc91
Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
266 |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
267 return mgCleanPathStr($url); |
0 | 268 } |
269 | |
270 | |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
271 function mgGetNaviActive($galPath, &$galIndex, $index, $delta, &$res, $entities) |
0 | 272 { |
273 $res = $index + $delta; | |
252
f85870271f51
Simplify mgGetNaviActive() a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
248
diff
changeset
|
274 |
0 | 275 if ($res >= 0 && $res <= sizeof($galIndex) - 1) |
252
f85870271f51
Simplify mgGetNaviActive() a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
248
diff
changeset
|
276 return mgGetURL($galPath, $galIndex[$res], $entities); |
0 | 277 else |
278 return FALSE; | |
279 } | |
280 | |
281 | |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
282 function mgGetNaviControlImage($galPath, &$galIndex, &$galEntries, $index, $class, $url) |
0 | 283 { |
253
5b41efcec87d
More work on webp/etc support implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
284 global $galTNPath, $galTNFormat; |
0 | 285 |
286 if ($url !== FALSE) | |
287 { | |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
288 $imgName = $galIndex[$index]; |
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
289 $imgEntry = $galEntries[$imgName]; |
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
290 $imgPath = isset($imgEntry["path"]) ? $imgEntry["path"] : $galPath; |
75
441d5338960e
Image control not needed when prev/next image does not exist.
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
291 return |
441d5338960e
Image control not needed when prev/next image does not exist.
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
292 "<div class=\"imageCtrl ".$class."\">". |
441d5338960e
Image control not needed when prev/next image does not exist.
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
293 "<a href=\"".$url."\"><img src=\"". |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
294 mgGetImageURL($imgPath, $galTNPath, $imgName, $galTNFormat). |
84 | 295 "\" alt=\"".$galIndex[$index]."\" /></a></div>"; |
0 | 296 } |
75
441d5338960e
Image control not needed when prev/next image does not exist.
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
297 else |
441d5338960e
Image control not needed when prev/next image does not exist.
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
298 return ""; |
0 | 299 } |
300 | |
301 | |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
302 function mgGetNaviControlImageBox($galPath, &$galIndex, &$galEntries, $index, $class, $delta) |
0 | 303 { |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
304 $url = mgGetNaviActive($galPath, $galIndex, $index, $delta, $res, TRUE); |
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
305 return mgGetNaviControlImage($galPath, $galIndex, $galEntries, $res, $class, $url); |
0 | 306 } |
307 | |
308 | |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
309 function mgGetNaviControlImageBoxJS($galPath, &$galIndex, &$galEntries, $index, $class, $delta) |
86
fd08e061413b
Use JavaScript to generate the "shadow"/bottom navigation elements in the
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
310 { |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
311 $str = mgGetNaviControlImageBox($galPath, $galIndex, $galEntries, $index, $class, $delta); |
115 | 312 |
313 if ($str != "") | |
150 | 314 return |
248
2656b64c4c04
Remove type="text/javascript" from script tags.
Matti Hamalainen <ccr@tnsp.org>
parents:
247
diff
changeset
|
315 "<script>". |
115 | 316 "document.write(\"".str_replace("\"", "\\\"", $str)."\");". |
86
fd08e061413b
Use JavaScript to generate the "shadow"/bottom navigation elements in the
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
317 "</script>"; |
115 | 318 else |
319 return ""; | |
86
fd08e061413b
Use JavaScript to generate the "shadow"/bottom navigation elements in the
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
320 } |
fd08e061413b
Use JavaScript to generate the "shadow"/bottom navigation elements in the
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
321 |
fd08e061413b
Use JavaScript to generate the "shadow"/bottom navigation elements in the
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
322 |
347
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
323 function mgGetImageKeywords(&$galData, &$data, $fmt1, $fmt2) |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
324 { |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
325 global $galShowKeywords; |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
326 $showKeywords = isset($galData["show_keywords"]) ? $galData["show_keywords"] : $galShowKeywords; |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
327 |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
328 if (is_array($showKeywords) && isset($data["keywords"]) && is_array($data["keywords"])) |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
329 { |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
330 if (array_intersect($showKeywords, ["*", "all"])) |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
331 $tmp = $data["keywords"]; |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
332 else |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
333 $tmp = array_intersect($showKeywords, $data["keywords"]); |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
334 |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
335 if (count($tmp) > 0) |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
336 return $fmt1.implode(", ", array_map("chentities", $tmp)).$fmt2; |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
337 } |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
338 return ""; |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
339 } |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
340 |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
341 |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
342 function mgPrintTable($class, $galData, $galPath, &$galEntries, &$galIndex, $start, $limit) |
0 | 343 { |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
344 global $galAlbumIcon, $galTNPath, $galTNFormat, |
253
5b41efcec87d
More work on webp/etc support implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
345 $galImageURL, $galUseCoverImages; |
0 | 346 |
347 $galCount = count($galIndex); | |
348 if ($start >= $galCount) | |
349 return $start; | |
350 | |
351 $end = ($limit === FALSE) ? $galCount : $start + $limit; | |
352 if ($end > $galCount) $end = $galCount; | |
353 | |
235
028291a78acb
Get rid of the "use tables" option.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
354 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
|
355 |
0 | 356 for ($index = $start; $index < $end; $index++) |
357 { | |
358 $filename = &$galIndex[$index]; | |
359 $data = &$galEntries[$filename]; | |
360 | |
235
028291a78acb
Get rid of the "use tables" option.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
361 echo " <div class=\"galleryEntry\">\n"; |
0 | 362 |
363 if ($data["type"] == 0) | |
364 { | |
365 echo | |
302
f8d812d3194f
Swap argument order of mgGetImageTitleStr().
Matti Hamalainen <ccr@tnsp.org>
parents:
297
diff
changeset
|
366 " <div class=\"imageBox\" title=\"".mgGetImageTitleStr($data, $filename). |
185
cb7019690a73
Separate medium image and thumbnail directories / handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
367 "\"><a href=\"".mgGetURL($galPath, $filename)."\"><img src=\"". |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
368 mgGetImageURL(isset($data["path"]) ? $data["path"] : $galPath, $galTNPath, $filename, $galTNFormat). |
200
39f50d08ec50
Fix quoting of image element alt texts.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
369 "\" alt=\"".dhentities($filename)."\"></a></div>\n". |
347
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
370 mgGetArr($data, "caption", " <div class=\"imageCaption\">%1</div>\n", "", "chentities"). |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
371 mgGetImageKeywords($galData, $data, " <div class=\"imageKeywords\">(", ")</div>\n"); |
0 | 372 /* |
373 if ($mode == "") | |
374 { | |
375 echo | |
376 " <select class=\"dropdown\" id=\"dd".$data["base"]."\" name=\"dd".$data["base"]. | |
270 | 377 "\" onchange=\"mgalPhotoDataChanged('".$data["base"]."');\">\n"; |
0 | 378 |
379 foreach ($picChoices as $name => $value) | |
380 { | |
381 echo " <option value=\"$value\"".($value == $data["id"] ? " selected=\"selected\"" : "").">".chentities($name)."</option>\n"; | |
382 } | |
383 echo | |
384 " </select>\n"; | |
385 } | |
386 */ | |
387 } | |
388 else | |
389 { | |
35
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
390 if ($galUseCoverImages && isset($data["image"])) |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
391 { |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
392 // Recursively determine the album cover image |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
393 $ptmp = [$galPath, $filename]; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
394 $curr = &$data; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
395 while (is_array($curr["image"])) |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
396 { |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
397 $curr = &$curr["image"]; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
398 $ptmp[] = $curr["base"]; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
399 } |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
400 |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
401 $ptmp[] = $galTNPath; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
402 $ptmp[] = $curr["image"]; |
39 | 403 |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
404 $atmp = mgCleanPathStr($galImageURL.implode("/", mgCleanPathArray(TRUE, 0, count($ptmp), $ptmp)).".".$galTNFormat); |
35
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
405 } |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
406 else |
288 | 407 // No album cover, use default |
35
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
408 $atmp = $galAlbumIcon; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
409 |
0 | 410 echo |
232
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
411 " <a href=\"".mgGetURL(mgCleanPath(TRUE, $galPath, $filename), FALSE)."\">". |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
412 "<img class=\"albumIcon\" src=\"".$atmp."\" alt=\"". |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
413 mgGetTrans($data["caption"], "dhentities"). |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
414 "\" />\n". |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
415 " <div class=\"albumTitle\">". |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
416 mgGetTrans($data["caption"], "chentities"). |
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
417 "</div></a>\n"; |
0 | 418 } |
419 | |
235
028291a78acb
Get rid of the "use tables" option.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
420 echo " </div>\n"; |
0 | 421 } |
19
59075f5e7a62
Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
422 |
235
028291a78acb
Get rid of the "use tables" option.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
423 echo "</div>\n"; |
0 | 424 return $index; |
425 } | |
426 | |
427 | |
124
eac2cf04261a
Change how date timestamps are stored and handled. This breaks cache file
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
428 function mgTimeStr($stamp) |
0 | 429 { |
245
8ddf84b459d3
Show timestamps in localized form.
Matti Hamalainen <ccr@tnsp.org>
parents:
243
diff
changeset
|
430 global $pageLang, $pageCharset; |
8ddf84b459d3
Show timestamps in localized form.
Matti Hamalainen <ccr@tnsp.org>
parents:
243
diff
changeset
|
431 $pageLocale = strtolower($pageLang)."_".strtoupper($pageLang).".".$pageCharset; |
8ddf84b459d3
Show timestamps in localized form.
Matti Hamalainen <ccr@tnsp.org>
parents:
243
diff
changeset
|
432 setlocale(LC_TIME, $pageLocale); |
287
290a42c52e35
Use instanceOf instead of is_object().
Matti Hamalainen <ccr@tnsp.org>
parents:
285
diff
changeset
|
433 return strftime("%d %b %Y (%H:%M:%S)", ($stamp instanceOf DateTime) ? $stamp->getTimestamp() : $stamp); |
0 | 434 } |
435 | |
436 | |
78
b7f2e643279f
Add file size to information shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
437 function mgFileSize($size) |
b7f2e643279f
Add file size to information shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
438 { |
b7f2e643279f
Add file size to information shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
439 foreach ([1024*1024 => "MiB", 1024 => "kiB"] as $mdiv => $mpost) |
b7f2e643279f
Add file size to information shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
440 { |
b7f2e643279f
Add file size to information shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
441 if ($size > $mdiv) |
b7f2e643279f
Add file size to information shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
442 return sprintf("%1.2f %s", $size / $mdiv, $mpost); |
b7f2e643279f
Add file size to information shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
443 } |
b7f2e643279f
Add file size to information shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
444 return sprintf("%d bytes", $size); |
b7f2e643279f
Add file size to information shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
445 } |
b7f2e643279f
Add file size to information shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
446 |
b7f2e643279f
Add file size to information shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
447 |
132
5ffc84b7da1a
Add class parameter to mgGetPageInfoHeaderStart().
Matti Hamalainen <ccr@tnsp.org>
parents:
130
diff
changeset
|
448 function mgGetPageInfoHeaderStart($class = NULL) |
101
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
449 { |
132
5ffc84b7da1a
Add class parameter to mgGetPageInfoHeaderStart().
Matti Hamalainen <ccr@tnsp.org>
parents:
130
diff
changeset
|
450 return "<div id=\"pageInfoHeader\"".($class != NULL ? " class=\"".$class."\"" : "").">\n"; |
101
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
451 } |
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
452 |
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
453 |
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
454 function mgGetPageInfoHeaderEnd() |
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
455 { |
151
4e25150aa868
Change js_path configuration setting to js_file.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
456 global $pageLang, $pageLanguages; |
4e25150aa868
Change js_path configuration setting to js_file.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
457 |
4e25150aa868
Change js_path configuration setting to js_file.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
458 $str = "<div id=\"languages\">"; |
4e25150aa868
Change js_path configuration setting to js_file.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
459 |
4e25150aa868
Change js_path configuration setting to js_file.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
460 if (isset($pageLanguages) && is_array($pageLanguages)) |
4e25150aa868
Change js_path configuration setting to js_file.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
461 { |
4e25150aa868
Change js_path configuration setting to js_file.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
462 foreach ($pageLanguages as $id => $lang) |
4e25150aa868
Change js_path configuration setting to js_file.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
463 $str .= "<a class=\"lang_".$id."\" href=\"?lang=".$id."\">".$lang."</a>"; |
4e25150aa868
Change js_path configuration setting to js_file.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
464 } |
4e25150aa868
Change js_path configuration setting to js_file.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
465 |
153 | 466 return $str. |
467 "</div>\n". | |
468 "</div>\n"; | |
101
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
469 } |
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
470 |
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
471 |
31
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
472 function mgGetBreadCrump($class, &$pdata) |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
473 { |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
474 return |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
475 "<a class=\"".$class."\" href=\"".mgGetURL($pdata["path"], FALSE)."\">". |
232
e618280253ca
Move mgGetTrans() to mgallery.php as it is used only there. Also change how
Matti Hamalainen <ccr@tnsp.org>
parents:
231
diff
changeset
|
476 mgGetTrans($pdata["caption"], "chentities"). |
47
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
477 "</a>"; |
31
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
478 } |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
479 |
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
480 |
0 | 481 function mgPrintBreadCrumbs($galData) |
482 { | |
63
1c32ece9acde
Some residual array() => [] conversions.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
483 $res = []; |
0 | 484 if ($galData["caption"]) |
31
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
485 $res[] = mgGetBreadCrump("naviBreadCrumbCurr", $galData); |
0 | 486 |
487 $tmp = $galData; | |
488 while (isset($tmp["parent"])) | |
489 { | |
490 $pdata = $tmp["parent"]; | |
31
300396947f04
Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
491 $res[] = mgGetBreadCrump("naviBreadCrumbItem", $pdata); |
0 | 492 $tmp = $tmp["parent"]; |
493 } | |
494 | |
495 if (count($res) > 1) | |
496 { | |
497 echo | |
118
6739c52e110c
Change naviBreadCrumbs to CSS id instead of class.
Matti Hamalainen <ccr@tnsp.org>
parents:
117
diff
changeset
|
498 "<div id=\"naviBreadCrumbs\">". |
0 | 499 implode("<span class=\"naviBreadCrumbSep\"></span>", array_reverse($res)). |
500 "</div>\n"; | |
501 } | |
502 } | |
503 | |
504 | |
296 | 505 function mgGetArrStr($data, $skeys, $sfmt1, $func = NULL) |
506 { | |
507 return mgGetArr($data, $skeys, $sfmt1, NULL, ($func == NULL) ? "chentities" : $func); | |
508 } | |
509 | |
510 | |
0 | 511 // |
76 | 512 // Global locale initialization |
513 // | |
514 if (!isset($localeInited) || !$localeInited) | |
515 { | |
516 $localeInited = TRUE; | |
517 $pageCharset = "UTF-8"; | |
518 | |
519 $tmp = "en_US.".strtolower(str_replace("-", "", $pageCharset)); | |
520 setlocale(LC_ALL, $tmp); | |
521 } | |
522 | |
523 | |
524 // | |
89
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
525 // Read and process gallery settings |
0 | 526 // |
297
77f85b1f35f2
Improve configuration file handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
527 if (mgReadSettings($searchPaths) === FALSE) |
77f85b1f35f2
Improve configuration file handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
528 { |
77f85b1f35f2
Improve configuration file handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
529 mgPrintPageHeader("Internal error!", "galleryPage"); |
77f85b1f35f2
Improve configuration file handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
530 |
77f85b1f35f2
Improve configuration file handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
531 echo |
77f85b1f35f2
Improve configuration file handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
532 "<h1>Internal error!</h1>\n". |
77f85b1f35f2
Improve configuration file handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
533 "<p>Could not find MGallery configuration file.</p>"; |
77f85b1f35f2
Improve configuration file handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
534 |
77f85b1f35f2
Improve configuration file handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
535 mgPrintPageFooter(); |
77f85b1f35f2
Improve configuration file handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
536 exit; |
77f85b1f35f2
Improve configuration file handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
537 } |
0 | 538 |
539 $pageCSS = mgGetSetting("css"); | |
322
2f4e3e458714
Improve configuration handling, and add "string array" configuration item type.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
540 $pageJS = mgGetSetting("js_file"); |
107
71de97240799
Add support for urchin file.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
541 $pageUrchin = mgGetSetting("urchin_file"); |
0 | 542 $galBasePath = mgGetSetting("base_path"); |
543 $galBaseURL = mgGetSetting("base_url"); | |
544 $galImageURL = mgGetSetting("image_url", mgGetSetting("base_url")); | |
545 | |
17
3f7bc4202df3
Add new configuration setting 'cover_images' to disable/enable sub-album
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
546 $galUseCoverImages = mgGetSetting("cover_images"); |
347
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
547 $galShowKeywords = mgGetSetting("show_keywords"); |
17
3f7bc4202df3
Add new configuration setting 'cover_images' to disable/enable sub-album
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
548 |
0 | 549 $galAlbumIcon = mgGetSetting("album_icon"); |
550 $galCleanURLS = mgGetSetting("clean_urls"); | |
551 $galTNPath = mgGetSetting("tn_path"); | |
185
cb7019690a73
Separate medium image and thumbnail directories / handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
552 $galMedPath = mgGetSetting("med_path"); |
0 | 553 $galTitlePrefix = mgGetSetting("title_prefix"); |
554 $galTitleSep = mgGetSetting("title_sep"); | |
555 | |
68
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
556 $galMode = mgGetRequestItem("mode", "view", TRUE); |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
557 $galPath = mgGetRequestItem("path", ".", TRUE); |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
558 $galPageIndex = intval(mgGetRequestItem("index", 0, TRUE)); |
941d3be57d7b
Get rid of mgeneric.inc.php dependency, as we don't need much from there .. for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
559 $galImage = mgGetRequestItem("image", FALSE, TRUE); |
0 | 560 |
347
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
561 |
0 | 562 if (is_string($galImage)) |
563 $galImage = basename($galImage); | |
564 | |
130
f825d644cf7a
Implement new config setting "timezone" for specifying the timezone used for date/timestamp interpretation.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
565 if (($pageTimeZone = mgGetSetting("timezone")) !== NULL) |
f825d644cf7a
Implement new config setting "timezone" for specifying the timezone used for date/timestamp interpretation.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
566 date_default_timezone_set($pageTimeZone); |
f825d644cf7a
Implement new config setting "timezone" for specifying the timezone used for date/timestamp interpretation.
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
567 |
0 | 568 |
89
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
569 // Check language setting |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
570 if (($tmp = mgGetRequestItem("lang", FALSE, TRUE)) !== FALSE) |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
571 { |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
572 $tmp = strtolower($tmp); |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
573 if (array_key_exists($tmp, $pageLanguages)) |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
574 { |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
575 $pageLang = $tmp; |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
576 mgSetCookie("mglang", $tmp); |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
577 } |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
578 } |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
579 else |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
580 if (isset($_COOKIE["mglang"])) |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
581 { |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
582 $tmp = strtolower($_COOKIE["mglang"]); |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
583 if (array_key_exists($tmp, $pageLanguages)) |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
584 $pageLang = $tmp; |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
585 } |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
586 |
d9524db8f6a5
Improve how language etc. cookie settings are handled.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
587 |
0 | 588 // |
589 // Attempt to read the data cache file | |
590 // | |
591 $filename = mgGetPath(mgCleanPath(TRUE, $galBasePath, $galPath), "cache_file"); | |
592 $filename2 = mgGetPath(mgCleanPath(FALSE, $galBasePath, $galPath), "cache_file"); | |
593 if ($filename == $filename2 && file_exists($filename) && ($fp = @fopen($filename, "rb")) !== FALSE) | |
594 { | |
595 if (flock($fp, LOCK_SH)) | |
596 { | |
597 require($filename); | |
598 flock($fp, LOCK_UN); | |
599 } | |
600 fclose($fp); | |
601 } | |
602 | |
603 // If no data available, show an error page | |
604 if (!isset($galData) || !isset($galEntries) || | |
605 !isset($galAlbumsIndex) || !isset($galImagesIndex)) | |
606 { | |
199
d03fad24f4bc
Make separate containing div elements for gallery and image view page types.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
607 mgPrintPageHeader($galTitlePrefix.$galTitleSep."ERROR!", "galleryPage"); |
0 | 608 |
609 echo | |
92
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
610 "<h1>".mgQM("gallery_error")."</h1>\n". |
17d1da44b140
Implement simple translation system for the "hardcoded" messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
611 "<p>".mgQM("invalid_gallery_path", chentities($galPath))."</p>"; |
0 | 612 |
12
79987aa7ee9a
Change some debugging (commented out).
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
613 //echo "<p>filename=: '".$filename."', X: galData=".intval(isset($galData)).", galEntries=".intval(isset($galEntries))."\n"; |
0 | 614 |
101
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
615 mgPrintPageFooter(); |
0 | 616 exit; |
617 } | |
618 | |
296 | 619 |
620 // Get gallery local settings | |
293
486398fb60ea
Allow album-specific {tn,med}_{width,height,format} settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
290
diff
changeset
|
621 $galTNFormat = mgGetAlbumSetting($galData, "tn_format"); |
486398fb60ea
Allow album-specific {tn,med}_{width,height,format} settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
290
diff
changeset
|
622 $galMedFormat = mgGetAlbumSetting($galData, "med_format"); |
486398fb60ea
Allow album-specific {tn,med}_{width,height,format} settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
290
diff
changeset
|
623 |
0 | 624 |
625 // | |
626 // Print page header, etc. | |
627 // | |
628 if (($index = array_search($galImage, $galImagesIndex)) !== FALSE) | |
629 { | |
630 // | |
631 // Single image mode | |
632 // | |
106
a3b8cd4183e6
Change {album,image}_navigation setting to *_flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
633 $ctrlFlags = mgGetSetting("image_flags"); |
0 | 634 $data = $galEntries[$galImage]; |
635 | |
66 | 636 $list = [ |
147
6c1467fe7d5c
Use a wrapper function for making the image metadata information box generation a bit simpler.
Matti Hamalainen <ccr@tnsp.org>
parents:
146
diff
changeset
|
637 mgGetArrStr($data, ["width", "height"], "<span class=\"infoDimensions\"><b>%1</b> x <b>%2</b> px</span>"), |
6c1467fe7d5c
Use a wrapper function for making the image metadata information box generation a bit simpler.
Matti Hamalainen <ccr@tnsp.org>
parents:
146
diff
changeset
|
638 mgGetArrStr($data, "model", "<span class=\"infoModel\"><b>%1</b></span>"), |
6c1467fe7d5c
Use a wrapper function for making the image metadata information box generation a bit simpler.
Matti Hamalainen <ccr@tnsp.org>
parents:
146
diff
changeset
|
639 mgGetArrStr($data, "fnumber", "<span class=\"infoFNumber\"><b>f/%1</b></span>"), |
6c1467fe7d5c
Use a wrapper function for making the image metadata information box generation a bit simpler.
Matti Hamalainen <ccr@tnsp.org>
parents:
146
diff
changeset
|
640 mgGetArrStr($data, "exposure", "<span class=\"infoExposure\"><b>%1</b> sec</span>"), |
6c1467fe7d5c
Use a wrapper function for making the image metadata information box generation a bit simpler.
Matti Hamalainen <ccr@tnsp.org>
parents:
146
diff
changeset
|
641 mgGetArrStr($data, "iso", "<span class=\"infoISO\">ISO <b>%1</b></span>"), |
6c1467fe7d5c
Use a wrapper function for making the image metadata information box generation a bit simpler.
Matti Hamalainen <ccr@tnsp.org>
parents:
146
diff
changeset
|
642 mgGetArrStr($data, "focallength", "<span class=\"infoFocalLength\">F-L <b>%1</b>mm</span>"), |
6c1467fe7d5c
Use a wrapper function for making the image metadata information box generation a bit simpler.
Matti Hamalainen <ccr@tnsp.org>
parents:
146
diff
changeset
|
643 mgGetArrStr($data, "lensmodel", "<span class=\"infoLensModel\"><i>%1</i></span>"), |
6c1467fe7d5c
Use a wrapper function for making the image metadata information box generation a bit simpler.
Matti Hamalainen <ccr@tnsp.org>
parents:
146
diff
changeset
|
644 mgGetArrStr($data, "filesize", "<span class=\"infoFileSize\">%1</span>", "mgFileSize"), |
66 | 645 ]; |
646 | |
47
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
647 $pageTitle = $galTitlePrefix.$galTitleSep.mgGetTrans($galData["caption"])." - ".$galImage; |
199
d03fad24f4bc
Make separate containing div elements for gallery and image view page types.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
648 mgPrintPageHeader($pageTitle, "imagePage"); |
44
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
649 echo |
186 | 650 // Info header |
132
5ffc84b7da1a
Add class parameter to mgGetPageInfoHeaderStart().
Matti Hamalainen <ccr@tnsp.org>
parents:
130
diff
changeset
|
651 mgGetPageInfoHeaderStart("imagePageHeader"). |
44
bc9da3b71888
Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
652 "<h1>".chentities($pageTitle)."</h1>\n"; |
0 | 653 |
106
a3b8cd4183e6
Change {album,image}_navigation setting to *_flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
654 if ($ctrlFlags & MGF_BREADCRUMBS) |
0 | 655 mgPrintBreadCrumbs($galData); |
656 | |
288 | 657 $gpath = isset($data["path"]) ? $data["path"] : $galPath; |
0 | 658 echo |
192 | 659 mgGetPageInfoHeaderEnd(). |
660 "\n". | |
661 // Hovering navigation buttons | |
193
96f5cdc71af5
Add translatable titles to navigation button elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
662 "<a id=\"pageInfoButton\" href=\"#\" title=\"".mgQM("page_info_button_title")."\">_</a>\n". |
96f5cdc71af5
Add translatable titles to navigation button elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
663 "<a id=\"pageUpNaviButton\" href=\"".mgGetURL($galData["path"], FALSE)."\" title=\"".mgQM("page_up_navi_button_title")."\">^</a>\n". |
198 | 664 // pageImageBox |
665 "<div id=\"pageImageBox\">\n". | |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
666 mgGetNaviControlImageBoxJS($galPath, $galImagesIndex, $galEntries, $index, "prevBtm", -1)."\n". |
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
667 mgGetNaviControlImageBox($galPath, $galImagesIndex, $galEntries, $index, "prev", -1)."\n". |
175
a51b59b552ef
Improve a bit of indentation for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
172
diff
changeset
|
668 "<div id=\"imageImageBox\" class=\"imageBox\">". |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
669 "<img id=\"imageImage\" src=\"". |
288 | 670 mgGetImageURL($gpath, $galMedPath, $galImage, $galMedFormat). |
185
cb7019690a73
Separate medium image and thumbnail directories / handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
671 "\" alt=\"".chentities($galImage)."\">". |
175
a51b59b552ef
Improve a bit of indentation for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
172
diff
changeset
|
672 "</div>\n". |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
673 mgGetNaviControlImageBoxJS($galPath, $galImagesIndex, $galEntries, $index, "nextBtm", 1)."\n". |
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
674 mgGetNaviControlImageBox($galPath, $galImagesIndex, $galEntries, $index, "next", 1)."\n". |
198 | 675 "</div>\n". // pageImageBox |
347
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
676 (isset($data["caption"]) ? |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
677 "<div id=\"pageImageCaption\" class=\"imageCaption\">".mgGetArrStr($data, "caption", "%1"). |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
678 mgGetImageKeywords($galData, $data, " (".mgQM("image_keywords_prefix"), mgQM("image_keywords_suffix").")")."</div>\n" : |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
679 mgGetImageKeywords($galData, $data, "<div id=\"pageImageCaption\" class=\"imageCaption\">".mgQM("image_keywords_prefix"), mgQM("image_keywords_suffix")."</div>\n") |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
680 ); |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
681 // infoBox |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
682 echo |
194
3562c43727e5
Move infoBox out of imageCBox element.
Matti Hamalainen <ccr@tnsp.org>
parents:
193
diff
changeset
|
683 "<div id=\"infoBox\">\n". |
3562c43727e5
Move infoBox out of imageCBox element.
Matti Hamalainen <ccr@tnsp.org>
parents:
193
diff
changeset
|
684 mgGetArr($data, "datetime", "<span class=\"infoDateTime\">%1</span>\n", "", "mgTimeStr"). |
3562c43727e5
Move infoBox out of imageCBox element.
Matti Hamalainen <ccr@tnsp.org>
parents:
193
diff
changeset
|
685 implode(",\n", array_filter($list, function($a) { return $a !== NULL; }))."\n". |
288 | 686 "<a id=\"imageLink\" href=\"". |
687 mgCleanPathStr($galImageURL.$gpath."/".$galImage)."\">". | |
194
3562c43727e5
Move infoBox out of imageCBox element.
Matti Hamalainen <ccr@tnsp.org>
parents:
193
diff
changeset
|
688 mgQM("view_best_quality")."</a>\n". |
3562c43727e5
Move infoBox out of imageCBox element.
Matti Hamalainen <ccr@tnsp.org>
parents:
193
diff
changeset
|
689 "</div>\n"; // infoBox |
0 | 690 |
691 // Javascript navigation | |
106
a3b8cd4183e6
Change {album,image}_navigation setting to *_flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
692 if ($ctrlFlags & MGF_JAVASCRIPT) |
0 | 693 { |
285
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
694 $prevURL = mgGetNaviActive($galPath, $galImagesIndex, $index, -1, $res, FALSE); |
25324e33fc78
Refactor gallery path handling somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
695 $nextURL = mgGetNaviActive($galPath, $galImagesIndex, $index, 1, $res, FALSE); |
0 | 696 echo |
248
2656b64c4c04
Remove type="text/javascript" from script tags.
Matti Hamalainen <ccr@tnsp.org>
parents:
247
diff
changeset
|
697 "<script>\n". |
269
371b9ee575b5
Oops, missed these variables in a previous commit.
Matti Hamalainen <ccr@tnsp.org>
parents:
254
diff
changeset
|
698 "var mgalPrevURL = \"".($prevURL !== FALSE ? $prevURL : "")."\";\n". |
371b9ee575b5
Oops, missed these variables in a previous commit.
Matti Hamalainen <ccr@tnsp.org>
parents:
254
diff
changeset
|
699 "var mgalNextURL = \"".($nextURL !== FALSE ? $nextURL : "")."\";\n". |
85
e017b5314d1c
Make "up" arrow key to go "up" to the album gallery in the image view.
Matti Hamalainen <ccr@tnsp.org>
parents:
84
diff
changeset
|
700 "var mgalUpURL = \"".mgGetURL($galData["path"], FALSE)."\";\n". |
0 | 701 "\n"; |
702 ?> | |
152
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
151
diff
changeset
|
703 mgalDisplayInfo(false); |
154
0b87e7c1675c
Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
704 mgalAddEvent("pageInfoButton", "click", mgalOpenInfo); |
198 | 705 mgalAddEvent("pageImageBox", "click", mgalCloseInfo); |
109
c8cfc6cc161a
Adjust image scaling to be delayed and not being done on each resize event
Matti Hamalainen <ccr@tnsp.org>
parents:
107
diff
changeset
|
706 |
210
0a0a2936d779
Adjust image adjustment etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
707 mgalAddEvent("imageImage", "load", mgalAdjustImage); |
154
0b87e7c1675c
Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
708 mgalAddEventOb("window", window, "resize", mgalAdjustImage); |
210
0a0a2936d779
Adjust image adjustment etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
709 mgalAddEventOb("window", window, "load", mgalAdjustImage); |
154
0b87e7c1675c
Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
710 mgalAddEventOb("document", document, "keypress", mgalProcessKeyPress); |
246
548a349bc015
Finally fix Chrome/Chromium support for keyboard navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
245
diff
changeset
|
711 mgalAddEventOb("document", document, "keydown", mgalProcessKeyPress); |
154
0b87e7c1675c
Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
712 |
222
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
214
diff
changeset
|
713 mgalAddEventOb("document", document, "touchstart", mgalTouchStart); |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
214
diff
changeset
|
714 mgalAddEventOb("document", document, "touchmove", mgalTouchMove); |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
214
diff
changeset
|
715 |
332 | 716 mgalAdjustImagePID = -1; |
149
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
147
diff
changeset
|
717 </script> |
0 | 718 <? |
719 } | |
720 } | |
721 else | |
722 { | |
723 // | |
724 // Gallery mode | |
725 // | |
726 // - needs sub-modes / handling of order shit | |
727 // - Javascript stuff for picture data updates | |
728 // | |
729 $pageTitle = $galTitlePrefix.mgGetArr($galData, "caption", " - %1", "", "chentities"); | |
199
d03fad24f4bc
Make separate containing div elements for gallery and image view page types.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
730 mgPrintPageHeader($pageTitle, "galleryPage"); |
125
379a8cd3bb2c
Show number of images and sub-galleries on the page title. (I can't figure
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
731 |
379a8cd3bb2c
Show number of images and sub-galleries on the page title. (I can't figure
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
732 $ptmp = []; |
379a8cd3bb2c
Show number of images and sub-galleries on the page title. (I can't figure
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
733 if (count($galImagesIndex) > 0) |
126
e14605c7aea0
Add translations for image/sub-album counts.
Matti Hamalainen <ccr@tnsp.org>
parents:
125
diff
changeset
|
734 $ptmp[] = count($galImagesIndex)." ".mgQM("gallery_nimages"); |
125
379a8cd3bb2c
Show number of images and sub-galleries on the page title. (I can't figure
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
735 if (count($galAlbumsIndex) > 0) |
126
e14605c7aea0
Add translations for image/sub-album counts.
Matti Hamalainen <ccr@tnsp.org>
parents:
125
diff
changeset
|
736 $ptmp[] = count($galAlbumsIndex)." ".mgQM("gallery_nsubalbums"); |
125
379a8cd3bb2c
Show number of images and sub-galleries on the page title. (I can't figure
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
737 |
379a8cd3bb2c
Show number of images and sub-galleries on the page title. (I can't figure
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
738 if (count($ptmp)) |
336 | 739 $pageTitle .= " (".implode(", ", $ptmp).")"; |
125
379a8cd3bb2c
Show number of images and sub-galleries on the page title. (I can't figure
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
740 |
48
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
741 echo |
145
d0ec01e13de5
Add class galleryPageHeader to pageInfoHeader.
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
742 mgGetPageInfoHeaderStart("galleryPageHeader"). |
48
5a2dd41ff7ad
Initial implementation of language selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
743 "<h1>".$pageTitle."</h1>\n"; |
0 | 744 |
106
a3b8cd4183e6
Change {album,image}_navigation setting to *_flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
745 $ctrlFlags = mgGetSetting("album_flags"); |
a3b8cd4183e6
Change {album,image}_navigation setting to *_flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
746 if ($ctrlFlags & MGF_BREADCRUMBS) |
0 | 747 mgPrintBreadCrumbs($galData); |
748 | |
348
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
749 if (isset($galData["header"]) && strlen($headerText = mgGetTrans($galData["header"])) > 0) |
13
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
750 { |
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
751 // Translate relative URLs in header, if needed |
348
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
752 echo "<div class=\"albumHeaderText\">". |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
753 mgTranslateRelativeURLs($headerText, $galPath, mgGetSetting("image_url")). |
596196f2b0c5
Improve relative URL translation in header text blobs.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
754 "</div>\n"; |
13
951752fb1c21
Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
755 } |
0 | 756 |
101
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
757 echo mgGetPageInfoHeaderEnd(); |
100
f74307f05696
Add pageInfoHeader element to contain the topmost info/navigation blurb elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
93
diff
changeset
|
758 |
347
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
759 mgPrintTable("albumTable", $galData, $galPath, $galEntries, $galAlbumsIndex, 0, FALSE); |
7da360685721
Implement show_keywords setting.
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
760 mgPrintTable("imageTable", $galData, $galPath, $galEntries, $galImagesIndex, 0, FALSE); |
0 | 761 } |
762 | |
101
00bcbe2473ff
Work on the page structure / element layout and clean up the header/footer code.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
763 mgPrintPageFooter(); |
0 | 764 ?> |