Example #1
0
 public function menuItems()
 {
     $items = [];
     $pages = Page::find()->where(['parent_id' => 0, 'menu_hidden' => Page::MENU_HIDDEN_NO, 'status' => Page::STATUS_PUBLISHED, 'deleted' => 0, 'revision_to' => 0])->orderBy('listing_order ASC')->all();
     foreach ($pages as $page) {
         $items[] = $this->renderMenuItem($page);
     }
     return $items;
 }
 /**
  * Returns hierarchical data of pages
  * @param int $parentId
  * @return array
  */
 private function renderTree($parentId = 0)
 {
     $query = Page::find();
     $query->andWhere(['deleted' => 0, 'revision_to' => 0, 'parent_id' => $parentId]);
     $query->orderBy('title ASC');
     if (($pages = $query->all()) == null) {
         //empty array if no data found
         return [];
     }
     $tree = $this->getBranch($pages, true);
     return $tree;
 }
Example #3
0
 /**
  * Lists all Menu models.
  * @return mixed
  */
 public function actionIndex()
 {
     $model = new Search();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $list = Page::find()->filterWhere(['like', 'text', $model['search']])->all();
         if (count($list) == 0) {
             $errors = 'По Вашему запросу ничего не найдено. Попробуйте задать другой запрос.';
             return $this->render('index', ['search' => $model['search'], 'errors' => $errors]);
         } else {
             return $this->render('index', ['search' => $model['search'], 'list' => $list]);
         }
     }
 }
Example #4
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 any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'date' => $this->date]);
     $query->andFilterWhere(['like', 'page_title', $this->page_title])->andFilterWhere(['like', 'page_slug', $this->page_slug])->andFilterWhere(['like', 'short_desc', $this->short_desc])->andFilterWhere(['like', 'meta_key', $this->meta_key])->andFilterWhere(['like', 'meta_desc', $this->meta_desc])->andFilterWhere(['like', 'page_desc', $this->page_desc])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
 /**
  * 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', 'name', $this->name])->andFilterWhere(['like', 'body', $this->body]);
     return $dataProvider;
 }
Example #6
0
 public static function getFormAttribs()
 {
     return ['id' => ['type' => TabularForm::INPUT_HIDDEN, 'columnOptions' => ['hidden' => true]], 'cat_title' => ['type' => TabularForm::INPUT_WIDGET, 'widgetClass' => \kartik\select2\Select2::classname(), 'options' => ['data' => ArrayHelper::map(Page::find()->asArray()->all(), 'id', 'page_title')]], 'cat_desc' => ['type' => TabularForm::INPUT_TEXT]];
 }
Example #7
0
 /**
  * Displays about page.
  *
  * @return mixed
  */
 public function actionAbout()
 {
     //return $this->render('about');
     $page = Page::find()->where(['url' => 'about'])->one();
     return $this->render('page', ['page' => $page]);
 }
Example #8
0
 /**
  * Displays a single Page model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $child_pages_q = Page::find()->joinWith('page_rel')->where(['page_self_rels.parent_page_id' => $id])->all();
     $breadcumb = array_reverse(Page::get_breadcumb($id));
     $child_pages = array();
     if (!empty($child_pages_q)) {
         foreach ($child_pages_q as $key) {
             $child_count = Page::find()->joinWith('page_rel')->where(['page_self_rels.parent_page_id' => $key->id])->count();
             $key->child_count = $child_count;
             array_push($child_pages, $key);
         }
     }
     MyGlobalClass::log_activity('Visited page - ID: ' . $model->id . ' and page title: ' . $model->page_title);
     return $this->render('view', ['model' => $model, 'child_pages' => $child_pages, 'breadcumb' => $breadcumb]);
 }
Example #9
0
                        </a> 
                        <a class="btn btn-danger btn-xs close-box" href="javascript:;">
                          <i class="fa fa-times"></i>
                        </a> 
                      </nav>
                    </div><!-- /.toolbar -->
                  </header>
                  <div class="body full-screen-box collapse in" id="div-1" aria-expanded="true" style="">
                    <form class="form-horizontal">
                      <div class="form-group">
                            <label class="control-label col-lg-4">Select Page</label>
                        <div class="col-lg-8">
                          
                            <select name="page_select" class="page_select form-control">
                                <?php 
$pages = Page::find()->all();
foreach ($pages as $key) {
    echo '<option value="' . $key->id . '">' . $key->page_title . '</option>';
}
?>
                            </select>
                        </div>
                      </div><!-- /.form-group -->
                      <div class="form-group">
                        <label class="control-label col-lg-4">Item Title</label>
                        <div class="col-lg-8">
                           <input type="text" name="title" class="item_title form-control">
                        </div>
                      </div><!-- /.form-group -->

                      <div class="form-group">
Example #10
0
 public static function restore_all_child($id)
 {
     $child = Page::find()->joinWith('page_rel')->where(['page_self_rels.parent_page_id' => $id])->all();
     if (!empty($child)) {
         foreach ($child as $value) {
             $value->is_archive = 0;
             $value->save();
             Page::restore_all_child($value->id);
         }
     }
     return true;
 }
Example #11
0
 /**
  * Lists all Page models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Page::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
 public function actionPayment()
 {
     $model = Page::find()->where(['name' => 'Доставка и оплата'])->one();
     return $this->render('faq', compact('model'));
 }