/**
  * Finds the Setting model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Setting the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Setting::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * @param $category
  * @return bool
  */
 protected static function checkNeeded($category)
 {
     $allLanguage = ArrayHelper::map(Language::getAllActive(), 'varCode', 'varName');
     if ($category === 'admin' && array_key_exists(Setting::getValue('languageAdminPanel'), $allLanguage)) {
         return true;
     } elseif ($category === 'app' && array_key_exists(Yii::$app->language, $allLanguage)) {
         return true;
     } else {
         return false;
     }
 }
Example #3
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     Yii::configure($this, require __DIR__ . '/config/main.php');
     Yii::$app->name = $this->panelName;
     Yii::$app->language = Setting::getValue('languageAdminPanel') ?: $this->language;
     if (YII_WEB_APP) {
         $this->configUser();
         $this->configTheme();
         $this->setMainPage();
     }
     $this->configTranslations();
     parent::init();
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Setting::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => false]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['intSettingID' => $this->intSettingID, 'isActive' => $this->isActive]);
     $query->andFilterWhere(['like', 'varKey', $this->varKey])->andFilterWhere(['like', 'varValue', $this->varValue]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Message::find();
     $query->joinWith('sourceMessage');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 15]]);
     $dataProvider->sort->attributes['sourceMessage.message'] = ['asc' => ['source_message.message' => SORT_ASC], 'desc' => ['source_message.message' => SORT_DESC]];
     $dataProvider->sort->attributes['sourceMessage.category'] = ['asc' => ['source_message.category' => SORT_ASC], 'desc' => ['source_message.category' => SORT_DESC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'source_message.category' => 'admin']);
     $query->andFilterWhere(['like', 'language', Setting::getValue('languageAdminPanel')])->andFilterWhere(['like', 'translation', $this->translation])->andFilterWhere(['like', 'source_message.message', $this->getAttribute('sourceMessage.message')])->andFilterWhere(['like', 'source_message.category', $this->getAttribute('sourceMessage.category')]);
     return $dataProvider;
 }