|
From: Jon O. <jon...@us...> - 2006-06-18 10:46:07
|
Update of /cvsroot/mxbb/core/includes In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv26131/includes Modified Files: mx_functions_style.php Log Message: update for phpBB 2.0.21 Index: mx_functions_style.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_style.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** mx_functions_style.php 17 Jun 2006 20:09:07 -0000 1.5 --- mx_functions_style.php 18 Jun 2006 10:46:03 -0000 1.6 *************** *** 256,260 **** { global $userdata, $board_config, $theme, $images; ! global $template, $lang, $phpEx, $phpbb_root_path, $mx_root_path; global $nav_links; --- 256,260 ---- { global $userdata, $board_config, $theme, $images; ! global $template, $lang, $phpEx, $phpbb_root_path, $mx_root_path, $db; global $nav_links; *************** *** 263,267 **** if ( !empty($userdata['user_lang'])) { ! $board_config['default_lang'] = $userdata['user_lang']; } --- 263,268 ---- if ( !empty($userdata['user_lang'])) { ! //$board_config['default_lang'] = $userdata['user_lang']; // See simpler lang select code below ! $default_lang = phpbb_ltrim(basename(phpbb_rtrim($userdata['user_lang'])), "'"); } *************** *** 276,280 **** --- 277,353 ---- } } + // + // New code (phpBB 2.0.21) from here on, to comment below + // + else + { + $default_lang = phpbb_ltrim(basename(phpbb_rtrim($board_config['default_lang'])), "'"); + } + + if ( !file_exists(@phpbb_realpath($mx_root_path . 'language/lang_' . $default_lang . '/lang_main.'.$phpEx)) ) + { + if ( $userdata['user_id'] != ANONYMOUS ) + { + // For logged in users, try the board default language next + $default_lang = phpbb_ltrim(basename(phpbb_rtrim($board_config['default_lang'])), "'"); + } + else + { + // For guests it means the default language is not present, try english + // This is a long shot since it means serious errors in the setup to reach here, + // but english is part of a new install so it's worth us trying + $default_lang = 'english'; + } + + if ( !file_exists(@phpbb_realpath($mx_root_path . 'language/lang_' . $default_lang . '/lang_main.'.$phpEx)) ) + { + message_die(CRITICAL_ERROR, 'Could not locate valid language pack'); + } + } + + // If we've had to change the value in any way then let's write it back to the database + // before we go any further since it means there is something wrong with it + if ( $userdata['user_id'] != ANONYMOUS && $userdata['user_lang'] !== $default_lang ) + { + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_lang = '" . $default_lang . "' + WHERE user_lang = '" . $userdata['user_lang'] . "'"; + + if ( !($result = $db->sql_query($sql)) ) + { + message_die(CRITICAL_ERROR, 'Could not update user language info'); + } + $userdata['user_lang'] = $default_lang; + } + elseif ( $userdata['user_id'] === ANONYMOUS && $board_config['default_lang'] !== $default_lang ) + { + $sql = 'UPDATE ' . CONFIG_TABLE . " + SET config_value = '" . $default_lang . "' + WHERE config_name = 'default_lang'"; + + if ( !($result = $db->sql_query($sql)) ) + { + message_die(CRITICAL_ERROR, 'Could not update user language info'); + } + } + + $board_config['default_lang'] = $default_lang; + + include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx); // Also include phpBB lang keys + include($mx_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx); + + if ( defined('IN_ADMIN') ) + { + if( !file_exists(@phpbb_realpath($mx_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.'.$phpEx)) ) + { + $board_config['default_lang'] = 'english'; + } + + include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx); // Also include phpBB lang keys + include($mx_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx); + } + + /* Note: This is a simpler "working" version. phpBB 2.0.21 introduced above code instead. // // Is the lang installed? *************** *** 304,307 **** --- 377,381 ---- include($mx_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx); } + */ // *************** *** 375,382 **** // // Get theme data. To cache? // ! $sql = "SELECT * ! FROM " . THEMES_TABLE . " ! WHERE themes_id = $style"; // --- 449,457 ---- // // Get theme data. To cache? + // Note: This part is different from original phpBB style setup // ! $sql = 'SELECT * ! FROM ' . THEMES_TABLE . ' ! WHERE themes_id = ' . (int) $style; // *************** *** 387,393 **** $style = $board_config['default_style']; ! $sql = "SELECT * ! FROM " . THEMES_TABLE . " ! WHERE themes_id = $style"; if ( !($result = $db->sql_query($sql, 120)) ) --- 462,468 ---- $style = $board_config['default_style']; ! $sql = 'SELECT * ! FROM ' . THEMES_TABLE . ' ! WHERE themes_id = ' . (int) $style; if ( !($result = $db->sql_query($sql, 120)) ) |