本文整理汇总了PHP中Language::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::model方法的具体用法?PHP Language::model怎么用?PHP Language::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUpdate
public function actionUpdate($id)
{
$model = new SettingsForm();
if (isset($_POST['SettingsForm'])) {
$model->attributes = $_POST['SettingsForm'];
if ($model->validate() && $model->save()) {
$this->redirect(array('index'));
}
} else {
$model->loadDataFromStore($id);
}
$directories = glob(Yii::getPathOfAlias('webroot.themes') . "/*", GLOB_ONLYDIR);
$themes = array();
foreach ($directories as $directory) {
$themes[] = basename($directory);
}
$layouts = CHtml::listData(Layout::model()->findAll(), 'layout_id', 'name');
$countries = CHtml::listData(Country::model()->findAll(), 'country_id', 'name');
$zones = CHtml::listData(Zone::model()->findAllByAttributes(array('country_id' => $model->country)), 'zone_id', 'name');
$languages = CHtml::listData(Language::model()->findAll(), 'language_id', 'name');
$currencies = CHtml::listData(Currency::model()->findAll(), 'currency_id', 'title');
$yesNoOptions = array(0 => Yii::t('settings', 'No'), 1 => Yii::t('settings', 'Yes'));
$lengthClasses = CHtml::listData(LengthClassDescription::model()->findAll(), 'length_class_id', 'title');
$weightClasses = CHtml::listData(WeightClassDescription::model()->findAll(), 'weight_class_id', 'title');
$taxesOptions = array("" => Yii::t("settings", "--- None ---"), "shipping" => Yii::t("settings", "Shipping Address"), "payment" => Yii::t("settings", "Payment Address"));
$customerGroups = CHtml::listData(CustomerGroupDescription::model()->findAll(), 'customer_group_id', 'name');
$informations = array_merge(array(0 => Yii::t("settings", "--- None ---")), CHtml::listData(InformationDescription::model()->findAll(), 'information_id', 'title'));
// TODO: localisation
$orderStatuses = CHtml::listData(OrderStatus::model()->findAllByAttributes(array('language_id' => 1)), 'order_status_id', 'name');
// TODO: localisation
$returnStatuses = CHtml::listData(ReturnStatus::model()->findAllByAttributes(array('language_id' => 1)), 'return_status_id', 'name');
$mailProtocols = array("mail" => Yii::t("settings", "Mail"), "smtp" => Yii::t("settings", "SMTP"));
$this->render('update', array('model' => $model, 'themes' => $themes, 'layouts' => $layouts, 'countries' => $countries, 'zones' => $zones, 'languages' => $languages, 'currencies' => $currencies, 'yesNoOptions' => $yesNoOptions, 'lengthClasses' => $lengthClasses, 'weightClasses' => $weightClasses, 'taxesOptions' => $taxesOptions, 'customerGroups' => $customerGroups, 'informations' => $informations, 'orderStatuses' => $orderStatuses, 'returnStatuses' => $returnStatuses, 'mailProtocols' => $mailProtocols));
}
示例2: beginRequest
public function beginRequest(CEvent $event)
{
if (isset(Yii::app()->session['preferred_language'])) {
$language = Yii::app()->session['preferred_language'];
} else {
$language = Yii::app()->request->getPreferredLanguage();
}
if ($language == 'sl_si') {
$language = 'sl';
}
// echo $language, "<br />";
$user = User::model()->find('id=:id', array(':id' => Yii::app()->user->id));
// load locale / language / timezone
if ($user != null && isset($user->profile->language_id)) {
$languageObject = Language::model()->find('id=:id', array(':id' => $user->profile->language_id));
if ($languageObject != null) {
$language = $languageObject->short;
}
}
$timezone = 'Europe/Ljubljana';
if ($user != null && isset($user->profile->timezone) && $user->profile->timezone != '') {
$timezone = $user->profile->timezone;
}
Yii::app()->language = $language;
Yii::app()->localtime->Locale = $language;
Yii::app()->localtime->TimeZone = $timezone;
// routing default controller based on domain
$sender = $event->sender;
if ($_SERVER['HTTP_HOST'] == 'boberadmin.comcode.si' || $_SERVER['HTTP_HOST'] == 'backend.bober') {
// default controller
} else {
// tekmovalni url
$sender->defaultController = 'startCompetition';
}
}
示例3: renderContent
public function renderContent()
{
Yii::app()->clientScript->registerCssFile($this->assets . '/css/flags.css');
$langs = Language::model()->findAll(array('order' => "id='ru' DESC"));
if (count($langs) > 1) {
$this->render('LanguageSwitcherAdmin', array('langs' => $langs));
}
}
示例4: initForPage
/**
* Renseigne les valeurs par défaut pour un texte rattaché à une page donnée
* @param int $pageId
* @param string $defaultName
* @param string $defaultTitle
* @param string $defaultContent
*/
public function initForPage($pageId, $defaultName, $defaultTitle, $defaultContent = ' ')
{
$this->web_page_id = $pageId;
$this->language_id = Language::model()->findByAttributes(array('code' => 'fr'))->id;
$this->name = $defaultName;
$this->title = $defaultTitle;
$this->content = $defaultContent;
}
示例5: selectLanId
public function selectLanId($name)
{
$criteria = new CDbCriteria();
$criteria->select = 'id';
$criteria->condition = 'name=:name';
$criteria->params = array(':name' => $name);
return Language::model()->find($criteria);
}
示例6: actionIndex
public function actionIndex()
{
$criteria = new CDbCriteria();
$criteria->select = '*';
$criteria->order = 'name ASC';
$this->allRec = Language::model()->findAll($criteria);
$this->render('index');
}
示例7: getList
public static function getList()
{
$languages = Yii::app()->cache->get('languages');
if (!$languages) {
$languages = ArrayHelper::extract(Language::model()->findAll(), 'id', 'name');
Yii::app()->cache->set('languages', $languages);
}
return $languages;
}
示例8: beforeAction
function beforeAction($action)
{
$language = Yii::app()->session['language_frontend'];
if (isset($language)) {
Yii::app()->language = $language;
} else {
Yii::app()->language = Language::model()->find('`default`=1')->code;
Yii::app()->session['language_frontend'] = Yii::app()->language;
}
return parent::beforeAction($action);
}
示例9: actionDelete
public function actionDelete($ids)
{
$ids = explode(',', $ids);
if (count($ids) > 0) {
foreach ($ids as $id) {
$language = Language::model()->findByPk($id);
$language->delete();
}
}
$this->redirect(array('index'));
}
示例10: run
public function run()
{
if (isset($_GET['Language'])) {
$languageId = $_GET['Language']['id'];
$preferredLanguage = \Language::model()->findByPk($languageId);
if ($preferredLanguage && $preferredLanguage->enabled) {
/** @var \myWebUser $webUser */
$webUser = \Yii::app()->user;
$webUser->setLanguageCode($preferredLanguage->code);
}
$this->controller->redirect(\Yii::app()->request->getUrlReferrer());
}
}
示例11: create
/**
* @test
*/
public function create()
{
$model = new Language();
$model->attributes = array('code' => 'test', 'name' => 'test');
$this->assertFalse($model->save());
$model = new Language();
$model->attributes = array('code' => 'te', 'name' => 'test');
$this->assertTrue($model->save());
$model = new Language();
$model->attributes = array('code' => 'test', 'name' => 'aaa');
$this->assertFalse($model->save());
$exception = null;
$model = new Language();
$model->attributes = array('name' => 'aaa');
$this->assertFalse($model->save());
$this->assertInstanceOf('Language', Language::model());
}
示例12: init
/**
*
*/
public function init()
{
parent::init();
// On règle le langage de l'application selon les indications du navigateur
/** @var \myWebUser $webUser */
$webUser = \Yii::app()->user;
if (!($code = $webUser->getLanguageCode())) {
$code = \Yii::app()->request->preferredLanguage;
}
if (!($preferredLanguage = \Language::findByCode($code))) {
$preferredLanguage = \Language::findByCode(\Yii::app()->language);
}
$webUser->setLanguageCode($preferredLanguage->code);
// On actualise le langage de l'application car c'est cette variable de configuration qui est lue
// par Yii::t()
\Yii::app()->language = $preferredLanguage->code;
// Chargement de la liste des langues disponibles
/** @noinspection PhpUndefinedMethodInspection */
$this->languages = \Language::model()->enabled()->alpha()->findAll();
}
示例13: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
if (isset($_GET['idLanguage'])) {
$idLanguage = $_GET['idLanguage'];
}
if (!isset($idLanguage)) {
$defaultLanguage = Language::model()->findByAttributes(array('code' => Yii::app()->params['defaultLanguage']));
$idLanguage = $defaultLanguage->getPrimaryKey();
}
$categories = Category::model()->findAllByAttributes(array('id_language' => $idLanguage, 'is_active' => 1));
$arrLectures = array();
foreach ($categories as $category) {
$criteria = new CDbCriteria();
$criteria->order = 'created_date DESC';
$criteria->addCondition(array(sprintf('id_category = %d', $category->getPrimaryKey()), 'is_active= 1'));
$criteria->limit = Yii::app()->params['numberOfLecturePerCategoryInIndexPage'];
$arrLectures[$category->getPrimaryKey()] = Lecture::model()->findAll($criteria);
}
$this->render('index', array('categories' => $categories, 'arrLectures' => $arrLectures));
}
示例14: beforeAction
function beforeAction($action)
{
$userId = Yii::app()->user->getId();
if (User::model()->checkStatusUser($userId) == false) {
session_unset();
if (Yii::app()->user->isGuest) {
Yii::app()->user->setFlash('Failure1', Yii::t('Login', 'User has been inactived or deleted by Admin'));
$this->redirect(array('/site/login'));
}
}
$language = Yii::app()->session['language'];
if (isset($language)) {
Yii::app()->language = $language;
} else {
Yii::app()->language = Language::model()->find('`default`=1')->code;
Yii::app()->session['language'] = Yii::app()->language;
}
$listRoles = Yii::app()->AuthManager->getRoles(Yii::app()->user->id);
if (array_key_exists('super user', $listRoles)) {
return parent::beforeAction($action);
}
if (!Yii::app()->user->checkAccess('manager')) {
throw new CHttpException(403, 'You are not authorized to performer.');
}
$controller = strtolower(Yii::app()->getController()->getId());
$nameaction = strtolower($action->id);
if (strtolower($controller) == 'personal') {
return parent::beforeAction($action);
}
if ($controller != 'default' && $action != 'errorauth') {
if (!Yii::app()->user->checkAccess($controller . '.' . $nameaction)) {
$this->redirect(array('/' . backend . '/Default/ErrorAuth'));
}
}
return parent::beforeAction($action);
}
示例15: convertLanguage
public static function convertLanguage($id)
{
$model = Language::model()->findByPk($id);
if ($model) {
return $model->lang_desc;
}
return '';
}