public function actionEnd() { if (!isset(Yii::$app->session['anketData'])) { $this->redirect('/site/index'); } $data = Yii::$app->session['anketData']; Yii::$app->session->remove('anketData'); return $this->render('end', ['text' => UserText::getText($data['group']['p_id'], $data['bank']['b_id'], $data['lang'], false)]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UserText::find(); $query->andWhere(['isStart' => $this->isStart, 'isEnd' => $this->isEnd]); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['ut_id' => $this->ut_id, 'p_id' => $this->p_id, 'b_id' => $this->b_id, 'l_id' => $this->l_id, 't_id' => $this->t_id]); return $dataProvider; }
public static function getText($user = null, $bank = null, $language = null, $isStart = true) { $query = UserText::find()->andWhere(['OR', 'p_id=0', 'p_id=' . $user])->andWhere(['OR', 'b_id=0', 'b_id="' . $bank . '"'])->andWhere(['OR', 'l_id=0', 'l_id=' . ($language == 'default' ? '0' : $language)]); if (!$isStart) { $query->andWhere(['isEnd' => 1]); } else { $query->andWhere(['isStart' => 1]); } $query->orderBy(['p_id' => SORT_DESC, 'b_id' => SORT_DESC, 'l_id' => SORT_DESC]); $text = $query->one(); return $text; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UserText::find(); $query->andWhere(['isStart' => $this->isStart, 'isEnd' => $this->isEnd]); $pageSize = Yii::$app->session->get('pageSize', Yii::$app->params['defaultPageSize']); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['ut_id' => $this->ut_id, 'p_id' => $this->p_id, 'b_id' => $this->b_id, 'l_id' => $this->l_id, 't_id' => $this->t_id]); return $dataProvider; }
public static function getText($user = null, $bank = null, $language = null, $isStart = true) { $query = UserText::find()->where(['p_id' => $user, 'b_id' => $bank, 'l_id' => $language == 'default' || $language === null ? '0' : $language])->orWhere(['p_id' => 0, 'b_id' => 0, 'l_id' => $language == 'default' || $language === null ? '0' : $language]); if (!$isStart) { $query->andWhere(['isEnd' => 1]); } else { $query->andWhere(['isStart' => 1]); } $query->orderBy(['p_id' => SORT_DESC, 'b_id' => SORT_DESC, 'l_id' => SORT_DESC]); $text = $query->one(); return $text; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UserText::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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(['id' => $this->id, 'id_user' => $this->id_user, 'id_device' => $this->id_device]); $query->andFilterWhere(['like', 'txt1', $this->txt1])->andFilterWhere(['like', 'txt2', $this->txt2]); return $dataProvider; }
/** * Finds the UserText model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return UserText the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = UserText::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionEnd() { if (!isset(Yii::$app->session['anketData'])) { $this->redirect(['/site/index']); } $data = Yii::$app->session['anketData']; Yii::$app->session->remove('anketData'); $text = UserText::getText($data['group']['p_id'], $data['bank']['b_id'], $data['lang'], false); if (is_null($text)) { return $this->render('error', ['name' => 'Fehler', 'message' => 'kein Endtext für diese Sprache gefunden']); } return $this->render('end', ['text' => $text, 'style' => $data['style']]); }