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


PHP Language::model方法代码示例

本文整理汇总了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));
 }
开发者ID:damnpoet,项目名称:yiicart,代码行数:34,代码来源:SettingsController.php

示例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';
     }
 }
开发者ID:lidijakralj,项目名称:bober,代码行数:35,代码来源:StartupBehavior.php

示例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));
     }
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:8,代码来源:LanguageSwitcherAdmin.php

示例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;
 }
开发者ID:ChristopheBrun,项目名称:hLib,代码行数:15,代码来源:WebText.php

示例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);
 }
开发者ID:vasia-ostapchuk,项目名称:source,代码行数:8,代码来源:language.php

示例6: actionIndex

 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->order = 'name ASC';
     $this->allRec = Language::model()->findAll($criteria);
     $this->render('index');
 }
开发者ID:dmitryplus,项目名称:gb,代码行数:8,代码来源:LanguageController.php

示例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;
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:9,代码来源:Language.php

示例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);
 }
开发者ID:huuly188,项目名称:vietnamrealty,代码行数:11,代码来源:BaseFrontController.php

示例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'));
 }
开发者ID:damnpoet,项目名称:yiicart,代码行数:11,代码来源:LanguagesController.php

示例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());
     }
 }
开发者ID:ChristopheBrun,项目名称:hLib,代码行数:13,代码来源:UserPreferredLanguageAction.php

示例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());
 }
开发者ID:ChristopheBrun,项目名称:hLib,代码行数:20,代码来源:LanguageTest.php

示例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();
 }
开发者ID:ChristopheBrun,项目名称:hLib,代码行数:23,代码来源:BaseController.php

示例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));
 }
开发者ID:laiello,项目名称:flexiblearning,代码行数:24,代码来源:SiteController.php

示例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);
 }
开发者ID:huuly188,项目名称:vietnamrealty,代码行数:36,代码来源:BaseController.php

示例15: convertLanguage

 public static function convertLanguage($id)
 {
     $model = Language::model()->findByPk($id);
     if ($model) {
         return $model->lang_desc;
     }
     return '';
 }
开发者ID:nganhtuan63,项目名称:gxc-cms,代码行数:8,代码来源:Language.php


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