本文整理汇总了PHP中Translatable::choose_site_lang方法的典型用法代码示例。如果您正苦于以下问题:PHP Translatable::choose_site_lang方法的具体用法?PHP Translatable::choose_site_lang怎么用?PHP Translatable::choose_site_lang使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translatable
的用法示例。
在下文中一共展示了Translatable::choose_site_lang方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
function init()
{
Director::set_site_mode('cms');
// set language
$member = Member::currentUser();
if (!empty($member->Locale)) {
i18n::set_locale($member->Locale);
}
// set reading lang
if (Translatable::is_enabled() && !Director::is_ajax()) {
Translatable::choose_site_lang(array_keys(i18n::get_existing_content_languages('SiteTree')));
}
parent::init();
// Allow customisation of the access check by a decorator
if ($this->hasMethod('alternateAccessCheck')) {
$isAllowed = $this->alternateAccessCheck();
// Default security check for LeftAndMain sub-class permissions
} else {
$isAllowed = Permission::check("CMS_ACCESS_{$this->class}");
if (!$isAllowed && $this->class == 'CMSMain') {
// When access /admin/, we should try a redirect to another part of the admin rather than be locked out
$menu = $this->MainMenu();
if (($first = $menu->First()) && $first->Link) {
Director::redirect($first->Link);
}
}
}
// Don't continue if there's already been a redirection request.
if (Director::redirected_to()) {
return;
}
// Access failure!
if (!$isAllowed) {
$messageSet = array('default' => _t('LeftAndMain.PERMDEFAULT', "Please choose an authentication method and enter your credentials to access the CMS."), 'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY', "I'm sorry, but you can't access that part of the CMS. If you want to log in as someone else, do so below"), 'logInAgain' => _t('LeftAndMain.PERMAGAIN', "You have been logged out of the CMS. If you would like to log in again, enter a username and password below."));
Security::permissionFailure($this, $messageSet);
return;
}
Requirements::javascript('jsparty/prototype.js');
Requirements::javascript('jsparty/behaviour.js');
Requirements::javascript('jsparty/prototype_improvements.js');
Requirements::javascript('jsparty/loader.js');
Requirements::javascript('jsparty/hover.js');
Requirements::javascript('jsparty/layout_helpers.js');
Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
Requirements::javascript('cms/javascript/ImageEditor/Activator.js');
Requirements::javascript('jsparty/tiny_mce_improvements.js');
Requirements::javascript('jsparty/scriptaculous/effects.js');
Requirements::javascript('jsparty/scriptaculous/dragdrop.js');
Requirements::javascript('jsparty/scriptaculous/controls.js');
Requirements::css('jsparty/greybox/greybox.css');
Requirements::javascript('jsparty/greybox/AmiJS.js');
Requirements::javascript('jsparty/greybox/greybox.js');
Requirements::javascript('jsparty/tree/tree.js');
Requirements::css('jsparty/tree/tree.css');
Requirements::javascript('jsparty/tabstrip/tabstrip.js');
Requirements::css('jsparty/tabstrip/tabstrip.css');
Requirements::css('cms/css/TinyMCEImageEnhancement.css');
Requirements::javascript('cms/javascript/TinyMCEImageEnhancement.js');
Requirements::javascript('cms/javascript/LeftAndMain.js');
Requirements::javascript('cms/javascript/LeftAndMain_left.js');
Requirements::javascript('cms/javascript/LeftAndMain_right.js');
Requirements::css('sapphire/css/Form.css');
// Requirements::javascript('cms/javascript/MemberList.js');
Requirements::javascript('cms/javascript/ForumAdmin.js');
Requirements::javascript('cms/javascript/SideTabs.js');
Requirements::javascript('cms/javascript/TaskList.js');
Requirements::javascript('cms/javascript/CommentList.js');
Requirements::javascript('cms/javascript/SideReports.js');
Requirements::javascript('cms/javascript/LangSelector.js');
Requirements::javascript('cms/javascript/TranslationTab.js');
Requirements::javascript('sapphire/javascript/Validator.js');
Requirements::javascript('sapphire/javascript/UniqueFields.js');
Requirements::javascript('sapphire/javascript/RedirectorPage.js');
Requirements::javascript('sapphire/javascript/DataReport.js');
Requirements::javascript('sapphire/javascript/ToggleCompositeField.js');
Requirements::css('sapphire/css/SubmittedFormReportField.css');
Requirements::javascript('sapphire/javascript/FieldEditor.js');
Requirements::css('sapphire/css/FieldEditor.css');
Requirements::css('sapphire/css/TableListField.css');
Requirements::css('sapphire/css/ComplexTableField.css');
Requirements::javascript('sapphire/javascript/TableListField.js');
Requirements::javascript('sapphire/javascript/TableField.js');
Requirements::javascript('sapphire/javascript/ComplexTableField.js');
Requirements::javascript('sapphire/javascript/RelationComplexTableField.js');
Requirements::css('sapphire/css/TreeDropdownField.css');
Requirements::css('sapphire/css/CheckboxSetField.css');
Requirements::javascript('jsparty/calendar/calendar.js');
Requirements::javascript('jsparty/calendar/lang/calendar-en.js');
Requirements::javascript('jsparty/calendar/calendar-setup.js');
Requirements::css('sapphire/css/CalendarDateField.css');
Requirements::css('jsparty/calendar/calendar-win2k-1.css');
Requirements::javascript('sapphire/javascript/DropdownTimeField.js');
Requirements::css('sapphire/css/DropdownTimeField.css');
Requirements::css('sapphire/css/PopupDateTimeField.css');
Requirements::javascript('sapphire/javascript/SelectionGroup.js');
Requirements::css('sapphire/css/SelectionGroup.css');
Requirements::javascript('jsparty/SWFUpload/SWFUpload.js');
Requirements::javascript('cms/javascript/Upload.js');
Requirements::javascript('sapphire/javascript/HasManyFileField.js');
Requirements::css('sapphire/css/HasManyFileField.css');
//.........这里部分代码省略.........
示例2: init
/**
* @uses LeftAndMainDecorator->init()
* @uses LeftAndMainDecorator->accessedCMS()
* @uses CMSMenu
* @uses Director::set_site_mode()
*/
function init() {
parent::init();
Director::set_site_mode('cms');
// set language
$member = Member::currentUser();
if(!empty($member->Locale)) {
i18n::set_locale($member->Locale);
}
// can't be done in cms/_config.php as locale is not set yet
CMSMenu::add_link(
'Help',
_t('LeftAndMain.HELP', 'Help', PR_HIGH, 'Menu title'),
'http://userhelp.silverstripe.com'
);
// set reading lang
if(Translatable::is_enabled() && !Director::is_ajax()) {
Translatable::choose_site_lang(array_keys(Translatable::get_existing_content_languages('SiteTree')));
}
// Allow customisation of the access check by a decorator
if(!$this->canView()) {
// When access /admin/, we should try a redirect to another part of the admin rather than be locked out
$menu = $this->MainMenu();
foreach($menu as $candidate) {
if(
$candidate->Link &&
$candidate->Link != $this->Link()
&& $candidate->MenuItem->controller
&& singleton($candidate->MenuItem->controller)->canView()
) {
return Director::redirect($candidate->Link);
}
}
if(Member::currentUser()) {
Session::set("BackURL", null);
}
// if no alternate menu items have matched, return a permission error
$messageSet = array(
'default' => _t('LeftAndMain.PERMDEFAULT',"Please choose an authentication method and enter your credentials to access the CMS."),
'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY',"I'm sorry, but you can't access that part of the CMS. If you want to log in as someone else, do so below"),
'logInAgain' => _t('LeftAndMain.PERMAGAIN',"You have been logged out of the CMS. If you would like to log in again, enter a username and password below."),
);
return Security::permissionFailure($this, $messageSet);
}
// Don't continue if there's already been a redirection request.
if(Director::redirected_to()) return;
// Audit logging hook
if(empty($_REQUEST['executeForm']) && !Director::is_ajax()) $this->extend('accessedCMS');
Requirements::css(CMS_DIR . '/css/typography.css');
Requirements::css(CMS_DIR . '/css/layout.css');
Requirements::css(CMS_DIR . '/css/cms_left.css');
Requirements::css(CMS_DIR . '/css/cms_right.css');
Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
if(isset($_REQUEST['debug_firebug'])) {
// Firebug is a useful console for debugging javascript
// Its available as a Firefox extension or a javascript library
// for easy inclusion in other browsers (just append ?debug_firebug=1 to the URL)
Requirements::javascript(THIRDPARTY_DIR . '/firebug/firebug-lite-compressed.js');
} else {
// By default, we include fake-objects for all firebug calls
// to avoid javascript errors when referencing console.log() etc in javascript code
Requirements::javascript(THIRDPARTY_DIR . '/firebug/firebugx.js');
}
Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery_improvements.js');
Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/livequery/jquery.livequery.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/core/jquery.ondemand.js');
Requirements::javascript(THIRDPARTY_DIR . '/prototype_improvements.js');
Requirements::javascript(THIRDPARTY_DIR . '/loader.js');
Requirements::javascript(THIRDPARTY_DIR . '/hover.js');
Requirements::javascript(THIRDPARTY_DIR . '/layout_helpers.js');
Requirements::javascript(SAPPHIRE_DIR . "/javascript/i18n.js");
Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/dragdrop.js');
Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/controls.js');
Requirements::css(THIRDPARTY_DIR . '/greybox/greybox.css');
Requirements::javascript(THIRDPARTY_DIR . '/greybox/AmiJS.js');
Requirements::javascript(THIRDPARTY_DIR . '/greybox/greybox.js');
//.........这里部分代码省略.........
示例3: init
function init() {
// set language
$member = Member::currentUser();
if(!empty($member->Locale)) {
i18n::set_locale($member->Locale);
}
// set reading lang
if(Translatable::is_enabled() && !Director::is_ajax()) {
Translatable::choose_site_lang(array_keys(Translatable::get_existing_content_languages('SiteTree')));
}
parent::init();
}