diff --git a/backend/modules/content/controllers/ArticleController.php b/backend/modules/content/controllers/ArticleController.php index 5940e37ab..37b6591e9 100644 --- a/backend/modules/content/controllers/ArticleController.php +++ b/backend/modules/content/controllers/ArticleController.php @@ -77,12 +77,11 @@ public function actionUpdate($id) if ($article->load(Yii::$app->request->post()) && $article->save()) { return $this->redirect(['index']); - } else { - return $this->render('update', [ - 'model' => $article, - 'categories' => ArticleCategory::find()->active()->all(), - ]); } + return $this->render('update', [ + 'model' => $article, + 'categories' => ArticleCategory::find()->active()->all(), + ]); } /** @@ -107,9 +106,9 @@ protected function findModel($id) { if (($model = Article::findOne($id)) !== null) { return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); } + throw new NotFoundHttpException('The requested page does not exist.'); + } } diff --git a/backend/modules/content/controllers/CategoryController.php b/backend/modules/content/controllers/CategoryController.php index 72ea7b223..306e205ab 100644 --- a/backend/modules/content/controllers/CategoryController.php +++ b/backend/modules/content/controllers/CategoryController.php @@ -39,20 +39,19 @@ public function actionIndex() if ($category->load(Yii::$app->request->post()) && $category->save()) { return $this->redirect(['index']); - } else { - $searchModel = new ArticleCategorySearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - $categories = ArticleCategory::find()->noParents()->all(); - $categories = ArrayHelper::map($categories, 'id', 'title'); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - 'model' => $category, - 'categories' => $categories, - ]); } + $searchModel = new ArticleCategorySearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + $categories = ArticleCategory::find()->noParents()->all(); + $categories = ArrayHelper::map($categories, 'id', 'title'); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'model' => $category, + 'categories' => $categories, + ]); } /** @@ -68,15 +67,14 @@ public function actionUpdate($id) if ($category->load(Yii::$app->request->post()) && $category->save()) { return $this->redirect(['index']); - } else { - $categories = ArticleCategory::find()->noParents()->andWhere(['not', ['id' => $id]])->all(); - $categories = ArrayHelper::map($categories, 'id', 'title'); - - return $this->render('update', [ - 'model' => $category, - 'categories' => $categories, - ]); } + $categories = ArticleCategory::find()->noParents()->andWhere(['not', ['id' => $id]])->all(); + $categories = ArrayHelper::map($categories, 'id', 'title'); + + return $this->render('update', [ + 'model' => $category, + 'categories' => $categories, + ]); } /** @@ -101,8 +99,7 @@ protected function findModel($id) { if (($model = ArticleCategory::findOne($id)) !== null) { return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); } + throw new NotFoundHttpException('The requested page does not exist.'); } } diff --git a/backend/modules/content/controllers/PageController.php b/backend/modules/content/controllers/PageController.php index 2091d43a0..eaf523bd2 100755 --- a/backend/modules/content/controllers/PageController.php +++ b/backend/modules/content/controllers/PageController.php @@ -38,16 +38,15 @@ public function actionIndex() if ($page->load(Yii::$app->request->post()) && $page->save()) { return $this->redirect(['index']); - } else { - $searchModel = new PageSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - 'model' => $page, - ]); } + $searchModel = new PageSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'model' => $page, + ]); } /** @@ -61,11 +60,10 @@ public function actionCreate() if ($page->load(Yii::$app->request->post()) && $page->save()) { return $this->redirect(['index']); - } else { - return $this->render('create', [ - 'model' => $page, - ]); } + return $this->render('create', [ + 'model' => $page, + ]); } /** @@ -110,8 +108,7 @@ protected function findModel($id) { if (($model = Page::findOne($id)) !== null) { return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); } + throw new NotFoundHttpException('The requested page does not exist.'); } } diff --git a/backend/modules/content/views/category/update.php b/backend/modules/content/views/category/update.php index 970346525..91b0ad435 100644 --- a/backend/modules/content/views/category/update.php +++ b/backend/modules/content/views/category/update.php @@ -11,7 +11,6 @@ ]) . ' ' . $model->title; $this->params['breadcrumbs'][] = ['label' => Yii::t('backend', 'Article Categories'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = Yii::t('backend', 'Update'); ?> diff --git a/backend/views/_gii/templates/controller.php b/backend/views/_gii/templates/controller.php index 6a746b464..10a215a2b 100644 --- a/backend/views/_gii/templates/controller.php +++ b/backend/views/_gii/templates/controller.php @@ -107,11 +107,10 @@ public function actionCreate() if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', ]); - } else { - return $this->render('create', [ - 'model' => $model, - ]); } + return $this->render('create', [ + 'model' => $model, + ]); } /** @@ -126,11 +125,10 @@ public function actionUpdate() if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', ]); - } else { - return $this->render('update', [ - 'model' => $model, - ]); } + return $this->render('update', [ + 'model' => $model, + ]); } /** @@ -168,8 +166,7 @@ protected function findModel() ?> if (($model = ::findOne()) !== null) { return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); } + throw new NotFoundHttpException('The requested page does not exist.'); } } diff --git a/backend/views/layouts/base.php b/backend/views/layouts/base.php index 2858022c6..ee7f889ab 100755 --- a/backend/views/layouts/base.php +++ b/backend/views/layouts/base.php @@ -8,9 +8,7 @@ $bundle = BackendAsset::register($this); -$this->params['body-class'] = array_key_exists('body-class', $this->params) ? - $this->params['body-class'] - : null; +$this->params['body-class'] = $this->params['body-class'] ?? null; ?> beginPage() ?> @@ -39,4 +37,4 @@ endBody() ?> -endPage() ?> \ No newline at end of file +endPage() ?> diff --git a/backend/views/layouts/clear.php b/backend/views/layouts/clear.php index 3fd13d7a9..9bda1bd77 100755 --- a/backend/views/layouts/clear.php +++ b/backend/views/layouts/clear.php @@ -1,8 +1,9 @@ beginContent('@backend/views/layouts/common.php'); ?> -endContent(); ?> \ No newline at end of file +endContent(); ?> diff --git a/backend/views/layouts/common.php b/backend/views/layouts/common.php index ab2683964..2d28e0643 100644 --- a/backend/views/layouts/common.php +++ b/backend/views/layouts/common.php @@ -1,6 +1,6 @@ 'label' => Yii::t('backend', 'Users'), 'icon' => '', 'url' => ['/user/index'], - 'active' => (Yii::$app->controller->id == 'user'), + 'active' => Yii::$app->controller->id === 'user', 'visible' => Yii::$app->user->can('administrator'), ], [ @@ -165,26 +165,27 @@ class="img-circle"/> 'label' => Yii::t('backend', 'Static pages'), 'url' => ['/content/page/index'], 'icon' => '', - 'active' => (Yii::$app->controller->id == 'page'), + 'active' => Yii::$app->controller->id === 'page', ], [ 'label' => Yii::t('backend', 'Articles'), 'url' => '#', 'icon' => '', 'options' => ['class' => 'treeview'], - 'active' => (Yii::$app->controller->module->id == 'article'), + 'active' => 'content' === Yii::$app->controller->module->id && + ('article' === Yii::$app->controller->id || 'category' === Yii::$app->controller->id), 'items' => [ [ 'label' => Yii::t('backend', 'Articles'), 'url' => ['/content/article/index'], 'icon' => '', - 'active' => (Yii::$app->controller->id == 'default'), + 'active' => Yii::$app->controller->id === 'article', ], [ 'label' => Yii::t('backend', 'Categories'), 'url' => ['/content/category/index'], 'icon' => '', - 'active' => (Yii::$app->controller->id == 'category'), + 'active' => Yii::$app->controller->id === 'category', ], ], ], @@ -193,19 +194,19 @@ class="img-circle"/> 'url' => '#', 'icon' => '', 'options' => ['class' => 'treeview'], - 'active' => (Yii::$app->controller->module->id == 'widget'), + 'active' => Yii::$app->controller->module->id === 'widget', 'items' => [ [ 'label' => Yii::t('backend', 'Text Blocks'), 'url' => ['/widget/text/index'], 'icon' => '', - 'active' => (Yii::$app->controller->id == 'text'), + 'active' => Yii::$app->controller->id === 'text', ], [ 'label' => Yii::t('backend', 'Menu'), 'url' => ['/widget/menu/index'], 'icon' => '', - 'active' => (Yii::$app->controller->id == 'menu'), + 'active' => Yii::$app->controller->id === 'menu', ], [ 'label' => Yii::t('backend', 'Carousel'), diff --git a/backend/views/layouts/main.php b/backend/views/layouts/main.php index c10940db8..950ab2d4c 100755 --- a/backend/views/layouts/main.php +++ b/backend/views/layouts/main.php @@ -1,6 +1,7 @@ beginContent('@backend/views/layouts/common.php'); ?> @@ -9,4 +10,4 @@ -endContent(); ?> \ No newline at end of file +endContent(); ?>