Mercurial > hg > mgallery
annotate mgallery.inc.php @ 219:0073439eff6d rel-0_9_3
Bump version.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 22 Mar 2018 21:23:20 +0200 |
parents | f3098855ad58 |
children | 77e72455c99f |
rev | line source |
---|---|
0 | 1 <?php |
2 // | |
3 // Yet Another Image Gallery | |
69
7777887bc515
Update header/copyright blurbs.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
4 // -- Common functions and data include |
7777887bc515
Update header/copyright blurbs.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
5 // Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org> |
161 | 6 // (C) Copyright 2015-2018 Tecnic Software productions (TNSP) |
0 | 7 // |
8 | |
219 | 9 $mgProgVersion = "v0.9.3"; |
0 | 10 $mgProgInfo = "Programmed by Matti 'ccr' Hamalainen"; |
11 $mgProgEmail = "<ccr@tnsp.org>"; | |
161 | 12 $mgProgCopyright = "2015-2018 Tecnic Software productions (TNSP)"; |
0 | 13 |
14 | |
15 // | |
106
a3b8cd4183e6
Change {album,image}_navigation setting to *_flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
16 // Navigation control defines |
a3b8cd4183e6
Change {album,image}_navigation setting to *_flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
17 // |
136 | 18 define("MGF_JAVASCRIPT" , 0x01); |
19 define("MGF_BREADCRUMBS" , 0x10); | |
20 define("MGF_CAPTIONS" , 0x20); | |
106
a3b8cd4183e6
Change {album,image}_navigation setting to *_flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
21 |
a3b8cd4183e6
Change {album,image}_navigation setting to *_flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
22 // |
0 | 23 // Constants for different value types |
24 // | |
136 | 25 define("MG_STR" , 1); |
26 define("MG_INT" , 2); | |
27 define("MG_DVA" , 3); | |
28 define("MG_BOOL" , 4); | |
29 define("MG_FLAGS" , 5); | |
30 define("MG_DATE" , 6); | |
0 | 31 |
32 | |
136 | 33 define("yes" , 1); |
34 define("no" , 0); | |
0 | 35 |
36 | |
114
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
37 $mgGFlags = [ |
136 | 38 "javascript" => MGF_JAVASCRIPT, |
39 "breadcrumbs" => MGF_BREADCRUMBS, | |
40 "captions" => MGF_CAPTIONS, | |
114
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
41 ]; |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
42 |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
43 |
0 | 44 function mgPathName($path) |
45 { | |
46 $tmp = mgCleanPathArray(TRUE, 0, func_num_args(), func_get_args()); | |
47 if (count($tmp) > 0) | |
48 return implode("/", array_splice($tmp, 0, -1))."/"; | |
49 else | |
50 return $path; | |
51 } | |
52 | |
53 // | |
54 // Configuration settings and their default values | |
55 // | |
127
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
56 $mgDefaults = [ |
130
f825d644cf7a
Implement new config setting "timezone" for specifying the timezone used for date/timestamp interpretation.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
57 "timezone" => [MG_STR, NULL], |
0 | 58 |
141
18061527d1cd
Reorder some settings in configuration data.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
59 "clean_urls" => [MG_BOOL, FALSE], |
127
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
60 "base_path" => [MG_STR, mgPathName(mgRealPath($_SERVER["SCRIPT_FILENAME"]))], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
61 "base_url" => [MG_STR, mgPathName($_SERVER["PHP_SELF"])], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
62 "image_url" => [MG_STR, mgPathName($_SERVER["PHP_SELF"])], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
63 "mgallery_php" => [MG_STR, "mgallery.php"], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
64 "format_exts" => [MG_STR, "\.jpg|\.png|\.gif|\.jpeg"], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
65 "captions_file" => [MG_STR, "captions.txt"], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
66 "header_file" => [MG_STR, "header.txt"], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
67 "info_file" => [MG_STR, "gallery.info"], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
68 "cache_file" => [MG_STR, ".mgallery.cache"], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
69 |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
70 "cover_images" => [MG_BOOL, TRUE], |
141
18061527d1cd
Reorder some settings in configuration data.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
71 "album_icon" => [MG_STR, "album_sm.png"], |
18061527d1cd
Reorder some settings in configuration data.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
72 |
142
9589faf2e8a1
Change use_tables default to FALSE.
Matti Hamalainen <ccr@tnsp.org>
parents:
141
diff
changeset
|
73 "use_tables" => [MG_BOOL, FALSE], |
141
18061527d1cd
Reorder some settings in configuration data.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
74 "album_row_limit" => [MG_INT, 5], |
0 | 75 |
127
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
76 "title_prefix" => [MG_STR, ""], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
77 "title_sep" => [MG_STR, " - "], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
78 "page_info" => [MG_STR, "<b>MGallery ".$mgProgVersion."</b> © Copyright ".$mgProgCopyright], |
151
4e25150aa868
Change js_path configuration setting to js_file.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
79 |
127
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
80 "css" => [MG_STR, NULL], |
151
4e25150aa868
Change js_path configuration setting to js_file.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
81 "js_file" => [MG_STR, NULL], |
127
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
82 "urchin_file" => [MG_STR, FALSE], |
0 | 83 |
127
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
84 "global_flags" => [MG_FLAGS, MGF_JAVASCRIPT | MGF_BREADCRUMBS | MGF_CAPTIONS, &$mgGFlags], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
85 "image_flags" => [MG_FLAGS, MGF_JAVASCRIPT | MGF_BREADCRUMBS, &$mgGFlags], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
86 "album_flags" => [MG_FLAGS, MGF_JAVASCRIPT | MGF_BREADCRUMBS, &$mgGFlags], |
0 | 87 |
127
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
88 "tn_path" => [MG_STR, "tn/"], |
185
cb7019690a73
Separate medium image and thumbnail directories / handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
171
diff
changeset
|
89 "med_path" => [MG_STR, "med/"], |
0 | 90 |
127
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
91 "tn_width" => [MG_INT, 140], // In pixels, applies as bounding box for w/h |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
92 "tn_height" => [MG_INT, 100], |
162
3c2674dbd185
Increase the generated mid- and thumbnail images JPEG quality slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
161
diff
changeset
|
93 "tn_quality" => [MG_INT, 85], // JPEG quality percent |
0 | 94 |
127
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
95 "med_width" => [MG_INT, 960], |
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
96 "med_height" => [MG_INT, 640], |
162
3c2674dbd185
Increase the generated mid- and thumbnail images JPEG quality slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
161
diff
changeset
|
97 "med_quality" => [MG_INT, 90], |
195 | 98 |
99 "debug" => [MG_BOOL, FALSE], | |
127
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
100 ]; |
0 | 101 |
102 | |
103 function mgDebug($msg) | |
104 { | |
105 // echo "MGAL[debug]: ".$msg; | |
106 } | |
107 | |
108 | |
109 function mgFatal($msg) | |
110 { | |
111 die("MGAL[fatal]: ".$msg); | |
112 } | |
113 | |
114 | |
115 function mgError($msg) | |
116 { | |
117 echo "MGAL[error]: ".$msg; | |
118 return FALSE; | |
119 } | |
120 | |
121 | |
122 function mgCArg($index, $clip = FALSE) | |
123 { | |
124 global $argc, $argv; | |
125 if ($index < $argc) | |
126 { | |
127 $str = $argv[$index]; | |
128 return ($clip !== FALSE) ? substr($str, 0, $clip) : $str; | |
129 } | |
130 else | |
131 return FALSE; | |
132 } | |
133 | |
134 | |
135 function mgCArgLC($index, $clip = FALSE) | |
136 { | |
137 global $argc, $argv; | |
138 if ($index < $argc) | |
139 { | |
140 $str = strtolower($argv[$index]); | |
141 return ($clip !== FALSE) ? substr($str, 0, $clip) : $str; | |
142 } | |
143 else | |
144 return FALSE; | |
145 } | |
146 | |
147 | |
148 function mgGetSetting($key, $default = NULL) | |
149 { | |
150 global $mgSettings, $mgDefaults; | |
151 | |
152 if (!array_key_exists($key, $mgDefaults)) | |
153 mgFatal("Setting '".$key."' does not exist.\n"); | |
154 | |
155 if (array_key_exists($key, $mgSettings)) | |
156 $val = $mgSettings[$key]; | |
157 else | |
158 $val = $mgDefaults[$key][1]; | |
159 | |
160 if (!isset($val) || $val === NULL) | |
161 { | |
162 if ($default !== NULL) | |
163 $val = $default; | |
164 else | |
165 mgFatal("Setting '".$key."' is not set, but is required to be configured.\n"); | |
166 } | |
167 | |
114
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
168 switch ($mgDefaults[$key][0]) |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
169 { |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
170 case MG_FLAGS: |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
171 if (is_string($val)) |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
172 { |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
173 $flags = $mgDefaults[$key][2]; |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
174 $cval = preg_split("/\s*[,|]\s*/", strtolower($val), -1, PREG_SPLIT_NO_EMPTY); |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
175 $nval = 0; |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
176 foreach ($cval as $qval) |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
177 { |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
178 if (array_key_exists($qval, $flags)) |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
179 $nval |= $flags[$qval]; |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
180 else |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
181 mgFatal("Invalid flag value for '".$key."': '".$qval."'."); |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
182 } |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
183 } |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
184 break; |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
185 } |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
186 |
0 | 187 return $val; |
188 } | |
189 | |
190 | |
191 function mgGetPath($path, $key) | |
192 { | |
193 $val = mgGetSetting($key); | |
194 return ($val !== FALSE) ? $path."/".$val : FALSE; | |
195 } | |
196 | |
197 | |
198 function mgReadSettings($filename = "mgallery.cfg") | |
199 { | |
200 global $mgSettings, $mgDefaults; | |
201 | |
127
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
202 $spaths = []; |
0 | 203 $spaths[] = getcwd()."/"; |
204 if (($tmp = getenv("HOME")) !== FALSE && strlen($tmp) > 0) | |
205 { | |
206 $spaths[] = $tmp."/.config/mgallery/"; | |
207 $spaths[] = $tmp."/."; | |
208 } | |
209 else | |
210 { | |
211 $data = posix_getpwuid(posix_getuid()); | |
212 if ($data !== FALSE && isset($data["dir"])) | |
213 { | |
214 $tmp = $data["dir"]; | |
215 $spaths[] = $tmp."/.config/mgallery/"; | |
216 $spaths[] = $tmp."/."; | |
217 } | |
218 } | |
219 $spaths[] = dirname(__FILE__)."/"; | |
220 | |
221 foreach (array_unique($spaths) as $path) | |
222 { | |
223 $file = $path.$filename; | |
224 mgDebug("Checking '".$file."' for configuration ..\n"); | |
225 if (file_exists($file) && | |
226 ($mgSettings = parse_ini_file($file, FALSE)) !== FALSE) | |
227 { | |
228 mgDebug("Found '".$file."' config.\n"); | |
229 | |
230 // Validate settings | |
231 $ok = TRUE; | |
232 foreach ($mgSettings as $setting => $val) | |
233 { | |
234 if (!array_key_exists($setting, $mgDefaults)) | |
235 { | |
236 mgError("Setting '".$setting."' does not exist.\n"); | |
237 $ok = FALSE; | |
238 } | |
239 } | |
240 return $ok; | |
241 } | |
242 } | |
243 | |
127
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
244 $mgSettings = []; |
0 | 245 return FALSE; |
246 } | |
247 | |
248 | |
249 function mgRealPath($path) | |
250 { | |
251 return realpath($path); | |
252 } | |
253 | |
254 | |
255 function mgCleanPathArray($refs, $start, $argc, $argv) | |
256 { | |
127
3ee66c432081
Use modern PHP array syntax.
Matti Hamalainen <ccr@tnsp.org>
parents:
124
diff
changeset
|
257 $path = []; |
0 | 258 $first = TRUE; |
259 for ($n = $start; $n < $argc; $n++) | |
260 { | |
261 foreach (explode("/", $argv[$n]) as $piece) | |
262 { | |
263 switch ($piece) | |
264 { | |
265 case ".": | |
266 case "": | |
267 if ($first) | |
268 $path[] = $piece; | |
269 break; | |
270 | |
271 case "..": | |
272 if ($refs && count($path) > 0) | |
273 array_pop($path); | |
274 break; | |
275 | |
276 default: | |
277 $path[] = $piece; | |
278 break; | |
279 } | |
280 $first = FALSE; | |
281 } | |
282 } | |
283 return $path; | |
284 } | |
285 | |
286 | |
287 function mgCleanPath($refs) | |
288 { | |
289 return implode("/", mgCleanPathArray($refs, 1, func_num_args(), func_get_args())); | |
290 } | |
291 | |
292 | |
113 | 293 function mgGetTrans($val, $useEntities = FALSE) |
47
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
294 { |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
295 global $pageLang; |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
296 |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
297 if (is_array($val)) |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
298 $str = array_key_exists($pageLang, $val) ? $val[$pageLang] : reset($val); |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
299 else |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
300 $str = $val; |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
301 |
113 | 302 return $useEntities ? chentities($str) : $str; |
47
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
303 } |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
304 |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
305 |
0 | 306 function mgGetArr($data, $skeys, $sfmt1 = "%1", $sfmt2 = "", $func = NULL) |
307 { | |
47
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
308 global $pageLang; |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
309 |
0 | 310 if (!is_array($skeys)) |
311 $skeys = array($skeys); | |
312 | |
313 foreach ($skeys as $skey) | |
314 if (!array_key_exists($skey, $data)) | |
315 return $sfmt2; | |
316 | |
317 $str = $sfmt1; | |
318 for ($i = 1; $i <= sizeof($skeys); $i++) | |
319 { | |
320 $val = $data[$skeys[$i - 1]]; | |
47
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
321 if (is_array($val)) |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
322 $vtmp = array_key_exists($pageLang, $val) ? $val[$pageLang] : reset($val); |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
323 else |
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
324 $vtmp = $val; |
0 | 325 |
326 if (is_callable($func)) | |
77
fcfd635d7abf
Oops, fix format string callback functions ..
Matti Hamalainen <ccr@tnsp.org>
parents:
70
diff
changeset
|
327 $vtmp = call_user_func($func, $vtmp); |
0 | 328 |
47
1e2b55775a84
Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents:
36
diff
changeset
|
329 $str = str_replace("%".$i, $vtmp, $str); |
0 | 330 } |
331 | |
332 return $str; | |
333 } | |
334 | |
335 | |
114
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
336 function mgGetDValStr($mdef, $val) |
0 | 337 { |
114
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
338 switch ($mdef[0]) |
0 | 339 { |
340 case MG_STR : return "\"".$val."\""; | |
341 case MG_BOOL : return $val ? "yes" : "no"; | |
114
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
342 case MG_FLAGS: |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
343 { |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
344 $mstr = []; |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
345 foreach ($mdef[2] as $vkey => $vval) |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
346 { |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
347 if ($val & $vval) |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
348 $mstr[] = $vkey; |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
349 } |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
350 return implode($mstr, " | "); |
c803235bd0f9
Implement flag config option type.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
351 } |
0 | 352 case MG_INT : |
353 default : return (string) $val; | |
354 } | |
355 } | |
356 | |
357 ?> |