本文整理汇总了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;
}