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


PHP Language::findOne方法代码示例

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


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

示例1: setLanguage

 private function setLanguage()
 {
     $request = Yii::$app->request;
     $cookie = $request->cookies->get('language');
     if ($cookie) {
         $lang = Language::findOne(['lang' => $cookie->value]);
         if ($lang) {
             Yii::$app->language = $lang->lang;
             return;
         }
     }
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $accepts = $request->parseAcceptHeader($_SERVER['HTTP_ACCEPT_LANGUAGE']);
         foreach ($accepts as $lang => $options) {
             //FIXME: DBと整合をとってちゃんとやる
             switch (strtolower($lang)) {
                 case 'ja':
                 case 'ja-jp':
                     Yii::$app->language = 'ja-JP';
                     return;
                 case 'en':
                 case 'en-US':
                     Yii::$app->language = 'en-US';
                     return;
             }
         }
     }
     Yii::$app->language = 'en-US';
 }
开发者ID:ExceptionError,项目名称:stat.ink,代码行数:29,代码来源:Controller.php

示例2: actionSelect

 public function actionSelect($id, $current_url = '')
 {
     $language = Language::findOne($id);
     Yii::$app->response->cookies->add(new Cookie(['name' => 'language', 'value' => $language->code, 'expire' => (new \Datetime())->modify('+1 year')->getTimestamp()]));
     if ($current_url) {
         $current_url = urldecode($current_url);
     } else {
         $current_url = ['site/index'];
     }
     return $this->redirect($current_url);
 }
开发者ID:vsguts,项目名称:crm,代码行数:11,代码来源:LanguageController.php

示例3: detectLanguageByCookie

 private function detectLanguageByCookie()
 {
     $cookie = Yii::$app->request->cookies->get('language');
     if (!$cookie) {
         return false;
     }
     if (!($lang = Language::findOne(['lang' => $cookie->value]))) {
         return false;
     }
     return $lang->lang;
 }
开发者ID:frozenpandaman,项目名称:stat.ink,代码行数:11,代码来源:Controller.php

示例4: setLanguage

 private function setLanguage()
 {
     $request = Yii::$app->request;
     $cookie = $request->cookies->get('language');
     if ($cookie) {
         $lang = Language::findOne(['lang' => $cookie->value]);
         if ($lang) {
             Yii::$app->language = $lang->lang;
             return;
         }
     }
 }
开发者ID:Bochozkar,项目名称:stat.ink,代码行数:12,代码来源:Controller.php

示例5: createUrl

 public function createUrl($params)
 {
     if (isset($params['lang_id'])) {
         $lang = Language::findOne($params['lang_id']);
         if ($lang === null) {
             $lang = Language::getDefaultLang();
         }
         unset($params['lang_id']);
     } else {
         $lang = Language::getCurrent();
     }
     $url = parent::createUrl($params);
     if ($url == '/') {
         return '/' . $lang->url;
     } else {
         return '/' . $lang->url . $url;
     }
 }
开发者ID:vagrant200192,项目名称:traning,代码行数:18,代码来源:LangUrlManager.php

示例6: createUrl

 public function createUrl($params)
 {
     if (isset($params['lang_id'])) {
         //Если указан идентификатор языка, то делаем попытку найти язык в БД,
         //иначе работаем с языком по умолчанию
         $lang = Language::findOne($params['lang_id']);
         if ($lang === null) {
             $lang = Language::getDefaultLang();
         }
         unset($params['lang_id']);
     } else {
         //Если не указан параметр языка, то работаем с текущим языком
         $lang = Language::getCurrent();
     }
     //Получаем сформированный URL(без префикса идентификатора языка)
     $url = parent::createUrl($params);
     //Добавляем к URL префикс - буквенный идентификатор языка
     if ($url == '/') {
         return '/' . $lang->url_key;
     } else {
         return '/' . $lang->url_key . $url;
     }
 }
开发者ID:altairsoft,项目名称:plutos,代码行数:23,代码来源:LangUrlManager.php

示例7: findModel

 /**
  * Finds the Language model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Language the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Language::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:emotionbanker,项目名称:emotion-banking,代码行数:15,代码来源:LanguageController.php

示例8: processCode

 public function processCode($fullCode)
 {
     $code = $fullCode['code'];
     $original = $fullCode['original'];
     if ($this->isCodeActive($code)) {
         $group = Group::findOne($code->z_p_id)->toArray();
         $bank = Bank::findOne($code->z_b_id)->toArray();
         $form = Form::findOne(['f_klasse' => $bank['klasse'], 'f_p_id' => $group['p_id']]);
         $style = Style::findOne(['s_b_id' => $bank['b_id'], 's_p_id' => $group['p_id']]);
         if (!$style) {
             $style = Settings::getSetting('style');
         } else {
             $style = $style->style;
         }
         $label = Yii::$app->params['default_next_label'];
         $message = Yii::$app->params['default_next_message'];
         if ($this->language != "default") {
             $language = Language::findOne($this->language);
             if ($language != null) {
                 if ($language->label != '') {
                     $label = $language->label;
                 }
                 if ($language->message != '') {
                     $message = $language->message;
                 }
             }
         }
         Yii::$app->session['anketData'] = ['original' => $original, 'code' => $code->toArray(), 'group' => $group, 'bank' => $bank, 'form' => $form->f_id, 'status' => 0, 'lang' => $this->language, 'style' => $style, 'label' => $label, 'message' => $message];
         $meta = Meta::findOne(['m_z_id' => $code->z_id]);
         if (!$meta) {
             $meta = new Meta();
             $meta->m_z_id = $code->z_id;
             $meta->ip = $_SERVER['REMOTE_ADDR'];
             $meta->time_start = time();
         } else {
             $meta->ip = $_SERVER['REMOTE_ADDR'];
         }
         $meta->save();
         return true;
     }
     return false;
 }
开发者ID:emotionbanker,项目名称:emotion-banking,代码行数:42,代码来源:AnketForm.php

示例9: function

echo Html::a('Neuer Benutzertext', ['user-text/create/' . $type], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'ut_id', ['attribute' => 'p_id', 'filterType' => GridView::FILTER_SELECT2, 'filter' => InputHelper::getDropdownOptions('app\\models\\Group', 'p_id', 'bezeichnung', true, true), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'value' => function ($model, $key, $index, $widget) {
    if (!$model->p_id) {
        return 'Alle';
    }
    $group = \app\models\Group::findOne($model->p_id);
    return $group ? $group->bezeichnung : $model->p_id;
}, 'filterInputOptions' => ['placeholder' => 'Bitte wählen Sie'], 'format' => 'raw'], ['attribute' => 'b_id', 'filterType' => GridView::FILTER_SELECT2, 'filter' => InputHelper::getDropdownOptions('app\\models\\Bank', 'b_id', 'bezeichnung', true, true), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'value' => function ($model, $key, $index, $widget) {
    if (!$model->b_id) {
        return 'Alle';
    }
    $group = \app\models\Bank::findOne($model->b_id);
    return $group ? $group->bezeichnung : $model->b_id;
}, 'filterInputOptions' => ['placeholder' => 'Bitte wählen Sie'], 'format' => 'raw'], ['attribute' => 'l_id', 'filterType' => GridView::FILTER_SELECT2, 'filter' => InputHelper::getDropdownOptions('app\\models\\Language', 'l_id', 'name', true, true, true), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'value' => function ($model, $key, $index, $widget) {
    if (!$model->b_id) {
        return 'Default';
    }
    $group = \app\models\Language::findOne($model->l_id);
    return $group ? $group->name : $model->l_id;
}, 'filterInputOptions' => ['placeholder' => 'Bitte wählen Sie'], 'format' => 'raw'], ['attribute' => 't_id', 'value' => function ($model, $key, $index, $widget) {
    $group = \app\models\Text::findOne($model->t_id);
    return $group ? $group->name : $model->t_id;
}, 'format' => 'raw'], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
?>

</div>
开发者ID:emotionbanker,项目名称:emotionbanking,代码行数:30,代码来源:index.php

示例10: actionQuestionnaire

 public function actionQuestionnaire($bezeichnung, $groupId, $langId)
 {
     $is_locked = Settings::getSetting('locked');
     if ($is_locked == 1) {
         return $this->render('error', ['name' => 'Fehler', 'message' => 'Das System ist gesperrt. Bei Fragen wenden sie sich bitte an Emotion Banking.']);
     }
     try {
         $bankKlasse = Bank::findOne(['b_id' => $bezeichnung])->klasse;
         $questionnaire = Form::findOne(['f_klasse' => $bankKlasse, 'f_p_id' => $groupId]);
         if (empty($questionnaire)) {
             throw new ErrorException('Es gibt keinen Fragebogen für ihre Banken-, bzw. Kundengruppenauswahl');
         }
         $code = $questionnaire->createSpecificCode($bezeichnung);
         if ($code->hasErrors()) {
             return $this->render('error', ['name' => 'Fehler', 'message' => $code->getLastErrorMessage()]);
         }
     } catch (ErrorException $e) {
         return $this->render('error', ['name' => 'Fehler', 'message' => $e->getMessage()]);
     }
     $codeString = $code->__toString();
     if ($codeString !== null) {
         $warning = '';
         $model = new AnketForm();
         $model->code = $codeString;
         $model->language = $langId;
         if ($langId != "default") {
             $lanuage = Language::findOne($langId);
             if (empty($lanuage)) {
                 $warning = "Die angegebene Sprache " . $langId . " kann nicht gefunden werden. Es wird die Standardsprache angezeigt";
             }
         }
         if ($code !== false && ($code = $model->validateCode())) {
             $model->processCode($code);
             $data = Yii::$app->session['anketData'];
             $text = UserText::getText($data['group']['p_id'], $data['bank']['b_id'], $data['lang'], true);
             if (is_null($text)) {
                 return $this->render('error', ['name' => 'Fehler', 'message' => 'kein Starttext für diese Sprache gefunden']);
             }
             return $this->render('welcome', ['text' => $text, 'code' => $data["original"], 'warning' => $warning, 'style' => $data['style']]);
         } else {
             return $this->render('error', ['name' => 'Fehler', 'message' => 'Bank gesperrt, Code ungültig oder bereits verwendet. Anmeldung fehlgeschlagen']);
         }
     } else {
         $this->redirect(['/site/index']);
     }
     $data = Yii::$app->session['anketData'];
     $form = Form::findOne($data['form']);
     $questions = $form->getQuestions($bank_id = $data["bank"]["b_id"]);
     //default
     $status = 0;
     //code not needed.
     if (Yii::$app->request->post('q')) {
         $userAnswers = Yii::$app->request->post('q');
         $status = $form->saveAnswers($data['code'], $userAnswers);
         $data['status'] = $status;
         $data['code']['status'] = $status;
     } else {
         $data = Yii::$app->session['anketData'];
         $text = UserText::getText($data['group']['p_id'], $data['bank']['b_id'], $data['lang'], true);
         if (is_null($text)) {
             return $this->render('error', ['name' => 'Fehler', 'message' => 'kein Starttext für diese Sprache gefunden']);
         }
         return $this->render('welcome', ['text' => $text, 'code' => $data["original"], 'style' => $data["style"]]);
     }
     Yii::$app->session['anketData'] = $data;
     if (!($status < $form->getQuestionsCount($questions))) {
         $this->redirect(['/site/end']);
     }
     return $this->render('form', ['status' => $status, 'percent' => round($status / $form->getQuestionsCount($questions) * 100), 'questions' => $questions, 'anket' => $form, 'bank' => $data['bank']['b_id'], 'style' => $data['style']]);
 }
开发者ID:emotionbanker,项目名称:emotion-banking,代码行数:70,代码来源:SiteController.php


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