示例#1
0
 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $show_reg_success = intval(Yii::$app->request->get('reg-success', 0));
     //		Yii::$app->session->setFlash('success', 'Тестовое success flash-сообщение.');
     //		Yii::$app->session->setFlash('error', 'Тестовое error flash-сообщение.');
     $meta_info = MetaInfo::getMetaInfo('main-page');
     return $this->render('index', ['meta_info' => $meta_info, 'show_reg_success' => $show_reg_success]);
 }
示例#2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MetaInfo::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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['like', 'meta_descr', $this->meta_descr]);
     return $dataProvider;
 }
示例#3
0
 /**
  * Lists all Page models.
  * @return mixed
  */
 public function actionIndex()
 {
     //		/echo 'index';die;
     $searchModel = new PageSearch();
     //$dataProvider = $searchModel->searchNews(Yii::$app->request->queryParams);
     $dataProvider = $searchModel->searchNews(Yii::$app->request->queryParams);
     $lang = Lang::getCurrent();
     switch ($lang->local) {
         case Lang::LANG_EN:
             $meta_key = 'news-list-en';
             break;
         case Lang::LANG_RU:
         default:
             $meta_key = 'news-list-ru';
             break;
     }
     $meta_info = MetaInfo::getMetaInfo($meta_key);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'meta_info' => $meta_info]);
 }
 private function showFantasyList($draft_id = 0, $meta_type = 'dota2-main')
 {
     $current_action = Yii::$app->controller->action->id;
     $fantasy_type = Yii::$app->request->get('type', 'all');
     $DotaDraft = new DotaDraft();
     $params = [];
     if ($draft_id > 0) {
         $params['DotaFantasySearch'] = ['draft_id' => $draft_id];
     }
     $searchModel = new DotaFantasySearch();
     $dataProvider = $searchModel->search($params, $fantasy_type);
     //echo'<pre>';print_r(Yii::$app->user->id);echo'</pre>';die;
     $fantasy_ids = [];
     foreach ($dataProvider->models as $model) {
         $fantasy_ids[] = $model->id;
     }
     if (count($fantasy_ids)) {
         $drafts_counts = $DotaDraft->getDraftsCount($fantasy_ids);
     } else {
         $drafts_counts = [];
     }
     //echo'<pre>';print_r($drafts_counts);echo'</pre>';die;
     if (Yii::$app->user->isGuest) {
         $user_rates = [];
     } else {
         $user_rates = $DotaDraft->getUserRateList(Yii::$app->user->id);
     }
     //echo'<pre>';print_r($user_rates);echo'</pre>';die;
     $meta_info = MetaInfo::getMetaInfo($meta_type);
     return $this->render('fantasy-list', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'current_action' => $current_action, 'fantasy_type' => $fantasy_type, 'draft_id' => $draft_id, 'user_rates' => $user_rates, 'drafts_counts' => $drafts_counts, 'meta_info' => $meta_info]);
 }
 /**
  * Finds the MetaInfo model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MetaInfo the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MetaInfo::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }