Skip to content

Commit

Permalink
Merge pull request #642 from nikosid/master
Browse files Browse the repository at this point in the history
Small fixes in backend menu and code style correcting
  • Loading branch information
Eugene Terentev authored Oct 21, 2018
2 parents 11fc1e2 + 824ce27 commit 546d9d0
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 71 deletions.
13 changes: 6 additions & 7 deletions backend/modules/content/controllers/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
]);
}

/**
Expand 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.');

}

}
43 changes: 20 additions & 23 deletions backend/modules/content/controllers/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}

/**
Expand All @@ -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,
]);
}

/**
Expand All @@ -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.');
}
}
27 changes: 12 additions & 15 deletions backend/modules/content/controllers/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}

/**
Expand All @@ -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,
]);
}

/**
Expand Down Expand Up @@ -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.');
}
}
1 change: 0 additions & 1 deletion backend/modules/content/views/category/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

?>
Expand Down
17 changes: 7 additions & 10 deletions backend/views/_gii/templates/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,10 @@ public function actionCreate()

if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', <?php echo $urlParams ?>]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
return $this->render('create', [
'model' => $model,
]);
}

/**
Expand All @@ -126,11 +125,10 @@ public function actionUpdate(<?php echo $actionParams ?>)

if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', <?php echo $urlParams ?>]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
return $this->render('update', [
'model' => $model,
]);
}

/**
Expand Down Expand Up @@ -168,8 +166,7 @@ protected function findModel(<?php echo $actionParams ?>)
?>
if (($model = <?php echo $modelClass ?>::findOne(<?php echo $condition ?>)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}
6 changes: 2 additions & 4 deletions backend/views/layouts/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
?>

<?php $this->beginPage() ?>
Expand Down Expand Up @@ -39,4 +37,4 @@
<?php $this->endBody() ?>
<?php echo Html::endTag('body') ?>
</html>
<?php $this->endPage() ?>
<?php $this->endPage() ?>
3 changes: 2 additions & 1 deletion backend/views/layouts/clear.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
/**
* @var $this yii\web\View
* @var $content string
*/
?>
<?php $this->beginContent('@backend/views/layouts/common.php'); ?>
<?php echo $content ?>
<?php $this->endContent(); ?>
<?php $this->endContent(); ?>
19 changes: 10 additions & 9 deletions backend/views/layouts/common.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @var $this yii\web\View
* @var $this yii\web\View
* @var $content string
*/

Expand Down Expand Up @@ -154,7 +154,7 @@ class="img-circle"/>
'label' => Yii::t('backend', 'Users'),
'icon' => '<i class="fa fa-users"></i>',
'url' => ['/user/index'],
'active' => (Yii::$app->controller->id == 'user'),
'active' => Yii::$app->controller->id === 'user',
'visible' => Yii::$app->user->can('administrator'),
],
[
Expand All @@ -165,26 +165,27 @@ class="img-circle"/>
'label' => Yii::t('backend', 'Static pages'),
'url' => ['/content/page/index'],
'icon' => '<i class="fa fa-thumb-tack"></i>',
'active' => (Yii::$app->controller->id == 'page'),
'active' => Yii::$app->controller->id === 'page',
],
[
'label' => Yii::t('backend', 'Articles'),
'url' => '#',
'icon' => '<i class="fa fa-files-o"></i>',
'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' => '<i class="fa fa-file-o"></i>',
'active' => (Yii::$app->controller->id == 'default'),
'active' => Yii::$app->controller->id === 'article',
],
[
'label' => Yii::t('backend', 'Categories'),
'url' => ['/content/category/index'],
'icon' => '<i class="fa fa-folder-open-o"></i>',
'active' => (Yii::$app->controller->id == 'category'),
'active' => Yii::$app->controller->id === 'category',
],
],
],
Expand All @@ -193,19 +194,19 @@ class="img-circle"/>
'url' => '#',
'icon' => '<i class="fa fa-code"></i>',
'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' => '<i class="fa fa-circle-o"></i>',
'active' => (Yii::$app->controller->id == 'text'),
'active' => Yii::$app->controller->id === 'text',
],
[
'label' => Yii::t('backend', 'Menu'),
'url' => ['/widget/menu/index'],
'icon' => '<i class="fa fa-circle-o"></i>',
'active' => (Yii::$app->controller->id == 'menu'),
'active' => Yii::$app->controller->id === 'menu',
],
[
'label' => Yii::t('backend', 'Carousel'),
Expand Down
3 changes: 2 additions & 1 deletion backend/views/layouts/main.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* @var $this yii\web\View
* @var $content string
*/
?>
<?php $this->beginContent('@backend/views/layouts/common.php'); ?>
Expand All @@ -9,4 +10,4 @@
<?php echo $content ?>
</div>
</div>
<?php $this->endContent(); ?>
<?php $this->endContent(); ?>

0 comments on commit 546d9d0

Please sign in to comment.