Exemplo n.º 1
0
 public function feedMenuModule()
 {
     $list = [];
     $pages = Page::find()->andWhere('isActive = 1')->orderBy(['root' => SORT_DESC, 'lft' => SORT_ASC])->all();
     foreach ($pages as $page) {
         $list[] = ['label' => $page->nestedTitle, 'route' => 'page/front/view', 'params' => ['id' => $page->id]];
     }
     return $list;
 }
Exemplo n.º 2
0
 public function search($params)
 {
     $query = Page::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['root' => SORT_DESC, 'lft' => SORT_ASC]]]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'isActive' => $this->isActive]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     $query->andFilterWhere(['like', 'language', $this->language]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post())) {
         if ($_POST['Page']['parentId'] != '0') {
             $parent = $model->parents(1)->one();
             if (!isset($parent) or $parent->id != $_POST['Page']['parentId']) {
                 $newParent = Page::findOne($_POST['Page']['parentId']);
                 $success = $model->appendTo($newParent);
             } else {
                 $success = $model->save();
             }
         } else {
             $success = $model->isRoot() ? $model->save() : $model->makeRoot();
         }
         if ($success) {
             Yii::$app->session->addFlash('success', 'صفحه ویرایش شده با موفقیت در سیستم به روز رسانی شد.');
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     return $this->render('update', ['model' => $model]);
 }