本文整理匯總了PHP中Director::get_site_mode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Director::get_site_mode方法的具體用法?PHP Director::get_site_mode怎麽用?PHP Director::get_site_mode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Director
的用法示例。
在下文中一共展示了Director::get_site_mode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: choose_site_locale
/**
* Choose the language the site is currently on.
* If $_GET['locale'] is set, then it will use that language, and store it in the session.
* Otherwise it checks the session for a possible stored language, either from namespace to the site_mode
* ('site' or 'cms'), or for a 'global' language setting.
* The final option is the member preference.
*
* @todo Re-implement cookie and member option
*
* @uses Director::get_site_mode()
* @param $langsAvailable array A numerical array of languages which are valid choices (optional)
* @return string Selected language (also saved in $current_locale).
*/
static function choose_site_locale($langsAvailable = array())
{
$siteMode = Director::get_site_mode();
// either 'cms' or 'site'
if (self::$current_locale) {
return self::$current_locale;
}
if (isset($_GET['locale']) && !$langsAvailable || isset($_GET['locale']) && in_array($_GET['locale'], $langsAvailable)) {
// get from GET parameter
self::set_current_locale($_GET['locale']);
} else {
self::set_current_locale(self::default_locale());
}
return self::$current_locale;
}
示例2: set_reading_lang
/**
* Set the reading language, either namespaced to 'site' (website content)
* or 'cms' (management backend).
*
* @param string $lang New reading language.
*/
static function set_reading_lang($lang) {
$key = (Director::get_site_mode()) ? 'lang.' . Director::get_site_mode() : 'lang.global';
Session::set($key, $lang);
self::$reading_lang = $lang;
}