Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::find();
     $query->with(['tags', 'parent']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['lft' => SORT_ASC]]]);
     if (!($this->load($params) && $this->validate())) {
         if ($this->excludeRoots) {
             $query->excludeRoots();
         }
         return $dataProvider;
     }
     $query->andFilterWhere(['{{%core_page}}.id' => $this->id, '{{%core_page}}.parent_id' => $this->parent_id, '{{%core_page}}.created_at' => $this->created_at, '{{%core_page}}.updated_at' => $this->updated_at, '{{%core_page}}.status' => $this->status, '{{%core_page}}.created_by' => $this->created_by, '{{%core_page}}.updated_by' => $this->updated_by, '{{%core_page}}.lft' => $this->lft, '{{%core_page}}.rgt' => $this->rgt, '{{%core_page}}.level' => $this->level, '{{%core_page}}.ordering' => $this->ordering, '{{%core_page}}.hits' => $this->hits, '{{%core_page}}.lock' => $this->lock]);
     $query->andFilterWhere(['like', '{{%core_page}}.title', $this->title])->andFilterWhere(['like', '{{%core_page}}.path', $this->path])->andFilterWhere(['like', '{{%core_page}}.alias', $this->alias])->andFilterWhere(['like', '{{%core_page}}.preview_text', $this->preview_text])->andFilterWhere(['like', '{{%core_page}}.detail_text', $this->detail_text])->andFilterWhere(['like', '{{%core_page}}.metakey', $this->metakey])->andFilterWhere(['like', '{{%core_page}}.metadesc', $this->metadesc]);
     if ($this->excludeRoots) {
         $query->excludeRoots();
     }
     if ($this->excludePage && ($page = Page::findOne($this->excludePage))) {
         /** @var $page Page */
         $query->excludePage($page);
     }
     if ($this->tags) {
         $query->innerJoinWith('tags')->andFilterWhere(['{{%core_tag}}.id' => $this->tags]);
     }
     return $dataProvider;
 }
Exemplo n.º 2
0
 public function init()
 {
     if ($this->page && !$this->page instanceof Page) {
         $this->page = Page::findOne(intval($this->page));
     }
     if (empty($this->page)) {
         throw new InvalidConfigException(Yii::t('gromver.platform', 'Page not found.'));
     }
 }
Exemplo n.º 3
0
 public function init()
 {
     if ($this->rootPage && !$this->rootPage instanceof Page) {
         $this->rootPage = Page::findOne(intval($this->rootPage));
     }
     if (empty($this->rootPage)) {
         throw new InvalidConfigException(Yii::t('gromver.platform', 'Page not found.'));
     }
     if ($this->page && !$this->page instanceof Page) {
         $this->page = Page::findOne(intval($this->page));
     }
     if (empty($this->page)) {
         throw new InvalidConfigException(Yii::t('gromver.platform', 'Page not found.'));
     }
     if ($this->useHighlights) {
         CkeditorHighlightAsset::register($this->getView());
     }
 }
 /**
  * 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($id)
 {
     if (($model = Page::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('gromver.platform', 'The requested page does not exist.'));
     }
 }
Exemplo n.º 5
0
 /**
  * Находит путь к пункту меню ссылающемуся на категорию $categoryId, либо ее предка
  * Если путь ведет к предку, то достраиваем путь категории $categoryId
  * @param $pageId
  * @param $menuMap \gromver\platform\core\components\MenuMap
  * @return null|string
  */
 private function findPageMenuPath($pageId, $menuMap)
 {
     /** @var Page $page */
     if (!isset($this->_pagePaths[$pageId])) {
         if ($path = $menuMap->getMenuPathByRoute(MenuItem::toRoute('page/frontend/default/guide', ['id' => $pageId]))) {
             $this->_pagePaths[$pageId] = $path;
         } elseif (($page = Page::findOne($pageId)) && !$page->isRoot() && ($path = $this->findPageMenuPath($page->parent_id, $menuMap))) {
             $this->_pagePaths[$pageId] = $path . '/' . $page->alias;
         } else {
             $this->_pagePaths[$pageId] = false;
         }
     }
     return $this->_pagePaths[$pageId];
 }