@@ -399,18 +399,18 @@ discard block |
||
| 399 | 399 | $quickbuttons = array( |
| 400 | 400 | 'approve' => array( |
| 401 | 401 | 'label' => Lang::$txt['approve'], |
| 402 | - 'href' => Config::$scripturl.'?action=moderate;area=postmod;sa='.Utils::$context['current_view'].';start='.Utils::$context['start'].';'.Utils::$context['session_var'].'='.Utils::$context['session_id'].';approve='.$item['id'], |
|
| 402 | + 'href' => Config::$scripturl . '?action=moderate;area=postmod;sa=' . Utils::$context['current_view'] . ';start=' . Utils::$context['start'] . ';' . Utils::$context['session_var'] . '=' . Utils::$context['session_id'] . ';approve=' . $item['id'], |
|
| 403 | 403 | 'icon' => 'approve', |
| 404 | 404 | ), |
| 405 | 405 | 'delete' => array( |
| 406 | 406 | 'label' => Lang::$txt['remove'], |
| 407 | - 'href' => Config::$scripturl.'?action=moderate;area=postmod;sa='.Utils::$context['current_view'].';start='.Utils::$context['start'].';'.Utils::$context['session_var'].'='.Utils::$context['session_id'].';delete='.$item['id'], |
|
| 407 | + 'href' => Config::$scripturl . '?action=moderate;area=postmod;sa=' . Utils::$context['current_view'] . ';start=' . Utils::$context['start'] . ';' . Utils::$context['session_var'] . '=' . Utils::$context['session_id'] . ';delete=' . $item['id'], |
|
| 408 | 408 | 'icon' => 'remove_button', |
| 409 | 409 | 'show' => $item['can_delete'] |
| 410 | 410 | ), |
| 411 | 411 | 'quickmod' => array( |
| 412 | 412 | 'class' => 'inline_mod_check', |
| 413 | - 'content' => '<input type="checkbox" name="item[]" value="'.$item['id'].'" checked>', |
|
| 413 | + 'content' => '<input type="checkbox" name="item[]" value="' . $item['id'] . '" checked>', |
|
| 414 | 414 | 'show' => !empty(Theme::$current->options['display_quick_mod']) && Theme::$current->options['display_quick_mod'] == 1 |
| 415 | 415 | ), |
| 416 | 416 | ); |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | $quickbuttons = array( |
| 472 | 472 | 'delete' => array( |
| 473 | 473 | 'label' => Lang::$txt['remove_message'], |
| 474 | - 'href' => Config::$scripturl.'?action=moderate;area=userwatch;sa=post;delete='.$post['id'].';start='.Utils::$context['start'].';'.Utils::$context['session_var'].'='.Utils::$context['session_id'], |
|
| 474 | + 'href' => Config::$scripturl . '?action=moderate;area=userwatch;sa=post;delete=' . $post['id'] . ';start=' . Utils::$context['start'] . ';' . Utils::$context['session_var'] . '=' . Utils::$context['session_id'], |
|
| 475 | 475 | 'javascript' => 'data-confirm="' . Lang::$txt['mc_watched_users_delete_post'] . '"', |
| 476 | 476 | 'class' => 'you_sure', |
| 477 | 477 | 'icon' => 'remove_button', |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | <script> |
| 396 | 396 | function swapPostGroup(isChecked) |
| 397 | 397 | { |
| 398 | - var is_moderator_group = ', (int)Utils::$context['is_moderator_group'], '; |
|
| 398 | + var is_moderator_group = ', (int) Utils::$context['is_moderator_group'], '; |
|
| 399 | 399 | var group_type = ', Utils::$context['group']['type'], '; |
| 400 | 400 | var min_posts_text = document.getElementById(\'min_posts_text\'); |
| 401 | 401 | var group_desc_text = document.getElementById(\'group_desc_text\'); |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | if (empty(Config::$modSettings['deny_boards_access'])) |
| 459 | 459 | echo ' |
| 460 | 460 | <li class="category"> |
| 461 | - <a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \''.$form_id.'\'); return false;"><strong>', $category['name'], '</strong></a> |
|
| 461 | + <a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'' . $form_id . '\'); return false;"><strong>', $category['name'], '</strong></a> |
|
| 462 | 462 | <ul>'; |
| 463 | 463 | else |
| 464 | 464 | echo ' |
@@ -753,7 +753,7 @@ discard block |
||
| 753 | 753 | // Filter out any redundant separators before we start the loop |
| 754 | 754 | Utils::$context['config_vars'] = array_filter( |
| 755 | 755 | Utils::$context['config_vars'], |
| 756 | - function ($v) |
|
| 756 | + function($v) |
|
| 757 | 757 | { |
| 758 | 758 | static $config_vars, $prev; |
| 759 | 759 | |
@@ -1638,7 +1638,7 @@ discard block |
||
| 1638 | 1638 | echo ' |
| 1639 | 1639 | <form action="' . Config::$scripturl . '?action=admin;area=search" method="post" accept-charset="' . Utils::$context['character_set'] . '" class="admin_search"> |
| 1640 | 1640 | <span class="main_icons filter centericon"></span> |
| 1641 | - <input type="search" name="search_term" placeholder="', Lang::$txt['admin_search'], '"', isset(Utils::$context['search_term']) ? ' value="' . Utils::$context['search_term'] . '"' : '','> |
|
| 1641 | + <input type="search" name="search_term" placeholder="', Lang::$txt['admin_search'], '"', isset(Utils::$context['search_term']) ? ' value="' . Utils::$context['search_term'] . '"' : '', '> |
|
| 1642 | 1642 | <select name="search_type"> |
| 1643 | 1643 | <option value="internal"', (empty(Utils::$context['admin_preferences']['sb']) || Utils::$context['admin_preferences']['sb'] == 'internal' ? ' selected' : ''), '>', Lang::$txt['admin_search_type_internal'], '</option> |
| 1644 | 1644 | <option value="member"', (!empty(Utils::$context['admin_preferences']['sb']) && Utils::$context['admin_preferences']['sb'] == 'member' ? ' selected' : ''), '>', Lang::$txt['admin_search_type_member'], '</option> |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | function template_single_pm($message) |
| 276 | 276 | { |
| 277 | 277 | echo ' |
| 278 | - <div class="windowbg" id="msg', $message['id'],'"> |
|
| 278 | + <div class="windowbg" id="msg', $message['id'], '"> |
|
| 279 | 279 | <div class="post_wrapper"> |
| 280 | 280 | <div class="poster">'; |
| 281 | 281 | |
@@ -1924,7 +1924,7 @@ discard block |
||
| 1924 | 1924 | <div class="smalltext"> |
| 1925 | 1925 | <div class="recipient_to"><strong>', Lang::$txt['pm_to'], ':</strong> ', implode(', ', $draft['recipients']['to']), '</div>'; |
| 1926 | 1926 | |
| 1927 | - if(!empty($draft['recipients']['bcc'])) |
|
| 1927 | + if (!empty($draft['recipients']['bcc'])) |
|
| 1928 | 1928 | echo' |
| 1929 | 1929 | <div class="pm_bbc"><strong>', Lang::$txt['pm_bcc'], ':</strong> ', implode(', ', $draft['recipients']['bcc']), '</div>'; |
| 1930 | 1930 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | <div class="board_icon"></div> |
| 124 | 124 | <div class="info">', Utils::$context['topics_headers']['subject'], ' / ', Utils::$context['topics_headers']['starter'], '</div> |
| 125 | 125 | <div class="board_stats centertext">', Utils::$context['topics_headers']['replies'], ' / ', Utils::$context['topics_headers']['views'], '</div> |
| 126 | - <div class="lastpost">', Utils::$context['topics_headers']['last_post'],'</div>'; |
|
| 126 | + <div class="lastpost">', Utils::$context['topics_headers']['last_post'], '</div>'; |
|
| 127 | 127 | |
| 128 | 128 | // Show a "select all" box for quick moderation? |
| 129 | 129 | if (Utils::$context['showCheckboxes']) |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | <div class="board_icon"></div> |
| 303 | 303 | <div class="info">', Utils::$context['topics_headers']['subject'], ' / ', Utils::$context['topics_headers']['starter'], '</div> |
| 304 | 304 | <div class="board_stats centertext">', Utils::$context['topics_headers']['replies'], ' / ', Utils::$context['topics_headers']['views'], '</div> |
| 305 | - <div class="lastpost">', Utils::$context['topics_headers']['last_post'],'</div>'; |
|
| 305 | + <div class="lastpost">', Utils::$context['topics_headers']['last_post'], '</div>'; |
|
| 306 | 306 | |
| 307 | 307 | // Show a "select all" box for quick moderation? |
| 308 | 308 | if (Utils::$context['showCheckboxes']) |
@@ -23,7 +23,8 @@ discard block |
||
| 23 | 23 | require __DIR__ . '/SSI.php'; |
| 24 | 24 | |
| 25 | 25 | // Viewing the homepage sample? |
| 26 | -if (isset($_GET['view']) && $_GET['view'] == 'home1') { |
|
| 26 | +if (isset($_GET['view']) && $_GET['view'] == 'home1') |
|
| 27 | +{ |
|
| 27 | 28 | template_homepage_sample1('output'); |
| 28 | 29 | |
| 29 | 30 | exit; |
@@ -89,7 +90,9 @@ discard block |
||
| 89 | 90 | <li><a href="#" onclick="showSSIBlock('ssi_quickSearch'); return false;">Quick Search Box</a></li> |
| 90 | 91 | <li><a href="#" onclick="showSSIBlock('ssi_recentAttachments'); return false;">Recent Attachments</a></li> |
| 91 | 92 | </ul> |
| 92 | - <?php if (SMF\User::$me->is_admin) { ?> |
|
| 93 | + <?php if (SMF\User::$me->is_admin) |
|
| 94 | +{ |
|
| 95 | +?> |
|
| 93 | 96 | <h3>Advanced Functions <img class="help" title="Functions that require additional tweaking, not just copy and paste." src="<?php echo SMF\Theme::$current->settings['images_url']; ?>/helptopics.png" alt=""></h3> |
| 94 | 97 | <ul> |
| 95 | 98 | <li><a href="#" onclick="showSSIBlock('ssi_showPoll'); return false;">Show Single Poll</a></li> |
@@ -586,7 +589,8 @@ discard block |
||
| 586 | 589 | </body> |
| 587 | 590 | </html>'; |
| 588 | 591 | |
| 589 | - if ($method == 'source') { |
|
| 592 | + if ($method == 'source') |
|
| 593 | + { |
|
| 590 | 594 | $header = '<?php require("' . (SMF\User::$me->is_admin ? addslashes(realpath(SMF\Config::$boarddir . '/SSI.php')) : 'SSI.php') . '"); ?>' . "\n" . $header; |
| 591 | 595 | |
| 592 | 596 | return $header . template_homepage_sample1_html() . $footer; |
@@ -604,7 +608,8 @@ discard block |
||
| 604 | 608 | { |
| 605 | 609 | $topics = SMF\ServerSideIncludes::recentTopics(8, null, null, 'array'); |
| 606 | 610 | |
| 607 | - foreach ($topics as $topic) { |
|
| 611 | + foreach ($topics as $topic) |
|
| 612 | + { |
|
| 608 | 613 | echo ' |
| 609 | 614 | <li><a href="', $topic['href'], '">', $topic['subject'], '</a> ', SMF\Lang::$txt['by'], ' ', $topic['poster']['link'], '</li>'; |
| 610 | 615 | } |
@@ -17,7 +17,8 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | // Don't do anything if SMF is already loaded. |
| 20 | -if (defined('SMF')) { |
|
| 20 | +if (defined('SMF')) |
|
| 21 | +{ |
|
| 21 | 22 | return true; |
| 22 | 23 | } |
| 23 | 24 | |
@@ -595,7 +595,7 @@ |
||
| 595 | 595 | * places. Otherwise it's automatically determined. |
| 596 | 596 | * @return string A formatted number |
| 597 | 597 | */ |
| 598 | - public static function numberFormat(int|float $number, ?int $decimals = null): string |
|
| 598 | + public static function numberFormat(int | float $number, ?int $decimals = null): string |
|
| 599 | 599 | { |
| 600 | 600 | // Cache these values... |
| 601 | 601 | if (!isset(self::$decimal_separator)) { |
@@ -163,36 +163,44 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public static function load(string $template_name, string $lang = '', bool $fatal = true, bool $force_reload = false) |
| 165 | 165 | { |
| 166 | - if (!isset(self::$default)) { |
|
| 166 | + if (!isset(self::$default)) |
|
| 167 | + { |
|
| 167 | 168 | self::$default = &Config::$language; |
| 168 | 169 | } |
| 169 | 170 | |
| 170 | 171 | // Default to the user's language. |
| 171 | - if ($lang == '') { |
|
| 172 | + if ($lang == '') |
|
| 173 | + { |
|
| 172 | 174 | $lang = User::$me->language ?? self::$default; |
| 173 | 175 | } |
| 174 | 176 | |
| 175 | 177 | // Don't repeat this unnecessarily. |
| 176 | - if (!$force_reload && isset(self::$already_loaded[$template_name]) && self::$already_loaded[$template_name] == $lang) { |
|
| 178 | + if (!$force_reload && isset(self::$already_loaded[$template_name]) && self::$already_loaded[$template_name] == $lang) |
|
| 179 | + { |
|
| 177 | 180 | return $lang; |
| 178 | 181 | } |
| 179 | 182 | |
| 180 | - if (empty(self::$dirs)) { |
|
| 183 | + if (empty(self::$dirs)) |
|
| 184 | + { |
|
| 181 | 185 | self::addDirs(); |
| 182 | 186 | } |
| 183 | 187 | |
| 184 | 188 | // For each file open it up and write it out! |
| 185 | - foreach (explode('+', $template_name) as $template) { |
|
| 189 | + foreach (explode('+', $template_name) as $template) |
|
| 190 | + { |
|
| 186 | 191 | $attempts = []; |
| 187 | 192 | |
| 188 | - foreach (self::$dirs as $dir) { |
|
| 193 | + foreach (self::$dirs as $dir) |
|
| 194 | + { |
|
| 189 | 195 | $attempts[] = [$dir, $template, $lang]; |
| 190 | 196 | $attempts[] = [$dir, $template, self::$default]; |
| 191 | 197 | } |
| 192 | 198 | |
| 193 | 199 | // Fall back to English if none of the preferred languages can be found. |
| 194 | - if (empty(Config::$modSettings['disable_language_fallback']) && !in_array('english', [$lang, self::$default])) { |
|
| 195 | - foreach (self::$dirs as $dir) { |
|
| 200 | + if (empty(Config::$modSettings['disable_language_fallback']) && !in_array('english', [$lang, self::$default])) |
|
| 201 | + { |
|
| 202 | + foreach (self::$dirs as $dir) |
|
| 203 | + { |
|
| 196 | 204 | $attempts[] = [$dir, $template, 'english']; |
| 197 | 205 | } |
| 198 | 206 | } |
@@ -200,8 +208,10 @@ discard block |
||
| 200 | 208 | // Try to find the language file. |
| 201 | 209 | $found = false; |
| 202 | 210 | |
| 203 | - foreach ($attempts as $k => $file) { |
|
| 204 | - if (file_exists($file[0] . '/' . $file[1] . '.' . $file[2] . '.php')) { |
|
| 211 | + foreach ($attempts as $k => $file) |
|
| 212 | + { |
|
| 213 | + if (file_exists($file[0] . '/' . $file[1] . '.' . $file[2] . '.php')) |
|
| 214 | + { |
|
| 205 | 215 | // Include it! |
| 206 | 216 | require $file[0] . '/' . $file[1] . '.' . $file[2] . '.php'; |
| 207 | 217 | |
@@ -209,8 +219,10 @@ discard block |
||
| 209 | 219 | $found = true; |
| 210 | 220 | |
| 211 | 221 | // Load the strings into our properties. |
| 212 | - foreach (['txt', 'txtBirthdayEmails', 'tztxt', 'editortxt', 'helptxt'] as $var) { |
|
| 213 | - if (!isset(${$var})) { |
|
| 222 | + foreach (['txt', 'txtBirthdayEmails', 'tztxt', 'editortxt', 'helptxt'] as $var) |
|
| 223 | + { |
|
| 224 | + if (!isset(${$var})) |
|
| 225 | + { |
|
| 214 | 226 | continue; |
| 215 | 227 | } |
| 216 | 228 | |
@@ -220,7 +232,8 @@ discard block |
||
| 220 | 232 | } |
| 221 | 233 | |
| 222 | 234 | // Did this file define the $forum_copyright? |
| 223 | - if (isset($forum_copyright)) { |
|
| 235 | + if (isset($forum_copyright)) |
|
| 236 | + { |
|
| 224 | 237 | self::$localized_copyright[$file[2]] = $forum_copyright; |
| 225 | 238 | |
| 226 | 239 | self::$forum_copyright = self::$localized_copyright[$lang] ?? (self::$localized_copyright[self::$default] ?? (self::$localized_copyright['english'] ?? '')); |
@@ -229,10 +242,14 @@ discard block |
||
| 229 | 242 | } |
| 230 | 243 | |
| 231 | 244 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
| 232 | - if (!empty(self::$txt['lang_locale'])) { |
|
| 233 | - if (strpos(self::$txt['lang_locale'], '.') !== false) { |
|
| 245 | + if (!empty(self::$txt['lang_locale'])) |
|
| 246 | + { |
|
| 247 | + if (strpos(self::$txt['lang_locale'], '.') !== false) |
|
| 248 | + { |
|
| 234 | 249 | $locale_variants = self::$txt['lang_locale']; |
| 235 | - } else { |
|
| 250 | + } |
|
| 251 | + else |
|
| 252 | + { |
|
| 236 | 253 | $locale_variants = array_unique(array_merge( |
| 237 | 254 | !empty(Config::$modSettings['global_character_set']) ? [self::$txt['lang_locale'] . '.' . Config::$modSettings['global_character_set']] : [], |
| 238 | 255 | !empty(Utils::$context['utf8']) ? [self::$txt['lang_locale'] . '.UTF-8', self::$txt['lang_locale'] . '.UTF8', self::$txt['lang_locale'] . '.utf-8', self::$txt['lang_locale'] . '.utf8'] : [], |
@@ -248,20 +265,24 @@ discard block |
||
| 248 | 265 | } |
| 249 | 266 | |
| 250 | 267 | // That couldn't be found! Log the error, but *try* to continue normally. |
| 251 | - if (!$found && $fatal) { |
|
| 268 | + if (!$found && $fatal) |
|
| 269 | + { |
|
| 252 | 270 | ErrorHandler::log(sprintf(self::$txt['theme_language_error'] ?? 'Unable to load the \'%1$s\' language file.', $template_name . '.' . $lang, 'template')); |
| 253 | 271 | break; |
| 254 | 272 | } |
| 255 | 273 | |
| 256 | 274 | // Copyright can't be empty. |
| 257 | - if (empty(self::$forum_copyright)) { |
|
| 275 | + if (empty(self::$forum_copyright)) |
|
| 276 | + { |
|
| 258 | 277 | $class_vars = get_class_vars(__CLASS__); |
| 259 | 278 | self::$forum_copyright = $class_vars['forum_copyright']; |
| 260 | 279 | } |
| 261 | 280 | |
| 262 | 281 | // For the sake of backward compatibility |
| 263 | - if (!empty(self::$txt['emails'])) { |
|
| 264 | - foreach (self::$txt['emails'] as $key => $value) { |
|
| 282 | + if (!empty(self::$txt['emails'])) |
|
| 283 | + { |
|
| 284 | + foreach (self::$txt['emails'] as $key => $value) |
|
| 285 | + { |
|
| 265 | 286 | self::$txt[$key . '_subject'] = $value['subject']; |
| 266 | 287 | self::$txt[$key . '_body'] = $value['body']; |
| 267 | 288 | } |
@@ -272,8 +293,10 @@ discard block |
||
| 272 | 293 | // empty in a normal install. If it isn't it means the forum is using |
| 273 | 294 | // something "old" (it may be the translation, it may be a mod) and this |
| 274 | 295 | // code (like the piece above) takes care of converting it to the new format |
| 275 | - if (!empty($birthdayEmails)) { |
|
| 276 | - foreach ($birthdayEmails as $key => $value) { |
|
| 296 | + if (!empty($birthdayEmails)) |
|
| 297 | + { |
|
| 298 | + foreach ($birthdayEmails as $key => $value) |
|
| 299 | + { |
|
| 277 | 300 | self::$txtBirthdayEmails[$key . '_subject'] = $value['subject']; |
| 278 | 301 | self::$txtBirthdayEmails[$key . '_body'] = $value['body']; |
| 279 | 302 | self::$txtBirthdayEmails[$key . '_author'] = $value['author']; |
@@ -283,7 +306,8 @@ discard block |
||
| 283 | 306 | } |
| 284 | 307 | |
| 285 | 308 | // Keep track of what we're up to, soldier. |
| 286 | - if (!empty(Config::$db_show_debug)) { |
|
| 309 | + if (!empty(Config::$db_show_debug)) |
|
| 310 | + { |
|
| 287 | 311 | Utils::$context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . basename(Theme::$current->settings['theme_url'] ?? 'unknown') . ')'; |
| 288 | 312 | } |
| 289 | 313 | |
@@ -309,20 +333,27 @@ discard block |
||
| 309 | 333 | public static function addDirs($custom_dirs = []) |
| 310 | 334 | { |
| 311 | 335 | // We only accept real directories. |
| 312 | - if (!empty($custom_dirs)) { |
|
| 336 | + if (!empty($custom_dirs)) |
|
| 337 | + { |
|
| 313 | 338 | $custom_dirs = array_filter(array_map('realpath', (array) $custom_dirs), 'is_dir'); |
| 314 | 339 | } |
| 315 | 340 | |
| 316 | - if (!empty($custom_dirs)) { |
|
| 341 | + if (!empty($custom_dirs)) |
|
| 342 | + { |
|
| 317 | 343 | self::$dirs = array_merge($custom_dirs, self::$dirs); |
| 318 | - } else { |
|
| 344 | + } |
|
| 345 | + else |
|
| 346 | + { |
|
| 319 | 347 | // Make sure we have Theme::$current->settings - if not we're in trouble and need to find it! |
| 320 | - if (empty(Theme::$current->settings['default_theme_dir'])) { |
|
| 348 | + if (empty(Theme::$current->settings['default_theme_dir'])) |
|
| 349 | + { |
|
| 321 | 350 | Theme::loadEssential(); |
| 322 | 351 | } |
| 323 | 352 | |
| 324 | - foreach (['theme_dir', 'base_theme_dir', 'default_theme_dir'] as $var) { |
|
| 325 | - if (isset(Theme::$current->settings[$var])) { |
|
| 353 | + foreach (['theme_dir', 'base_theme_dir', 'default_theme_dir'] as $var) |
|
| 354 | + { |
|
| 355 | + if (isset(Theme::$current->settings[$var])) |
|
| 356 | + { |
|
| 326 | 357 | self::$dirs[] = Theme::$current->settings[$var] . '/languages'; |
| 327 | 358 | } |
| 328 | 359 | } |
@@ -344,9 +375,11 @@ discard block |
||
| 344 | 375 | public static function get($use_cache = true) |
| 345 | 376 | { |
| 346 | 377 | // Either we don't use the cache, or its expired. |
| 347 | - if (!$use_cache || (Utils::$context['languages'] = CacheApi::get('known_languages', !empty(CacheApi::$enable) && CacheApi::$enable < 1 ? 86400 : 3600)) == null) { |
|
| 378 | + if (!$use_cache || (Utils::$context['languages'] = CacheApi::get('known_languages', !empty(CacheApi::$enable) && CacheApi::$enable < 1 ? 86400 : 3600)) == null) |
|
| 379 | + { |
|
| 348 | 380 | // If we don't have our theme information yet, let's get it. |
| 349 | - if (empty(Theme::$current->settings['default_theme_dir'])) { |
|
| 381 | + if (empty(Theme::$current->settings['default_theme_dir'])) |
|
| 382 | + { |
|
| 350 | 383 | Theme::load(0, false); |
| 351 | 384 | } |
| 352 | 385 | |
@@ -355,35 +388,42 @@ discard block |
||
| 355 | 388 | Theme::$current->settings['default_theme_dir'] . '/languages', |
| 356 | 389 | ]; |
| 357 | 390 | |
| 358 | - if (!empty(Theme::$current->settings['actual_theme_dir']) && Theme::$current->settings['actual_theme_dir'] != Theme::$current->settings['default_theme_dir']) { |
|
| 391 | + if (!empty(Theme::$current->settings['actual_theme_dir']) && Theme::$current->settings['actual_theme_dir'] != Theme::$current->settings['default_theme_dir']) |
|
| 392 | + { |
|
| 359 | 393 | $language_directories[] = Theme::$current->settings['actual_theme_dir'] . '/languages'; |
| 360 | 394 | } |
| 361 | 395 | |
| 362 | 396 | // We possibly have a base theme directory. |
| 363 | - if (!empty(Theme::$current->settings['base_theme_dir'])) { |
|
| 397 | + if (!empty(Theme::$current->settings['base_theme_dir'])) |
|
| 398 | + { |
|
| 364 | 399 | $language_directories[] = Theme::$current->settings['base_theme_dir'] . '/languages'; |
| 365 | 400 | } |
| 366 | 401 | |
| 367 | 402 | // Remove any duplicates. |
| 368 | 403 | $language_directories = array_unique($language_directories); |
| 369 | 404 | |
| 370 | - foreach ($language_directories as $language_dir) { |
|
| 405 | + foreach ($language_directories as $language_dir) |
|
| 406 | + { |
|
| 371 | 407 | // Can't look in here... doesn't exist! |
| 372 | - if (!file_exists($language_dir)) { |
|
| 408 | + if (!file_exists($language_dir)) |
|
| 409 | + { |
|
| 373 | 410 | continue; |
| 374 | 411 | } |
| 375 | 412 | |
| 376 | 413 | $dir = dir($language_dir); |
| 377 | 414 | |
| 378 | - while ($entry = $dir->read()) { |
|
| 415 | + while ($entry = $dir->read()) |
|
| 416 | + { |
|
| 379 | 417 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
| 380 | - if (!preg_match('~^index\.((?:.(?!-utf8))+)\.php$~', $entry, $matches)) { |
|
| 418 | + if (!preg_match('~^index\.((?:.(?!-utf8))+)\.php$~', $entry, $matches)) |
|
| 419 | + { |
|
| 381 | 420 | continue; |
| 382 | 421 | } |
| 383 | 422 | |
| 384 | 423 | $langName = Utils::ucwords(strtr($matches[1], ['_' => ' '])); |
| 385 | 424 | |
| 386 | - if (($spos = strpos($langName, ' ')) !== false) { |
|
| 425 | + if (($spos = strpos($langName, ' ')) !== false) |
|
| 426 | + { |
|
| 387 | 427 | $langName = substr($langName, 0, ++$spos) . '(' . substr($langName, $spos) . ')'; |
| 388 | 428 | } |
| 389 | 429 | |
@@ -391,18 +431,23 @@ discard block |
||
| 391 | 431 | $fp = @fopen($language_dir . '/' . $entry, 'r'); |
| 392 | 432 | |
| 393 | 433 | // Yay! |
| 394 | - if ($fp) { |
|
| 395 | - while (($line = fgets($fp)) !== false) { |
|
| 396 | - if (strpos($line, '$txt[\'native_name\']') === false) { |
|
| 434 | + if ($fp) |
|
| 435 | + { |
|
| 436 | + while (($line = fgets($fp)) !== false) |
|
| 437 | + { |
|
| 438 | + if (strpos($line, '$txt[\'native_name\']') === false) |
|
| 439 | + { |
|
| 397 | 440 | continue; |
| 398 | 441 | } |
| 399 | 442 | |
| 400 | 443 | preg_match('~\$txt\[\'native_name\'\]\s*=\s*\'([^\']+)\';~', $line, $matchNative); |
| 401 | 444 | |
| 402 | 445 | // Set the language's name. |
| 403 | - if (!empty($matchNative) && !empty($matchNative[1])) { |
|
| 446 | + if (!empty($matchNative) && !empty($matchNative[1])) |
|
| 447 | + { |
|
| 404 | 448 | // Don't mislabel the language if the translator missed this one. |
| 405 | - if ($langName !== 'English' && $matchNative[1] === 'English') { |
|
| 449 | + if ($langName !== 'English' && $matchNative[1] === 'English') |
|
| 450 | + { |
|
| 406 | 451 | break; |
| 407 | 452 | } |
| 408 | 453 | |
@@ -428,12 +473,14 @@ discard block |
||
| 428 | 473 | |
| 429 | 474 | // Avoid confusion when we have more than one English variant installed. |
| 430 | 475 | // Honestly, our default English version should always have been called "English (US)" |
| 431 | - if (substr_count(implode(' ', array_keys(Utils::$context['languages'])), 'english') > 1 && Utils::$context['languages']['english']['name'] === 'English') { |
|
| 476 | + if (substr_count(implode(' ', array_keys(Utils::$context['languages'])), 'english') > 1 && Utils::$context['languages']['english']['name'] === 'English') |
|
| 477 | + { |
|
| 432 | 478 | Utils::$context['languages']['english']['name'] = 'English (US)'; |
| 433 | 479 | } |
| 434 | 480 | |
| 435 | 481 | // Let's cash in on this deal. |
| 436 | - if (!empty(CacheApi::$enable)) { |
|
| 482 | + if (!empty(CacheApi::$enable)) |
|
| 483 | + { |
|
| 437 | 484 | CacheApi::put('known_languages', Utils::$context['languages'], !empty(CacheApi::$enable) && CacheApi::$enable < 1 ? 86400 : 3600); |
| 438 | 485 | } |
| 439 | 486 | } |
@@ -457,22 +504,26 @@ discard block |
||
| 457 | 504 | { |
| 458 | 505 | static $censor_vulgar = null, $censor_proper; |
| 459 | 506 | |
| 460 | - if ((!empty(Theme::$current->options['show_no_censored']) && !empty(Config::$modSettings['allow_no_censored']) && !$force) || empty(Config::$modSettings['censor_vulgar']) || !is_string($text) || trim($text) === '') { |
|
| 507 | + if ((!empty(Theme::$current->options['show_no_censored']) && !empty(Config::$modSettings['allow_no_censored']) && !$force) || empty(Config::$modSettings['censor_vulgar']) || !is_string($text) || trim($text) === '') |
|
| 508 | + { |
|
| 461 | 509 | return $text; |
| 462 | 510 | } |
| 463 | 511 | |
| 464 | 512 | IntegrationHook::call('integrate_word_censor', [&$text]); |
| 465 | 513 | |
| 466 | 514 | // If they haven't yet been loaded, load them. |
| 467 | - if ($censor_vulgar == null) { |
|
| 515 | + if ($censor_vulgar == null) |
|
| 516 | + { |
|
| 468 | 517 | $censor_vulgar = explode("\n", Config::$modSettings['censor_vulgar']); |
| 469 | 518 | $censor_proper = explode("\n", Config::$modSettings['censor_proper']); |
| 470 | 519 | |
| 471 | 520 | // Quote them for use in regular expressions. |
| 472 | - if (!empty(Config::$modSettings['censorWholeWord'])) { |
|
| 521 | + if (!empty(Config::$modSettings['censorWholeWord'])) |
|
| 522 | + { |
|
| 473 | 523 | $charset = empty(Config::$modSettings['global_character_set']) ? self::$txt['lang_character_set'] : Config::$modSettings['global_character_set']; |
| 474 | 524 | |
| 475 | - for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) { |
|
| 525 | + for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
|
| 526 | + { |
|
| 476 | 527 | $censor_vulgar[$i] = str_replace(['\\\\\\*', '\\*', '&', '\''], ['[*]', '[^\\s]*?', '&', '''], preg_quote($censor_vulgar[$i], '/')); |
| 477 | 528 | |
| 478 | 529 | // Use the faster \b if we can, or something more complex if we can't |
@@ -485,10 +536,13 @@ discard block |
||
| 485 | 536 | } |
| 486 | 537 | |
| 487 | 538 | // Censoring isn't so very complicated :P. |
| 488 | - if (empty(Config::$modSettings['censorWholeWord'])) { |
|
| 539 | + if (empty(Config::$modSettings['censorWholeWord'])) |
|
| 540 | + { |
|
| 489 | 541 | $func = !empty(Config::$modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
| 490 | 542 | $text = $func($censor_vulgar, $censor_proper, $text); |
| 491 | - } else { |
|
| 543 | + } |
|
| 544 | + else |
|
| 545 | + { |
|
| 492 | 546 | $text = preg_replace($censor_vulgar, $censor_proper, $text); |
| 493 | 547 | } |
| 494 | 548 | |
@@ -506,7 +560,8 @@ discard block |
||
| 506 | 560 | */ |
| 507 | 561 | public static function tokenTxtReplace(string $string = ''): string |
| 508 | 562 | { |
| 509 | - if (empty($string)) { |
|
| 563 | + if (empty($string)) |
|
| 564 | + { |
|
| 510 | 565 | return ''; |
| 511 | 566 | } |
| 512 | 567 | |
@@ -514,8 +569,10 @@ discard block |
||
| 514 | 569 | $toFind = []; |
| 515 | 570 | $replaceWith = []; |
| 516 | 571 | |
| 517 | - if (!empty($matches[1])) { |
|
| 518 | - foreach ($matches[1] as $token) { |
|
| 572 | + if (!empty($matches[1])) |
|
| 573 | + { |
|
| 574 | + foreach ($matches[1] as $token) |
|
| 575 | + { |
|
| 519 | 576 | $toFind[] = '{' . $token . '}'; |
| 520 | 577 | $replaceWith[] = self::$txt[$token] ?? $token; |
| 521 | 578 | } |
@@ -537,15 +594,18 @@ discard block |
||
| 537 | 594 | public static function sentenceList(array $list): string |
| 538 | 595 | { |
| 539 | 596 | // Make sure the bare necessities are defined. |
| 540 | - if (empty(Lang::$txt['sentence_list_format']['n'])) { |
|
| 597 | + if (empty(Lang::$txt['sentence_list_format']['n'])) |
|
| 598 | + { |
|
| 541 | 599 | Lang::$txt['sentence_list_format']['n'] = '{series}'; |
| 542 | 600 | } |
| 543 | 601 | |
| 544 | - if (!isset(Lang::$txt['sentence_list_separator'])) { |
|
| 602 | + if (!isset(Lang::$txt['sentence_list_separator'])) |
|
| 603 | + { |
|
| 545 | 604 | Lang::$txt['sentence_list_separator'] = ', '; |
| 546 | 605 | } |
| 547 | 606 | |
| 548 | - if (!isset(Lang::$txt['sentence_list_separator_alt'])) { |
|
| 607 | + if (!isset(Lang::$txt['sentence_list_separator_alt'])) |
|
| 608 | + { |
|
| 549 | 609 | Lang::$txt['sentence_list_separator_alt'] = '; '; |
| 550 | 610 | } |
| 551 | 611 | |
@@ -555,8 +615,10 @@ discard block |
||
| 555 | 615 | // Do we want the normal separator or the alternate? |
| 556 | 616 | $separator = Lang::$txt['sentence_list_separator']; |
| 557 | 617 | |
| 558 | - foreach ($list as $item) { |
|
| 559 | - if (strpos($item, $separator) !== false) { |
|
| 618 | + foreach ($list as $item) |
|
| 619 | + { |
|
| 620 | + if (strpos($item, $separator) !== false) |
|
| 621 | + { |
|
| 560 | 622 | $separator = Lang::$txt['sentence_list_separator_alt']; |
| 561 | 623 | $format = strtr($format, trim(Lang::$txt['sentence_list_separator']), trim($separator)); |
| 562 | 624 | break; |
@@ -568,14 +630,16 @@ discard block |
||
| 568 | 630 | // Special handling for the last items on the list. |
| 569 | 631 | $i = 0; |
| 570 | 632 | |
| 571 | - while (strpos($format, '{' . --$i . '}') !== false) { |
|
| 633 | + while (strpos($format, '{' . --$i . '}') !== false) |
|
| 634 | + { |
|
| 572 | 635 | $replacements['{' . $i . '}'] = array_pop($list); |
| 573 | 636 | } |
| 574 | 637 | |
| 575 | 638 | // Special handling for the first items on the list. |
| 576 | 639 | $i = 0; |
| 577 | 640 | |
| 578 | - while (strpos($format, '{' . ++$i . '}') !== false) { |
|
| 641 | + while (strpos($format, '{' . ++$i . '}') !== false) |
|
| 642 | + { |
|
| 579 | 643 | $replacements['{' . $i . '}'] = array_shift($list); |
| 580 | 644 | } |
| 581 | 645 | |
@@ -598,9 +662,11 @@ discard block |
||
| 598 | 662 | public static function numberFormat(int|float $number, ?int $decimals = null): string |
| 599 | 663 | { |
| 600 | 664 | // Cache these values... |
| 601 | - if (!isset(self::$decimal_separator)) { |
|
| 665 | + if (!isset(self::$decimal_separator)) |
|
| 666 | + { |
|
| 602 | 667 | // Not set for whatever reason? |
| 603 | - if (empty(Lang::$txt['number_format']) || preg_match('~^1(\D*)234(\D*)(0*)$~', Lang::$txt['number_format'], $matches) != 1) { |
|
| 668 | + if (empty(Lang::$txt['number_format']) || preg_match('~^1(\D*)234(\D*)(0*)$~', Lang::$txt['number_format'], $matches) != 1) |
|
| 669 | + { |
|
| 604 | 670 | return (string) $number; |
| 605 | 671 | } |
| 606 | 672 | |
@@ -621,7 +687,8 @@ discard block |
||
| 621 | 687 | } |
| 622 | 688 | |
| 623 | 689 | // Export public static functions and properties to global namespace for backward compatibility. |
| 624 | -if (is_callable(__NAMESPACE__ . '\\Lang::exportStatic')) { |
|
| 690 | +if (is_callable(__NAMESPACE__ . '\\Lang::exportStatic')) |
|
| 691 | +{ |
|
| 625 | 692 | Lang::exportStatic(); |
| 626 | 693 | } |
| 627 | 694 | |
@@ -175,7 +175,8 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // Patrons with invalid tokens get the boot. |
| 178 | - if ($reset) { |
|
| 178 | + if ($reset) |
|
| 179 | + { |
|
| 179 | 180 | // Might as well do some cleanup on this. |
| 180 | 181 | self::clean(); |
| 181 | 182 | |
@@ -189,7 +190,8 @@ discard block |
||
| 189 | 190 | unset($_SESSION['token'][$type . '-' . $action]); |
| 190 | 191 | |
| 191 | 192 | // Randomly check if we should delete some older tokens. |
| 192 | - if (mt_rand(0, 138) == 23) { |
|
| 193 | + if (mt_rand(0, 138) == 23) |
|
| 194 | + { |
|
| 193 | 195 | self::clean(); |
| 194 | 196 | } |
| 195 | 197 | |
@@ -207,19 +209,23 @@ discard block |
||
| 207 | 209 | public static function clean(bool $complete = false): void |
| 208 | 210 | { |
| 209 | 211 | // We appreciate cleaning up after yourselves. |
| 210 | - if (empty($_SESSION['token'])) { |
|
| 212 | + if (empty($_SESSION['token'])) |
|
| 213 | + { |
|
| 211 | 214 | return; |
| 212 | 215 | } |
| 213 | 216 | |
| 214 | - if ($complete) { |
|
| 217 | + if ($complete) |
|
| 218 | + { |
|
| 215 | 219 | $_SESSION['token'] = []; |
| 216 | 220 | |
| 217 | 221 | return; |
| 218 | 222 | } |
| 219 | 223 | |
| 220 | 224 | // Clean up tokens, trying to give enough time still. |
| 221 | - foreach ($_SESSION['token'] as $key => $token) { |
|
| 222 | - if (!($token instanceof self) || $token->time + self::EXPIRY_TIME < time()) { |
|
| 225 | + foreach ($_SESSION['token'] as $key => $token) |
|
| 226 | + { |
|
| 227 | + if (!($token instanceof self) || $token->time + self::EXPIRY_TIME < time()) |
|
| 228 | + { |
|
| 223 | 229 | unset($_SESSION['token'][$key]); |
| 224 | 230 | } |
| 225 | 231 | } |
@@ -252,7 +258,8 @@ discard block |
||
| 252 | 258 | } |
| 253 | 259 | |
| 254 | 260 | // Export public static functions and properties to global namespace for backward compatibility. |
| 255 | -if (is_callable(__NAMESPACE__ . '\\SecurityToken::exportStatic')) { |
|
| 261 | +if (is_callable(__NAMESPACE__ . '\\SecurityToken::exportStatic')) |
|
| 262 | +{ |
|
| 256 | 263 | SecurityToken::exportStatic(); |
| 257 | 264 | } |
| 258 | 265 | |