Exemplo n.º 1
0
 /**
  * Make pages alias list
  * @return array
  */
 protected static function getPageAliasList()
 {
     $items = [];
     foreach (\page\common\models\Page::find()->select(['alias', 'title'])->asArray()->all() as $row) {
         $items[$row['alias']] = $row['title'];
     }
     return $items;
 }
Exemplo n.º 2
0
 /**
  * Show page contents
  * @param string $alias 
  * @return void
  */
 public function actionIndex($alias)
 {
     $model = Page::findByAlias($alias);
     if ($model === null || !$model->active) {
         throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
     }
     return $this->render('index', ['model' => $model]);
 }
Exemplo n.º 3
0
 /**
  * Page deleting.
  * @param integer $id Page id.
  * @return void
  */
 public function actionDelete($id)
 {
     $item = Page::findOne($id);
     if ($item === null) {
         throw new BadRequestHttpException(Yii::t('page', 'Page not found.'));
     }
     if ($item->delete()) {
         Yii::$app->storage->removeObject($item);
         Yii::$app->session->setFlash('success', Yii::t('page', 'Page deleted successfully.'));
     }
     return $this->redirect(['index']);
 }
Exemplo n.º 4
0
 /**
  * Search function
  * @param array $params Attributes array
  * @return yii\data\ActiveDataProvider
  */
 public function search($params)
 {
     //ActiveQuery
     $query = Page::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     //return data provider if no search
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     //search
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }