/** * Initializes the vB framework. * All framework level objects and services are created so that they are available * throughout the application. This is only done once per actual request. * * Note: If the framework is used this way then there are several limitations. * - If no vB_Bootstrap was created (ie, the admincp), then you cannot render any * views created by the framework. * - VB_ENTRY must be defined to a valid request script that runs the framework * with vB::Main() * - If you are rendering views, try to create all of the views that will be * used before rendering any of them. This optimises template and phrase * fetching. */ public static function init($relative_path = false) { global $vbulletin, $vbphrase; if (self::$initialized) { return; } // Reference legacy registry self::$vbulletin = $vbulletin; // Legacy DB self::$db = $vbulletin->db; // Set a top level exception handler set_exception_handler(array('vB', 'handleException')); // Set unserializer to use spl registered autoloader ini_set('unserialize_callback_func', 'spl_autoload_call'); // Set class autoloader spl_autoload_register(array('vB', 'autoload')); // Legacy language vB_Phrase::setLanguage(!empty(self::$vbulletin->session->vars['languageid']) ? self::$vbulletin->session->vars['languageid'] : intval(self::$vbulletin->options['languageid'])); vB_Phrase::preCache($vbphrase, $GLOBALS['phrasegroups']); // Ensure we have friendly url class require_once DIR . '/includes/class_friendly_url.php'; if ($relative_path) { vB_Router::setRelativePath($relative_path); } // Done self::$initialized = true; }
/** * Returns the initial $vbphrase array * * @return array */ function init_language() { global $vbulletin, $phrasegroups, $vbphrasegroup; global $copyrightyear, $timediff, $timenow, $datenow; // define languageid define('LANGUAGEID', iif(empty($vbulletin->userinfo['languageid']), $vbulletin->options['languageid'], $vbulletin->userinfo['languageid'])); // define language direction define('LANGUAGE_DIRECTION', iif($vbulletin->userinfo['lang_options'] & $vbulletin->bf_misc_languageoptions['direction'], 'ltr', 'rtl')); // define html language code (lang="xyz") define('LANGUAGE_CODE', $vbulletin->userinfo['lang_code']); // initialize the $vbphrase array $vbphrase = array(); // populate the $vbphrase array with phrase groups foreach ($phrasegroups as $phrasegroup) { $tmp = unserialize($vbulletin->userinfo["phrasegroup_{$phrasegroup}"]); if (is_array($tmp)) { $vbphrase = array_merge($vbphrase, $tmp); } unset($vbulletin->userinfo["phrasegroup_{$phrasegroup}"], $tmp); } $vbphrasegroup = array(); $tmp = unserialize($vbulletin->userinfo["lang_phrasegroupinfo"]); if (is_array($tmp)) { $vbphrasegroup = $tmp; } unset($vbulletin->userinfo['lang_phrasegroupinfo']); // prepare phrases for construct_phrase / sprintf use //$vbphrase = preg_replace('/\{([0-9]+)\}/siU', '%\\1$s', $vbphrase); if (!defined('NOGLOBALPHRASE')) { // pre-parse some global phrases $tzoffset = iif($vbulletin->userinfo['tzoffset'], ' ' . $vbulletin->userinfo['tzoffset']); $vbphrase['all_times_are_gmt_x_time_now_is_y'] = construct_phrase($vbphrase['all_times_are_gmt_x_time_now_is_y'], $tzoffset, $timenow, $datenow); $vbphrase['vbulletin_copyright_orig'] = $vbphrase['vbulletin_copyright']; $vbphrase['vbulletin_copyright'] = construct_phrase($vbphrase['vbulletin_copyright'], $vbulletin->options['templateversion'], $copyrightyear); $vbphrase['powered_by_vbulletin'] = construct_phrase($vbphrase['powered_by_vbulletin'], $vbulletin->options['templateversion'], $copyrightyear); $vbphrase['timezone'] = construct_phrase($vbphrase['timezone'], $timediff, $timenow, $datenow); } vB_Phrase::preCache($vbphrase, $phrasegroups); // all done return $vbphrase; }