Beispiel #1
0
 /**
  * Lists all Content models.
  * @return mixed
  */
 public function actionIndex()
 {
     $query = Content::find();
     $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
     $contents = $query->orderBy('id')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('index', ['contents' => $contents, 'pagination' => $pagination]);
 }
Beispiel #2
0
 public function actions()
 {
     $ret = [];
     foreach (Yii::$app->params["languages"] as $lng => $name) {
         $model = Content::find()->andWhere('name="briefing"')->andWhere('language="' . $lng . '"')->one();
         $ret[$lng] = ['class' => BriefingAction::className(), 'model' => $model];
     }
     return $ret;
 }
Beispiel #3
0
 public function makeDropDown($langs = null)
 {
     global $data;
     $langs = $langs ? $langs : 'thai';
     $data = array();
     $parents = Content::find()->where(['langs' => $langs])->all();
     foreach ($parents as $parent) {
         $data[$parent->id] = $parent->title;
     }
     return $data;
 }
Beispiel #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Content::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, 'user_id' => $this->user_id, 'category_id' => $this->category_id, 'create_time' => $this->create_time]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'summary', $this->summary]);
     return $dataProvider;
 }
Beispiel #5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Content::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, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'title_uk', $this->title_uk])->andFilterWhere(['like', 'title_ru', $this->title_ru])->andFilterWhere(['like', 'title_en', $this->title_en])->andFilterWhere(['like', 'content_uk', $this->content_uk])->andFilterWhere(['like', 'content_ru', $this->content_ru])->andFilterWhere(['like', 'content_en', $this->content_en])->andFilterWhere(['like', 'tags_uk', $this->tags_uk])->andFilterWhere(['like', 'tags_ru', $this->tags_ru])->andFilterWhere(['like', 'tags_en', $this->tags_en])->andFilterWhere(['like', 'type', $this->type]);
     return $dataProvider;
 }
Beispiel #6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Content::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, 'courses_id' => $this->courses_id]);
     $query->andFilterWhere(['like', 'text', $this->text]);
     return $dataProvider;
 }
Beispiel #7
0
 public static function findOneByURL($url)
 {
     return Content::find()->select('content.*')->leftJoin('surl', 'surl.content_id = content.id')->where(['surl.name' => $url])->one();
 }
 public function actionDelete($id)
 {
     $model = Content::find($id);
     $model->delete();
     return $this->redirect(array('index'));
 }
Beispiel #9
0
 public function actionIndex()
 {
     $bl = Content::find()->andWhere('name = "bannerLabel"')->one();
     $bd = Content::find()->andWhere('name = "homePage"')->one();
     return $this->render('index', ['bl' => $bl, 'bd' => $bd]);
 }
Beispiel #10
0
 public function destroy($id)
 {
     Content::find($id)->delete();
     return Redirect::route('admin.content.index');
 }
Beispiel #11
0
 public function actionAbout()
 {
     $model = Content::find()->where(['id' => 1])->one();
     \Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => $model->name]);
     $this->getMetaTagsDefault();
     return $this->render('about', ['model' => $model]);
 }
Beispiel #12
0
 public function actionPost()
 {
     $user = new User();
     $user = \Yii::$app->user;
     if (\Yii::$app->user->isGuest) {
         return $this->redirect(['login']);
     }
     $query = Content::find()->where(['user_id' => $user->id]);
     $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
     $contents = $query->orderBy('id')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('post', ['contents' => $contents, 'user' => $user, 'pagination' => $pagination]);
 }
 public function actionList()
 {
     $dataProvider = new ActiveDataProvider(['query' => Content::find(), 'pagination' => ['pageSize' => 2]]);
     return $this->render('list', ['dataProvider' => $dataProvider]);
 }