supernova-ws /
SuperNova
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | // Wrappers for functions |
||
| 4 | |||
| 5 | /** |
||
| 6 | * @param $u_dpath |
||
| 7 | * |
||
| 8 | * @return mixed |
||
| 9 | */ |
||
| 10 | function gettemplatename($u_dpath) { |
||
| 11 | static $template_names = array(); |
||
| 12 | |||
| 13 | if(!isset($template_names[$u_dpath])) { |
||
| 14 | $template_names[$u_dpath] = file_exists(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') ? sys_file_read(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') : TEMPLATE_NAME; |
||
| 15 | } |
||
| 16 | |||
| 17 | return $template_names[$u_dpath]; |
||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param $mes |
||
| 22 | * @param string $title |
||
| 23 | * @param string $dest |
||
| 24 | * @param int $time |
||
| 25 | */ |
||
| 26 | function AdminMessage($mes, $title = 'Error', $dest = '', $time = 3) { |
||
| 27 | $page = parsetemplate(gettemplate('admin/message_body'), array('title' => $title, 'mes' => $mes,)); |
||
| 28 | |||
| 29 | display($page, $title, false, ($dest ? "<meta http-equiv=\"refresh\" content=\"{$time};URL=javascript:self.location='{$dest}';\">" : ''), true); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param $mes |
||
| 34 | * @param string $title |
||
| 35 | * @param string $dest |
||
| 36 | * @param int $time |
||
| 37 | * @param bool|true $show_header |
||
| 38 | */ |
||
| 39 | function message($mes, $title = 'Error', $dest = '', $time = 5, $show_header = true) { |
||
| 40 | $template = gettemplate('message_body', true); |
||
| 41 | $template->assign_vars(array( |
||
| 42 | 'title' => $title, |
||
| 43 | 'mes' => $mes, |
||
| 44 | 'DEST' => $dest, |
||
| 45 | )); |
||
| 46 | |||
| 47 | display($template, $title, $show_header, (($dest != '') ? "<meta http-equiv=\"refresh\" content=\"{$time};url={$dest}\">" : ""), false); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param $sn_menu |
||
| 52 | * @param $sn_menu_extra |
||
| 53 | */ |
||
| 54 | function tpl_menu_merge_extra(&$sn_menu, &$sn_menu_extra) { |
||
| 55 | if(empty($sn_menu) || empty($sn_menu_extra)) { |
||
| 56 | return; |
||
| 57 | } |
||
| 58 | |||
| 59 | foreach($sn_menu_extra as $menu_item_id => $menu_item) { |
||
| 60 | if(empty($menu_item['LOCATION'])) { |
||
| 61 | $sn_menu[$menu_item_id] = $menu_item; |
||
| 62 | continue; |
||
| 63 | } |
||
| 64 | |||
| 65 | $item_location = $menu_item['LOCATION']; |
||
| 66 | unset($menu_item['LOCATION']); |
||
| 67 | |||
| 68 | $is_positioned = $item_location[0]; |
||
| 69 | if($is_positioned == '+' || $is_positioned == '-') { |
||
| 70 | $item_location = substr($item_location, 1); |
||
| 71 | } else { |
||
| 72 | $is_positioned = ''; |
||
| 73 | } |
||
| 74 | |||
| 75 | if($item_location) { |
||
| 76 | $menu_keys = array_keys($sn_menu); |
||
| 77 | $insert_position = array_search($item_location, $menu_keys); |
||
| 78 | if($insert_position === false) { |
||
| 79 | $insert_position = count($sn_menu) - 1; |
||
| 80 | $is_positioned = '+'; |
||
| 81 | $item_location = ''; |
||
| 82 | } |
||
| 83 | } else { |
||
| 84 | $insert_position = $is_positioned == '-' ? 0 : count($sn_menu); |
||
| 85 | } |
||
| 86 | |||
| 87 | $insert_position += $is_positioned == '+' ? 1 : 0; |
||
| 88 | $spliced = array_splice($sn_menu, $insert_position, count($sn_menu) - $insert_position); |
||
| 89 | $sn_menu[$menu_item_id] = $menu_item; |
||
| 90 | |||
| 91 | if(!$is_positioned && $item_location) { |
||
| 92 | unset($spliced[$item_location]); |
||
| 93 | } |
||
| 94 | $sn_menu = array_merge($sn_menu, $spliced); |
||
| 95 | } |
||
| 96 | |||
| 97 | $sn_menu_extra = array(); |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @param array $sn_menu |
||
| 102 | * @param template $template |
||
| 103 | */ |
||
| 104 | function tpl_menu_assign_to_template(&$sn_menu, &$template) { |
||
| 105 | if(empty($sn_menu) || !is_array($sn_menu)) { |
||
| 106 | return; |
||
| 107 | } |
||
| 108 | |||
| 109 | foreach($sn_menu as $menu_item_id => $menu_item) { |
||
| 110 | if(!$menu_item) { |
||
| 111 | continue; |
||
| 112 | } |
||
| 113 | |||
| 114 | if(is_string($menu_item_id)) { |
||
| 115 | $menu_item['ID'] = $menu_item_id; |
||
| 116 | } |
||
| 117 | |||
| 118 | if($menu_item['TYPE'] == 'lang') { |
||
| 119 | $lang_string = &classLocale::$lang; |
||
| 120 | if(preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) { |
||
| 121 | for($i = 1; $i < count($matches); $i++) { |
||
| 122 | if(defined($matches[$i])) { |
||
| 123 | $matches[$i] = constant($matches[$i]); |
||
| 124 | } |
||
| 125 | $lang_string = &$lang_string[$matches[$i]]; |
||
| 126 | } |
||
| 127 | } |
||
| 128 | $menu_item['ITEM'] = $lang_string && is_string($lang_string) ? $lang_string : "{L_{$menu_item['ITEM']}}"; |
||
| 129 | } |
||
| 130 | |||
| 131 | $menu_item['ALT'] = htmlentities($menu_item['ALT']); |
||
| 132 | $menu_item['TITLE'] = htmlentities($menu_item['TITLE']); |
||
| 133 | |||
| 134 | if(!empty($menu_item['ICON'])) { |
||
| 135 | if(is_string($menu_item['ICON'])) { |
||
| 136 | $menu_item['ICON_PATH'] = $menu_item['ICON']; |
||
| 137 | } else { |
||
| 138 | $menu_item['ICON'] = $menu_item_id; |
||
| 139 | } |
||
| 140 | } |
||
| 141 | |||
| 142 | $template->assign_block_vars('menu', $menu_item); |
||
| 143 | } |
||
| 144 | } |
||
| 145 | |||
| 146 | /** |
||
| 147 | * @return template |
||
| 148 | */ |
||
| 149 | function tpl_render_menu() { |
||
| 150 | global $user, $template_result, $sn_menu_admin_extra, $sn_menu_admin, $sn_menu, $sn_menu_extra; |
||
| 151 | |||
| 152 | lng_include('admin'); |
||
| 153 | |||
| 154 | $template = gettemplate('menu', true); |
||
| 155 | $template->assign_recursive($template_result); |
||
| 156 | |||
| 157 | $template->assign_vars(array( |
||
| 158 | 'USER_AUTHLEVEL' => $user['authlevel'], |
||
| 159 | 'USER_AUTHLEVEL_NAME' => classLocale::$lang['user_level'][$user['authlevel']], |
||
| 160 | // 'USER_IMPERSONATOR' => $template_result[F_IMPERSONATE_STATUS] != LOGIN_UNDEFINED, |
||
| 161 | 'PAYMENT' => sn_module_get_active_count('payment'), |
||
| 162 | 'MENU_START_HIDE' => !empty($_COOKIE[SN_COOKIE . '_menu_hidden']) || defined('SN_GOOGLE'), |
||
| 163 | )); |
||
| 164 | |||
| 165 | if(isset($template_result['MENU_CUSTOMIZE'])) { |
||
| 166 | $template->assign_vars(array( |
||
| 167 | 'PLAYER_OPTION_MENU_SHOW_ON_BUTTON' => classSupernova::$user_options[PLAYER_OPTION_MENU_SHOW_ON_BUTTON], |
||
| 168 | 'PLAYER_OPTION_MENU_HIDE_ON_BUTTON' => classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_ON_BUTTON], |
||
| 169 | 'PLAYER_OPTION_MENU_HIDE_ON_LEAVE' => classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_ON_LEAVE], |
||
| 170 | 'PLAYER_OPTION_MENU_UNPIN_ABSOLUTE' => classSupernova::$user_options[PLAYER_OPTION_MENU_UNPIN_ABSOLUTE], |
||
| 171 | 'PLAYER_OPTION_MENU_ITEMS_AS_BUTTONS' => classSupernova::$user_options[PLAYER_OPTION_MENU_ITEMS_AS_BUTTONS], |
||
| 172 | 'PLAYER_OPTION_MENU_WHITE_TEXT' => classSupernova::$user_options[PLAYER_OPTION_MENU_WHITE_TEXT], |
||
| 173 | 'PLAYER_OPTION_MENU_OLD' => classSupernova::$user_options[PLAYER_OPTION_MENU_OLD], |
||
| 174 | 'PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON' => empty($_COOKIE[SN_COOKIE . '_menu_hidden']) && !defined('SN_GOOGLE') |
||
| 175 | ? classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON] : 1, |
||
| 176 | )); |
||
| 177 | } |
||
| 178 | |||
| 179 | if(defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) { |
||
| 180 | tpl_menu_merge_extra($sn_menu_admin, $sn_menu_admin_extra); |
||
| 181 | tpl_menu_assign_to_template($sn_menu_admin, $template); |
||
| 182 | } else { |
||
| 183 | tpl_menu_merge_extra($sn_menu, $sn_menu_extra); |
||
| 184 | tpl_menu_assign_to_template($sn_menu, $template); |
||
| 185 | } |
||
| 186 | |||
| 187 | return $template; |
||
| 188 | } |
||
| 189 | |||
| 190 | /** |
||
| 191 | * @param template|string $page |
||
| 192 | * @param string $title |
||
| 193 | * @param bool|true $isDisplayTopNav |
||
| 194 | * @param string $metatags |
||
| 195 | * @param bool|false $AdminPage |
||
| 196 | * @param bool|true $isDisplayMenu |
||
| 197 | * |
||
| 198 | * @return mixed |
||
| 199 | */ |
||
| 200 | function display($page, $title = '', $isDisplayTopNav = true, $metatags = '', $AdminPage = false, $isDisplayMenu = true, $exitStatus = true) { |
||
| 201 | return sn_function_call(__FUNCTION__, array($page, $title, $isDisplayTopNav, $metatags, $isDisplayMenu, $exitStatus)); |
||
| 202 | } |
||
| 203 | |||
| 204 | /** |
||
| 205 | * @param template|string $page |
||
| 206 | * @param string $title |
||
| 207 | * @param bool|true $isDisplayTopNav |
||
| 208 | * @param string $metatags |
||
| 209 | * @param bool|false $AdminPage |
||
| 210 | * @param bool|true $isDisplayMenu |
||
| 211 | * @param bool|int|string $exitStatus - Код или сообщение выхода |
||
| 212 | */ |
||
| 213 | function sn_display($page, $title = '', $isDisplayTopNav = true, $metatags = '', $isDisplayMenu = true, $exitStatus = true) { |
||
| 214 | global $debug, $user, $planetrow, $config, $template_result, $sn_page_name; |
||
| 215 | |||
| 216 | $in_admin = defined('IN_ADMIN') && IN_ADMIN === true; |
||
| 217 | $is_login = defined('LOGIN_LOGOUT') && LOGIN_LOGOUT === true; |
||
| 218 | |||
| 219 | if(is_object($page)) { |
||
| 220 | isset($page->_rootref['MENU']) ? $isDisplayMenu = $page->_rootref['MENU'] : false; |
||
| 221 | isset($page->_rootref['NAVBAR']) ? $isDisplayTopNav = $page->_rootref['NAVBAR'] : false; |
||
| 222 | |||
| 223 | !$title && !empty($page->_rootref['PAGE_HEADER']) ? $title = $page->_rootref['PAGE_HEADER'] : false; |
||
| 224 | !isset($page->_rootref['PAGE_HEADER']) && $title ? $page->assign_var('PAGE_HEADER', $title) : false; |
||
| 225 | } |
||
| 226 | |||
| 227 | if(empty($user['id']) || !is_numeric($user['id'])) { |
||
| 228 | $isDisplayMenu = false; |
||
| 229 | $isDisplayTopNav = false; |
||
| 230 | } |
||
| 231 | |||
| 232 | !empty(classSupernova::$sn_mvc['view']['']) && execute_hooks(classSupernova::$sn_mvc['view'][''], $page, 'view', ''); |
||
| 233 | |||
| 234 | // Global header |
||
| 235 | $user_time_diff = playerTimeDiff::user_time_diff_get(); |
||
| 236 | $user_time_measured_unix = intval(isset($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) ? strtotime($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) : 0); |
||
| 237 | |||
| 238 | $font_size = !empty($_COOKIE[SN_COOKIE_F]) ? $_COOKIE[SN_COOKIE_F] : classSupernova::$user_options[PLAYER_OPTION_BASE_FONT_SIZE]; |
||
| 239 | View Code Duplication | if(strpos($font_size, '%') !== false) { |
|
| 240 | // Размер шрифта в процентах |
||
| 241 | $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX) . '%'; |
||
| 242 | } elseif(strpos($font_size, 'px') !== false) { |
||
| 243 | // Размер шрифта в пикселях |
||
| 244 | $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX) . 'px'; |
||
| 245 | } else { |
||
| 246 | // Не мышонка, не лягушка... |
||
| 247 | $font_size = FONT_SIZE_PERCENT_DEFAULT_STRING; |
||
| 248 | } |
||
| 249 | |||
| 250 | $template_result['LOGIN_LOGOUT'] = $is_login; |
||
| 251 | |||
| 252 | $template = gettemplate('_global_header', true); |
||
| 253 | |||
| 254 | if(!empty(classSupernova::$sn_mvc['javascript'])) { |
||
| 255 | View Code Duplication | foreach(classSupernova::$sn_mvc['javascript'] as $page_name => $script_list) { |
|
| 256 | if(empty($page_name) || $page_name == $sn_page_name) { |
||
| 257 | foreach($script_list as $filename => $content) { |
||
| 258 | $template_result['.']['javascript'][] = array( |
||
| 259 | 'FILE' => $filename, |
||
| 260 | 'CONTENT' => $content, |
||
| 261 | ); |
||
| 262 | } |
||
| 263 | } |
||
| 264 | } |
||
| 265 | } |
||
| 266 | |||
| 267 | empty(classSupernova::$sn_mvc['css']) ? classSupernova::$sn_mvc['css'] = array('' => array()) : false; |
||
| 268 | $standard_css = array( |
||
| 269 | 'design/css/jquery-ui.css' => '', |
||
| 270 | 'design/css/global.min.css' => '', |
||
| 271 | ); |
||
| 272 | $is_login ? $standard_css['design/css/login.min.css'] = '' : false; |
||
| 273 | $standard_css += array( |
||
| 274 | // 'design/css/design/css/global-ie.min.css' => '', // TODO |
||
| 275 | TEMPLATE_PATH . '/_template.min.css' => '', |
||
| 276 | ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH) . 'skin.min.css' => '', |
||
| 277 | ); |
||
| 278 | |||
| 279 | // Prepending standard CSS files |
||
| 280 | classSupernova::$sn_mvc['css'][''] = array_merge($standard_css, classSupernova::$sn_mvc['css']['']); |
||
| 281 | |||
| 282 | |||
| 283 | View Code Duplication | foreach(classSupernova::$sn_mvc['css'] as $page_name => $script_list) { |
|
| 284 | if(empty($page_name) || $page_name == $sn_page_name) { |
||
| 285 | foreach($script_list as $filename => $content) { |
||
| 286 | $template_result['.']['css'][] = array( |
||
| 287 | 'FILE' => $filename, |
||
| 288 | 'CONTENT' => $content, |
||
| 289 | ); |
||
| 290 | } |
||
| 291 | } |
||
| 292 | } |
||
| 293 | |||
| 294 | $template->assign_vars(array( |
||
| 295 | 'USER_AUTHLEVEL' => intval($user['authlevel']), |
||
| 296 | |||
| 297 | 'FONT_SIZE' => $font_size, |
||
| 298 | 'FONT_SIZE_PERCENT_DEFAULT_STRING' => FONT_SIZE_PERCENT_DEFAULT_STRING, |
||
| 299 | |||
| 300 | 'SN_TIME_NOW' => SN_TIME_NOW, |
||
| 301 | 'LOGIN_LOGOUT' => $is_login, |
||
| 302 | 'GAME_MODE_CSS_PREFIX' => $config->game_mode == GAME_BLITZ ? 'blitz_' : '', |
||
| 303 | //'TIME_DIFF' => SN_CLIENT_TIME_DIFF, |
||
| 304 | 'TIME_DIFF_MEASURE' => intval( |
||
| 305 | empty($user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) |
||
| 306 | && |
||
| 307 | (SN_TIME_NOW - $user_time_measured_unix > PERIOD_HOUR || $user_time_diff[PLAYER_OPTION_TIME_DIFF] == '') |
||
| 308 | ), // Проводить замер только если не выставлен флаг форсированного замера И (иссяк интервал замера ИЛИ замера еще не было) |
||
| 309 | //'TIME_UTC_OFFSET' => defined('SN_CLIENT_TIME_UTC_OFFSET') ? SN_CLIENT_TIME_UTC_OFFSET : '', |
||
| 310 | |||
| 311 | 'title' => ($title ? "{$title} - " : '') . classLocale::$lang['sys_server'] . " {$config->game_name} - " . classLocale::$lang['sys_supernova'], |
||
| 312 | '-meta-' => $metatags, |
||
| 313 | 'ADV_SEO_META_DESCRIPTION' => $config->adv_seo_meta_description, |
||
| 314 | 'ADV_SEO_META_KEYWORDS' => $config->adv_seo_meta_keywords, |
||
| 315 | 'ADV_SEO_JAVASCRIPT' => $config->adv_seo_javascript, |
||
| 316 | |||
| 317 | 'LANG_LANGUAGE' => classLocale::$lang['LANG_INFO']['LANG_NAME_ISO2'], |
||
| 318 | 'LANG_ENCODING' => 'utf-8', |
||
| 319 | 'LANG_DIRECTION' => classLocale::$lang['LANG_INFO']['LANG_DIRECTION'], |
||
| 320 | |||
| 321 | 'SOUND_ENABLED' => classSupernova::$user_options[PLAYER_OPTION_SOUND_ENABLED], |
||
| 322 | 'PLAYER_OPTION_ANIMATION_DISABLED' => classSupernova::$user_options[PLAYER_OPTION_ANIMATION_DISABLED], |
||
| 323 | 'PLAYER_OPTION_PROGRESS_BARS_DISABLED' => classSupernova::$user_options[PLAYER_OPTION_PROGRESS_BARS_DISABLED], |
||
| 324 | |||
| 325 | 'IMPERSONATING' => !empty($template_result[F_IMPERSONATE_STATUS]) ? sprintf(classLocale::$lang['sys_impersonated_as'], $user['username'], $template_result[F_IMPERSONATE_OPERATOR]) : '', |
||
| 326 | 'PLAYER_OPTION_DESIGN_DISABLE_BORDERS' => classSupernova::$user_options[PLAYER_OPTION_DESIGN_DISABLE_BORDERS], |
||
| 327 | )); |
||
| 328 | $template->assign_recursive($template_result); |
||
| 329 | displayP(parsetemplate($template)); |
||
| 330 | |||
| 331 | if(($isDisplayMenu || $in_admin) && !isset($_COOKIE['menu_disable'])) { |
||
| 332 | // $AdminPage = $AdminPage ? $user['authlevel'] : 0; |
||
| 333 | displayP(parsetemplate(tpl_render_menu())); |
||
| 334 | } |
||
| 335 | |||
| 336 | if($isDisplayTopNav && !$in_admin) { |
||
| 337 | displayP(parsetemplate(tpl_render_topnav($user, $planetrow))); |
||
| 338 | } |
||
| 339 | |||
| 340 | displayP(parsetemplate(gettemplate('_content_header', true))); |
||
| 341 | |||
| 342 | !is_array($page) ? $page = array($page) : false; |
||
| 343 | $result_added = false; |
||
| 344 | foreach($page as $page_item) { |
||
| 345 | if(!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) { |
||
| 346 | $page_item = gettemplate('_result_message', $page_item); |
||
| 347 | $temp = $page_item->files['_result_message']; |
||
| 348 | unset($page_item->files['_result_message']); |
||
| 349 | $page_item->files = array_reverse($page_item->files); |
||
| 350 | $page_item->files['_result_message'] = $temp; |
||
| 351 | $page_item->files = array_reverse($page_item->files); |
||
|
0 ignored issues
–
show
|
|||
| 352 | $result_added = true; |
||
| 353 | } |
||
| 354 | displayP($page_item); |
||
| 355 | } |
||
| 356 | |||
| 357 | displayP(parsetemplate(gettemplate('_content_footer', true))); |
||
| 358 | |||
| 359 | // Global footer |
||
| 360 | $template = gettemplate('_global_footer', true); |
||
| 361 | $template->assign_vars(array( |
||
| 362 | 'ADMIN_EMAIL' => $config->game_adminEmail, |
||
| 363 | 'SN_TIME_NOW' => SN_TIME_NOW, |
||
| 364 | 'SN_VERSION' => SN_VERSION, |
||
| 365 | )); |
||
| 366 | displayP(parsetemplate($template)); |
||
| 367 | |||
| 368 | $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false;; |
||
| 369 | |||
| 370 | sn_db_disconnect(); |
||
| 371 | |||
| 372 | $exitStatus and die($exitStatus === true ? 0 : $exitStatus); |
||
| 373 | } |
||
| 374 | |||
| 375 | /** |
||
| 376 | * @param $time |
||
| 377 | * @param $event |
||
| 378 | * @param $msg |
||
| 379 | * @param $coordinates |
||
| 380 | * @param $is_decrease |
||
| 381 | * @param Fleet $objFleet |
||
| 382 | * @param $fleet_flying_sorter |
||
| 383 | * @param $fleet_flying_events |
||
| 384 | * @param $fleet_event_count |
||
| 385 | */ |
||
| 386 | function tpl_topnav_event_build_helper($time, $event, $msg, $coordinates, $is_decrease, Fleet $objFleet, &$fleet_flying_sorter, &$fleet_flying_events, &$fleet_event_count) { |
||
| 387 | $fleet_flying_sorter[$fleet_event_count] = $time; |
||
| 388 | $fleet_flying_events[$fleet_event_count] = array( |
||
| 389 | 'OBJECT' => $objFleet, |
||
| 390 | 'FLEET_ID' => $objFleet->dbId, |
||
| 391 | 'EVENT' => $event, |
||
| 392 | 'COORDINATES' => uni_render_coordinates($coordinates, ''), |
||
| 393 | 'COORDINATES_TYPE' => $coordinates['type'], |
||
| 394 | 'TEXT' => $msg, |
||
| 395 | 'DECREASE' => $is_decrease, |
||
| 396 | ); |
||
| 397 | $fleet_event_count++; |
||
| 398 | } |
||
| 399 | |||
| 400 | /** |
||
| 401 | * @param template $template |
||
| 402 | * @param FleetList|null $FleetList |
||
| 403 | * @param string $type |
||
| 404 | */ |
||
| 405 | function tpl_topnav_event_build(&$template, $FleetList, $type = 'fleet') { |
||
| 406 | if(empty($FleetList)) { |
||
| 407 | return; |
||
| 408 | } |
||
| 409 | |||
| 410 | $classLocale = classLocale::$lang; |
||
| 411 | |||
| 412 | $fleet_event_count = 0; |
||
| 413 | $fleet_flying_sorter = array(); |
||
| 414 | $fleet_flying_events = array(); |
||
| 415 | foreach($FleetList->_container as $objFleet) { |
||
| 416 | $will_return = true; |
||
| 417 | if(!$objFleet->isReturning()) { |
||
| 418 | // cut fleets on Hold and Expedition |
||
| 419 | if($objFleet->time_arrive_to_target >= SN_TIME_NOW) { |
||
| 420 | $objFleet->mission_type == MT_RELOCATE ? $will_return = false : false; |
||
| 421 | tpl_topnav_event_build_helper($objFleet->time_arrive_to_target, EVENT_FLEET_ARRIVE, classLocale::$lang['sys_event_arrive'], $objFleet->target_coordinates_typed(), !$will_return, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
||
| 422 | } |
||
| 423 | if($objFleet->time_mission_job_complete) { |
||
| 424 | tpl_topnav_event_build_helper($objFleet->time_mission_job_complete, EVENT_FLEET_STAY, classLocale::$lang['sys_event_stay'], $objFleet->target_coordinates_typed(), false, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
||
| 425 | } |
||
| 426 | } |
||
| 427 | if($will_return) { |
||
| 428 | tpl_topnav_event_build_helper($objFleet->time_return_to_source, EVENT_FLEET_RETURN, classLocale::$lang['sys_event_return'], $objFleet->launch_coordinates_typed(), true, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
||
| 429 | } |
||
| 430 | } |
||
| 431 | |||
| 432 | asort($fleet_flying_sorter); |
||
| 433 | |||
| 434 | $fleet_flying_count = $FleetList->count(); |
||
| 435 | foreach($fleet_flying_sorter as $fleet_event_id => $fleet_time) { |
||
| 436 | $fleet_event = &$fleet_flying_events[$fleet_event_id]; |
||
| 437 | $template->assign_block_vars("flying_{$type}s", array( |
||
| 438 | 'TIME' => max(0, $fleet_time - SN_TIME_NOW), |
||
| 439 | 'TEXT' => $fleet_flying_count, |
||
| 440 | 'HINT' => date(FMT_DATE_TIME, $fleet_time + SN_CLIENT_TIME_DIFF) . " - {$classLocale['sys_fleet']} {$fleet_event['TEXT']} {$fleet_event['COORDINATES']} {$classLocale['sys_planet_type_sh'][$fleet_event['COORDINATES_TYPE']]} {$classLocale['type_mission'][$fleet_event['OBJECT']->mission_type]}", |
||
| 441 | )); |
||
| 442 | $fleet_event['DECREASE'] ? $fleet_flying_count-- : false; |
||
| 443 | } |
||
| 444 | } |
||
| 445 | |||
| 446 | /** |
||
| 447 | * @param array $user |
||
| 448 | * @param array $planetrow |
||
| 449 | * |
||
| 450 | * @return string|template |
||
| 451 | */ |
||
| 452 | function tpl_render_topnav(&$user, $planetrow) { return sn_function_call(__FUNCTION__, array(&$user, $planetrow)); } |
||
| 453 | |||
| 454 | /** |
||
| 455 | * @param array $user |
||
| 456 | * @param array $planetrow |
||
| 457 | * |
||
| 458 | * @return string|template |
||
| 459 | */ |
||
| 460 | function sn_tpl_render_topnav(&$user, $planetrow) { |
||
| 461 | global $config, $template_result; |
||
| 462 | $classLocale = classLocale::$lang; |
||
| 463 | |||
| 464 | if(!is_array($user)) { |
||
| 465 | return ''; |
||
| 466 | } |
||
| 467 | |||
| 468 | $GET_mode = sys_get_param_str('mode'); |
||
| 469 | |||
| 470 | $template = gettemplate('navbar', true); |
||
| 471 | |||
| 472 | $template->assign_recursive($template_result); |
||
| 473 | |||
| 474 | /* |
||
| 475 | $planetrow = $planetrow ? $planetrow : $user['current_planet']; |
||
| 476 | |||
| 477 | sn_db_transaction_start(); |
||
| 478 | $planetrow = sys_o_get_updated($user, $planetrow, SN_TIME_NOW); |
||
| 479 | sn_db_transaction_commit(); |
||
| 480 | $planetrow = $planetrow['planet']; |
||
| 481 | */ |
||
| 482 | |||
| 483 | $ThisUsersPlanets = db_planet_list_sorted($user); |
||
| 484 | // while ($CurPlanet = db_fetch($ThisUsersPlanets)) |
||
| 485 | foreach($ThisUsersPlanets as $CurPlanet) { |
||
| 486 | if($CurPlanet['destruyed']) { |
||
| 487 | continue; |
||
| 488 | } |
||
| 489 | |||
| 490 | // $fleet_listx = flt_get_fleets_to_planet($CurPlanet); |
||
| 491 | $fleet_listx = FleetList::EMULATE_flt_get_fleets_to_planet($CurPlanet); |
||
| 492 | |||
| 493 | $template->assign_block_vars('topnav_planets', array( |
||
| 494 | 'ID' => $CurPlanet['id'], |
||
| 495 | 'NAME' => $CurPlanet['name'], |
||
| 496 | 'TYPE' => $CurPlanet['planet_type'], |
||
| 497 | 'TYPE_TEXT' => classLocale::$lang['sys_planet_type_sh'][$CurPlanet['planet_type']], |
||
| 498 | 'PLIMAGE' => $CurPlanet['image'], |
||
| 499 | 'FLEET_ENEMY' => $fleet_listx['enemy']['count'], |
||
| 500 | 'COORDS' => uni_render_coordinates($CurPlanet), |
||
| 501 | 'SELECTED' => $CurPlanet['id'] == $user['current_planet'] ? ' selected' : '', |
||
| 502 | )); |
||
| 503 | } |
||
| 504 | |||
| 505 | /** |
||
| 506 | * @var FleetList[] $fleet_flying_list |
||
| 507 | */ |
||
| 508 | $fleet_flying_list = array(); |
||
| 509 | $fleet_flying_list[0] = FleetList::dbGetFleetListByOwnerId($user['id']); |
||
| 510 | foreach($fleet_flying_list[0]->_container as $fleet_id => $objFleet) { |
||
| 511 | if(empty($fleet_flying_list[$objFleet->mission_type])) { |
||
| 512 | $fleet_flying_list[$objFleet->mission_type] = new FleetList(); |
||
| 513 | } |
||
| 514 | $fleet_flying_list[$objFleet->mission_type][$fleet_id] = $objFleet; |
||
| 515 | } |
||
| 516 | tpl_topnav_event_build($template, $fleet_flying_list[0]); |
||
| 517 | tpl_topnav_event_build($template, $fleet_flying_list[MT_EXPLORE], 'expedition'); |
||
| 518 | |||
| 519 | que_tpl_parse($template, QUE_STRUCTURES, $user, $planetrow, null, true); |
||
| 520 | que_tpl_parse($template, QUE_RESEARCH, $user, array(), null, !classSupernova::$user_options[PLAYER_OPTION_NAVBAR_RESEARCH_WIDE]); |
||
| 521 | que_tpl_parse($template, SUBQUE_FLEET, $user, $planetrow, null, true); |
||
| 522 | |||
| 523 | if(!empty(classSupernova::$sn_mvc['navbar_prefix_button']) && is_array(classSupernova::$sn_mvc['navbar_prefix_button'])) { |
||
| 524 | foreach(classSupernova::$sn_mvc['navbar_prefix_button'] as $navbar_button_image => $navbar_button_url) { |
||
| 525 | $template->assign_block_vars('navbar_prefix_button', array( |
||
| 526 | 'IMAGE' => $navbar_button_image, |
||
| 527 | 'URL_RELATIVE' => $navbar_button_url, |
||
| 528 | )); |
||
| 529 | } |
||
| 530 | } |
||
| 531 | |||
| 532 | $template->assign_var('NAVBAR_PREFIX_BUTTONS', is_array(classSupernova::$sn_mvc['navbar_prefix_button']) ? count(classSupernova::$sn_mvc['navbar_prefix_button']) : 0); |
||
| 533 | |||
| 534 | $str_date_format = "%3$02d %2$0s %1$04d {$classLocale['top_of_year']} %4$02d:%5$02d:%6$02d"; |
||
| 535 | $time_now_parsed = getdate(SN_TIME_NOW); |
||
| 536 | $time_local_parsed = getdate(defined('SN_CLIENT_TIME_LOCAL') ? SN_CLIENT_TIME_LOCAL : SN_TIME_NOW); |
||
| 537 | |||
| 538 | if($config->game_news_overview) { |
||
| 539 | $user_last_read_safe = intval($user['news_lastread']); |
||
| 540 | nws_render($template, "WHERE UNIX_TIMESTAMP(`tsTimeStamp`) >= {$user_last_read_safe}", $config->game_news_overview); |
||
| 541 | } |
||
| 542 | |||
| 543 | $notes_query = db_note_list_by_owner($user['id'], true); |
||
| 544 | while($note_row = db_fetch($notes_query)) { |
||
| 545 | note_assign($template, $note_row); |
||
| 546 | } |
||
| 547 | |||
| 548 | $premium_lvl = mrc_get_level($user, false, UNIT_PREMIUM, true, true); |
||
| 549 | $template->assign_vars(array( |
||
| 550 | 'HALLOWEEN' => !empty(sn_module::$sn_module_list['event']['event_halloween_2015']) && sn_module::$sn_module_list['event']['event_halloween_2015']->manifest['active'], |
||
| 551 | |||
| 552 | 'QUE_ID' => QUE_RESEARCH, |
||
| 553 | 'QUE_HTML' => 'topnav', |
||
| 554 | |||
| 555 | 'RESEARCH_ONGOING' => (boolean)$user['que'], |
||
| 556 | |||
| 557 | 'TIME_TEXT' => sprintf($str_date_format, $time_now_parsed['year'], classLocale::$lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'], |
||
| 558 | $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds'] |
||
| 559 | ), |
||
| 560 | 'TIME_TEXT_LOCAL' => sprintf($str_date_format, $time_local_parsed['year'], classLocale::$lang['months'][$time_local_parsed['mon']], $time_local_parsed['mday'], |
||
| 561 | $time_local_parsed['hours'], $time_local_parsed['minutes'], $time_local_parsed['seconds'] |
||
| 562 | ), |
||
| 563 | |||
| 564 | 'GAME_BLITZ_REGISTER' => $config->game_blitz_register, |
||
| 565 | 'GAME_BLITZ_REGISTER_TEXT' => classLocale::$lang['sys_blitz_registration_mode_list'][$config->game_blitz_register], |
||
| 566 | 'BLITZ_REGISTER_OPEN' => $config->game_blitz_register == BLITZ_REGISTER_OPEN, |
||
| 567 | 'BLITZ_REGISTER_CLOSED' => $config->game_blitz_register == BLITZ_REGISTER_CLOSED, |
||
| 568 | 'BLITZ_REGISTER_SHOW_LOGIN' => $config->game_blitz_register == BLITZ_REGISTER_SHOW_LOGIN, |
||
| 569 | 'BLITZ_REGISTER_DISCLOSURE_NAMES' => $config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES, |
||
| 570 | 'GAME_BLITZ' => $config->game_mode == GAME_BLITZ, |
||
| 571 | |||
| 572 | 'USERS_ONLINE' => $config->var_online_user_count, |
||
| 573 | 'USERS_TOTAL' => $config->users_amount, |
||
| 574 | 'USER_RANK' => $user['total_rank'], |
||
| 575 | 'USER_NICK' => $user['username'], |
||
| 576 | 'USER_AVATAR' => $user['avatar'], |
||
| 577 | 'USER_AVATARID' => $user['id'], |
||
| 578 | 'USER_PREMIUM' => $premium_lvl, |
||
| 579 | 'USER_RACE' => $user['player_race'], |
||
| 580 | |||
| 581 | 'TOPNAV_CURRENT_PLANET' => $user['current_planet'], |
||
| 582 | 'TOPNAV_CURRENT_PLANET_NAME' => uni_render_planet_full($planetrow), // htmlspecialchars($planetrow['name']), |
||
| 583 | 'TOPNAV_CURRENT_PLANET_IMAGE' => $planetrow['image'], |
||
| 584 | 'TOPNAV_COLONIES_CURRENT' => get_player_current_colonies($user), |
||
| 585 | 'TOPNAV_COLONIES_MAX' => get_player_max_colonies($user), |
||
| 586 | 'TOPNAV_MODE' => $GET_mode, |
||
| 587 | |||
| 588 | 'TOPNAV_DARK_MATTER' => mrc_get_level($user, '', RES_DARK_MATTER), |
||
| 589 | 'TOPNAV_DARK_MATTER_TEXT' => pretty_number(mrc_get_level($user, '', RES_DARK_MATTER)), |
||
| 590 | 'TOPNAV_DARK_MATTER_PLAIN' => mrc_get_level($user, '', RES_DARK_MATTER, false, true), |
||
| 591 | 'TOPNAV_DARK_MATTER_PLAIN_TEXT' => pretty_number(mrc_get_level($user, '', RES_DARK_MATTER, false, true)), |
||
| 592 | 'TOPNAV_METAMATTER' => mrc_get_level($user, '', RES_METAMATTER), |
||
| 593 | 'TOPNAV_METAMATTER_TEXT' => pretty_number(mrc_get_level($user, '', RES_METAMATTER)), |
||
| 594 | |||
| 595 | // TODO ГРЯЗНЫЙ ХАК!!! |
||
| 596 | 'TOPNAV_PAYMENT' => sn_module_get_active_count('payment') && !defined('SN_GOOGLE'), |
||
| 597 | |||
| 598 | 'TOPNAV_MESSAGES_ADMIN' => $user['msg_admin'], |
||
| 599 | 'TOPNAV_MESSAGES_PLAYER' => $user['mnl_joueur'], |
||
| 600 | 'TOPNAV_MESSAGES_ALLIANCE' => $user['mnl_alliance'], |
||
| 601 | 'TOPNAV_MESSAGES_ATTACK' => $user['mnl_attaque'], |
||
| 602 | 'TOPNAV_MESSAGES_ALL' => $user['new_message'], |
||
| 603 | |||
| 604 | 'TOPNAV_FLEETS_FLYING' => is_object($fleet_flying_list[0]) ? $fleet_flying_list[0]->count() : 0, |
||
| 605 | 'TOPNAV_FLEETS_TOTAL' => GetMaxFleets($user), |
||
| 606 | 'TOPNAV_EXPEDITIONS_FLYING' => is_object($fleet_flying_list[MT_EXPLORE]) ? $fleet_flying_list[MT_EXPLORE]->count() : 0, |
||
| 607 | 'TOPNAV_EXPEDITIONS_TOTAL' => get_player_max_expeditons($user), |
||
| 608 | |||
| 609 | 'TOPNAV_QUEST_COMPLETE' => get_quest_amount_complete($user['id']), |
||
| 610 | |||
| 611 | 'GAME_NEWS_OVERVIEW' => $config->game_news_overview, |
||
| 612 | 'GAME_RESEARCH_DISABLED' => defined('GAME_RESEARCH_DISABLED') && GAME_RESEARCH_DISABLED, |
||
| 613 | 'GAME_DEFENSE_DISABLED' => defined('GAME_DEFENSE_DISABLED') && GAME_DEFENSE_DISABLED, |
||
| 614 | 'GAME_STRUCTURES_DISABLED' => defined('GAME_STRUCTURES_DISABLED') && GAME_STRUCTURES_DISABLED, |
||
| 615 | 'GAME_HANGAR_DISABLED' => defined('GAME_HANGAR_DISABLED') && GAME_HANGAR_DISABLED, |
||
| 616 | |||
| 617 | 'PLAYER_OPTION_NAVBAR_PLANET_VERTICAL' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_PLANET_VERTICAL], |
||
| 618 | 'PLAYER_OPTION_NAVBAR_DISABLE_RESEARCH' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_RESEARCH], |
||
| 619 | 'PLAYER_OPTION_NAVBAR_DISABLE_PLANET' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_PLANET], |
||
| 620 | 'PLAYER_OPTION_NAVBAR_DISABLE_HANGAR' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_HANGAR], |
||
| 621 | 'PLAYER_OPTION_NAVBAR_DISABLE_FLYING_FLEETS' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_FLYING_FLEETS], |
||
| 622 | 'PLAYER_OPTION_NAVBAR_DISABLE_EXPEDITIONS' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_EXPEDITIONS], |
||
| 623 | 'PLAYER_OPTION_NAVBAR_DISABLE_QUESTS' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_QUESTS], |
||
| 624 | 'PLAYER_OPTION_NAVBAR_DISABLE_META_MATTER' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_DISABLE_META_MATTER], |
||
| 625 | 'PLAYER_OPTION_NAVBAR_RESEARCH_WIDE' => classSupernova::$user_options[PLAYER_OPTION_NAVBAR_RESEARCH_WIDE], |
||
| 626 | |||
| 627 | 'SUBQUE_FLEET' => SUBQUE_FLEET, |
||
| 628 | 'QUE_RESEARCH' => QUE_RESEARCH, |
||
| 629 | 'QUE_STRUCTURES' => QUE_STRUCTURES, |
||
| 630 | )); |
||
| 631 | |||
| 632 | if((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) { |
||
| 633 | tpl_set_resource_info($template, $planetrow); |
||
| 634 | $template->assign_vars(array( |
||
| 635 | 'SN_RENDER_NAVBAR_PLANET' => true, |
||
| 636 | 'SN_NAVBAR_HIDE_FLEETS' => true, |
||
| 637 | )); |
||
| 638 | } |
||
| 639 | |||
| 640 | return $template; |
||
| 641 | } |
||
| 642 | |||
| 643 | /** |
||
| 644 | * @param template|string $template |
||
| 645 | */ |
||
| 646 | function displayP($template) { |
||
| 647 | if(is_object($template)) { |
||
| 648 | if(empty($template->parsed)) { |
||
| 649 | parsetemplate($template); |
||
| 650 | } |
||
| 651 | |||
| 652 | foreach($template->files as $section => $filename) { |
||
| 653 | $template->display($section); |
||
| 654 | } |
||
| 655 | } else { |
||
| 656 | print($template); |
||
| 657 | } |
||
| 658 | } |
||
| 659 | |||
| 660 | /** |
||
| 661 | * @param template|string $template |
||
| 662 | * @param array|bool $array |
||
| 663 | * |
||
| 664 | * @return mixed |
||
| 665 | */ |
||
| 666 | function parsetemplate($template, $array = false) { |
||
| 667 | if(is_object($template)) { |
||
| 668 | global $user; |
||
| 669 | |||
| 670 | if(!empty($array) && is_array($array)) { |
||
| 671 | foreach($array as $key => $data) { |
||
| 672 | $template->assign_var($key, $data); |
||
| 673 | } |
||
| 674 | } |
||
| 675 | |||
| 676 | $template->assign_vars(array( |
||
| 677 | 'dpath' => $user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH, |
||
| 678 | 'SN_TIME_NOW' => SN_TIME_NOW, |
||
| 679 | 'USER_AUTHLEVEL' => isset($user['authlevel']) ? $user['authlevel'] : -1, |
||
| 680 | 'SN_GOOGLE' => defined('SN_GOOGLE'), |
||
| 681 | )); |
||
| 682 | |||
| 683 | $template->parsed = true; |
||
| 684 | |||
| 685 | return $template; |
||
| 686 | } else { |
||
| 687 | $search[] = '#\{L_([a-z0-9\-_]*?)\[([a-z0-9\-_]*?)\]\}#Ssie'; |
||
| 688 | $replace[] = '((isset(classLocale::$lang[\'\1\'][\'\2\'])) ? classLocale::$lang[\'\1\'][\'\2\'] : \'{L_\1[\2]}\');'; |
||
| 689 | |||
| 690 | $search[] = '#\{L_([a-z0-9\-_]*?)\}#Ssie'; |
||
| 691 | $replace[] = '((isset(classLocale::$lang[\'\1\'])) ? classLocale::$lang[\'\1\'] : \'{L_\1}\');'; |
||
| 692 | |||
| 693 | $search[] = '#\{([a-z0-9\-_]*?)\}#Ssie'; |
||
| 694 | $replace[] = '((isset($array[\'\1\'])) ? $array[\'\1\'] : \'{\1}\');'; |
||
| 695 | |||
| 696 | return preg_replace($search, $replace, $template); |
||
| 697 | } |
||
| 698 | } |
||
| 699 | |||
| 700 | /** |
||
| 701 | * @param array|string $files |
||
| 702 | * @param template|bool $template |
||
| 703 | * @param string|bool $template_path |
||
| 704 | * |
||
| 705 | * @return template |
||
| 706 | */ |
||
| 707 | function gettemplate($files, $template = false, $template_path = false) { |
||
| 708 | global $sn_page_name, $user; |
||
| 709 | |||
| 710 | $template_ex = '.tpl.html'; |
||
| 711 | |||
| 712 | if($template === false) { |
||
| 713 | return sys_file_read(TEMPLATE_DIR . '/' . $files . $template_ex); |
||
| 714 | } |
||
| 715 | |||
| 716 | is_string($files) ? $files = array(basename($files) => $files) : false; |
||
| 717 | |||
| 718 | !is_object($template) ? $template = new template() : false; |
||
| 719 | //$template->set_custom_template($template_path ? $template_path : TEMPLATE_DIR, TEMPLATE_NAME, TEMPLATE_DIR); |
||
| 720 | |||
| 721 | $tmpl_name = gettemplatename($user['dpath']); |
||
| 722 | $template->set_custom_template(($template_path ? $template_path : SN_ROOT_PHYSICAL . 'design/templates/') . $tmpl_name . '/', $tmpl_name, TEMPLATE_DIR); |
||
| 723 | |||
| 724 | // TODO ГРЯЗНЫЙ ХАК! Это нужно, что бы по возможности перезаписать инфу из языковых пакетов модулей там, где она была перезаписана раньше инфой из основного пакета. Почему? |
||
| 725 | // - сначала грузятся модули и их языковые пакеты |
||
| 726 | // - затем по ходу дела ОСНОВНОЙ языковой пакет может перезаписать данные из МОДУЛЬНОГО языкового пакета |
||
| 727 | // Поэтому и нужен этот грязный хак |
||
| 728 | // В норме же - страницы заявляют сами, какие им пакеты нужны. Так что сначала всегда должны грузится основные языковые пакеты, а уже ПОВЕРХ них - пакеты модулей |
||
| 729 | !empty(classSupernova::$sn_mvc['i18n']['']) ? lng_load_i18n(classSupernova::$sn_mvc['i18n']['']) : false; |
||
| 730 | $sn_page_name ? lng_load_i18n(classSupernova::$sn_mvc['i18n'][$sn_page_name]) : false; |
||
| 731 | |||
| 732 | foreach($files as &$filename) { |
||
| 733 | $filename = $filename . $template_ex; |
||
| 734 | } |
||
| 735 | |||
| 736 | $template->set_filenames($files); |
||
| 737 | |||
| 738 | return $template; |
||
| 739 | } |
||
| 740 | |||
| 741 | /** |
||
| 742 | * @param template $template |
||
| 743 | */ |
||
| 744 | function tpl_login_lang(&$template) { |
||
| 745 | global $language; |
||
| 746 | |||
| 747 | $url_params = array(); |
||
| 748 | |||
| 749 | $language ? $url_params[] = "lang={$language}" : false; |
||
| 750 | |||
| 751 | ($id_ref = sys_get_param_id('id_ref')) ? $url_params[] = "id_ref={$id_ref}" : false; |
||
| 752 | |||
| 753 | $template->assign_vars($q = array( |
||
| 754 | 'LANG' => $language ? $language : '', |
||
| 755 | 'referral' => $id_ref ? '&id_ref=' . $id_ref : '', |
||
| 756 | |||
| 757 | 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '',// "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
||
| 758 | 'FILENAME' => basename($_SERVER['PHP_SELF']), |
||
| 759 | )); |
||
| 760 | |||
| 761 | foreach(lng_get_list() as $lng_id => $lng_data) { |
||
| 762 | if(isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) { |
||
| 763 | foreach($lng_data['LANG_VARIANTS'] as $lang_variant) { |
||
| 764 | $lng_data1 = $lng_data; |
||
| 765 | $lng_data1 = array_merge($lng_data1, $lang_variant); |
||
| 766 | $template->assign_block_vars('language', $lng_data1); |
||
| 767 | } |
||
| 768 | } else { |
||
| 769 | $template->assign_block_vars('language', $lng_data); |
||
| 770 | } |
||
| 771 | } |
||
| 772 | } |
||
| 773 | |||
| 774 | /** |
||
| 775 | * @param template $template |
||
| 776 | * @param array $planet |
||
| 777 | * @param int $que_type |
||
| 778 | * |
||
| 779 | * @return int |
||
| 780 | */ |
||
| 781 | function tpl_assign_hangar(&$template, $planet, $que_type) { |
||
| 782 | $que = que_get($planet['id_owner'], $planet['id'], $que_type); |
||
| 783 | $que = $que['ques'][$que_type][$planet['id_owner']][$planet['id']]; |
||
| 784 | |||
| 785 | $que_length = 0; |
||
| 786 | if(!empty($que)) { |
||
| 787 | foreach($que as $que_item) { |
||
| 788 | $template->assign_block_vars('que', que_tpl_parse_element($que_item)); |
||
| 789 | } |
||
| 790 | $que_length = count($que); |
||
| 791 | } |
||
| 792 | |||
| 793 | return $que_length; |
||
| 794 | } |
||
| 795 | |||
| 796 | /** |
||
| 797 | * @param template $template |
||
| 798 | * @param array $density_price_chart |
||
| 799 | * @param int $user_dark_matter |
||
| 800 | */ |
||
| 801 | function tpl_planet_density_info(&$template, &$density_price_chart, $user_dark_matter) { |
||
| 802 | foreach($density_price_chart as $density_price_index => &$density_price_data) { |
||
| 803 | $density_cost = $density_price_data; |
||
| 804 | $density_number_style = pretty_number($density_cost, true, $user_dark_matter, false, false); |
||
| 805 | |||
| 806 | $density_price_data = array( |
||
| 807 | 'COST' => $density_cost, |
||
| 808 | 'COST_TEXT' => $density_number_style['text'], |
||
| 809 | 'COST_TEXT_CLASS' => $density_number_style['class'], |
||
| 810 | 'REST' => $user_dark_matter - $density_cost, |
||
| 811 | 'ID' => $density_price_index, |
||
| 812 | 'TEXT' => classLocale::$lang['uni_planet_density_types'][$density_price_index], |
||
| 813 | ); |
||
| 814 | $template->assign_block_vars('densities', $density_price_data); |
||
| 815 | } |
||
| 816 | } |
||
| 817 | |||
| 818 | /** |
||
| 819 | * @param template $template |
||
| 820 | * @param string $name |
||
| 821 | * @param mixed $values |
||
| 822 | */ |
||
| 823 | function tpl_assign_select(&$template, $name, $values) { |
||
| 824 | !is_array($values) ? $values = array($values => $values) : false; |
||
| 825 | |||
| 826 | foreach($values as $key => $value) { |
||
| 827 | $template->assign_block_vars($name, array( |
||
| 828 | 'KEY' => htmlentities($key, ENT_COMPAT, 'UTF-8'), |
||
| 829 | 'VALUE' => htmlentities($value, ENT_COMPAT, 'UTF-8'), |
||
| 830 | )); |
||
| 831 | } |
||
| 832 | } |
||
| 833 |
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.