function setLanguage() { $lang = 'en'; // Fetch language requests if (!empty($_REQUEST['lang'])) { $lang = preg_replace('/[^a-zA-Z\\-]/', NULL, $_REQUEST['lang']); } // Set language try { Lang::initialize(); Lang::set($lang, false); } catch (Exception $s) { return NULL; } return true; }
/** * The Symphony constructor initialises the class variables of Symphony. At present * constructor has a couple of responsibilities: * - Start a profiler instance * - If magic quotes are enabled, clean `$_SERVER`, `$_COOKIE`, `$_GET` and `$_POST` arrays * - Initialise the correct Language for the currently logged in Author. * - Start the session and adjust the error handling if the user is logged in */ protected function __construct() { self::$Profiler = Profiler::instance(); if (get_magic_quotes_gpc()) { General::cleanArray($_SERVER); General::cleanArray($_COOKIE); General::cleanArray($_GET); General::cleanArray($_POST); } // Initialize language management Lang::initialize(); Lang::set(self::$Configuration->get('lang', 'symphony')); self::initialiseCookie(); // If the user is not a logged in Author, turn off the verbose error messages. if (!self::isLoggedIn() && is_null(self::$Author)) { GenericExceptionHandler::$enabled = false; } // Engine is ready. self::$Profiler->sample('Engine Initialisation'); }
/** * The Symphony constructor initialises the class variables of Symphony. * It will set the DateTime settings, define new date constants and initialise * the correct Language for the currently logged in Author. If magic quotes * are enabled, Symphony will sanitize the `$_SERVER`, `$_COOKIE`, * `$_GET` and `$_POST` arrays. The constructor loads in * the initial Configuration values from the `CONFIG` file */ protected function __construct() { self::$Profiler = Profiler::instance(); self::$Profiler->sample('Engine Initialisation'); if (get_magic_quotes_gpc()) { General::cleanArray($_SERVER); General::cleanArray($_COOKIE); General::cleanArray($_GET); General::cleanArray($_POST); } $this->initialiseConfiguration(); define_safe('__SYM_DATE_FORMAT__', self::Configuration()->get('date_format', 'region')); define_safe('__SYM_TIME_FORMAT__', self::Configuration()->get('time_format', 'region')); define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . self::Configuration()->get('datetime_separator', 'region') . __SYM_TIME_FORMAT__); DateTimeObj::setSettings(self::Configuration()->get('region')); // Initialize language management Lang::initialize(); $this->initialiseLog(); GenericExceptionHandler::initialise(self::Log()); GenericErrorHandler::initialise(self::Log()); $this->initialiseDatabase(); $this->initialiseExtensionManager(); $this->initialiseCookie(); // If the user is not a logged in Author, turn off the verbose error messages. if (!self::isLoggedIn() && is_null($this->Author)) { GenericExceptionHandler::$enabled = false; } // Set system language Lang::set(self::$Configuration->get('lang', 'symphony')); }
/** * Initialises the language by looking at the `lang` key, * passed via GET or POST */ public function initialiseLang() { $lang = !empty($_REQUEST['lang']) ? preg_replace('/[^a-zA-Z\\-]/', NULL, $_REQUEST['lang']) : 'en'; Lang::initialize(); Lang::set($lang, false); }
/** * The Symphony constructor initialises the class variables of Symphony. * It will set the DateTime settings, define new date constants and initialise * the correct Language for the currently logged in Author. If magic quotes * are enabled, Symphony will sanitize the `$_SERVER`, `$_COOKIE`, * `$_GET` and `$_POST` arrays. The constructor loads in * the initial Configuration values from the `CONFIG` file */ protected function __construct() { $this->Profiler = Profiler::instance(); $this->Profiler->sample('Engine Initialisation'); if (get_magic_quotes_gpc()) { General::cleanArray($_SERVER); General::cleanArray($_COOKIE); General::cleanArray($_GET); General::cleanArray($_POST); } // Includes the existing CONFIG file and initialises the Configuration // by setting the values with the setArray function. include CONFIG; self::$Configuration = new Configuration(true); self::$Configuration->setArray($settings); DateTimeObj::setDefaultTimezone(self::$Configuration->get('timezone', 'region')); define_safe('__SYM_DATE_FORMAT__', self::$Configuration->get('date_format', 'region')); define_safe('__SYM_TIME_FORMAT__', self::$Configuration->get('time_format', 'region')); define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . self::$Configuration->get('datetime_separator', 'region') . __SYM_TIME_FORMAT__); // Initialize language management Lang::initialize(); $this->initialiseLog(); GenericExceptionHandler::initialise(self::$Log); GenericErrorHandler::initialise(self::$Log, self::$Configuration->get('strict_error_handling', 'symphony')); $this->initialiseDatabase(); $this->initialiseExtensionManager(); $this->initialiseCookie(); // If the user is not a logged in Author, turn off the verbose error // messages. if (!self::isLoggedIn() && is_null($this->Author)) { GenericExceptionHandler::$enabled = false; } // Set system language Lang::set(self::$Configuration->get('lang', 'symphony')); }