当前位置: 首页>>代码示例>>PHP>>正文


PHP LanguageManager::getAvailableLanguages方法代码示例

本文整理汇总了PHP中LanguageManager::getAvailableLanguages方法的典型用法代码示例。如果您正苦于以下问题:PHP LanguageManager::getAvailableLanguages方法的具体用法?PHP LanguageManager::getAvailableLanguages怎么用?PHP LanguageManager::getAvailableLanguages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LanguageManager的用法示例。


在下文中一共展示了LanguageManager::getAvailableLanguages方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preFilter

 /**
  * Renders the change language form and handles its submission
  * @param CFilterChain $filterChain
  * @return boolean whether to continue execution
  */
 protected function preFilter($filterChain)
 {
     if (isset($_POST['ChangeLanguageForm'])) {
         $model = new ChangeLanguageForm();
         $model->attributes = $_POST['ChangeLanguageForm'];
         if ($model->validate()) {
             // Get the display name of the new language
             $languages = LanguageManager::getAvailableLanguages();
             $newLanguage = $languages[$model->language];
             // Update user's default language
             if ($model->setDefault) {
                 $user = User::model()->findByPk(Yii::app()->user->id);
                 $user->language = $model->language;
                 // Don't rehash the password, it hasn't been changed
                 $user->inhibitPasswordHash();
                 $user->save();
             }
             // Update and inform
             Yii::app()->languageManager->setCurrent($model->language);
             Yii::app()->user->setFlash('success', Yii::t('Language', 'Language changed to {newLanguage}', array('{newLanguage}' => $newLanguage)));
         }
     }
     return true;
 }
开发者ID:pweisenburger,项目名称:xbmc-video-server,代码行数:29,代码来源:ChangeLanguageFilter.php

示例2: array

/* @var $this Controller */
/* @var $model ChangeLanguageForm */
/* @var $form TbActiveForm */
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('layout' => TbHtml::FORM_LAYOUT_HORIZONTAL));
// Cache the contents of the form
$cacheDependency = new CFileCacheDependency(Yii::app()->basePath . '/messages');
$cacheDuration = 60 * 60 * 24 * 365;
if ($this->beginCache('ChangeLanguageModal', array('dependency' => $cacheDependency, 'duration' => $cacheDuration, 'varyByExpression' => function () {
    return implode('_', array(Yii::app()->user->role, Yii::app()->language));
}))) {
    // Notify administrators that changing the language here only affects them
    if (Yii::app()->user->getRole() === User::ROLE_ADMIN) {
        $settingsLink = CHtml::link(Yii::t('Settings', 'Settings'), $this->createUrl('setting/admin'));
        echo FormHelper::helpBlock(Yii::t('Language', 'To change the application language for all users go to {settingsUrl} instead', array('{settingsUrl}' => $settingsLink)));
    }
    echo $form->dropdownListControlGroup($model, 'language', LanguageManager::getAvailableLanguages());
    echo $form->checkboxControlGroup($model, 'setDefault');
    ?>
	<div class="form-actions">
		<?php 
    echo TbHtml::submitButton(Yii::t('ChangeLanguageForm', 'Change language'), array('color' => TbHtml::BUTTON_COLOR_PRIMARY));
    ?>

		<?php 
    echo TbHtml::button(Yii::t('ChangeLanguageForm', 'Close'), array('class' => 'btn-padded', 'color' => TbHtml::BUTTON_COLOR_INFO, 'data-toggle' => 'modal', 'data-target' => '#change-language-modal'));
    ?>
	</div>

	<?php 
    $this->endCache();
}
开发者ID:pweisenburger,项目名称:xbmc-video-server,代码行数:31,代码来源:_cachedChangeLanguageModalContent.php

示例3: getDefinitions

    /**
     * Returns the settings definitions
     * @return array
     */
    public function getDefinitions()
    {
        return array('language' => array('label' => Yii::t('Settings', 'Application language'), 'separator' => array('icon' => 'fa fa-pencil-square-o', 'label' => Yii::t('Settings', 'Look and feel')), 'type' => self::TYPE_DROPDOWN, 'default' => 'en', 'description' => Yii::t('Settings', 'Changing this will reset the default language for all users'), 'listData' => LanguageManager::getAvailableLanguages(), 'order' => 50), 'applicationName' => array('label' => Yii::t('Settings', 'Application name'), 'type' => self::TYPE_TEXT, 'default' => 'XBMC Video Server', 'order' => 100), 'applicationSubtitle' => array('label' => Yii::t('Settings', 'Application subtitle'), 'type' => self::TYPE_TEXT, 'default' => Yii::t('Misc', 'Free your library'), 'order' => 125), 'playlistFormat' => array('label' => Yii::t('Settings', 'Playlist format'), 'type' => self::TYPE_DROPDOWN, 'default' => 'm3u', 'listData' => PlaylistFactory::getTypes(), 'order' => 150), 'singleFilePlaylist' => array('label' => Yii::t('Settings', "Don't use playlists when item consists of a single file"), 'type' => self::TYPE_CHECKBOX, 'default' => '0', 'description' => Yii::t('Settings', 'You may have to right-click and copy the address in order to stream (not download) the file'), 'order' => 200), 'showHelpBlocks' => array('label' => Yii::t('Settings', 'Show help blocks throughout the site'), 'type' => self::TYPE_CHECKBOX, 'default' => '1', 'order' => 300), 'pagesize' => array('label' => Yii::t('Settings', 'Amount of results to show per page'), 'type' => self::TYPE_TEXT, 'default' => '60', 'description' => Yii::t('Settings', 'Leave empty to disable pagination altogether'), 'htmlOptions' => array('span' => 1), 'order' => 500), 'ignoreArticle' => array('label' => Yii::t('Settings', 'Ignore article ("the") in results'), 'type' => self::TYPE_CHECKBOX, 'default' => '', 'order' => 550), 'requestTimeout' => array('label' => Yii::t('Settings', 'Request timeout'), 'separator' => array('icon' => 'fa fa-lock', 'label' => Yii::t('Settings', 'Security and performance')), 'type' => self::TYPE_TEXT, 'default' => '30', 'description' => Yii::t('Settings', 'Determines how long the application should wait for a response from XBMC. Increase this if you get timeout errors.'), 'htmlOptions' => array('span' => 1), 'order' => 625), 'cacheApiCalls' => array('label' => Yii::t('Settings', 'Cache all API results'), 'type' => self::TYPE_CHECKBOX, 'default' => '0', 'description' => Yii::t('Settings', 'Useful on slow hardware. A refresh button will appear in the menu which flushes the cache'), 'order' => 650), 'useHttpsForVfsUrls' => array('label' => Yii::t('Settings', 'Use HTTPS when streaming'), 'type' => self::TYPE_CHECKBOX, 'default' => '0', 'description' => Yii::t('Settings', 'When checked, streaming will be done over HTTPS if 
					the application is accessed over HTTPS. This will usually only 
					work if the server uses a real signed certificate, thus it is 
					not enabled by default.'), 'order' => 700), 'allowUserPowerOff' => array('label' => Yii::t('Settings', 'Allow users to power off backends'), 'type' => self::TYPE_CHECKBOX_LIST, 'default' => '', 'listData' => array(Setting::POWER_OPTION_SHUTDOWN => Yii::t('Settings', 'Shutdown'), Setting::POWER_OPTION_SUSPEND => Yii::t('Settings', 'Suspend'), Setting::POWER_OPTION_HIBERNATE => Yii::t('Settings', 'Hibernate'), Setting::POWER_OPTION_REBOOT => Yii::t('Settings', 'Reboot')), 'description' => Yii::t('Settings', 'Administrators are not affected by this setting and can always power off backends.'), 'order' => 750), 'whitelist' => array('label' => Yii::t('Settings', 'Access whitelist'), 'type' => self::TYPE_TEXT_WIDE, 'default' => '', 'description' => Yii::t('Settings', "If specified, access is restricted to the defined \n\t\t\t\t\twhitelist. Valid values are IP addresses, IP subnets and \n\t\t\t\t\tdomain names (including wildcards). Example: 192.168.1.0/24,1.2.3.4,example.com,*.user.com"), 'order' => 800));
    }
开发者ID:Tebro,项目名称:xbmc-video-server,代码行数:11,代码来源:Setting.php

示例4: rules

 /**
  * @return array the validation rules for this controller
  */
 public function rules()
 {
     return array(array('language, setDefault', 'required'), array('language', 'in', 'range' => array_keys(LanguageManager::getAvailableLanguages())));
 }
开发者ID:pweisenburger,项目名称:xbmc-video-server,代码行数:7,代码来源:ChangeLanguageForm.php


注:本文中的LanguageManager::getAvailableLanguages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。