Example #1
0
 /**
  * finds and return content of requested block by name
  * @param $name
  * @param bool $isGlobal
  * @return bool|string
  * @throws BadRequestHttpException
  */
 public function loadBlock($name, $isGlobal = false)
 {
     if (is_null($name)) {
         throw new BadRequestHttpException('Block name not specified.');
     }
     $find = ['title' => $name];
     if ($isGlobal === false) {
         //if not global
         if (isset($this->params['block']['id'])) {
             $find['parent'] = $this->params['block']['id'];
         }
         if (isset($this->params['block']['layout'])) {
             $find['parent_layout'] = $this->params['block']['layout'];
         }
         if (isset($this->params['block']['slug'])) {
             //get parent page id
             /**
              * @var $page \backend\models\Page
              */
             if ($page = Page::findOne(['slug' => $this->params['block']['slug']])) {
                 $find['parent'] = $page->id;
             }
         }
     }
     /**
      * @var $block \backend\models\Block
      */
     if ($block = Block::findOne($find)) {
         //if block found
         return $block->render();
     }
     return false;
 }
Example #2
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 #4
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 #5
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 #7
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 #8
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 #9
0
<div class="page-form">

    


            <div id="wizard">

                <section class="first_step">
                    <div class="row">
                    <?php 
$form = ActiveForm::begin();
?>
                        <div class="col-md-4">
                                <label>Parent Page</label>
                                <?php 
echo Select2::widget(['model' => $PageSelfRels_model, 'attribute' => 'parent_page_id', 'data' => Page::getHierarchy_page(), 'options' => ['placeholder' => 'Select parent page ...', 'multiple' => true], 'pluginOptions' => ['allowClear' => true]]);
?>
                                <br/>

                                <?php 
echo $form->field($model, 'page_title')->textInput(['maxlength' => 255]);
?>

                                <?php 
echo $form->field($model, 'page_slug')->textInput(['maxlength' => 255]);
?>

                                <?php 
echo $form->field($model, 'short_desc')->textInput(['maxlength' => 255]);
?>
Example #10
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($id)
 {
     if (($model = Page::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #11
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 #12
0
 public function getPage_rel()
 {
     // Order has_one Customer via Customer.id -> customer_id
     return $this->hasOne(Page::className(), ['id' => 'page_id']);
 }
Example #13
0
 public function getPage()
 {
     return $this->hasOne(Page::className(), ['id' => 'page_id']);
 }
Example #14
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;
 }
 public function actionPayment()
 {
     $model = Page::find()->where(['name' => 'Доставка и оплата'])->one();
     return $this->render('faq', compact('model'));
 }