Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchNews($params)
 {
     $lang = Lang::getCurrent();
     switch ($lang->local) {
         case Lang::LANG_EN:
             $category_id = self::NEWS_CATEGORY_EN;
             break;
         case Lang::LANG_RU:
         default:
             $category_id = self::NEWS_CATEGORY;
             break;
     }
     $query = Page::find()->joinWith('user');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => Yii::$app->params['items-per-page'], '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, 'category_id' => $category_id, 'published' => 1, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     /*
             $query->andFilterWhere(['like', 'name', $this->name])
                 ->andFilterWhere(['like', 'intro', $this->intro])
                 ->andFilterWhere(['like', 'text', $this->text])
                 ->andFilterWhere(['like', 'meta_title', $this->meta_title])
                 ->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])
                 ->andFilterWhere(['like', 'meta_descr', $this->meta_descr]);
     */
     return $dataProvider;
 }
 public function actionIndex()
 {
     $query = Page::find()->where(['user_id' => Yii::$app->user->identity->id]);
     $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $query->count()]);
     $pages = $query->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('index', ['pages' => $pages, 'pagination' => $pagination]);
 }
Example #3
0
 public function actionIndex($catid = 0)
 {
     $view = LuLu::getView();
     $category = null;
     $query = Page::find()->where(['status' => 1]);
     if (intval($catid) > 0) {
         $query->andWhere(['category_id' => $catid]);
         $category = PageCategory::findOne($catid);
         if ($category !== null) {
             $view->setTitle(empty($category['seo_title']) ? $category['name'] : $category['seo_title']);
             $view->setMetaTag('keywords', $category['seo_keywords']);
             $view->setMetaTag('description', $category['seo_description']);
             $view->addBreadcrumb('页面', ['page/index']);
             $view->addBreadcrumb($category['name']);
         }
     }
     if ($category == null) {
         $view->setTitle('页面');
         $view->addBreadcrumb('页面');
     }
     $locals = LuLu::getPagedRows($query);
     $locals['catid'] = $catid;
     $locals['currentCategory'] = $category;
     return $this->render('index', $locals);
 }
 public function actionView($id)
 {
     $model = Page::find()->andWhere(['id' => $id, 'published' => 1])->one();
     if (!$model) {
         throw new NotFoundHttpException();
     }
     return $this->render('view', ['model' => $model]);
 }
Example #5
0
 /**
  * Finds the Page model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Page the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($alias)
 {
     if (($model = Page::find()->where(['alias' => $alias])->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #6
0
 public function actionPage($slug)
 {
     $page = Page::find()->andWhere(['slug' => $slug])->one();
     if (!$page) {
         throw new NotFoundHttpException('页面不存在');
     }
     return $this->render('page', ['page' => $page]);
 }
 public function actionView($slug)
 {
     $model = Page::find()->where(['slug' => $slug, 'status' => Page::STATUS_PUBLISHED])->one();
     if (!$model) {
         throw new NotFoundHttpException(Yii::t('frontend', 'Page not found'));
     }
     $viewFile = $model->view ?: 'view';
     return $this->render($viewFile, ['model' => $model]);
 }
 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $query = Page::find()->where(['live' => 1]);
     $pagination = new Pagination(['defaultPageSize' => 2, 'totalCount' => $query->count()]);
     $pages = $query->offset($pagination->offset)->limit($pagination->limit)->all();
     $comments = Comment::getRecentComments();
     $sidebarCategories = Category::getSidebarCategories();
     $tags = Tag::getTagList();
     return $this->render('index', ['pages' => $pages, 'pagination' => $pagination, 'comments' => $comments, 'sidebarCategories' => $sidebarCategories, 'tags' => $tags]);
 }
Example #9
0
 public function search($params)
 {
     $query = Page::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'publish_time' => $this->publish_time, 'modify_time' => $this->modify_time, 'status' => $this->status, 'sort_num' => $this->sort_num]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'title_format', $this->title_format])->andFilterWhere(['like', 'title_pic', $this->title_pic])->andFilterWhere(['like', 'summary', $this->summary])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'tpl', $this->tpl])->andFilterWhere(['like', 'seo_title', $this->seo_title])->andFilterWhere(['like', 'seo_keywords', $this->seo_keywords])->andFilterWhere(['like', 'seo_description', $this->seo_description]);
     return $dataProvider;
 }
Example #10
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'body', $this->body]);
     return $dataProvider;
 }
 /**
  * Displays a single Page model.
  *
  * @param $slug
  * @return mixed
  */
 public function actionView($slug)
 {
     $model = Page::find()->where(['slug' => $slug, 'status' => Page::STATUS_ACTIVE])->one();
     if (!$model) {
         throw new NotFoundHttpException(Yii::t('frontend', 'Page not found.'));
     }
     // meta keywords
     $this->getView()->registerMetaTag(['name' => 'description', 'content' => $model->description]);
     // meta description
     $this->getView()->registerMetaTag(['name' => 'keywords', 'content' => $model->keywords]);
     return $this->render('view', ['model' => $model]);
 }
Example #12
0
 public function search($params)
 {
     $query = Page::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'name', $this->name]);
     $query->andFilterWhere(['like', 'slug', $this->slug]);
     $query->andFilterWhere(['published' => $this->published]);
     return $dataProvider;
 }
Example #13
0
 public function actionPage($alias)
 {
     $result = Page::find()->where(['alias' => $alias, 'project_id' => TFA::$info['id']])->one();
     if (!$result) {
         throw new HttpException(404, 'No Page');
     }
     if ($result->as_theme == 0) {
         echo $result->content;
         die;
     }
     return $this->render('page', ['result' => $result]);
 }
Example #14
0
 public function init()
 {
     $pages = Page::find()->selectNoText()->published()->all();
     $this->_htmlStr = '<ul class="menu">';
     $this->_htmlStr .= '<li role="presentation" ' . ($this->active('site', 'index', '') ? 'class="nav-current"' : '') . '>' . Html::a('首页', Url::home()) . '</li>';
     if (!empty($pages)) {
         foreach ($pages as $page) {
             $this->_htmlStr .= '<li role="presentation" ' . ($this->active('site', 'page', $page->slug) ? 'class="nav-current"' : '') . '>' . Html::a($page->title, ['site/page', 'slug' => $page->slug, $this->options]) . '</li>';
         }
     }
     $this->_htmlStr .= '</ul>';
 }
Example #15
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::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, 'parent_id' => $this->parent_id, 'is_url' => $this->is_url, 'is_seo' => $this->is_seo, 'status' => $this->status, 'created_dt' => $this->created_dt]);
     $query->andFilterWhere(['like', 'page_url', $this->page_url])->andFilterWhere(['like', 'page_name', $this->page_name])->andFilterWhere(['like', 'page_content', $this->page_content])->andFilterWhere(['like', 'page_seo_name', $this->page_seo_name])->andFilterWhere(['like', 'meta_values', $this->meta_values]);
     return $dataProvider;
 }
Example #16
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::find();
     if (!\Yii::$app->user->can('administrator')) {
         $query->forDomain();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'domain_id' => $this->domain_id]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'before_body', $this->before_body])->andFilterWhere(['like', 'after_body', $this->after_body])->andFilterWhere(['like', 'on_scenario', $this->on_scenario]);
     return $dataProvider;
 }
Example #17
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::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]);
     $query->andFilterWhere(['like', 'route', $this->route])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
Example #18
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::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, 'project_id' => Yii::$app->request->get('project_id')]);
     $query->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'META_TITLE', $this->META_TITLE])->andFilterWhere(['like', 'META_DESC', $this->META_DESC])->andFilterWhere(['like', 'META_KEYS', $this->META_KEYS]);
     return $dataProvider;
 }
Example #19
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::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, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_description', $this->meta_description])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords]);
     return $dataProvider;
 }
Example #20
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::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, 'pid' => $this->pid, 'order' => $this->order]);
     $query->andFilterWhere(['like', 'header', $this->header])->andFilterWhere(['like', 'sid', $this->sid])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'desription', $this->desription])->andFilterWhere(['like', 'keywords', $this->keywords]);
     return $dataProvider;
 }
Example #21
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchNews($params, $category_id = 0)
 {
     $query = Page::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $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, 'category_id' => $category_id, 'published' => $this->published, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'intro', $this->intro])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['like', 'meta_descr', $this->meta_descr]);
     //echo'<pre>';print_r($query);echo'</pre>';die;
     return $dataProvider;
 }
Example #22
0
 public function actionView($sid)
 {
     $service = Service::find()->select('*')->innerJoinWith('secs')->where(['service.sid' => $sid])->one();
     $page = Page::find()->where(['sid' => Yii::$app->controller->id])->select(['id', 'pid', 'sid', 'header'])->one();
     $pages = Page::find()->select(['id', 'pid', 'sid', 'header'])->asArray()->indexBy('id')->all();
     $mode = $pages[$page->id];
     $branch[] = $mode;
     while (!is_null($mode['pid'])) {
         $mode = $pages[$mode['pid']];
         $branch[] = $mode;
     }
     krsort($branch);
     $branch[] = ['header' => $service->header];
     return $this->render('view', ['service' => $service, 'branch' => $branch]);
 }
 public function actionView($slug)
 {
     /** @var Page $model */
     $model = Page::find()->where(['slug' => $slug, 'status' => Page::STATUS_PUBLISHED])->one();
     if (!$model) {
         throw new NotFoundHttpException(Yii::t('frontend', 'Page not found'));
     }
     //Мета-теги
     foreach (['description', 'keywords'] as $name) {
         $attr = 'meta_' . $name;
         \Yii::$app->view->registerMetaTag(['name' => $name, 'content' => strlen($model->{$attr}) > 0 ? $model->{$attr} : Yii::$app->keyStorage->get('frontend.' . $attr)], $name);
     }
     $viewFile = $model->view ?: 'view';
     return $this->render($viewFile, ['model' => $model]);
 }
Example #24
0
 public function actionView($sid)
 {
     $model = Page::find()->where(['sid' => $sid])->one();
     $models = Page::find()->select(['id', 'pid', 'sid', 'header'])->asArray()->indexBy('id')->all();
     $mode = $models[$model->id];
     $branch[] = $mode;
     while (!is_null($mode['pid'])) {
         $mode = $models[$mode['pid']];
         $branch[] = $mode;
     }
     krsort($branch);
     $db = Yii::$app->db;
     $current_menu = $db->createCommand('call current_menu(:sid)')->bindValue(':sid', $model->sid)->queryAll();
     $current_menu = Tree::level($current_menu, $model->pid);
     return $this->render('view', ['model' => $model, 'current_menu' => $current_menu, 'branch' => $branch]);
 }
Example #25
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PageModel::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, 'title_id' => $this->title_id, 'content_id' => $this->content_id, 'meta_title_id' => $this->meta_title_id, 'meta_description_id' => $this->meta_description_id, 'meta_keywords_id' => $this->meta_keywords_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'url_alias', $this->url_alias]);
     return $dataProvider;
 }
Example #26
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::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, 'published' => $this->published, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['like', 'meta_description', $this->meta_description])->andFilterWhere(['like', 'meta_params', $this->meta_params])->andFilterWhere(['like', 'layouts', $this->layouts])->andFilterWhere(['like', 'views', $this->views]);
     return $dataProvider;
 }
Example #27
0
 /**
  * Creates data provider instance with search query applied.
  *
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 30]]);
     $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, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'keywords', $this->keywords])->andFilterWhere(['like', 'body', $this->body]);
     return $dataProvider;
 }
Example #28
0
 public function actionView($sid, $section)
 {
     $news = News::find()->select('*')->where(['sid' => $sid])->one();
     $sectionM = SecNews::find()->select(['id', 'sid', 'header'])->where(['sid' => $section])->asArray()->one();
     $page = Page::find()->where(['sid' => Yii::$app->controller->id])->select(['id', 'pid', 'sid', 'header'])->one();
     $pages = Page::find()->select(['id', 'pid', 'sid', 'header'])->asArray()->indexBy('id')->all();
     $mode = $pages[$page->id];
     $branch[] = $mode;
     while (!is_null($mode['pid'])) {
         $mode = $pages[$mode['pid']];
         $branch[] = $mode;
     }
     krsort($branch);
     $branch[] = $sectionM;
     $branch[] = ['header' => $news->header];
     return $this->render('view', ['news' => $news, 'branch' => $branch]);
 }
Example #29
0
 /**
  * Creates a new Page model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     foreach (Yii::$app->params['availableLocales'] as $key => $value) {
         $currentModel = Page::getLocaleInstance($key);
         $currentModel->locale = $key;
         if (Yii::$app->request->get('scenario')) {
             $currentModel->on_scenario = Yii::$app->request->get('scenario');
         }
         $models[$key] = $currentModel;
     }
     //set data from default model
     if (Yii::$app->request->get('locale_group_id')) {
         $defaultDomainModels = Page::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale_group_id' => Yii::$app->request->get('locale_group_id')])->all();
         foreach ($defaultDomainModels as $key => $value) {
             if (!in_array($value->locale, array_keys(Yii::$app->params['availableLocales']))) {
                 continue;
             }
             $models[$value->locale]->slug = $value->slug;
             $models[$value->locale]->title = $value->title;
             $models[$value->locale]->head = $value->head;
             $models[$value->locale]->body = $value->body;
             $models[$value->locale]->before_body = $value->before_body;
             $models[$value->locale]->after_body = $value->after_body;
         }
     }
     $model = new MultiModel(['models' => $models]);
     if ($model->load(Yii::$app->request->post()) && Page::multiSave($model)) {
         return $this->redirect(['index']);
     } else {
         switch (Yii::$app->request->get('scenario')) {
             case 'extend':
                 $viewName = 'extend';
                 break;
             default:
                 $viewName = 'create';
         }
         return $this->render($viewName, ['model' => $model]);
     }
 }
Example #30
0
 /**
  * Creates data provider instance with search query applied
  * @param $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     /** @var ActiveQuery $query */
     $query = Page::find();
     if (!isset($params['sort'])) {
         $query->orderBy(['updated_at' => SORT_DESC]);
     }
     $session = Yii::$app->session;
     if (!$session['language_id']) {
         $session['language_id'] = LanguageRecord::getMainLanguageId();
     }
     $query->andWhere(['language_id' => $session['language_id']]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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(['active' => $this->active, 'public' => $this->public]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }