Example #1
0
 /**
  * Lists all Pages models.
  * @return mixed
  */
 public function actionIndex()
 {
     if (!$this->is_access('pages/index')) {
         Yii::$app->session->setFlash('error', $this->errorInfo);
         return $this->redirect($this->redirectUrl);
     }
     $dataProvider = new ActiveDataProvider(['query' => Pages::find()]);
     Yii::$app->view->params['meta_title'] = '文章单页';
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Example #2
0
 public function show($type = 'T')
 {
     $model = new Controller();
     $userMenu = ArrayHelper::map(self::find()->where(['type' => $type])->all(), 'title', 'url');
     $pageMenu = ArrayHelper::map(Pages::find()->where(['menu' => $type])->all(), 'title', 'url');
     foreach ($pageMenu as $title => $url) {
         $pageMenu[$title] = Url::toRoute(['/page/view', 'url' => $url]);
     }
     $items = array_merge($userMenu, $pageMenu);
     return $model->renderPartial('/report/menu', ['items' => $items]);
 }
 public function actionShowPage($slug = 'error')
 {
     //        var_dump($this->defaultAction);
     //        var_dump($slug);
     //        Yii::app()->clientScript->registerMetaTag($model->description, 'description');
     //        Yii::app()->clientScript->registerMetaTag($model->keywords, 'keywords');
     if (($model = Pages::find()->where(['slug' => $slug])->one()) !== null) {
         return $this->render('showPage', ['model' => $model]);
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionEdit()
 {
     $id = \Yii::$app->request->get('id');
     $page = Pages::find()->andWhere(['id' => $id])->one();
     $form = \Yii::$app->request->post('Pages');
     if ($form) {
         $page->title = $form['title'];
         $page->text = $form['text'];
         $page->save();
     }
     return $this->render('edit', ['item' => $page]);
 }
Example #5
0
 public function actionIndex()
 {
     $get = Yii::$app->request->get();
     if (!isset($get['slug'])) {
         throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
     }
     $page = Pages::find()->where(['slug' => $get['slug']])->asArray()->one();
     $this->view->title = $page['title'];
     Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => $page['meta_desc']]);
     Yii::$app->view->registerMetaTag(['name' => 'keywords', 'content' => $page['meta_keys']]);
     $this->view->params['breadcrumbs'][] = $page['title'];
     return $this->render('index', ['page' => $page]);
 }
Example #6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pages::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', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'meta_desc', $this->meta_desc])->andFilterWhere(['like', 'meta_keys', $this->meta_keys])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'page_title', $this->page_title])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Example #7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pages::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, 'active' => $this->active, 'date' => $this->date]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'text', $this->text]);
     return $dataProvider;
 }
Example #8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pages::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pagesize' => 10, 'forcePageParam' => false, 'pageSizeParam' => 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(['id' => $this->id, 'created' => $this->created, 'updated' => $this->updated, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'uri', $this->uri]);
     return $dataProvider;
 }
Example #9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pages::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['like', 'meta_descr', $this->meta_descr])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
 public function actionAbout()
 {
     return $this->render('about', ['page' => Pages::find()->where(['id' => 1])->one()]);
 }