@@ -173,6 +173,9 @@ |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | |
176 | + /** |
|
177 | + * @param string $path |
|
178 | + */ |
|
176 | 179 | protected function lng_try_filepath($path, $file_path_relative) { |
177 | 180 | $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
178 | 181 | return file_exists($file_path) ? $file_path : false; |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | |
36 | 36 | $this->container = array(); |
37 | 37 | |
38 | - if(classSupernova::$cache->getMode() != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
38 | + if (classSupernova::$cache->getMode() != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
39 | 39 | $this->cache = classSupernova::$cache; |
40 | 40 | classSupernova::log_file('locale.__constructor: Cache is present'); |
41 | 41 | //$this->cache->unset_by_prefix($this->cache_prefix); // TODO - remove? 'cause debug! |
42 | 42 | } |
43 | 43 | |
44 | - if($enable_stat_usage && empty($this->stat_usage)) { |
|
44 | + if ($enable_stat_usage && empty($this->stat_usage)) { |
|
45 | 45 | $this->enable_stat_usage = $enable_stat_usage; |
46 | 46 | $this->usage_stat_load(); |
47 | 47 | // TODO shutdown function |
@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | unset($fallback[$this->active]); |
68 | 68 | |
69 | 69 | // Проходим по оставшимся локалям |
70 | - foreach($fallback as $try_language) { |
|
70 | + foreach ($fallback as $try_language) { |
|
71 | 71 | // Если нет такой строки - пытаемся вытащить из кэша |
72 | - if(!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
73 | - $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset); |
|
72 | + if (!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
73 | + $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix.$try_language.'_'.$offset); |
|
74 | 74 | // Записываем результат работы кэша |
75 | 75 | $locale_cache_statistic['queries']++; |
76 | 76 | isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['hits']++ : $locale_cache_statistic['misses']++; |
77 | -!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix . $try_language . '_' . $offset : false; |
|
77 | +!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix.$try_language.'_'.$offset : false; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Если мы как-то где-то нашли строку... |
81 | - if(isset($this->container[$try_language][$offset])) { |
|
81 | + if (isset($this->container[$try_language][$offset])) { |
|
82 | 82 | // ...значит она получена в результате фоллбэка и записываем её в кэш и контейнер |
83 | 83 | $this[$offset] = $this->container[$try_language][$offset]; |
84 | 84 | $locale_cache_statistic['fallbacks']++; |
@@ -94,16 +94,16 @@ discard block |
||
94 | 94 | $this->container[$this->active][] = $value; |
95 | 95 | } else { |
96 | 96 | $this->container[$this->active][$offset] = $value; |
97 | - if($this->cache) { |
|
98 | - $this->cache->__set($this->cache_prefix_lang . $offset, $value); |
|
97 | + if ($this->cache) { |
|
98 | + $this->cache->__set($this->cache_prefix_lang.$offset, $value); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | 102 | public function offsetExists($offset) { |
103 | 103 | // Шорткат если у нас уже есть строка в памяти PHP |
104 | - if(!isset($this->container[$this->active][$offset])) { |
|
104 | + if (!isset($this->container[$this->active][$offset])) { |
|
105 | 105 | // pdump($this->cache_prefix_lang . $offset); |
106 | - if(!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
106 | + if (!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang.$offset))) { |
|
107 | 107 | // pdump($this->cache_prefix_lang . $offset); |
108 | 108 | // Если нету такой строки - делаем фоллбэк |
109 | 109 | $this->locale_string_fallback($offset); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | public function offsetGet($offset) { |
121 | 121 | $value = $this->offsetExists($offset) ? $this->container[$this->active][$offset] : null; |
122 | - if($this->enable_stat_usage) { |
|
122 | + if ($this->enable_stat_usage) { |
|
123 | 123 | $this->usage_stat_log($offset, $value); |
124 | 124 | } |
125 | 125 | return $value; |
@@ -134,23 +134,23 @@ discard block |
||
134 | 134 | |
135 | 135 | |
136 | 136 | public function usage_stat_load() { |
137 | - $this->stat_usage = classSupernova::$cache->lng_stat_usage = array(); |
|
138 | - if(empty($this->stat_usage)) { |
|
137 | + $this->stat_usage = classSupernova::$cache->lng_stat_usage = array(); |
|
138 | + if (empty($this->stat_usage)) { |
|
139 | 139 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{lng_usage_stat}}`"); |
140 | - while($row = db_fetch($query)) { |
|
141 | - $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty']; |
|
140 | + while ($row = db_fetch($query)) { |
|
141 | + $this->stat_usage[$row['lang_code'].':'.$row['string_id'].':'.$row['file'].':'.$row['line']] = $row['is_empty']; |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
145 | 145 | public function usage_stat_save() { |
146 | - if(!empty($this->stat_usage_new)) { |
|
146 | + if (!empty($this->stat_usage_new)) { |
|
147 | 147 | classSupernova::$cache->lng_stat_usage = $this->stat_usage; |
148 | 148 | classSupernova::$db->doSelect("SELECT 1 FROM `{{lng_usage_stat}}` LIMIT 1"); |
149 | - foreach($this->stat_usage_new as &$value) { |
|
150 | - foreach($value as &$value2) { |
|
151 | - $value2 = '"' . db_escape($value2) . '"'; |
|
149 | + foreach ($this->stat_usage_new as &$value) { |
|
150 | + foreach ($value as &$value2) { |
|
151 | + $value2 = '"'.db_escape($value2).'"'; |
|
152 | 152 | } |
153 | - $value = '(' . implode(',', $value) .')'; |
|
153 | + $value = '('.implode(',', $value).')'; |
|
154 | 154 | } |
155 | 155 | classSupernova::$gc->db->doReplaceValuesDeprecated( |
156 | 156 | 'lng_usage_stat', |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | |
174 | 174 | $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1)); |
175 | 175 | |
176 | - $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line']; |
|
177 | - if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
176 | + $string_id = $this->active.':'.$offset.':'.$file.':'.$trace[1]['line']; |
|
177 | + if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
178 | 178 | $this->stat_usage[$string_id] = empty($value); |
179 | 179 | $this->stat_usage_new[] = array( |
180 | 180 | 'lang_code' => $this->active, |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | 'file' => $file, |
183 | 183 | 'line' => $trace[1]['line'], |
184 | 184 | 'is_empty' => intval(empty($value)), |
185 | - 'locale' => '' . $value, |
|
185 | + 'locale' => ''.$value, |
|
186 | 186 | ); |
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | 190 | |
191 | 191 | protected function lng_try_filepath($path, $file_path_relative) { |
192 | - $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
|
192 | + $file_path = SN_ROOT_PHYSICAL.($path && file_exists(SN_ROOT_PHYSICAL.$path.$file_path_relative) ? $path : '').$file_path_relative; |
|
193 | 193 | return file_exists($file_path) ? $file_path : false; |
194 | 194 | } |
195 | 195 | |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | |
212 | 212 | classSupernova::log_file("locale.include: Loading data from domain '{$filename}'", 1); |
213 | 213 | |
214 | - $cache_file_key = $this->cache_prefix_lang . '__' . $filename; |
|
214 | + $cache_file_key = $this->cache_prefix_lang.'__'.$filename; |
|
215 | 215 | |
216 | 216 | // Подключен ли внешний кэш? |
217 | - if($this->cache) { |
|
217 | + if ($this->cache) { |
|
218 | 218 | // Загружен ли уже данный файл? |
219 | 219 | $cache_file_status = $this->cache->__get($cache_file_key); |
220 | - classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is " . ($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0); |
|
221 | - if($cache_file_status) { |
|
220 | + classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is ".($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0); |
|
221 | + if ($cache_file_status) { |
|
222 | 222 | // Если да - повторять загрузку нет смысла |
223 | 223 | return null; |
224 | 224 | } |
@@ -232,47 +232,47 @@ discard block |
||
232 | 232 | $this->make_fallback($language); |
233 | 233 | |
234 | 234 | $file_path = ''; |
235 | - foreach($this->fallback as $lang_try) { |
|
236 | - if(!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
235 | + foreach ($this->fallback as $lang_try) { |
|
236 | + if (!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
237 | 237 | continue; |
238 | 238 | } |
239 | 239 | |
240 | - if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
240 | + if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
241 | 241 | break; |
242 | 242 | } |
243 | 243 | |
244 | - if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
244 | + if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
245 | 245 | break; |
246 | 246 | } |
247 | 247 | |
248 | 248 | $file_path = ''; |
249 | 249 | } |
250 | 250 | |
251 | - if($file_path) { |
|
251 | + if ($file_path) { |
|
252 | 252 | $a_lang_array = array(); |
253 | 253 | include($file_path); |
254 | 254 | |
255 | - if(!empty($a_lang_array)) { |
|
255 | + if (!empty($a_lang_array)) { |
|
256 | 256 | $this->merge($a_lang_array); |
257 | 257 | |
258 | 258 | // Загрузка данных из файла в кэш |
259 | - if($this->cache) { |
|
259 | + if ($this->cache) { |
|
260 | 260 | classSupernova::log_file("Locale: loading '{$filename}' into cache"); |
261 | - foreach($a_lang_array as $key => $value) { |
|
262 | - $value_cache_key = $this->cache_prefix_lang . $key; |
|
263 | - if($this->cache->__isset($value_cache_key)) { |
|
264 | - if(is_array($value)) { |
|
261 | + foreach ($a_lang_array as $key => $value) { |
|
262 | + $value_cache_key = $this->cache_prefix_lang.$key; |
|
263 | + if ($this->cache->__isset($value_cache_key)) { |
|
264 | + if (is_array($value)) { |
|
265 | 265 | $alt_value = $this->cache->__get($value_cache_key); |
266 | 266 | $value = array_replace_recursive($alt_value, $value); |
267 | 267 | // pdump($alt_value, $alt_value); |
268 | 268 | } |
269 | 269 | } |
270 | - $this->cache->__set($this->cache_prefix_lang . $key, $value); |
|
270 | + $this->cache->__set($this->cache_prefix_lang.$key, $value); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
275 | - if($this->cache) { |
|
275 | + if ($this->cache) { |
|
276 | 276 | $this->cache->__set($cache_file_key, true); |
277 | 277 | } |
278 | 278 | |
@@ -285,14 +285,14 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | public function lng_load_i18n($i18n) { |
288 | - if(!isset($i18n)) { |
|
288 | + if (!isset($i18n)) { |
|
289 | 289 | return; |
290 | 290 | } |
291 | 291 | |
292 | - foreach($i18n as $i18n_data) { |
|
293 | - if(is_string($i18n_data)) { |
|
292 | + foreach ($i18n as $i18n_data) { |
|
293 | + if (is_string($i18n_data)) { |
|
294 | 294 | $this->lng_include($i18n_data); |
295 | - } elseif(is_array($i18n_data)) { |
|
295 | + } elseif (is_array($i18n_data)) { |
|
296 | 296 | $this->lng_include($i18n_data['file'], $i18n_data['path']); |
297 | 297 | } |
298 | 298 | } |
@@ -310,27 +310,27 @@ discard block |
||
310 | 310 | |
311 | 311 | classSupernova::log_file("locale.switch: Trying to switch language to '{$language_new}'"); |
312 | 312 | |
313 | - if($language_new == $this->active) { |
|
313 | + if ($language_new == $this->active) { |
|
314 | 314 | classSupernova::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1); |
315 | 315 | return false; |
316 | 316 | } |
317 | 317 | |
318 | 318 | $this->active = $language = $language_new; |
319 | - $this->cache_prefix_lang = $this->cache_prefix . $this->active . '_'; |
|
319 | + $this->cache_prefix_lang = $this->cache_prefix.$this->active.'_'; |
|
320 | 320 | |
321 | 321 | $this['LANG_INFO'] = $this->lng_get_info($this->active); |
322 | 322 | $this->make_fallback($this->active); |
323 | 323 | |
324 | - if($this->cache) { |
|
325 | - $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT'); |
|
326 | - classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is " . ($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0); |
|
327 | - if($cache_lang_init_status) { |
|
324 | + if ($this->cache) { |
|
325 | + $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang.'__INIT'); |
|
326 | + classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is ".($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0); |
|
327 | + if ($cache_lang_init_status) { |
|
328 | 328 | return false; |
329 | 329 | } |
330 | 330 | |
331 | 331 | // Чистим текущие локализации из кэша. Достаточно почистить только флаги инициализации языкового кэша и загрузки файлов - они начинаются с '__' |
332 | 332 | classSupernova::log_file("locale.switch: Cache - invalidating data"); |
333 | - $this->cache->unset_by_prefix($this->cache_prefix_lang . '__'); |
|
333 | + $this->cache->unset_by_prefix($this->cache_prefix_lang.'__'); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | $this->lng_include('system'); |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | // Loading global language files |
341 | 341 | $this->lng_load_i18n(classSupernova::$sn_mvc['i18n']['']); |
342 | 342 | |
343 | - if($this->cache) { |
|
344 | - classSupernova::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT'); |
|
345 | - $this->cache->__set($this->cache_prefix_lang . '__INIT', true); |
|
343 | + if ($this->cache) { |
|
344 | + classSupernova::log_file("locale.switch: Cache - setting flag ".$this->cache_prefix_lang.'__INIT'); |
|
345 | + $this->cache->__set($this->cache_prefix_lang.'__INIT', true); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | classSupernova::log_file("locale.switch: Complete - EXIT"); |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | |
353 | 353 | |
354 | 354 | public function lng_get_info($entry) { |
355 | - $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php'; |
|
355 | + $file_name = SN_ROOT_PHYSICAL.'language/'.$entry.'/language.mo.php'; |
|
356 | 356 | $lang_info = array(); |
357 | - if(file_exists($file_name)) { |
|
357 | + if (file_exists($file_name)) { |
|
358 | 358 | include($file_name); |
359 | 359 | } |
360 | 360 | |
@@ -362,15 +362,15 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | public function lng_get_list() { |
365 | - if(empty($this->lang_list)) { |
|
365 | + if (empty($this->lang_list)) { |
|
366 | 366 | $this->lang_list = array(); |
367 | 367 | |
368 | - $path = SN_ROOT_PHYSICAL . 'language/'; |
|
368 | + $path = SN_ROOT_PHYSICAL.'language/'; |
|
369 | 369 | $dir = dir($path); |
370 | - while(false !== ($entry = $dir->read())) { |
|
371 | - if(is_dir($path . $entry) && $entry[0] != '.') { |
|
370 | + while (false !== ($entry = $dir->read())) { |
|
371 | + if (is_dir($path.$entry) && $entry[0] != '.') { |
|
372 | 372 | $lang_info = $this->lng_get_info($entry); |
373 | - if($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
373 | + if ($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
374 | 374 | $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info; |
375 | 375 | } |
376 | 376 | } |
@@ -47,6 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | /** |
49 | 49 | * constuctor |
50 | + * @param template $template |
|
50 | 51 | */ |
51 | 52 | function template_compile(&$template) |
52 | 53 | { |
@@ -463,6 +464,7 @@ discard block |
||
463 | 464 | * Compile IF tags - much of this is from Smarty with |
464 | 465 | * some adaptions for our block level methods |
465 | 466 | * @access private |
467 | + * @param boolean $elseif |
|
466 | 468 | */ |
467 | 469 | function compile_tag_if($tag_args, $elseif) |
468 | 470 | { |
@@ -620,6 +622,7 @@ discard block |
||
620 | 622 | /** |
621 | 623 | * Compile DEFINE tags |
622 | 624 | * @access private |
625 | + * @param boolean $op |
|
623 | 626 | */ |
624 | 627 | function compile_tag_define($tag_args, $op) |
625 | 628 | { |
@@ -698,6 +701,7 @@ discard block |
||
698 | 701 | * parse expression |
699 | 702 | * This is from Smarty |
700 | 703 | * @access private |
704 | + * @param string $is_arg |
|
701 | 705 | */ |
702 | 706 | function _parse_is_expr($is_arg, $tokens) |
703 | 707 | { |
@@ -794,6 +798,8 @@ discard block |
||
794 | 798 | * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. |
795 | 799 | * NOTE: does not expect a trailing "." on the blockname. |
796 | 800 | * @access private |
801 | + * @param string $blockname |
|
802 | + * @param boolean $include_last_iterator |
|
797 | 803 | */ |
798 | 804 | function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
799 | 805 | { |
@@ -832,6 +838,7 @@ discard block |
||
832 | 838 | /** |
833 | 839 | * Write compiled file to cache directory |
834 | 840 | * @access private |
841 | + * @param string $data |
|
835 | 842 | */ |
836 | 843 | function compile_write($handle, $data) |
837 | 844 | { |
@@ -857,6 +864,7 @@ discard block |
||
857 | 864 | /** |
858 | 865 | * Minifies template w/i PHP code by removing extra spaces |
859 | 866 | * @access private |
867 | + * @return string |
|
860 | 868 | */ |
861 | 869 | function minify($html) |
862 | 870 | { |
@@ -44,17 +44,17 @@ discard block |
||
44 | 44 | var $block_else_level = array(); |
45 | 45 | |
46 | 46 | /** |
47 | - * constuctor |
|
48 | - */ |
|
47 | + * constuctor |
|
48 | + */ |
|
49 | 49 | function template_compile(&$template) |
50 | 50 | { |
51 | 51 | $this->template = &$template; |
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | - * Load template source from file |
|
56 | - * @access private |
|
57 | - */ |
|
55 | + * Load template source from file |
|
56 | + * @access private |
|
57 | + */ |
|
58 | 58 | function _tpl_load_file($handle, $store_in_db = false) |
59 | 59 | { |
60 | 60 | // Try and open template for read |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
100 | - * Remove any PHP tags that do not belong, these regular expressions are derived from |
|
101 | - * the ones that exist in zend_language_scanner.l |
|
102 | - * @access private |
|
103 | - */ |
|
100 | + * Remove any PHP tags that do not belong, these regular expressions are derived from |
|
101 | + * the ones that exist in zend_language_scanner.l |
|
102 | + * @access private |
|
103 | + */ |
|
104 | 104 | function remove_php_tags(&$code) |
105 | 105 | { |
106 | 106 | // This matches the information gathered from the internal PHP lexer |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | - * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
|
118 | - * @access private |
|
119 | - */ |
|
117 | + * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
|
118 | + * @access private |
|
119 | + */ |
|
120 | 120 | function compile($code, $no_echo = false, $echo_var = '') |
121 | 121 | { |
122 | 122 | if ($echo_var) |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
288 | - * Compile variables |
|
289 | - * @access private |
|
290 | - */ |
|
288 | + * Compile variables |
|
289 | + * @access private |
|
290 | + */ |
|
291 | 291 | function compile_var_tags(&$text_blocks) |
292 | 292 | { |
293 | 293 | // change template varrefs into PHP varrefs |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
350 | - * Compile blocks |
|
351 | - * @access private |
|
352 | - */ |
|
350 | + * Compile blocks |
|
351 | + * @access private |
|
352 | + */ |
|
353 | 353 | function compile_tag_block($tag_args) |
354 | 354 | { |
355 | 355 | $no_nesting = false; |
@@ -435,14 +435,14 @@ discard block |
||
435 | 435 | $tag_template_php .= 'if ($_' . $tag_args . '_count) {'; |
436 | 436 | |
437 | 437 | /** |
438 | - * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory |
|
439 | - * <code> |
|
440 | - * if (!$offset) |
|
441 | - * { |
|
442 | - * $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){'; |
|
443 | - * } |
|
444 | - * </code> |
|
445 | - */ |
|
438 | + * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory |
|
439 | + * <code> |
|
440 | + * if (!$offset) |
|
441 | + * { |
|
442 | + * $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){'; |
|
443 | + * } |
|
444 | + * </code> |
|
445 | + */ |
|
446 | 446 | |
447 | 447 | $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){'; |
448 | 448 | // $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;'; |
@@ -453,10 +453,10 @@ discard block |
||
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
456 | - * Compile IF tags - much of this is from Smarty with |
|
457 | - * some adaptions for our block level methods |
|
458 | - * @access private |
|
459 | - */ |
|
456 | + * Compile IF tags - much of this is from Smarty with |
|
457 | + * some adaptions for our block level methods |
|
458 | + * @access private |
|
459 | + */ |
|
460 | 460 | function compile_tag_if($tag_args, $elseif) |
461 | 461 | { |
462 | 462 | // Tokenize args for 'if' tag. |
@@ -611,9 +611,9 @@ discard block |
||
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
614 | - * Compile DEFINE tags |
|
615 | - * @access private |
|
616 | - */ |
|
614 | + * Compile DEFINE tags |
|
615 | + * @access private |
|
616 | + */ |
|
617 | 617 | function compile_tag_define($tag_args, $op) |
618 | 618 | { |
619 | 619 | preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match); |
@@ -664,9 +664,9 @@ discard block |
||
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
667 | - * Compile INCLUDE tag |
|
668 | - * @access private |
|
669 | - */ |
|
667 | + * Compile INCLUDE tag |
|
668 | + * @access private |
|
669 | + */ |
|
670 | 670 | function compile_tag_include($tag_args) |
671 | 671 | { |
672 | 672 | // Process dynamic includes |
@@ -679,19 +679,19 @@ discard block |
||
679 | 679 | } |
680 | 680 | |
681 | 681 | /** |
682 | - * Compile INCLUDE_PHP tag |
|
683 | - * @access private |
|
684 | - */ |
|
682 | + * Compile INCLUDE_PHP tag |
|
683 | + * @access private |
|
684 | + */ |
|
685 | 685 | function compile_tag_include_php($tag_args) |
686 | 686 | { |
687 | 687 | return "\$this->_php_include('$tag_args');"; |
688 | 688 | } |
689 | 689 | |
690 | 690 | /** |
691 | - * parse expression |
|
692 | - * This is from Smarty |
|
693 | - * @access private |
|
694 | - */ |
|
691 | + * parse expression |
|
692 | + * This is from Smarty |
|
693 | + * @access private |
|
694 | + */ |
|
695 | 695 | function _parse_is_expr($is_arg, $tokens) |
696 | 696 | { |
697 | 697 | $expr_end = 0; |
@@ -756,13 +756,13 @@ discard block |
||
756 | 756 | } |
757 | 757 | |
758 | 758 | /** |
759 | - * Generates a reference to the given variable inside the given (possibly nested) |
|
760 | - * block namespace. This is a string of the form: |
|
761 | - * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . ' |
|
762 | - * It's ready to be inserted into an "echo" line in one of the templates. |
|
763 | - * NOTE: expects a trailing "." on the namespace. |
|
764 | - * @access private |
|
765 | - */ |
|
759 | + * Generates a reference to the given variable inside the given (possibly nested) |
|
760 | + * block namespace. This is a string of the form: |
|
761 | + * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . ' |
|
762 | + * It's ready to be inserted into an "echo" line in one of the templates. |
|
763 | + * NOTE: expects a trailing "." on the namespace. |
|
764 | + * @access private |
|
765 | + */ |
|
766 | 766 | function generate_block_varref($namespace, $varname, $echo = true, $defop = false) |
767 | 767 | { |
768 | 768 | // Strip the trailing period. |
@@ -780,14 +780,14 @@ discard block |
||
780 | 780 | } |
781 | 781 | |
782 | 782 | /** |
783 | - * Generates a reference to the array of data values for the given |
|
784 | - * (possibly nested) block namespace. This is a string of the form: |
|
785 | - * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] |
|
786 | - * |
|
787 | - * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. |
|
788 | - * NOTE: does not expect a trailing "." on the blockname. |
|
789 | - * @access private |
|
790 | - */ |
|
783 | + * Generates a reference to the array of data values for the given |
|
784 | + * (possibly nested) block namespace. This is a string of the form: |
|
785 | + * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] |
|
786 | + * |
|
787 | + * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. |
|
788 | + * NOTE: does not expect a trailing "." on the blockname. |
|
789 | + * @access private |
|
790 | + */ |
|
791 | 791 | function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
792 | 792 | { |
793 | 793 | // Get an array of the blocks involved. |
@@ -823,9 +823,9 @@ discard block |
||
823 | 823 | } |
824 | 824 | |
825 | 825 | /** |
826 | - * Write compiled file to cache directory |
|
827 | - * @access private |
|
828 | - */ |
|
826 | + * Write compiled file to cache directory |
|
827 | + * @access private |
|
828 | + */ |
|
829 | 829 | function compile_write($handle, $data) |
830 | 830 | { |
831 | 831 | $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | |
849 | 849 | // Gorlum's minifier BOF |
850 | 850 | /** |
851 | - * Minifies template w/i PHP code by removing extra spaces |
|
852 | - */ |
|
851 | + * Minifies template w/i PHP code by removing extra spaces |
|
852 | + */ |
|
853 | 853 | private function minify($html) |
854 | 854 | { |
855 | 855 | if(!classSupernova::$config->tpl_minifier) |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | 'template_data' => trim(@file_get_contents($this->template->files[$handle])), |
92 | 92 | ); |
93 | 93 | |
94 | - $sql = 'INSERT INTO ' . STYLES_TEMPLATE_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); |
|
94 | + $sql = 'INSERT INTO '.STYLES_TEMPLATE_DATA_TABLE.' '.$db->sql_build_array('INSERT', $sql_ary); |
|
95 | 95 | $db->sql_query($sql); |
96 | 96 | } |
97 | 97 | } |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | |
139 | 139 | preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches); |
140 | 140 | $include_blocks = $matches[1]; |
141 | - if($include_blocks) |
|
141 | + if ($include_blocks) |
|
142 | 142 | { |
143 | - foreach($include_blocks as &$included_file) |
|
143 | + foreach ($include_blocks as &$included_file) |
|
144 | 144 | { |
145 | 145 | $included_file .= '.tpl.html'; |
146 | 146 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | { |
170 | 170 | case 'BEGIN': |
171 | 171 | $this->block_else_level[] = false; |
172 | - $compile_blocks[] = '<?php ' . $this->compile_tag_block($block_val[2]) . ' ?>'; |
|
172 | + $compile_blocks[] = '<?php '.$this->compile_tag_block($block_val[2]).' ?>'; |
|
173 | 173 | break; |
174 | 174 | |
175 | 175 | case 'BEGINELSE': |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | |
180 | 180 | case 'END': |
181 | 181 | array_pop($this->block_names); |
182 | - $compile_blocks[] = '<?php ' . ((array_pop($this->block_else_level)) ? '}' : '}}') . ' ?>'; |
|
182 | + $compile_blocks[] = '<?php '.((array_pop($this->block_else_level)) ? '}' : '}}').' ?>'; |
|
183 | 183 | break; |
184 | 184 | |
185 | 185 | case 'IF': |
186 | - $compile_blocks[] = '<?php ' . $this->compile_tag_if($block_val[2], false) . ' ?>'; |
|
186 | + $compile_blocks[] = '<?php '.$this->compile_tag_if($block_val[2], false).' ?>'; |
|
187 | 187 | break; |
188 | 188 | |
189 | 189 | case 'ELSE': |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | break; |
192 | 192 | |
193 | 193 | case 'ELSEIF': |
194 | - $compile_blocks[] = '<?php ' . $this->compile_tag_if($block_val[2], true) . ' ?>'; |
|
194 | + $compile_blocks[] = '<?php '.$this->compile_tag_if($block_val[2], true).' ?>'; |
|
195 | 195 | break; |
196 | 196 | |
197 | 197 | case 'ENDIF': |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | break; |
200 | 200 | |
201 | 201 | case 'DEFINE': |
202 | - $compile_blocks[] = '<?php ' . $this->compile_tag_define($block_val[2], true) . ' ?>'; |
|
202 | + $compile_blocks[] = '<?php '.$this->compile_tag_define($block_val[2], true).' ?>'; |
|
203 | 203 | break; |
204 | 204 | |
205 | 205 | case 'UNDEFINE': |
206 | - $compile_blocks[] = '<?php ' . $this->compile_tag_define($block_val[2], false) . ' ?>'; |
|
206 | + $compile_blocks[] = '<?php '.$this->compile_tag_define($block_val[2], false).' ?>'; |
|
207 | 207 | break; |
208 | 208 | |
209 | 209 | case 'INCLUDE': |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $file = $temp; |
235 | 235 | } |
236 | 236 | |
237 | - $compile_blocks[] = '<?php ' . $this->compile_tag_include($temp) . ' ?>'; |
|
237 | + $compile_blocks[] = '<?php '.$this->compile_tag_include($temp).' ?>'; |
|
238 | 238 | |
239 | 239 | // No point in checking variable includes |
240 | 240 | if ($file) |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | break; |
245 | 245 | |
246 | 246 | case 'INCLUDEPHP': |
247 | - $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php ' . $this->compile_tag_include_php(array_shift($includephp_blocks)) . ' ?>' : ''; |
|
247 | + $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php '.$this->compile_tag_include_php(array_shift($includephp_blocks)).' ?>' : ''; |
|
248 | 248 | break; |
249 | 249 | |
250 | 250 | case 'PHP': |
251 | - $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php ' . array_shift($php_blocks) . ' ?>' : ''; |
|
251 | + $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php '.array_shift($php_blocks).' ?>' : ''; |
|
252 | 252 | break; |
253 | 253 | |
254 | 254 | default: |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | for ($i = 0, $size = sizeof($text_blocks); $i < $size; $i++) |
264 | 264 | { |
265 | 265 | $trim_check_text = trim($text_blocks[$i]); |
266 | - $template_php .= (!$no_echo) ? (($trim_check_text != '') ? $text_blocks[$i] : '') . ((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '') : (($trim_check_text != '') ? $text_blocks[$i] : '') . ((isset($compile_blocks[$i])) ? $compile_blocks[$i] : ''); |
|
266 | + $template_php .= (!$no_echo) ? (($trim_check_text != '') ? $text_blocks[$i] : '').((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '') : (($trim_check_text != '') ? $text_blocks[$i] : '').((isset($compile_blocks[$i])) ? $compile_blocks[$i] : ''); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | // Remove unused opening/closing tags |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | // we'll strip out such occurences, minimising such switching |
279 | 279 | if ($no_echo) |
280 | 280 | { |
281 | - return "\$$echo_var .= '" . $template_php . "'"; |
|
281 | + return "\$$echo_var .= '".$template_php."'"; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | return $template_php; |
@@ -373,30 +373,30 @@ discard block |
||
373 | 373 | |
374 | 374 | if ($match[2] < 0) |
375 | 375 | { |
376 | - $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')'; |
|
376 | + $loop_start = '($_'.$tag_args.'_count '.$match[2].' < 0 ? 0 : $_'.$tag_args.'_count '.$match[2].')'; |
|
377 | 377 | } |
378 | 378 | else |
379 | 379 | { |
380 | - $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')'; |
|
380 | + $loop_start = '($_'.$tag_args.'_count < '.$match[2].' ? $_'.$tag_args.'_count : '.$match[2].')'; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | if (strlen($match[3]) < 1 || $match[3] == -1) |
384 | 384 | { |
385 | - $loop_end = '$_' . $tag_args . '_count'; |
|
385 | + $loop_end = '$_'.$tag_args.'_count'; |
|
386 | 386 | } |
387 | 387 | else if ($match[3] >= 0) |
388 | 388 | { |
389 | - $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')'; |
|
389 | + $loop_end = '('.($match[3] + 1).' > $_'.$tag_args.'_count ? $_'.$tag_args.'_count : '.($match[3] + 1).')'; |
|
390 | 390 | } |
391 | 391 | else //if ($match[3] < -1) |
392 | 392 | { |
393 | - $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1); |
|
393 | + $loop_end = '$_'.$tag_args.'_count'.($match[3] + 1); |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | else |
397 | 397 | { |
398 | 398 | $loop_start = 0; |
399 | - $loop_end = '$_' . $tag_args . '_count'; |
|
399 | + $loop_end = '$_'.$tag_args.'_count'; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | $tag_template_php = ''; |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | if (sizeof($block) < 2) |
416 | 416 | { |
417 | 417 | // Block is not nested. |
418 | - $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
|
418 | + $tag_template_php = '$_'.$tag_args."_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
|
419 | 419 | $varref = "\$this->_tpldata['$tag_args']"; |
420 | 420 | } |
421 | 421 | else |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | $varref = $this->generate_block_data_ref($namespace, false); |
430 | 430 | |
431 | 431 | // Create the for loop code to iterate over this block. |
432 | - $tag_template_php = '$_' . $tag_args . '_count = (isset(' . $varref . ')) ? sizeof(' . $varref . ') : 0;'; |
|
432 | + $tag_template_php = '$_'.$tag_args.'_count = (isset('.$varref.')) ? sizeof('.$varref.') : 0;'; |
|
433 | 433 | } |
434 | 434 | |
435 | - $tag_template_php .= 'if ($_' . $tag_args . '_count) {'; |
|
435 | + $tag_template_php .= 'if ($_'.$tag_args.'_count) {'; |
|
436 | 436 | |
437 | 437 | /** |
438 | 438 | * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory |
@@ -444,10 +444,10 @@ discard block |
||
444 | 444 | * </code> |
445 | 445 | */ |
446 | 446 | |
447 | - $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){'; |
|
447 | + $tag_template_php .= 'for ($_'.$tag_args.'_i = '.$loop_start.'; $_'.$tag_args.'_i < '.$loop_end.'; ++$_'.$tag_args.'_i){'; |
|
448 | 448 | // $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;'; |
449 | - $tag_template_php .= '$_'. $tag_args . '_val = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
450 | - $tag_template_php .= '$this->_block_value["'. $tag_args . '"] = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
449 | + $tag_template_php .= '$_'.$tag_args.'_val = &'.$varref.'[$_'.$tag_args.'_i];'; |
|
450 | + $tag_template_php .= '$this->_block_value["'.$tag_args.'"] = &'.$varref.'[$_'.$tag_args.'_i];'; |
|
451 | 451 | |
452 | 452 | return $tag_template_php; |
453 | 453 | } |
@@ -551,10 +551,10 @@ discard block |
||
551 | 551 | break; |
552 | 552 | |
553 | 553 | case 'is': |
554 | - $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1; |
|
554 | + $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1; |
|
555 | 555 | $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); |
556 | 556 | |
557 | - $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1)); |
|
557 | + $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1)); |
|
558 | 558 | |
559 | 559 | array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens); |
560 | 560 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | default: |
566 | 566 | if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs)) |
567 | 567 | { |
568 | - $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']'); |
|
568 | + $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]).'[\''.$varrefs[3].'\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\''.$varrefs[3].'\']' : '$this->_rootref[\''.$varrefs[3].'\']'); |
|
569 | 569 | } |
570 | 570 | else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
571 | 571 | { |
@@ -582,20 +582,20 @@ discard block |
||
582 | 582 | $varref = $this->generate_block_data_ref($namespace, true); |
583 | 583 | |
584 | 584 | // Add the block reference for the last child. |
585 | - $varref .= "['" . $block . "']"; |
|
585 | + $varref .= "['".$block."']"; |
|
586 | 586 | } |
587 | 587 | else |
588 | 588 | { |
589 | 589 | $varref = '$this->_tpldata'; |
590 | 590 | |
591 | 591 | // Add the block reference for the last child. |
592 | - $varref .= "['" . $blocks[0] . "']"; |
|
592 | + $varref .= "['".$blocks[0]."']"; |
|
593 | 593 | } |
594 | 594 | $token = "sizeof($varref)"; |
595 | 595 | } |
596 | 596 | else if (!empty($token)) |
597 | 597 | { |
598 | - $token = '(' . $token . ')'; |
|
598 | + $token = '('.$token.')'; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | break; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | { |
608 | 608 | $tokens = array('false'); |
609 | 609 | } |
610 | - return (($elseif) ? '} else if (' : 'if (') . (implode(' ', $tokens) . ') { '); |
|
610 | + return (($elseif) ? '} else if (' : 'if (').(implode(' ', $tokens).') { '); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | |
626 | 626 | if (!$op) |
627 | 627 | { |
628 | - return 'unset(' . (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ');'; |
|
628 | + return 'unset('.(($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true).'[\''.$match[2].'\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\''.$match[2].'\']').');'; |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | // Are we a string? |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | $match[4] = $this->compile($match[4]); |
638 | 638 | |
639 | 639 | // Now replace the php code |
640 | - $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'"; |
|
640 | + $match[4] = "'".str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4])."'"; |
|
641 | 641 | } |
642 | 642 | else |
643 | 643 | { |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | } |
661 | 661 | } |
662 | 662 | |
663 | - return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ' = ' . $match[4] . ';'; |
|
663 | + return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true).'[\''.$match[2].'\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\''.$match[2].'\']').' = '.$match[4].';'; |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -801,24 +801,24 @@ discard block |
||
801 | 801 | // Build up the string with everything but the last child. |
802 | 802 | for ($i = 0; $i < $blockcount; $i++) |
803 | 803 | { |
804 | - $varref .= "['" . $blocks[$i] . "'][\$_" . $blocks[$i] . '_i]'; |
|
804 | + $varref .= "['".$blocks[$i]."'][\$_".$blocks[$i].'_i]'; |
|
805 | 805 | } |
806 | 806 | // Add the block reference for the last child. |
807 | - $varref .= "['" . $blocks[$blockcount] . "']"; |
|
807 | + $varref .= "['".$blocks[$blockcount]."']"; |
|
808 | 808 | // Add the iterator for the last child if requried. |
809 | 809 | if ($include_last_iterator) |
810 | 810 | { |
811 | - $varref .= '[$_' . $blocks[$blockcount] . '_i]'; |
|
811 | + $varref .= '[$_'.$blocks[$blockcount].'_i]'; |
|
812 | 812 | } |
813 | 813 | return $varref; |
814 | 814 | } |
815 | 815 | else if ($include_last_iterator) |
816 | 816 | { |
817 | - return '$_'. $blocks[$blockcount] . '_val'; |
|
817 | + return '$_'.$blocks[$blockcount].'_val'; |
|
818 | 818 | } |
819 | 819 | else |
820 | 820 | { |
821 | - return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
|
821 | + return '$_'.$blocks[$blockcount - 1].'_val[\''.$blocks[$blockcount].'\']'; |
|
822 | 822 | } |
823 | 823 | } |
824 | 824 | |
@@ -828,14 +828,14 @@ discard block |
||
828 | 828 | */ |
829 | 829 | function compile_write($handle, $data) |
830 | 830 | { |
831 | - $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
|
831 | + $filename = $this->template->cachepath.str_replace('/', '.', $this->template->filename[$handle]).DOT_PHP_EX; |
|
832 | 832 | |
833 | - $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data); |
|
833 | + $data = "<?php if (!defined('INSIDE')) exit;".((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>'.$data); |
|
834 | 834 | |
835 | 835 | if ($fp = @fopen($filename, 'wb')) |
836 | 836 | { |
837 | 837 | @flock($fp, LOCK_EX); |
838 | - @fwrite ($fp, $data); |
|
838 | + @fwrite($fp, $data); |
|
839 | 839 | @flock($fp, LOCK_UN); |
840 | 840 | @fclose($fp); |
841 | 841 | |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | */ |
853 | 853 | private function minify($html) |
854 | 854 | { |
855 | - if(!classSupernova::$config->tpl_minifier) |
|
855 | + if (!classSupernova::$config->tpl_minifier) |
|
856 | 856 | { |
857 | 857 | return $html; |
858 | 858 | } |
@@ -862,14 +862,14 @@ discard block |
||
862 | 862 | $html = preg_replace('/(<script[^>]*?>.*?<\/script>)/si', '#pre#', $html); |
863 | 863 | $html = preg_replace('/>[\s]*</', '><', $html); // Strip spacechars between tags |
864 | 864 | $html = preg_replace('/[\s]+/', ' ', $html); // Replace several spacechars with one space |
865 | - if(!empty($pre[0])) |
|
865 | + if (!empty($pre[0])) |
|
866 | 866 | { |
867 | - foreach($pre[0] as $tag) |
|
867 | + foreach ($pre[0] as $tag) |
|
868 | 868 | { |
869 | 869 | $tag = preg_replace('/^\ *\/\/[^\<]*?$/m', ' ', $tag); // Strips comments - except those that contains HTML comment inside |
870 | 870 | $tag = preg_replace('/[\ \t]{2,}/', ' ', $tag); // Replace several spaces by one |
871 | 871 | $tag = preg_replace('/\s{2,}/', "\r\n", $tag); // Replace several linefeeds by one |
872 | - $html = preg_replace('/#pre#/', $tag, $html,1); |
|
872 | + $html = preg_replace('/#pre#/', $tag, $html, 1); |
|
873 | 873 | } |
874 | 874 | } |
875 | 875 |
@@ -66,8 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | return; |
68 | 68 | trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR); |
69 | - } |
|
70 | - else |
|
69 | + } else |
|
71 | 70 | { |
72 | 71 | $this->template->files[$handle] = $this->template->files_inherit[$handle]; |
73 | 72 | } |
@@ -225,15 +224,13 @@ discard block |
||
225 | 224 | $var = substr($temp, 2, -1); |
226 | 225 | //$file = $this->template->_tpldata['DEFINE']['.'][$var]; |
227 | 226 | $temp = "\$this->_tpldata['DEFINE']['.']['$var']"; |
228 | - } |
|
229 | - else |
|
227 | + } else |
|
230 | 228 | { |
231 | 229 | $var = substr($temp, 1, -1); |
232 | 230 | //$file = $this->template->_rootref[$var]; |
233 | 231 | $temp = "\$this->_rootref['$var']"; |
234 | 232 | } |
235 | - } |
|
236 | - else |
|
233 | + } else |
|
237 | 234 | { |
238 | 235 | $file = $temp; |
239 | 236 | } |
@@ -381,8 +378,7 @@ discard block |
||
381 | 378 | if ($match[2] < 0) |
382 | 379 | { |
383 | 380 | $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')'; |
384 | - } |
|
385 | - else |
|
381 | + } else |
|
386 | 382 | { |
387 | 383 | $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')'; |
388 | 384 | } |
@@ -390,17 +386,14 @@ discard block |
||
390 | 386 | if (strlen($match[3]) < 1 || $match[3] == -1) |
391 | 387 | { |
392 | 388 | $loop_end = '$_' . $tag_args . '_count'; |
393 | - } |
|
394 | - else if ($match[3] >= 0) |
|
389 | + } else if ($match[3] >= 0) |
|
395 | 390 | { |
396 | 391 | $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')'; |
397 | - } |
|
398 | - else //if ($match[3] < -1) |
|
392 | + } else //if ($match[3] < -1) |
|
399 | 393 | { |
400 | 394 | $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1); |
401 | 395 | } |
402 | - } |
|
403 | - else |
|
396 | + } else |
|
404 | 397 | { |
405 | 398 | $loop_start = 0; |
406 | 399 | $loop_end = '$_' . $tag_args . '_count'; |
@@ -413,8 +406,7 @@ discard block |
||
413 | 406 | { |
414 | 407 | // We need to implode $no_nesting times from the end... |
415 | 408 | $block = array_slice($this->block_names, -$no_nesting); |
416 | - } |
|
417 | - else |
|
409 | + } else |
|
418 | 410 | { |
419 | 411 | $block = $this->block_names; |
420 | 412 | } |
@@ -424,8 +416,7 @@ discard block |
||
424 | 416 | // Block is not nested. |
425 | 417 | $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
426 | 418 | $varref = "\$this->_tpldata['$tag_args']"; |
427 | - } |
|
428 | - else |
|
419 | + } else |
|
429 | 420 | { |
430 | 421 | // This block is nested. |
431 | 422 | // Generate a namespace string for this block. |
@@ -573,8 +564,7 @@ discard block |
||
573 | 564 | if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs)) |
574 | 565 | { |
575 | 566 | $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']'); |
576 | - } |
|
577 | - else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
567 | + } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
578 | 568 | { |
579 | 569 | // Allow checking if loops are set with .loopname |
580 | 570 | // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example |
@@ -590,8 +580,7 @@ discard block |
||
590 | 580 | |
591 | 581 | // Add the block reference for the last child. |
592 | 582 | $varref .= "['" . $block . "']"; |
593 | - } |
|
594 | - else |
|
583 | + } else |
|
595 | 584 | { |
596 | 585 | $varref = '$this->_tpldata'; |
597 | 586 | |
@@ -599,8 +588,7 @@ discard block |
||
599 | 588 | $varref .= "['" . $blocks[0] . "']"; |
600 | 589 | } |
601 | 590 | $token = "sizeof($varref)"; |
602 | - } |
|
603 | - else if (!empty($token)) |
|
591 | + } else if (!empty($token)) |
|
604 | 592 | { |
605 | 593 | $token = '(' . $token . ')'; |
606 | 594 | } |
@@ -645,8 +633,7 @@ discard block |
||
645 | 633 | |
646 | 634 | // Now replace the php code |
647 | 635 | $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'"; |
648 | - } |
|
649 | - else |
|
636 | + } else |
|
650 | 637 | { |
651 | 638 | preg_match('#true|false|\.#i', $match[4], $type); |
652 | 639 | |
@@ -708,8 +695,7 @@ discard block |
||
708 | 695 | { |
709 | 696 | $negate_expr = true; |
710 | 697 | $expr_type = array_shift($tokens); |
711 | - } |
|
712 | - else |
|
698 | + } else |
|
713 | 699 | { |
714 | 700 | $expr_type = $first_token; |
715 | 701 | } |
@@ -722,8 +708,7 @@ discard block |
||
722 | 708 | $expr_end++; |
723 | 709 | $expr_arg = $tokens[$expr_end++]; |
724 | 710 | $expr = "!(($is_arg / $expr_arg) % $expr_arg)"; |
725 | - } |
|
726 | - else |
|
711 | + } else |
|
727 | 712 | { |
728 | 713 | $expr = "!($is_arg & 1)"; |
729 | 714 | } |
@@ -735,8 +720,7 @@ discard block |
||
735 | 720 | $expr_end++; |
736 | 721 | $expr_arg = $tokens[$expr_end++]; |
737 | 722 | $expr = "(($is_arg / $expr_arg) % $expr_arg)"; |
738 | - } |
|
739 | - else |
|
723 | + } else |
|
740 | 724 | { |
741 | 725 | $expr = "($is_arg & 1)"; |
742 | 726 | } |
@@ -818,12 +802,10 @@ discard block |
||
818 | 802 | $varref .= '[$_' . $blocks[$blockcount] . '_i]'; |
819 | 803 | } |
820 | 804 | return $varref; |
821 | - } |
|
822 | - else if ($include_last_iterator) |
|
805 | + } else if ($include_last_iterator) |
|
823 | 806 | { |
824 | 807 | return '$_'. $blocks[$blockcount] . '_val'; |
825 | - } |
|
826 | - else |
|
808 | + } else |
|
827 | 809 | { |
828 | 810 | return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
829 | 811 | } |
@@ -151,6 +151,9 @@ |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | |
154 | + /** |
|
155 | + * @param integer $user_id |
|
156 | + */ |
|
154 | 157 | public function __construct($user_id) { |
155 | 158 | $this->user_change($user_id); |
156 | 159 | } |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | |
123 | 123 | $update_cache = false; |
124 | 124 | |
125 | - if(!empty($this->to_write)) { |
|
126 | - foreach($this->to_write as $key => $cork) { |
|
125 | + if (!empty($this->to_write)) { |
|
126 | + foreach ($this->to_write as $key => $cork) { |
|
127 | 127 | $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД |
128 | - $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')"; |
|
128 | + $this->to_write[$key] = "({$this->user_id}, '".db_escape($key)."', '".db_escape($value)."')"; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | classSupernova::$gc->db->doReplaceValuesDeprecated( |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | $update_cache = true; |
144 | 144 | } |
145 | 145 | |
146 | - if(!empty($this->to_delete)) { |
|
147 | - foreach($this->to_delete as $key => &$value) { |
|
148 | - $value = is_string($key) ? "'". db_escape($key) . "'" : $key; |
|
146 | + if (!empty($this->to_delete)) { |
|
147 | + foreach ($this->to_delete as $key => &$value) { |
|
148 | + $value = is_string($key) ? "'".db_escape($key)."'" : $key; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | classSupernova::$db->doDeleteDanger( |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | 'player_id' => $this->user_id, |
155 | 155 | ), |
156 | 156 | array( |
157 | - "`option_id` IN (" . implode(',', $this->to_delete) . ")", |
|
157 | + "`option_id` IN (".implode(',', $this->to_delete).")", |
|
158 | 158 | ) |
159 | 159 | ); |
160 | 160 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $update_cache = true; |
163 | 163 | } |
164 | 164 | |
165 | - if($update_cache) { |
|
165 | + if ($update_cache) { |
|
166 | 166 | $field_name = $this->cached_name(); |
167 | 167 | classSupernova::$cache->$field_name = $this->data; |
168 | 168 | } |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | $this->load(); |
182 | 182 | } |
183 | 183 | protected function cached_name() { |
184 | - return 'options_' . $this->user_id; |
|
184 | + return 'options_'.$this->user_id; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | protected function load() { |
188 | - if($this->loaded) { |
|
188 | + if ($this->loaded) { |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | $this->to_write = array(); |
194 | 194 | $this->to_delete = array(); |
195 | 195 | |
196 | - if(!$this->user_id) { |
|
196 | + if (!$this->user_id) { |
|
197 | 197 | $this->loaded = true; |
198 | 198 | return; |
199 | 199 | } |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | $field_name = $this->cached_name(); |
202 | 202 | $a_data = classSupernova::$cache->$field_name; |
203 | 203 | |
204 | - if(!empty($a_data)) { |
|
204 | + if (!empty($a_data)) { |
|
205 | 205 | $this->data = array_replace_recursive($this->data, $a_data); |
206 | 206 | return; |
207 | 207 | } |
208 | 208 | |
209 | 209 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
210 | - while($row = db_fetch($query)) { |
|
210 | + while ($row = db_fetch($query)) { |
|
211 | 211 | // $this->data[$row['option_id']] = $row['value']; |
212 | 212 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
213 | 213 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | protected function cached_name() { |
287 | - return 'options_' . $this->user_id; |
|
287 | + return 'options_'.$this->user_id; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | // TODO - serialize/unserialize options |
@@ -292,14 +292,14 @@ discard block |
||
292 | 292 | // Если в массиве индекса только один элемент - значит это просто индекс |
293 | 293 | is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false; |
294 | 294 | |
295 | - if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
295 | + if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
296 | 296 | $this->load(); |
297 | 297 | } |
298 | 298 | |
299 | - if(is_array($option_id)) { |
|
299 | + if (is_array($option_id)) { |
|
300 | 300 | $result = $this->data; |
301 | - foreach($option_id as $sub_key) { |
|
302 | - if(!isset($result) || !isset($result[$sub_key])) { |
|
301 | + foreach ($option_id as $sub_key) { |
|
302 | + if (!isset($result) || !isset($result[$sub_key])) { |
|
303 | 303 | $result = null; |
304 | 304 | break; |
305 | 305 | } |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | * @param null|mixed $value |
318 | 318 | */ |
319 | 319 | public function __set($option, $value = null) { |
320 | - if(empty($option) || !$this->user_id) { |
|
320 | + if (empty($option) || !$this->user_id) { |
|
321 | 321 | return; |
322 | 322 | } |
323 | 323 | |
324 | 324 | // Если в массиве индекса только один элемент - значит это просто индекс |
325 | - if(is_array($option) && count($option) == 1) { |
|
325 | + if (is_array($option) && count($option) == 1) { |
|
326 | 326 | // Разворачиваем его в индекс |
327 | 327 | $option = array(reset($option) => $value); |
328 | 328 | unset($value); |
@@ -331,13 +331,13 @@ discard block |
||
331 | 331 | |
332 | 332 | $to_write = array(); |
333 | 333 | // Адресация многомерного массива через массив индексов в $option |
334 | - if(is_array($option) && isset($value)) { |
|
334 | + if (is_array($option) && isset($value)) { |
|
335 | 335 | $a_data = &$this->data; |
336 | - foreach($option as $option_id) { |
|
336 | + foreach ($option as $option_id) { |
|
337 | 337 | !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false; |
338 | 338 | $a_data = &$a_data[$option_id]; |
339 | 339 | } |
340 | - if($a_data != $value) { |
|
340 | + if ($a_data != $value) { |
|
341 | 341 | $a_data = $value; |
342 | 342 | $to_write[reset($option)] = null; |
343 | 343 | } |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | // Пакетная запись из массива ключ -> значение |
346 | 346 | !is_array($option) ? $option = array($option => $value) : false; |
347 | 347 | |
348 | - foreach($option as $option_id => $option_value) { |
|
349 | - if($this->data[$option_id] !== $option_value) { |
|
348 | + foreach ($option as $option_id => $option_value) { |
|
349 | + if ($this->data[$option_id] !== $option_value) { |
|
350 | 350 | // TODO - вынести отдельно в обработчик |
351 | - if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
352 | - sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
|
351 | + if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
352 | + sn_setcookie(SN_COOKIE.'_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | $this->data[$option_id] = $option_value; |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | - if(!empty($to_write)) { |
|
361 | + if (!empty($to_write)) { |
|
362 | 362 | $field_name = $this->cached_name(); |
363 | 363 | classSupernova::$cache->$field_name = $this->data; |
364 | 364 | |
365 | - foreach($to_write as $option_id => &$option_value) { |
|
365 | + foreach ($to_write as $option_id => &$option_value) { |
|
366 | 366 | $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД |
367 | - $to_write[$option_id] = "({$this->user_id}, '" . db_escape($option_id) . "', '" . db_escape($option_value) . "')"; |
|
367 | + $to_write[$option_id] = "({$this->user_id}, '".db_escape($option_id)."', '".db_escape($option_value)."')"; |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | classSupernova::$gc->db->doReplaceValuesDeprecated( |
@@ -380,26 +380,26 @@ discard block |
||
380 | 380 | } |
381 | 381 | |
382 | 382 | protected function load() { |
383 | - if($this->loaded) { |
|
383 | + if ($this->loaded) { |
|
384 | 384 | return; |
385 | 385 | } |
386 | 386 | |
387 | 387 | $this->data = $this->defaults; |
388 | 388 | |
389 | - if(!$this->user_id) { |
|
389 | + if (!$this->user_id) { |
|
390 | 390 | return; |
391 | 391 | } |
392 | 392 | |
393 | 393 | $field_name = $this->cached_name(); |
394 | 394 | $a_data = classSupernova::$cache->$field_name; |
395 | 395 | |
396 | - if(!empty($a_data)) { |
|
396 | + if (!empty($a_data)) { |
|
397 | 397 | $this->data = array_replace($this->data, $a_data); |
398 | 398 | return; |
399 | 399 | } |
400 | 400 | |
401 | 401 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
402 | - while($row = db_fetch($query)) { |
|
402 | + while ($row = db_fetch($query)) { |
|
403 | 403 | // $this->data[$row['option_id']] = $row['value']; |
404 | 404 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
405 | 405 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | return $this->__get($offset); |
416 | 416 | } |
417 | 417 | public function offsetSet($offset, $value) { |
418 | - if(!is_null($offset)) { |
|
418 | + if (!is_null($offset)) { |
|
419 | 419 | // $this->data[$offset] = $value; |
420 | 420 | $this->__set($offset, $value); |
421 | 421 | } else { |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | !is_array($offset) ? $offset = array($offset) : false; |
39 | 39 | |
40 | 40 | $current_leaf = $this->__get(reset($offset)); |
41 | - while(($leaf_index = next($offset)) !== false) { |
|
42 | - if(!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
41 | + while (($leaf_index = next($offset)) !== false) { |
|
42 | + if (!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
43 | 43 | unset($current_leaf); |
44 | 44 | break; |
45 | 45 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | |
65 | 65 | !is_array($offset) ? $offset = array($offset) : false; |
66 | 66 | |
67 | - if($this->offsetExists($offset)) { |
|
67 | + if ($this->offsetExists($offset)) { |
|
68 | 68 | $result = $this->__get(reset($offset)); |
69 | - while(($leaf_index = next($offset)) !== false) { |
|
69 | + while (($leaf_index = next($offset)) !== false) { |
|
70 | 70 | $result = $result[$leaf_index]; |
71 | 71 | } |
72 | 72 | } |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function offsetSet($offset, $value = null) { |
93 | 93 | // Если нет никакого индекса - значит нечего записывать |
94 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
94 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | 98 | // Если в массиве индекса только один элемент - значит это просто индекс |
99 | - if(is_array($offset) && count($offset) == 1) { |
|
99 | + if (is_array($offset) && count($offset) == 1) { |
|
100 | 100 | // Разворачиваем его в индекс |
101 | 101 | $offset = array(reset($offset) => $value); |
102 | 102 | unset($value); |
@@ -104,20 +104,20 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | // Адресация многомерного массива через массив индексов в $option |
107 | - if(is_array($offset) && isset($value)) { |
|
107 | + if (is_array($offset) && isset($value)) { |
|
108 | 108 | // TODO - а не переделать ли это всё на __isset() ?? |
109 | 109 | //pdump($offset, '$offset'); |
110 | 110 | //pdump($value, '$value'); |
111 | 111 | // Вытаскиваем корневой элемент |
112 | 112 | $root = $this->__get(reset($offset)); |
113 | 113 | $current_leaf = &$root; |
114 | - while(($leaf_index = next($offset)) !== false) { |
|
114 | + while (($leaf_index = next($offset)) !== false) { |
|
115 | 115 | !is_array($current_leaf[$leaf_index]) ? $current_leaf[$leaf_index] = array() : false; |
116 | 116 | $current_leaf = &$current_leaf[$leaf_index]; |
117 | 117 | } |
118 | 118 | //pdump($current_leaf, '$current_leaf'); |
119 | 119 | //pdump($value, '$value'); |
120 | - if($current_leaf != $value) { |
|
120 | + if ($current_leaf != $value) { |
|
121 | 121 | $current_leaf = $value; |
122 | 122 | //pdump(reset($offset), 'reset($offset)'); |
123 | 123 | //pdump($root, '$root'); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | // Пакетная запись из массива ключ -> значение |
129 | 129 | !is_array($offset) ? $offset = array($offset => $value) : false; |
130 | 130 | |
131 | - foreach($offset as $key => $value) { |
|
131 | + foreach ($offset as $key => $value) { |
|
132 | 132 | $this->__get($key) !== $value ? $this->__set($key, $value) : false; |
133 | 133 | } |
134 | 134 | } |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function offsetUnset($offset) { |
151 | 151 | // Если нет никакого индекса - значит нечего записывать |
152 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
152 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | 156 | !is_array($offset) ? $offset = array($offset) : false; |
157 | 157 | |
158 | - if($this->offsetExists($offset)) { |
|
158 | + if ($this->offsetExists($offset)) { |
|
159 | 159 | //pdump($offset); |
160 | 160 | // Перематываем массив в конец |
161 | 161 | $key_to_delete = end($offset); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | //pdump($key_to_delete, '$key_to_delete'); |
164 | 164 | $parent_offset = $offset; |
165 | 165 | array_pop($parent_offset); |
166 | - if(!count($parent_offset)) { |
|
166 | + if (!count($parent_offset)) { |
|
167 | 167 | // В массиве был один элемент - мы удаляем в корне. Просто удаляем элемент |
168 | 168 | $this->__unset($key_to_delete); |
169 | 169 | } else { |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | 'advGoogleLeftMenuCode' => '(Place here code for banner)', |
191 | 191 | |
192 | 192 | // Alliance bonus calculations |
193 | - 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
193 | + 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
194 | 194 | 'ali_bonus_brackets' => 10, // Brackets count for ALI_BONUS_BY_RANK |
195 | - 'ali_bonus_brackets_divisor' => 10,// Bonus divisor for ALI_BONUS_BY_RANK |
|
195 | + 'ali_bonus_brackets_divisor' => 10, // Bonus divisor for ALI_BONUS_BY_RANK |
|
196 | 196 | 'ali_bonus_divisor' => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS |
197 | 197 | 'ali_bonus_members' => 10, // Minumum alliace size to start using bonus |
198 | 198 | |
@@ -223,25 +223,25 @@ discard block |
||
223 | 223 | 'deuterium_basic_income' => 0, |
224 | 224 | 'eco_scale_storage' => 1, |
225 | 225 | 'eco_stockman_fleet' => '', // Black Market - Starting amount of s/h ship merchant to sell |
226 | - 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
226 | + 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
227 | 227 | 'empire_mercenary_base_period' => PERIOD_MONTH, // Base |
228 | 228 | 'empire_mercenary_temporary' => 0, // Temporary empire-wide mercenaries |
229 | 229 | 'energy_basic_income' => 0, |
230 | 230 | |
231 | 231 | // Bashing protection settings |
232 | - 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
233 | - 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
234 | - 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
235 | - 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
236 | - 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
232 | + 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
233 | + 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
234 | + 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
235 | + 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
236 | + 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
237 | 237 | |
238 | 238 | 'Fleet_Cdr' => 30, |
239 | 239 | 'fleet_speed' => 1, |
240 | 240 | |
241 | 241 | 'fleet_update_interval' => 4, |
242 | 242 | |
243 | - 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
244 | - 'game_counter' => 0, // Does built-in page hit counter is on? |
|
243 | + 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
244 | + 'game_counter' => 0, // Does built-in page hit counter is on? |
|
245 | 245 | // Defaults |
246 | 246 | 'game_default_language' => 'ru', |
247 | 247 | 'game_default_skin' => 'skins/EpicBlue/', |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | 'game_maxSystem' => 199, |
256 | 256 | 'game_maxPlanet' => 15, |
257 | 257 | // Game global settings |
258 | - 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
258 | + 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
259 | 259 | 'game_name' => 'SuperNova', // Server name (would be on banners and on top of left menu) |
260 | 260 | |
261 | 261 | 'game_news_actual' => 259200, // How long announcement would be marked as "New". In seconds. Default - 3 days |
262 | - 'game_news_overview' => 3, // How much last news to show in Overview page |
|
262 | + 'game_news_overview' => 3, // How much last news to show in Overview page |
|
263 | 263 | // Noob protection |
264 | - 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
264 | + 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
265 | 265 | 'game_noob_points' => 5000, // Below this point user threated as noob. 0 to disable |
266 | 266 | |
267 | 267 | 'game_multiaccount_enabled' => 0, // 1 - allow interactions for players with same IP (multiaccounts) |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | 'payment_currency_exchange_wmu' => 30, |
312 | 312 | 'payment_currency_exchange_wmz' => 1, |
313 | 313 | |
314 | - 'payment_lot_price' => 1, // Lot price in default currency |
|
315 | - 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
314 | + 'payment_lot_price' => 1, // Lot price in default currency |
|
315 | + 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
316 | 316 | |
317 | 317 | 'planet_teleport_cost' => 50000, // |
318 | 318 | 'planet_teleport_timeout' => 86400, // |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | 'resource_multiplier' => 1, |
331 | 331 | |
332 | 332 | //Roleplay system |
333 | - 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
333 | + 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
334 | 334 | 'rpg_bonus_minimum' => 10000, // Minimum DM ammount for starting paying bonuses to affiliate |
335 | 335 | |
336 | 336 | // Black Market - General |
@@ -1,5 +1,4 @@ |
||
1 | 1 | <?php |
2 | -use DBStatic\DBStaticUser; |
|
3 | 2 | |
4 | 3 | /** |
5 | 4 | * |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | 'checkSpeedPercentOld' => FLIGHT_FLEET_SPEED_WRONG, |
15 | 15 | 'checkTargetInUniverse' => FLIGHT_VECTOR_BEYOND_UNIVERSE, |
16 | 16 | 'checkTargetNotSource' => FLIGHT_VECTOR_SAME_SOURCE, |
17 | - 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, // tODO |
|
17 | + 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, // tODO |
|
18 | 18 | 'checkTargetNoVacation' => FLIGHT_PLAYER_VACATION, |
19 | 19 | 'checkFleetNotEmpty' => FLIGHT_SHIPS_NO_SHIPS, |
20 | 20 | // 'checkUnitsPositive' => FLIGHT_SHIPS_NEGATIVE, // Unused - 'cause it's not allowed to put negative units into Unit class |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | $checkResult = call_user_func(array($this, $condition)); |
135 | 135 | defined('DEBUG_FLEET_MISSION_VALIDATE_DUMP_STEPS') |
136 | - ? pdump($action, $condition . ' ' . ($checkResult ? 'TRUE' : 'FALSE')) : false; |
|
136 | + ? pdump($action, $condition.' '.($checkResult ? 'TRUE' : 'FALSE')) : false; |
|
137 | 137 | |
138 | 138 | // If check failed and there no alternative actions - throw exception |
139 | 139 | // Shortcut ACTION => FAIL_STATUS instead of ACTION => array(false => FAIL_STATUS) |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $this->checkMissionRestrictions($action); |
157 | 157 | } else { |
158 | 158 | // No - then just performing action |
159 | - if($exception) { |
|
159 | + if ($exception) { |
|
160 | 160 | throw new ExceptionFleetInvalid($action, $action); |
161 | 161 | } else { |
162 | 162 | return $action; |
@@ -598,10 +598,10 @@ discard block |
||
598 | 598 | protected function checkMissionPrefix($name, $prefix) { |
599 | 599 | $result = false; |
600 | 600 | if (strpos($name, $prefix) === 0) { |
601 | - $mission = 'MT_' . strtoupper(substr($name, strlen($prefix))); |
|
601 | + $mission = 'MT_'.strtoupper(substr($name, strlen($prefix))); |
|
602 | 602 | if (!defined($mission)) { |
603 | 603 | // TODO - Ну, как-то получше это обделать |
604 | - throw new Exception('Mission type "' . $mission . '" is not defined', FLIGHT_MISSION_UNKNOWN); |
|
604 | + throw new Exception('Mission type "'.$mission.'" is not defined', FLIGHT_MISSION_UNKNOWN); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | $result = constant($mission); |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @throws ExceptionFleetInvalid |
35 | 35 | */ |
36 | 36 | public static function build($missionType, $fleet) { |
37 | - if (!empty(self::$missions[$missionType]) && class_exists($className = __NAMESPACE__ . '\\' . self::$missions[$missionType])) { |
|
37 | + if (!empty(self::$missions[$missionType]) && class_exists($className = __NAMESPACE__.'\\'.self::$missions[$missionType])) { |
|
38 | 38 | $result = new $className($fleet); |
39 | 39 | } else { |
40 | 40 | throw new ExceptionFleetInvalid("Mission type {$missionType} unknown", FLIGHT_MISSION_UNKNOWN); |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | function loadModuleRootConfig() { |
75 | - require SN_ROOT_PHYSICAL . 'config.php'; |
|
75 | + require SN_ROOT_PHYSICAL.'config.php'; |
|
76 | 76 | |
77 | - $module_config_array = get_class($this) . '_config'; |
|
78 | - if(!empty($$module_config_array) && is_array($$module_config_array)) { |
|
77 | + $module_config_array = get_class($this).'_config'; |
|
78 | + if (!empty($$module_config_array) && is_array($$module_config_array)) { |
|
79 | 79 | $this->config = $$module_config_array; |
80 | 80 | |
81 | 81 | return true; |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | |
94 | 94 | // TODO: Load configuration from DB. Manifest setting |
95 | 95 | // Trying to load configuration from file |
96 | - if(!$config_exists = $this->loadModuleRootConfig()) { |
|
96 | + if (!$config_exists = $this->loadModuleRootConfig()) { |
|
97 | 97 | // Конфигурация может лежать в config_path в манифеста или в корне модуля |
98 | - if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) { |
|
98 | + if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'].'/config.php')) { |
|
99 | 99 | $config_exists = true; |
100 | - } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) { |
|
100 | + } elseif (file_exists($config_filename = dirname($filename).'/config.php')) { |
|
101 | 101 | $config_exists = true; |
102 | 102 | } |
103 | 103 | |
104 | - if($config_exists) { |
|
104 | + if ($config_exists) { |
|
105 | 105 | include($config_filename); |
106 | - $module_config_array = $class_module_name . '_config'; |
|
106 | + $module_config_array = $class_module_name.'_config'; |
|
107 | 107 | $this->config = $$module_config_array; |
108 | 108 | } |
109 | 109 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | // Checking module status - is it installed and active |
120 | 120 | $this->check_status(); |
121 | - if(!$this->manifest['active']) { |
|
121 | + if (!$this->manifest['active']) { |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | |
139 | 139 | protected function setSystemConstants() { |
140 | 140 | // Setting constants - if any |
141 | - if(empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
141 | + if (empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | - foreach($this->manifest['constants'] as $constant_name => $constant_value) { |
|
145 | + foreach ($this->manifest['constants'] as $constant_name => $constant_value) { |
|
146 | 146 | !defined($constant_name) ? define($constant_name, $constant_value) : false; |
147 | 147 | } |
148 | 148 | } |
@@ -154,48 +154,48 @@ discard block |
||
154 | 154 | // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays) |
155 | 155 | // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]' |
156 | 156 | $this->manifest['vars'] = $this->__assign_vars(); |
157 | - if(empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
157 | + if (empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | 161 | $vars_assigned = array(); |
162 | - foreach($this->manifest['vars'] as $var_name => $var_value) { |
|
162 | + foreach ($this->manifest['vars'] as $var_name => $var_value) { |
|
163 | 163 | $sub_vars = explode('[', str_replace(']', '', $var_name)); |
164 | 164 | $var_name = $sub_vars[0]; |
165 | 165 | |
166 | - if(!isset($vars_assigned[$var_name])) { |
|
166 | + if (!isset($vars_assigned[$var_name])) { |
|
167 | 167 | $vars_assigned[$var_name] = true; |
168 | 168 | global $$var_name; |
169 | 169 | } |
170 | 170 | |
171 | 171 | $pointer = &$$var_name; |
172 | - if(($n = count($sub_vars)) > 1) { |
|
173 | - for($i = 1; $i < $n; $i++) { |
|
174 | - if(defined($sub_vars[$i])) { |
|
172 | + if (($n = count($sub_vars)) > 1) { |
|
173 | + for ($i = 1; $i < $n; $i++) { |
|
174 | + if (defined($sub_vars[$i])) { |
|
175 | 175 | $sub_vars[$i] = constant($sub_vars[$i]); |
176 | 176 | } |
177 | 177 | |
178 | - if(!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
178 | + if (!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
179 | 179 | $pointer[$sub_vars[$i]] = array(); |
180 | 180 | } |
181 | 181 | $pointer = &$pointer[$sub_vars[$i]]; |
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | - if(!isset($pointer) || !is_array($pointer)) { |
|
185 | + if (!isset($pointer) || !is_array($pointer)) { |
|
186 | 186 | $pointer = $var_value; |
187 | - } elseif(is_array($$var_name)) { |
|
187 | + } elseif (is_array($$var_name)) { |
|
188 | 188 | $pointer = array_merge_recursive_numeric($pointer, $var_value); |
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | 193 | protected function mergeMenu(&$sn_menu_extra, &$menu_patch) { |
194 | - if(!is_array($menu_patch)) { |
|
194 | + if (!is_array($menu_patch)) { |
|
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
198 | - foreach($menu_patch as $menu_item_name => $menu_item_data) { |
|
198 | + foreach ($menu_patch as $menu_item_name => $menu_item_data) { |
|
199 | 199 | $sn_menu_extra[$menu_item_name] = $menu_item_data; |
200 | 200 | } |
201 | 201 | } |
@@ -204,34 +204,34 @@ discard block |
||
204 | 204 | // Overriding function if any |
205 | 205 | sn_sys_handler_add(classSupernova::$functions, $this->manifest['functions'], $this); |
206 | 206 | |
207 | - foreach(classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
207 | + foreach (classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
208 | 208 | sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type); |
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | 212 | protected function mergeNavbarButton() { |
213 | - if(empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
213 | + if (empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
214 | 214 | return; |
215 | 215 | } |
216 | 216 | |
217 | - foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
217 | + foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
218 | 218 | classSupernova::$sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative; |
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | 222 | protected function mergeI18N() { |
223 | 223 | $arrayName = 'i18n'; |
224 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
224 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
229 | - foreach($contentList as &$i18n_file_data) { |
|
230 | - if(is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
228 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
229 | + foreach ($contentList as &$i18n_file_data) { |
|
230 | + if (is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
231 | 231 | $i18n_file_data['path'] = $this->manifest['root_relative']; |
232 | 232 | } |
233 | 233 | } |
234 | - if(!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
234 | + if (!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
235 | 235 | classSupernova::$sn_mvc[$arrayName][$pageName] = array(); |
236 | 236 | } |
237 | 237 | classSupernova::$sn_mvc[$arrayName][$pageName] += $contentList; |
@@ -239,13 +239,13 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | protected function mergeArraySpecial($arrayName) { |
242 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
242 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
243 | 243 | return; |
244 | 244 | } |
245 | 245 | |
246 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
246 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
247 | 247 | !isset(classSupernova::$sn_mvc[$arrayName][$pageName]) ? classSupernova::$sn_mvc[$arrayName][$pageName] = array() : false; |
248 | - foreach($contentList as $contentName => &$content) { |
|
248 | + foreach ($contentList as $contentName => &$content) { |
|
249 | 249 | classSupernova::$sn_mvc[$arrayName][$pageName][$contentName] = $content; |
250 | 250 | } |
251 | 251 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $load_order[$loaded_module_name] = $level; |
300 | 300 | } |
301 | 301 | } |
302 | - } while($prev_order != $load_order); |
|
302 | + } while ($prev_order != $load_order); |
|
303 | 303 | |
304 | 304 | asort($load_order); |
305 | 305 |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
4 | 4 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
7 | 7 | $template = gettemplate('ali_search', true); |
8 | 8 | |
9 | 9 | $ali_search_text = sys_get_param_str('searchtext'); |
10 | -if($ali_search_text) { |
|
10 | +if ($ali_search_text) { |
|
11 | 11 | $template->assign_var('SEARCH_TEXT', $ali_search_text); |
12 | 12 | |
13 | 13 | $search = DBStaticAlly::db_ally_search_by_name_or_tag($ali_search_text); |
14 | - if(classSupernova::$db->db_num_rows($search)) { |
|
15 | - while($ally_row = db_fetch($search)) { |
|
14 | + if (classSupernova::$db->db_num_rows($search)) { |
|
15 | + while ($ally_row = db_fetch($search)) { |
|
16 | 16 | $template->assign_block_vars('alliances', array( |
17 | 17 | 'ID' => $ally_row['id'], |
18 | 18 | 'TAG' => $ally_row['ally_tag'], |