Browse Source

PHP8 support 2

master
Error202 3 years ago
parent
commit
d342f81838
  1. 2
      Vagrantfile
  2. 1
      backend/assets/AdminLteSkinAsset.php
  3. 11
      backend/assets/AppAsset.php
  4. 2
      backend/bootstrap/SetUp.php
  5. 35
      backend/components/ToggleAction.php
  6. 30
      backend/components/ToggleColumn.php
  7. 50
      backend/components/menu/css/menu.css
  8. 11
      backend/components/menu/widgets/MenuEditorWidget.php
  9. 49
      backend/components/menu/widgets/views/_item.php
  10. 17
      backend/components/menu/widgets/views/_item_tab.php
  11. 159
      backend/components/menu/widgets/views/menu.php
  12. 42
      backend/config/main.php
  13. 11
      backend/controllers/AuthController.php
  14. 59
      backend/controllers/MenuController.php
  15. 61
      backend/controllers/ModuleController.php
  16. 38
      backend/controllers/PermissionController.php
  17. 70
      backend/controllers/RoleController.php
  18. 43
      backend/controllers/SiteController.php
  19. 40
      backend/controllers/SliderController.php
  20. 56
      backend/controllers/UserController.php
  21. 39
      backend/controllers/post/CategoryController.php
  22. 40
      backend/controllers/post/CommentController.php
  23. 71
      backend/controllers/post/PostController.php
  24. 37
      backend/controllers/post/TagController.php
  25. 27
      backend/controllers/post/TypeController.php
  26. 52
      backend/controllers/settings/ListController.php
  27. 18
      backend/forms/SettingsSearch.php
  28. 19
      backend/forms/UserSearch.php
  29. 14
      backend/forms/rbac/RbacCreatePermissionForm.php
  30. 14
      backend/forms/rbac/RbacCreateRoleForm.php
  31. 15
      backend/forms/rbac/RbacEditPermissionForm.php
  32. 15
      backend/forms/rbac/RbacEditRoleForm.php
  33. 6
      backend/forms/rbac/RbacUpdateChildren.php
  34. 13
      backend/helpers/DashboardHelper.php
  35. 1
      backend/messages/ru/menu.php
  36. 8
      backend/views/auth/login.php
  37. 238
      backend/views/layouts/content-origin.php
  38. 289
      backend/views/layouts/content.php
  39. 33
      backend/views/layouts/error-origin.php
  40. 11
      backend/views/layouts/error.php
  41. 265
      backend/views/layouts/header-origin.php
  42. 306
      backend/views/layouts/header.php
  43. 211
      backend/views/layouts/left-origin.php
  44. 369
      backend/views/layouts/left.php
  45. 31
      backend/views/layouts/main-login-origin.php
  46. 29
      backend/views/layouts/main-login.php
  47. 66
      backend/views/layouts/main-origin.php
  48. 140
      backend/views/layouts/main.php
  49. 18
      backend/views/menu/_form.php
  50. 11
      backend/views/menu/_form_tab.php
  51. 4
      backend/views/menu/create.php
  52. 74
      backend/views/menu/menu.php
  53. 10
      backend/views/menu/select_menu.php
  54. 7
      backend/views/menu/update.php
  55. 14
      backend/views/module/list.php
  56. 3
      backend/views/module/remote-list.php
  57. 14
      backend/views/permission/create.php
  58. 12
      backend/views/permission/index.php
  59. 18
      backend/views/permission/update.php
  60. 14
      backend/views/permission/view.php
  61. 18
      backend/views/post/articles/_form.php
  62. 7
      backend/views/post/articles/create.php
  63. 12
      backend/views/post/articles/index.php
  64. 13
      backend/views/post/articles/update.php
  65. 6
      backend/views/post/articles/view.php
  66. 18
      backend/views/post/blog/_form.php
  67. 7
      backend/views/post/blog/create.php
  68. 9
      backend/views/post/blog/index.php
  69. 13
      backend/views/post/blog/update.php
  70. 6
      backend/views/post/blog/view.php
  71. 5
      backend/views/post/category/_form.php
  72. 7
      backend/views/post/category/create.php
  73. 6
      backend/views/post/category/index.php
  74. 10
      backend/views/post/category/update.php
  75. 6
      backend/views/post/category/view.php
  76. 3
      backend/views/post/comment/index.php
  77. 6
      backend/views/post/comment/update.php
  78. 8
      backend/views/post/comment/view.php
  79. 16
      backend/views/post/gallery/_form.php
  80. 7
      backend/views/post/gallery/create.php
  81. 9
      backend/views/post/gallery/index.php
  82. 10
      backend/views/post/gallery/update.php
  83. 6
      backend/views/post/gallery/view.php
  84. 18
      backend/views/post/news/_form.php
  85. 7
      backend/views/post/news/create.php
  86. 12
      backend/views/post/news/index.php
  87. 13
      backend/views/post/news/update.php
  88. 6
      backend/views/post/news/view.php
  89. 18
      backend/views/post/post/_form.php
  90. 7
      backend/views/post/post/create.php
  91. 12
      backend/views/post/post/index.php
  92. 13
      backend/views/post/post/update.php
  93. 6
      backend/views/post/post/view.php
  94. 3
      backend/views/post/tag/_form.php
  95. 7
      backend/views/post/tag/create.php
  96. 6
      backend/views/post/tag/index.php
  97. 10
      backend/views/post/tag/update.php
  98. 6
      backend/views/post/tag/view.php
  99. 3
      backend/views/post/type/_form.php
  100. 4
      backend/views/post/type/create.php
  101. Some files were not shown because too many files have changed in this diff Show More

2
Vagrantfile vendored

@ -32,7 +32,7 @@ end
# vagrant configurate # vagrant configurate
Vagrant.configure(2) do |config| Vagrant.configure(2) do |config|
# select the box # select the box
config.vm.box = 'bento/ubuntu-16.04' config.vm.box = 'bento/ubuntu-20.04'
# should we ask about box updates? # should we ask about box updates?
config.vm.box_check_update = options['box_check_update'] config.vm.box_check_update = options['box_check_update']

1
backend/assets/AdminLteSkinAsset.php

@ -6,7 +6,6 @@
namespace backend\assets; namespace backend\assets;
use yii\web\AssetBundle; use yii\web\AssetBundle;
class AdminLteSkinAsset extends AssetBundle class AdminLteSkinAsset extends AssetBundle

11
backend/assets/AppAsset.php

@ -2,7 +2,10 @@
namespace backend\assets; namespace backend\assets;
use yii\bootstrap\BootstrapAsset;
use yii\bootstrap\BootstrapPluginAsset;
use yii\web\AssetBundle; use yii\web\AssetBundle;
use yii\web\YiiAsset;
/** /**
* Main backend application asset bundle. * Main backend application asset bundle.
@ -12,12 +15,14 @@ class AppAsset extends AssetBundle
public $basePath = '@webroot'; public $basePath = '@webroot';
public $baseUrl = '@web'; public $baseUrl = '@web';
public $css = [ public $css = [
'css/site.css', 'css/site.css?v1.01',
'css/ui.jqgrid-bootstrap.css'
]; ];
public $js = [ public $js = [
]; ];
public $depends = [ public $depends = [
'yii\web\YiiAsset', YiiAsset::class,
'yii\bootstrap\BootstrapPluginAsset', BootstrapAsset::class,
BootstrapPluginAsset::class
]; ];
} }

2
backend/bootstrap/SetUp.php

@ -46,7 +46,7 @@ class SetUp implements BootstrapInterface
// load settings // load settings
$settings = Settings::find()->with('translations')->andWhere(['active' => 1])->all(); $settings = Settings::find()->with('translations')->andWhere(['active' => 1])->all();
$settings_array = $settings ? ArrayHelper::map($settings, 'key', function ($el) { $settings_array = $settings ? ArrayHelper::map($settings, 'key', function ($el) {
return isset($el->translation->value) ? $el->translation->value : ''; return $el->translation->value ?? '';
}, 'section') : []; }, 'section') : [];
$app->params['settings'] = $settings_array; $app->params['settings'] = $settings_array;

35
backend/components/ToggleAction.php

@ -7,59 +7,68 @@
namespace backend\components; namespace backend\components;
use yii\base\Action; use yii\base\Action;
use yii\base\ExitException;
use yii\db\ActiveRecord;
use yii\db\Expression; use yii\db\Expression;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
use yii\web\MethodNotAllowedHttpException; use yii\web\MethodNotAllowedHttpException;
use Yii; use Yii;
use yii\web\Response;
class ToggleAction extends Action class ToggleAction extends Action
{ {
/** /**
* @var string name of the model * @var string name of the model
*/ */
public $modelClass; public string $modelClass;
/** /**
* @var string model attribute * @var string model attribute
*/ */
public $attribute = 'active'; public string $attribute = 'active';
/** /**
* @var string scenario model * @var string scenario model
*/ */
public $scenario = null; public ?string $scenario = null;
/** /**
* @var string|array additional condition for loading the model * @var string|array additional condition for loading the model
*/ */
public $andWhere; public string|array $andWhere;
/** /**
* @var string|int|boolean|Expression what to set active models to * @var string|int|boolean|Expression what to set active models to
*/ */
public $onValue = 1; public string|int|bool|Expression $onValue = 1;
/** /**
* @var string|int|boolean what to set inactive models to * @var string|int|boolean what to set inactive models to
*/ */
public $offValue = 0; public string|int|bool $offValue = 0;
/** /**
* @var bool whether to set flash messages or not * @var bool whether to set flash messages or not
*/ */
public $setFlash = false; public bool $setFlash = false;
/** /**
* @var string flash message on success * @var string flash message on success
*/ */
public $flashSuccess = 'Model saved'; public string $flashSuccess = 'Model saved';
/** /**
* @var string flash message on error * @var string flash message on error
*/ */
public $flashError = 'Error saving Model'; public string $flashError = 'Error saving Model';
/** /**
* @var string|array URL to redirect to * @var string|array URL to redirect to
*/ */
public $redirect; public string|array $redirect;
/** /**
* @var string pk field name * @var string pk field name
*/ */
public $primaryKey = 'id'; public string $primaryKey = 'id';
/**
* @param $id
* @return Response
* @throws InvalidConfigException
* @throws MethodNotAllowedHttpException
* @throws ExitException
*/
public function run($id) public function run($id)
{ {
if (!Yii::$app->request->getIsPost()) { if (!Yii::$app->request->getIsPost()) {
@ -70,7 +79,7 @@ class ToggleAction extends Action
if (empty($this->modelClass) || !class_exists($this->modelClass)) { if (empty($this->modelClass) || !class_exists($this->modelClass)) {
throw new InvalidConfigException("Model class doesn't exist"); throw new InvalidConfigException("Model class doesn't exist");
} }
/* @var $modelClass \yii\db\ActiveRecord */ /* @var $modelClass ActiveRecord */
$modelClass = $this->modelClass; $modelClass = $this->modelClass;
$attribute = $this->attribute; $attribute = $this->attribute;
$model = $modelClass::find()->where([$this->primaryKey => $id]); $model = $modelClass::find()->where([$this->primaryKey => $id]);

30
backend/components/ToggleColumn.php

@ -17,54 +17,54 @@ class ToggleColumn extends DataColumn
* Toggle action that will be used as the toggle action in your controller * Toggle action that will be used as the toggle action in your controller
* @var string * @var string
*/ */
public $action = 'toggle'; public string $action = 'toggle';
/** /**
* @var string pk field name * @var string pk field name
*/ */
public $primaryKey = 'primaryKey'; public string $primaryKey = 'primaryKey';
/** /**
* Whether to use ajax or not * Whether to use ajax or not
* @var bool * @var bool
*/ */
public $enableAjax = true; public bool $enableAjax = true;
/** /**
* @var string glyphicon for 'on' value * @var string glyphicon for 'on' value
*/ */
public $iconOn = 'ok'; public string $iconOn = 'ok';
/** /**
* @var string glyphicon for 'off' value * @var string glyphicon for 'off' value
*/ */
public $iconOff = 'remove'; public string $iconOff = 'remove';
/** /**
* @var string text to display on the 'on' link * @var string|null text to display on the 'on' link
*/ */
public $onText; public ?string $onText = null;
/** /**
* @var string text to display on the 'off' link * @var string|null text to display on the 'off' link
*/ */
public $offText; public ?string $offText = null;
/** /**
* @var string text to display next to the 'on' link * @var string|bool text to display next to the 'on' link
*/ */
public $displayValueText = false; public string|bool $displayValueText = false;
/** /**
* @var string text to display next to the 'on' link * @var string|null text to display next to the 'on' link
*/ */
public $onValueText; public ?string $onValueText = null;
/** /**
* @var string text to display next to the 'off' link * @var string|null text to display next to the 'off' link
*/ */
public $offValueText; public ?string $offValueText = null;
public function init() public function init()

50
backend/components/menu/css/menu.css

@ -22,7 +22,7 @@ p { line-height: 1.5em; }
position: relative; position: relative;
display: block; display: block;
margin: 0; padding: 0; margin: 0; padding: 0;
max-width: 600px; /*max-width: 600px;*/
list-style: none; list-style: none;
font-size: 13px; font-size: 13px;
line-height: 20px; line-height: 20px;
@ -43,7 +43,8 @@ p { line-height: 1.5em; }
.dd-placeholder { .dd-placeholder {
display: block; display: block;
position: relative; position: relative;
margin: 0; padding: 1px; margin: 0;
padding: 1px;
min-height: 20px; min-height: 20px;
font-size: 13px; font-size: 13px;
line-height: 10px; line-height: 10px;
@ -134,7 +135,7 @@ p { line-height: 1.5em; }
@media only screen and (min-width: 700px) { @media only screen and (min-width: 700px) {
.dd { float: left; width: 70%; } .dd { float: left; width: 100%; }
.dd + .dd { margin-left: 2%; } .dd + .dd { margin-left: 2%; }
} }
@ -167,9 +168,19 @@ p { line-height: 1.5em; }
.dd-dragel > .dd3-item > .dd3-content { margin: 0; } .dd-dragel > .dd3-item > .dd3-content { margin: 0; }
.dd3-item > button { margin-left: 30px; } .dd3-item > button {
position: absolute;
margin-left: 30px;
}
.dd3-handle { position: absolute; margin: 0; left: 0; top: 0; cursor: pointer; width: 30px; text-indent: 100%; white-space: nowrap; overflow: hidden; .dd3-handle {
position: absolute;
margin: 0; left: 0; top: 0;
cursor: pointer;
width: 30px;
/*text-indent: 100%;*/
white-space: nowrap;
overflow: hidden;
border: 1px solid #aaa; border: 1px solid #aaa;
background: #ddd; background: #ddd;
background: -webkit-linear-gradient(top, #ddd 0%, #bbb 100%); background: -webkit-linear-gradient(top, #ddd 0%, #bbb 100%);
@ -179,8 +190,8 @@ p { line-height: 1.5em; }
border-bottom-right-radius: 0; border-bottom-right-radius: 0;
} }
.dd3-handle:before { .dd3-handle:before {
content: "\f047"; content: "\f0b2";
font-family: FontAwesome; font-family: "Font Awesome 5 Free";
display: block; display: block;
position: absolute; position: absolute;
left: 0; top: 10px; left: 0; top: 10px;
@ -189,16 +200,29 @@ p { line-height: 1.5em; }
text-indent: 0; text-indent: 0;
color: #fff; color: #fff;
font-size: 15px; font-size: 15px;
font-weight: normal; /*font-weight: normal;*/
} }
.dd3-handle:hover { background: #ddd; } .dd3-handle:hover { background: #ddd; }
.panel-group { .card-group {
margin-bottom: 0 !important; margin-bottom: 0 !important;
} }
.panel-heading { .card-header {
position: relative; position: relative !important;
color: #333333 !important;
background-color: #f5f5f5 !important;
border-color: #ddd !important;
}
.card-header h4 {
padding-left: 15px;
font-size: 16px;
} }
.panel-heading h4 {
padding-left: 25px; .card-header h4 a {
color: #333333;
}
.menu-selector p, .menu-selector .form-group {
margin: 0 !important;
padding: 0 !important;
} }

11
backend/components/menu/widgets/MenuEditorWidget.php

@ -12,9 +12,9 @@ use yii\base\Widget;
class MenuEditorWidget extends Widget class MenuEditorWidget extends Widget
{ {
public $menu_id; public int $menu_id;
public function run() public function run(): string
{ {
$menu = Menu::findOne($this->menu_id); $menu = Menu::findOne($this->menu_id);
$items = $menu->items; $items = $menu->items;
@ -26,14 +26,15 @@ class MenuEditorWidget extends Widget
} }
/** /**
* @param $items MenuItem[] * @param array $items
* * @param null $paren_id
* @return array * @return array
*/ */
private function getMenu($items, $paren_id = null) private function getMenu(array $items, $paren_id = null): array
{ {
$array = []; $array = [];
foreach ($items as $item) { foreach ($items as $item) {
/* @var $item MenuItem */
if ($item->parent_id != $paren_id) { if ($item->parent_id != $paren_id) {
continue; continue;
} }

49
backend/components/menu/widgets/views/_item.php

@ -4,33 +4,44 @@
* Date: 11.07.2018 * Date: 11.07.2018
*/ */
use core\components\bootstrap4\widgets\Tab4;
use core\entities\menu\MenuItem;
use core\forms\menu\MenuItemForm;
use yii\helpers\Html; use yii\helpers\Html;
use kartik\form\ActiveForm; use kartik\form\ActiveForm;
use yii\web\View;
/** /**
* @var $this \yii\web\View * @var $this View
* @var $item array * @var $item array
* @var $model \core\forms\menu\MenuItemForm * @var $model MenuItemForm
*/ */
/* @var $menu_item \core\entities\menu\MenuItem */ /* @var $menu_item MenuItem */
$menu_item = $item['item']; $menu_item = $item['item'];
?> ?>
<li class="dd-item dd3-item" data-id="<?= $menu_item->id ?>"> <li class="dd-item dd3-item" data-id="<?= $menu_item->id ?>" xmlns="http://www.w3.org/1999/html">
<div class="dd3-content"> <div class="dd3-content">
<div class="panel-group" id="accordion"> <div class="card-group" id="accordion">
<div class="panel panel-default"> <div class="card m-0">
<div class="panel-heading"> <div class="card-header" style="border: 0 !important; padding-left: 40px;">
<h4 class="panel-title"> <h4 class="card-title">
<div class="dd-handle dd3-handle"> </div> <div class="dd-handle dd3-handle"> </div>
<a data-toggle="collapse" data-parent="#accordion" href="#collapse<?= $menu_item->id ?>"><?= $menu_item->translation->name ?> <a data-toggle="collapse" data-parent="#accordion" href="#collapse<?= $menu_item->id ?>">
<i class="fa fa-angle-down pull-right" aria-hidden="true"></i> <span style="font-size: 14px; color: #999" class="pull-right"><?= Yii::t($menu_item->module, ucfirst($menu_item->module)) ?></span></a> <?= $menu_item->translation->name ?>
<div style="position: absolute; right: 10px; top: 10px;">
<span style="font-size: 14px; color: #999"><?= Yii::t($menu_item->module, ucfirst($menu_item->module)) ?></span>
<i class="fas fa-angle-down" aria-hidden="true"></i>
</div>
</a>
</h4> </h4>
<div>
</div>
</div> </div>
<div id="collapse<?= $menu_item->id ?>" class="panel-collapse collapse"> <div id="collapse<?= $menu_item->id ?>" class="panel-collapse collapse">
<div class="panel-body"> <div class="panel-body p-2">
<?php $form = ActiveForm::begin([ <?php $form = ActiveForm::begin([
'action' => ['/menu/save-item', 'id' => $menu_item->id], 'action' => ['/menu/save-item', 'id' => $menu_item->id],
@ -51,7 +62,7 @@ $menu_item = $item['item'];
?> ?>
<div class="nav-tabs-custom"> <div class="nav-tabs-custom">
<?= \yii\bootstrap\Tabs::widget([ <?= Tab4::widget([
'items' => $items 'items' => $items
]) ?> ]) ?>
</div> </div>
@ -61,18 +72,20 @@ $menu_item = $item['item'];
<?= $form->field($model, 'target')->dropDownList([ <?= $form->field($model, 'target')->dropDownList([
'' => Yii::t('menu', 'Self Window'), '' => Yii::t('menu', 'Self Window'),
'_blank' => Yii::t('menu', 'Blank Window'), '_blank' => Yii::t('menu', 'Blank Window'),
]) ?> ], [
<?= $form->field($model, 'style')->textInput(['maxlength' => true]) ?> 'class' => 'form-control form-control-sm'
]) ?>
<?= $form->field($model, 'style')->textInput(['maxlength' => true, 'class' => 'form-control form-control-sm'],) ?>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<?= $form->field($model, 'css')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'css')->textInput(['maxlength' => true, 'class' => 'form-control form-control-sm']) ?>
<?php if (!$menu_item->url_params): ?> <?php if (!$menu_item->url_params): ?>
<?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'url')->textInput(['maxlength' => true, 'class' => 'form-control form-control-sm']) ?>
<?php endif; ?> <?php endif; ?>
</div> </div>
</div> </div>
<div class="pull-right"> <div class="float-right">
<?= Html::a(Yii::t('buttons', 'Delete'), '#', [ <?= Html::a(Yii::t('buttons', 'Delete'), '#', [
'class' => 'item-delete-button btn btn-sm btn-danger', 'class' => 'item-delete-button btn btn-sm btn-danger',
'data-id' => $menu_item->id, 'data-id' => $menu_item->id,

17
backend/components/menu/widgets/views/_item_tab.php

@ -4,22 +4,25 @@
* Date: 24.08.2018 * Date: 24.08.2018
*/ */
use core\forms\menu\MenuItemForm;
use yii\web\View;
use yii\widgets\ActiveForm;
/** /**
* @var $this \yii\web\View * @var $this View
* @var $form \yii\widgets\ActiveForm * @var $form ActiveForm
* @var $model \core\forms\menu\MenuItemForm * @var $model MenuItemForm
* @var $language string * @var $language string
*/ */
$postfix = $language == Yii::$app->params['defaultLanguage'] ? '' : '_' . $language; $postfix = $language == Yii::$app->params['defaultLanguage'] ? '' : '_' . $language;
?> ?>
<div class="row"> <div class="row mt-3">
<div class="col-md-6"> <div class="col-md-6">
<?= $form->field($model, 'name' . $postfix)->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'name' . $postfix)->textInput(['maxlength' => true, 'class' => 'form-control form-control-sm']) ?>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<?= $form->field($model, 'title_attr' . $postfix)->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'title_attr' . $postfix)->textInput(['maxlength' => true, 'class' => 'form-control form-control-sm']) ?>
</div> </div>
</div> </div>

159
backend/components/menu/widgets/views/menu.php

@ -4,21 +4,24 @@
* Date: 11.07.2018 * Date: 11.07.2018
*/ */
/**
* @var $this \yii\web\View
* @var $items array
* @var $menu \core\entities\menu\Menu
*/
use backend\components\menu\assets\MenuAsset; use backend\components\menu\assets\MenuAsset;
use core\entities\menu\Menu;
use core\forms\menu\MenuItemForm; use core\forms\menu\MenuItemForm;
use yii\helpers\Html; use yii\helpers\Html;
use yii\helpers\Url; use yii\helpers\Url;
use yii\web\JsExpression; use yii\web\JsExpression;
use yii\web\View;
/**
* @var $this View
* @var $items array
* @var $menu Menu
*/
MenuAsset::register($this); MenuAsset::register($this);
function menu_generate($items) { function menu_generate($items): string
{
$html = '<ol class="dd-list">'; $html = '<ol class="dd-list">';
foreach ($items as $item) { foreach ($items as $item) {
$menuItemForm = new MenuItemForm($item['item']); $menuItemForm = new MenuItemForm($item['item']);
@ -31,39 +34,11 @@ function menu_generate($items) {
} }
$name_empty_error = Yii::t('menu', 'Name must be specified'); $name_empty_error = Yii::t('menu', 'Name must be specified');
//$item_save_url = Url::to(['menu/save-menu-item-data']);
$item_save_url = ''; // delete this $item_save_url = ''; // delete this
$item_delete_url = Url::to(['menu/delete-menu-item']); $item_delete_url = Url::to(['menu/delete-menu-item']);
$confirm_delete_message = Yii::t('buttons', 'Are you sure you want to delete this item?'); $confirm_delete_message = Yii::t('buttons', 'Are you sure you want to delete this item?');
$current_url = Url::to(['menu/index', 'id' => $menu->id]); $current_url = Url::to(['menu/index', 'id' => $menu->id]);
$js = <<<JS $js = <<<JS
/*$(".item-save-button").on('click', function(e) {
e.preventDefault();
var id = $(this).data('id');
var name = $("#item-name-" + id).val();
var title = $("#item-title-attr-" + id).val();
var style = $("#item-style-" + id).val();
var css = $("#item-css-" + id).val();
var url = $("#item-url-" + id).val();
var target = $("#item-target-" + id).val();
if (name) {
$.ajax({
method: "POST",
url: "{$item_save_url}",
data: { name: name, title: title, style: style, css: css, url: url, target: target, id: id }
})
.done(function( data ) {
if (data.result === 'success') {
document.location.href = '{$current_url}';
}
});
}
else {
alert('{$name_empty_error}');
}
});*/
$(".item-delete-button").on('click', function(e) { $(".item-delete-button").on('click', function(e) {
e.preventDefault(); e.preventDefault();
if (confirm('{$confirm_delete_message}')) { if (confirm('{$confirm_delete_message}')) {
@ -91,121 +66,11 @@ $redirect = Url::to(['menu/index', 'id' => $menu->id]);
<?= menu_generate($items) ?> <?= menu_generate($items) ?>
</div> </div>
<!--
<div class="dd" id="nestable2">
<ol class="dd-list">
<li class="dd-item dd3-item" data-id="13">
<div class="dd3-content">
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<div class="dd-handle dd3-handle"> </div>
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">Item 13
<i class="fa fa-angle-down pull-right" aria-hidden="true"></i></a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">
Content Panel
</div>
</div>
</div>
</div>
</div>
</li>
<li class="dd-item dd3-item" data-id="14">
<div class="dd3-content">
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<div class="dd-handle dd3-handle"> </div>
<a data-toggle="collapse" data-parent="#accordion" href="#collapse2">Item 14
<i class="fa fa-angle-down pull-right" aria-hidden="true"></i></a>
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">
Content Panel
</div>
</div>
</div>
</div>
</div>
</li>
<li class="dd-item dd3-item" data-id="15">
<div class="dd3-content">
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<div class="dd-handle dd3-handle"> </div>
<a data-toggle="collapse" data-parent="#accordion" href="#collapse3">Item 15
<i class="fa fa-angle-down pull-right" aria-hidden="true"></i></a>
</h4>
</div>
<div id="collapse3" class="panel-collapse collapse">
<div class="panel-body">
Content Panel
</div>
</div>
</div>
</div>
</div>
<ol class="dd-list">
<li class="dd-item dd3-item" data-id="16">
<div class="dd3-content">
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<div class="dd-handle dd3-handle"> </div>
<a data-toggle="collapse" data-parent="#accordion" href="#collapse4">Item 16
<i class="fa fa-angle-down pull-right" aria-hidden="true"></i></a>
</h4>
</div>
<div id="collapse4" class="panel-collapse collapse">
<div class="panel-body">
Content Panel
</div>
</div>
</div>
</div>
</div>
</li>
</ol>
</li>
</ol>
</div>
</div>
<div style="clear: both;"></div>
<hr>
<button class="btn btn-primary" id="serialize">Serialize</button>
<hr>
<textarea class="form-control" id="output"></textarea>
<hr>
<textarea class="form-control" id="output2"></textarea>
-->
<div style="clear: both;"></div> <div style="clear: both;"></div>
<hr> <hr>
<?= Html::button(Yii::t('buttons', 'Save'), [ <?= Html::button(Yii::t('buttons', 'Save'), [
'class' => 'btn btn-success pull-right', 'class' => 'btn btn-success float-right',
'onclick' => new JsExpression('sendTree('.$menu->id.', "'.$url.'", "'.$redirect.'")'), 'onclick' => new JsExpression('sendTree('.$menu->id.', "'.$url.'", "'.$redirect.'")'),
]) ?> ]) ?>

42
backend/config/main.php

@ -149,6 +149,48 @@ return [
], ],
], ],
], ],
'assetManager' => [
'bundles' => [
'yii\bootstrap\BootstrapAsset' => [
'sourcePath' => '@core/components/bootstrap4', // do not publish the bundle
'css' => [
YII_ENV_DEV ? 'css/bootstrap.css' : 'css/bootstrap.min.css'
],
],
'yii\bootstrap\BootstrapPluginAsset' => [
'sourcePath' => '@core/components/bootstrap4',
'js' => [
YII_ENV_DEV ? 'js/bootstrap.bundle.js' : 'js/bootstrap.bundle.min.js'
],
'depends' => [
'yii\web\JqueryAsset',
'yii\bootstrap\BootstrapAsset',
],
],
/*'yii\web\JqueryAsset' => [
'sourcePath' => '@cp/assets/libs/jquery321', // do not publish the bundle
'js' => [
YII_ENV_DEV ? 'jquery-3.2.1.js' : 'jquery-3.2.1.min.js'
],
],
'yii\bootstrap\BootstrapAsset' => [
'sourcePath' => '@cp/assets/libs/bootstrap4/css', // do not publish the bundle
'css' => [
YII_ENV_DEV ? 'bootstrap.css' : 'bootstrap.min.css'
],
],
'yii\bootstrap\BootstrapPluginAsset' => [
'sourcePath' => '@cp/assets/libs/bootstrap4/js', // do not publish the bundle
'js' => [
YII_ENV_DEV ? 'bootstrap.js' : 'bootstrap.min.js'
],
'depends' => [
'yii\web\JqueryAsset',
'yii\bootstrap\BootstrapAsset',
],
],*/
],
],
], ],
'params' => $params, 'params' => $params,
]; ];

11
backend/controllers/AuthController.php

@ -10,10 +10,11 @@ use yii\filters\VerbFilter;
use core\forms\auth\LoginForm; use core\forms\auth\LoginForm;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use DomainException; use DomainException;
use yii\web\Response;
class AuthController extends Controller class AuthController extends Controller
{ {
private $auth_service; private AuthService $auth_service;
public function __construct($id, $module, AuthService $service, $config = []) public function __construct($id, $module, AuthService $service, $config = [])
{ {
@ -56,9 +57,9 @@ class AuthController extends Controller
} }
/** /**
* @return mixed * @return string|Response
*/ */
public function actionLogin() public function actionLogin(): string|Response
{ {
if (!Yii::$app->user->isGuest) { if (!Yii::$app->user->isGuest) {
return $this->goHome(); return $this->goHome();
@ -85,9 +86,9 @@ class AuthController extends Controller
} }
/** /**
* @return mixed * @return Response
*/ */
public function actionLogout() public function actionLogout(): Response
{ {
Yii::$app->user->logout(); Yii::$app->user->logout();

59
backend/controllers/MenuController.php

@ -14,6 +14,7 @@ use core\forms\menu\MenuItemForm;
use core\forms\menu\MenuSelectForm; use core\forms\menu\MenuSelectForm;
use core\services\menu\MenuItemManageService; use core\services\menu\MenuItemManageService;
use core\services\menu\MenuManageService; use core\services\menu\MenuManageService;
use yii\db\StaleObjectException;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\helpers\Json; use yii\helpers\Json;
@ -26,8 +27,8 @@ use Yii;
class MenuController extends Controller class MenuController extends Controller
{ {
public $menu_service; public MenuManageService $menu_service;
public $menu_item_service; public MenuItemManageService $menu_item_service;
public function __construct( public function __construct(
string $id, string $id,
@ -68,7 +69,12 @@ class MenuController extends Controller
]; ];
} }
public function actionIndex($id = null) /**
* @param null $id
* @return Response|string
* @throws NotFoundHttpException
*/
public function actionIndex($id = null): Response|string
{ {
$menus = []; // menu list $menus = []; // menu list
$menu_records = Menu::find()->all(); $menu_records = Menu::find()->all();
@ -82,10 +88,12 @@ class MenuController extends Controller
if ($form->load(Yii::$app->request->get()) && $form->validate()) { if ($form->load(Yii::$app->request->get()) && $form->validate()) {
return $this->redirect(['menu/index', 'id' => $form->id]); return $this->redirect(['menu/index', 'id' => $form->id]);
} elseif ($id) { } elseif ($id) {
$this->createMenuItem(); // create menu item if MenuItemForm sent
$menu = $this->findModel($id); $menu = $this->findModel($id);
if ($this->createMenuItem()) {
return $this->redirect(['/menu/index', 'id' => $id]);
}; // create menu item if MenuItemForm sent
$creatorWidgets = $this->getCreatorWidgets($menu->id); $creatorWidgets = $this->getCreatorWidgets($menu->id);
return $this->render('menu', [ return $this->render('menu', [
@ -102,7 +110,7 @@ class MenuController extends Controller
} }
} }
public function actionCreate() public function actionCreate(): Response|string
{ {
$form = new MenuForm(); $form = new MenuForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) { if ($form->load(Yii::$app->request->post()) && $form->validate()) {
@ -121,7 +129,12 @@ class MenuController extends Controller
]); ]);
} }
public function actionUpdate($id) /**
* @param $id
* @return Response|string
* @throws NotFoundHttpException
*/
public function actionUpdate($id): Response|string
{ {
$menu = $this->findModel($id); $menu = $this->findModel($id);
@ -143,7 +156,7 @@ class MenuController extends Controller
]); ]);
} }
public function actionDelete($id) public function actionDelete($id): Response
{ {
try { try {
$this->menu_service->remove($id); $this->menu_service->remove($id);
@ -155,7 +168,12 @@ class MenuController extends Controller
return $this->redirect(['index']); return $this->redirect(['index']);
} }
public function actionSaveItem($id) /**
* @param $id
* @return Response
* @throws NotFoundHttpException
*/
public function actionSaveItem($id): Response
{ {
$item = $this->findItemModel($id); $item = $this->findItemModel($id);
$form = new MenuItemForm($item); $form = new MenuItemForm($item);
@ -173,7 +191,12 @@ class MenuController extends Controller
return $this->redirect(['index', 'id' => $item->menu_id]); return $this->redirect(['index', 'id' => $item->menu_id]);
} }
public function actionDeleteMenuItem() /**
* @return array
* @throws NotFoundHttpException
* @throws StaleObjectException
*/
public function actionDeleteMenuItem(): array
{ {
Yii::$app->response->format = Response::FORMAT_JSON; Yii::$app->response->format = Response::FORMAT_JSON;
if (Yii::$app->request->isAjax) { if (Yii::$app->request->isAjax) {
@ -193,7 +216,7 @@ class MenuController extends Controller
return ['result' => 'error', 'message' => 'Request error']; return ['result' => 'error', 'message' => 'Request error'];
} }
public function actionSaveMenuItems() public function actionSaveMenuItems(): array
{ {
$json = Yii::$app->request->post('json'); $json = Yii::$app->request->post('json');
Yii::$app->response->format = Response::FORMAT_JSON; Yii::$app->response->format = Response::FORMAT_JSON;
@ -230,18 +253,25 @@ class MenuController extends Controller
return $widgets; return $widgets;
} }
private function createMenuItem() private function createMenuItem(): bool
{ {
$form = new MenuItemForm(); $form = new MenuItemForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) { if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try { try {
$this->menu_item_service->create($form); $this->menu_item_service->create($form);
return true;
} catch (DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
} }
} }
return false;
} }
/**
* @param $id
* @return Menu
* @throws NotFoundHttpException
*/
protected function findModel($id): Menu protected function findModel($id): Menu
{ {
if (($model = Menu::findOne($id)) !== null) { if (($model = Menu::findOne($id)) !== null) {
@ -250,6 +280,11 @@ class MenuController extends Controller
throw new NotFoundHttpException('The requested menu does not exist.'); throw new NotFoundHttpException('The requested menu does not exist.');
} }
/**
* @param $id
* @return MenuItem
* @throws NotFoundHttpException
*/
protected function findItemModel($id): MenuItem protected function findItemModel($id): MenuItem
{ {
if (($model = MenuItem::findOne($id)) !== null) { if (($model = MenuItem::findOne($id)) !== null) {

61
backend/controllers/ModuleController.php

@ -7,12 +7,15 @@
namespace backend\controllers; namespace backend\controllers;
use core\entities\ModuleRecord; use core\entities\ModuleRecord;
use core\helpers\FileHelper;
use core\services\ModuleService; use core\services\ModuleService;
use Yii;
use yii\base\ErrorException;
use yii\db\Exception;
use yii\web\Controller; use yii\web\Controller;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\web\Response;
/** /**
* Modules Management * Modules Management
@ -24,12 +27,12 @@ class ModuleController extends Controller
/** /**
* @var ModuleService Modules management service * @var ModuleService Modules management service
*/ */
private $_service; private $service;
public function __construct(string $id, $module, ModuleService $service, array $config = []) public function __construct(string $id, $module, ModuleService $service, array $config = [])
{ {
parent::__construct($id, $module, $config); parent::__construct($id, $module, $config);
$this->_service = $service; $this->service = $service;
} }
public function behaviors(): array public function behaviors(): array
@ -65,40 +68,57 @@ class ModuleController extends Controller
* List of modules * List of modules
* @return string * @return string
*/ */
public function actionList() public function actionList(): string
{ {
$modules = \Yii::$app->moduleManager->getModules(); $modules = Yii::$app->moduleManager->getModules();
return $this->render('list', [ return $this->render('list', [
'modules' => $modules, 'modules' => $modules,
]); ]);
} }
public function actionDelete($id) /**
* @param $id
* @return Response
* @throws NotFoundHttpException
* @throws ErrorException
* @throws Exception
*/
public function actionDelete($id): Response
{ {
$module = $this->findModel($id); $module = $this->findModel($id);
$this->_service->delete($module); $this->service->delete($module);
return $this->redirect(['module/list']); return $this->redirect(['module/list']);
} }
public function actionDisable($id) /**
* @param $id
* @return Response
* @throws NotFoundHttpException
*/
public function actionDisable($id): Response
{ {
$module = $this->findModel($id); $module = $this->findModel($id);
$this->_service->disable($module); $this->service->disable($module);
return $this->redirect(['module/list']); return $this->redirect(['module/list']);
} }
public function actionEnable($id) /**
* @param $id
* @return Response
* @throws NotFoundHttpException
*/
public function actionEnable($id): Response
{ {
$module = $this->findModel($id); $module = $this->findModel($id);
$this->_service->enable($module); $this->service->enable($module);
return $this->redirect(['module/list']); return $this->redirect(['module/list']);
} }
public function actionSearch() public function actionSearch(): string
{ {
$message = null; $message = null;
try { try {
@ -113,22 +133,22 @@ class ModuleController extends Controller
continue; continue;
} }
$languageFile = str_replace('manifest.php', 'messages/' . \Yii::$app->language . '/' . $manifest['name'] . '.php', $link); $languageFile = str_replace('manifest.php', 'messages/' . Yii::$app->language . '/' . $manifest['name'] . '.php', $link);
try { try {
$language = file_get_contents($languageFile); $language = file_get_contents($languageFile);
$language = eval(str_replace('<?php', '', $language)); $language = eval(str_replace('<?php', '', $language));
$manifest['locale_name'] = isset($language[$manifest['name']]) ? $language[$manifest['name']] : $manifest['name']; $manifest['locale_name'] = $language[$manifest['name']] ?? $manifest['name'];
$manifest['locale_description'] = isset($language[$manifest['description']]) ? $language[$manifest['description']] : $manifest['description']; $manifest['locale_description'] = $language[$manifest['description']] ?? $manifest['description'];
} catch (\Exception $e) { } catch (\Exception) {
$manifest['locale_name'] = $manifest['name']; $manifest['locale_name'] = $manifest['name'];
$manifest['locale_description'] = $manifest['description']; $manifest['locale_description'] = $manifest['description'];
} }
$modules[] = $manifest; $modules[] = $manifest;
} }
} catch (\Exception $e) { } catch (\Exception) {
$modules = []; $modules = [];
$message = \Yii::t('main', 'Available modules not found'); $message = Yii::t('main', 'Available modules not found');
} }
return $this->render('remote-list', [ return $this->render('remote-list', [
@ -137,6 +157,11 @@ class ModuleController extends Controller
]); ]);
} }
/**
* @param $id
* @return ModuleRecord
* @throws NotFoundHttpException
*/
protected function findModel($id): ModuleRecord protected function findModel($id): ModuleRecord
{ {
if (($model = ModuleRecord::findOne($id)) !== null) { if (($model = ModuleRecord::findOne($id)) !== null) {

38
backend/controllers/PermissionController.php

@ -9,6 +9,8 @@ namespace backend\controllers;
use backend\forms\rbac\RbacCreatePermissionForm; use backend\forms\rbac\RbacCreatePermissionForm;
use backend\forms\rbac\RbacEditPermissionForm; use backend\forms\rbac\RbacEditPermissionForm;
use core\services\PermissionManager; use core\services\PermissionManager;
use DomainException;
use Exception;
use yii\behaviors\TimestampBehavior; use yii\behaviors\TimestampBehavior;
use yii\data\ArrayDataProvider; use yii\data\ArrayDataProvider;
use yii\rbac\Permission; use yii\rbac\Permission;
@ -16,15 +18,16 @@ use yii\web\Controller;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use Yii; use Yii;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\Response;
class PermissionController extends Controller class PermissionController extends Controller
{ {
private $_permission; private PermissionManager $permission;
public function __construct($id, $module, PermissionManager $permission, $config = []) public function __construct($id, $module, PermissionManager $permission, $config = [])
{ {
parent::__construct($id, $module, $config); parent::__construct($id, $module, $config);
$this->_permission = $permission; $this->permission = $permission;
} }
/** /**
@ -59,14 +62,14 @@ class PermissionController extends Controller
]; ];
} }
public function actionIndex() public function actionIndex(): string
{ {
$data = array_map(function (Permission $permission) { $data = array_map(function (Permission $permission) {
return [ return [
'name' => $permission->name, 'name' => $permission->name,
'description' => $permission->description, 'description' => $permission->description,
]; ];
}, $this->_permission->getPermissions()); }, $this->permission->getPermissions());
$dataProvider = new ArrayDataProvider([ $dataProvider = new ArrayDataProvider([
'allModels' => $data, 'allModels' => $data,
@ -81,15 +84,15 @@ class PermissionController extends Controller
return $this->render('index', ['dataProvider' => $dataProvider]); return $this->render('index', ['dataProvider' => $dataProvider]);
} }
public function actionCreate() public function actionCreate(): Response|string
{ {
$form = new RbacCreatePermissionForm(); $form = new RbacCreatePermissionForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) { if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try { try {
$this->_permission->create($form->name, $form->description, $form->rule_name, $form->data); $this->permission->create($form->name, $form->description, $form->rule_name, $form->data);
return $this->redirect(['view', 'id' => $form->name]); return $this->redirect(['view', 'id' => $form->name]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -100,17 +103,22 @@ class PermissionController extends Controller
]); ]);
} }
public function actionUpdate($id) /**
* @param $id
* @return Response|string
* @throws Exception
*/
public function actionUpdate($id): Response|string
{ {
$permission = $this->findModel($id); $permission = $this->findModel($id);
$form = new RbacEditPermissionForm($permission); $form = new RbacEditPermissionForm($permission);
if ($form->load(Yii::$app->request->post()) && $form->validate()) { if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try { try {
$this->_permission->update($permission->name, $form->name, $form->description, $form->rule_name, $form->data); $this->permission->update($permission->name, $form->name, $form->description, $form->rule_name, $form->data);
return $this->redirect(['view', 'id' => $form->name]); return $this->redirect(['view', 'id' => $form->name]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -121,22 +129,22 @@ class PermissionController extends Controller
]); ]);
} }
public function actionDelete($id) public function actionDelete($id): Response
{ {
$this->_permission->delete($id); $this->permission->delete($id);
return $this->redirect(['index']); return $this->redirect(['index']);
} }
public function actionView($id) public function actionView($id): string
{ {
return $this->render('view', [ return $this->render('view', [
'model' => $this->findModel($id), 'model' => $this->findModel($id),
]); ]);
} }
protected function findModel($id) protected function findModel($id): ?Permission
{ {
return $this->_permission->getPermission($id); return $this->permission->getPermission($id);
} }
} }

70
backend/controllers/RoleController.php

@ -9,25 +9,29 @@ namespace backend\controllers;
use backend\forms\rbac\RbacEditRoleForm; use backend\forms\rbac\RbacEditRoleForm;
use backend\forms\rbac\RbacUpdateChildren; use backend\forms\rbac\RbacUpdateChildren;
use core\services\PermissionManager; use core\services\PermissionManager;
use DomainException;
use Exception;
use yii\behaviors\TimestampBehavior; use yii\behaviors\TimestampBehavior;
use backend\forms\rbac\RbacCreateRoleForm; use backend\forms\rbac\RbacCreateRoleForm;
use core\services\RoleManager; use core\services\RoleManager;
use yii\data\ArrayDataProvider; use yii\data\ArrayDataProvider;
use yii\rbac\Role;
use yii\web\Controller; use yii\web\Controller;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use Yii; use Yii;
use yii\web\Response;
class RoleController extends Controller class RoleController extends Controller
{ {
private $_role; private RoleManager $role;
private $_permission; private PermissionManager $permission;
public function __construct($id, $module, RoleManager $role, PermissionManager $permission, $config = []) public function __construct($id, $module, RoleManager $role, PermissionManager $permission, $config = [])
{ {
parent::__construct($id, $module, $config); parent::__construct($id, $module, $config);
$this->_role = $role; $this->role = $role;
$this->_permission = $permission; $this->permission = $permission;
} }
/** /**
@ -62,9 +66,9 @@ class RoleController extends Controller
]; ];
} }
public function actionIndex() public function actionIndex(): string
{ {
$data = $this->_role->getRolesListArray(); $data = $this->role->getRolesListArray();
$dataProvider = new ArrayDataProvider([ $dataProvider = new ArrayDataProvider([
'allModels' => $data, 'allModels' => $data,
@ -79,15 +83,19 @@ class RoleController extends Controller
return $this->render('index', ['dataProvider' => $dataProvider]); return $this->render('index', ['dataProvider' => $dataProvider]);
} }
public function actionCreate() /**
* @return Response|string
* @throws Exception
*/
public function actionCreate(): Response|string
{ {
$form = new RbacCreateRoleForm(); $form = new RbacCreateRoleForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) { if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try { try {
$this->_role->create($form->name, $form->description, $form->rule_name, $form->data); $this->role->create($form->name, $form->description, $form->rule_name, $form->data);
return $this->redirect(['view', 'id' => $form->name]); return $this->redirect(['view', 'id' => $form->name]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -98,17 +106,22 @@ class RoleController extends Controller
]); ]);
} }
public function actionUpdate($id) /**
* @param $id
* @return string|Response
* @throws Exception
*/
public function actionUpdate($id): Response|string
{ {
$role = $this->findModel($id); $role = $this->findModel($id);
$form = new RbacEditRoleForm($role); $form = new RbacEditRoleForm($role);
if ($form->load(Yii::$app->request->post()) && $form->validate()) { if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try { try {
$this->_role->update($role->name, $form->name, $form->description, $form->rule_name, $form->data); $this->role->update($role->name, $form->name, $form->description, $form->rule_name, $form->data);
return $this->redirect(['view', 'id' => $form->name]); return $this->redirect(['view', 'id' => $form->name]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -119,11 +132,11 @@ class RoleController extends Controller
]); ]);
} }
public function actionDelete($id) public function actionDelete($id): Response
{ {
try { try {
$this->_role->delete($id); $this->role->delete($id);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -131,21 +144,26 @@ class RoleController extends Controller
return $this->redirect(['index']); return $this->redirect(['index']);
} }
public function actionView($id) /**
* @param $id
* @return string
* @throws \yii\base\Exception
*/
public function actionView($id): string
{ {
$currentRole = $this->_role->getRole($id); $currentRole = $this->role->getRole($id);
$rolesSelectArray = array_diff_assoc($this->_role->getRolesSelectArray(), [$currentRole->name => $currentRole->description]); $rolesSelectArray = array_diff_assoc($this->role->getRolesSelectArray(), [$currentRole->name => $currentRole->description]);
$itemsForm = new RbacUpdateChildren(); $itemsForm = new RbacUpdateChildren();
if ($itemsForm->load(Yii::$app->request->post()) && $itemsForm->validate()) { if ($itemsForm->load(Yii::$app->request->post()) && $itemsForm->validate()) {
$this->_role->saveChildren($id, $itemsForm->roles, $itemsForm->permissions); $this->role->saveChildren($id, $itemsForm->roles, $itemsForm->permissions);
Yii::$app->session->setFlash('success', Yii::t('user', 'Children roles and permissions for "{role}" is updated.', ['role' => $currentRole->description])); Yii::$app->session->setFlash('success', Yii::t('user', 'Children roles and permissions for "{role}" is updated.', ['role' => $currentRole->description]));
} }
$rolesSelected = $this->_role->getRolesSelectArrayByRole($id); $rolesSelected = $this->role->getRolesSelectArrayByRole($id);
$permissionsSelectArray = $this->_permission->getPermissionsSelectArray(); $permissionsSelectArray = $this->permission->getPermissionsSelectArray();
$permissionsSelected = $this->_permission->getPermissionsSelectArrayByRole($id); $permissionsSelected = $this->permission->getPermissionsSelectArrayByRole($id);
$itemsForm->roles = $rolesSelected; $itemsForm->roles = $rolesSelected;
$itemsForm->permissions = $permissionsSelected; $itemsForm->permissions = $permissionsSelected;
@ -158,8 +176,12 @@ class RoleController extends Controller
]); ]);
} }
protected function findModel($id) /**
* @param $id
* @return Role|null
*/
protected function findModel($id): ?Role
{ {
return $this->_role->getRole($id); return $this->role->getRole($id);
} }
} }

43
backend/controllers/SiteController.php

@ -5,24 +5,29 @@ namespace backend\controllers;
use core\entities\Search; use core\entities\Search;
use core\forms\SearchForm; use core\forms\SearchForm;
use core\services\user\UserManageService; use core\services\user\UserManageService;
use DomainException;
use RuntimeException;
use Yii; use Yii;
use yii\base\Action;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use yii\web\BadRequestHttpException;
use yii\web\Controller; use yii\web\Controller;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use core\helpers\UserHelper; use core\helpers\UserHelper;
use yii\web\Response;
/** /**
* Site controller * Site controller
*/ */
class SiteController extends Controller class SiteController extends Controller
{ {
private $_service; private UserManageService $service;
public function __construct(string $id, $module, UserManageService $service, array $config = []) public function __construct(string $id, $module, UserManageService $service, array $config = [])
{ {
parent::__construct($id, $module, $config); parent::__construct($id, $module, $config);
$this->_service = $service; $this->service = $service;
} }
/** /**
@ -75,12 +80,12 @@ class SiteController extends Controller
* *
* @return string * @return string
*/ */
public function actionIndex() public function actionIndex(): string
{ {
return $this->render('index'); return $this->render('index');
} }
public function actionSearch() public function actionSearch(): string
{ {
$form = new SearchForm(); $form = new SearchForm();
@ -102,28 +107,28 @@ class SiteController extends Controller
'provider' => $provider, 'provider' => $provider,
'form' => $form 'form' => $form
]); ]);
} catch (DomainException) {
//$page = $this->service->create($form);
//return $this->redirect(['view', 'id' => $page->id]);
} catch (\DomainException $e) {
//Yii::$app->errorHandler->logException($e);
//Yii::$app->session->setFlash('error', $e->getMessage());
} }
} }
return ''; return '';
} }
public function actionLanguage($language) public function actionLanguage($language): Response
{ {
if ($language && in_array($language, array_keys(Yii::$app->params['backendTranslatedLanguages']))) { if ($language && in_array($language, array_keys(Yii::$app->params['backendTranslatedLanguages']))) {
$this->_service->setBackendLanguage($language); $this->service->setBackendLanguage($language);
} }
return $this->redirect(Yii::$app->request->referrer); return $this->redirect(Yii::$app->request->referrer);
} }
public function beforeAction($action) /**
* @param Action $action
* @return bool
* @throws BadRequestHttpException
*/
public function beforeAction($action): bool
{ {
if ($action->id === 'error') { if ($action->id === 'error') {
$this->layout = 'error'; $this->layout = 'error';
@ -132,20 +137,20 @@ class SiteController extends Controller
return parent::beforeAction($action); return parent::beforeAction($action);
} }
public function actionGetWidgetsList() public function actionGetWidgetsList(): string
{ {
return $this->renderAjax('widgets-list'); return $this->renderAjax('widgets-list');
} }
public function actionAddWidget($itemIdx, $color = '') public function actionAddWidget($itemIdx, $color = ''): string
{ {
if (!Yii::$app->request->isAjax) { if (!Yii::$app->request->isAjax) {
throw new \RuntimeException(Yii::t('main', 'The requested page does not exist.')); throw new RuntimeException(Yii::t('main', 'The requested page does not exist.'));
} }
$widgets = UserHelper::getSetting('widgetsLayout', []); $widgets = UserHelper::getSetting('widgetsLayout', []);
$item = Yii::$app->params['dashboard_widgets'][$itemIdx]; //require($itemFile); $item = Yii::$app->params['dashboard_widgets'][$itemIdx]; //require($itemFile);
$resizable = isset($item['resizable']) ? $item['resizable'] : 0; $resizable = $item['resizable'] ?? 0;
$newWidget = [ $newWidget = [
'w' => $item['size']['width'] ?: 0, 'w' => $item['size']['width'] ?: 0,
'h' => $item['size']['height'] ?: 0, 'h' => $item['size']['height'] ?: 0,
@ -168,7 +173,7 @@ class SiteController extends Controller
public function actionRemoveWidget($idx) public function actionRemoveWidget($idx)
{ {
if (!Yii::$app->request->isAjax) { if (!Yii::$app->request->isAjax) {
throw new \RuntimeException(Yii::t('main', 'The requested page does not exist.')); throw new RuntimeException(Yii::t('main', 'The requested page does not exist.'));
} }
$widgets = UserHelper::getSetting('widgetsLayout', []); $widgets = UserHelper::getSetting('widgetsLayout', []);
array_splice($widgets, $idx, 1); array_splice($widgets, $idx, 1);
@ -184,7 +189,7 @@ class SiteController extends Controller
} }
} }
public function actionGetSelectedWidgetsList() public function actionGetSelectedWidgetsList(): string
{ {
return $this->renderAjax( 'widgets-selected-list'); return $this->renderAjax( 'widgets-selected-list');
} }

40
backend/controllers/SliderController.php

@ -5,21 +5,23 @@ namespace backend\controllers;
use core\entities\Slider; use core\entities\Slider;
use core\forms\SliderForm; use core\forms\SliderForm;
use core\services\SliderService; use core\services\SliderService;
use DomainException;
use Yii; use Yii;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\Response;
class SliderController extends Controller class SliderController extends Controller
{ {
private $_service; private SliderService $service;
public function __construct($id, $module, SliderService $service, $config = []) public function __construct($id, $module, SliderService $service, $config = [])
{ {
parent::__construct($id, $module, $config); parent::__construct($id, $module, $config);
$this->_service = $service; $this->service = $service;
} }
/** /**
@ -51,10 +53,8 @@ class SliderController extends Controller
]; ];
} }
public function actionIndex() public function actionIndex(): string
{ {
//$searchModel = new UserSearch();
//$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$query = Slider::find(); $query = Slider::find();
$dataProvider = new ActiveDataProvider([ $dataProvider = new ActiveDataProvider([
'query' => $query, 'query' => $query,
@ -79,7 +79,7 @@ class SliderController extends Controller
* @return string * @return string
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionView($id) public function actionView($id): string
{ {
return $this->render('view', [ return $this->render('view', [
'model' => $this->findModel($id), 'model' => $this->findModel($id),
@ -89,18 +89,18 @@ class SliderController extends Controller
/** /**
* Creates a new User model. * Creates a new User model.
* If creation is successful, the browser will be redirected to the 'view' page. * If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed * @return string|Response
*/ */
public function actionCreate() public function actionCreate(): Response|string
{ {
$form = new SliderForm(); $form = new SliderForm();
$form->scenario = Slider::SCENARIO_CREATE; $form->scenario = Slider::SCENARIO_CREATE;
if ($form->load(Yii::$app->request->post()) && $form->validate()) { if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try { try {
$slider = $this->_service->create($form); $slider = $this->service->create($form);
return $this->redirect(['view', 'id' => $slider->id]); return $this->redirect(['view', 'id' => $slider->id]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -114,10 +114,10 @@ class SliderController extends Controller
/** /**
* @param $id * @param $id
* *
* @return string|\yii\web\Response * @return string|Response
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionUpdate($id) public function actionUpdate($id): Response|string
{ {
$slider = $this->findModel($id); $slider = $this->findModel($id);
@ -125,10 +125,10 @@ class SliderController extends Controller
$form->scenario = Slider::SCENARIO_UPDATE; $form->scenario = Slider::SCENARIO_UPDATE;
if ($form->load(Yii::$app->request->post()) && $form->validate()) { if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try { try {
$this->_service->edit($slider->id, $form); $this->service->edit($slider->id, $form);
return $this->redirect(['view', 'id' => $slider->id]); return $this->redirect(['view', 'id' => $slider->id]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -143,16 +143,20 @@ class SliderController extends Controller
/** /**
* @param $id * @param $id
* *
* @return \yii\web\Response * @return Response
*/ */
public function actionDelete($id) public function actionDelete($id): Response
{ {
$this->_service->remove($id); $this->service->remove($id);
return $this->redirect(['index']); return $this->redirect(['index']);
} }
/**
* @param $id
* @return Slider|null
* @throws NotFoundHttpException
*/
protected function findModel($id): ?Slider protected function findModel($id): ?Slider
{ {
if (($model = Slider::findOne($id)) !== null) { if (($model = Slider::findOne($id)) !== null) {

56
backend/controllers/UserController.php

@ -6,13 +6,16 @@ use core\forms\user\ProfileEditForm;
use core\forms\user\UserForm; use core\forms\user\UserForm;
use core\services\user\ProfileService; use core\services\user\ProfileService;
use core\services\user\UserManageService; use core\services\user\UserManageService;
use DomainException;
use Yii; use Yii;
use core\entities\user\User; use core\entities\user\User;
use backend\forms\UserSearch; use backend\forms\UserSearch;
use yii\base\Exception;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\Response;
use yii\web\UploadedFile; use yii\web\UploadedFile;
/** /**
@ -20,14 +23,14 @@ use yii\web\UploadedFile;
*/ */
class UserController extends Controller class UserController extends Controller
{ {
private $_service; private UserManageService $service;
private $_profile_service; private ProfileService $profile_service;
public function __construct($id, $module, UserManageService $service, ProfileService $profile_service, $config = []) public function __construct($id, $module, UserManageService $service, ProfileService $profile_service, $config = [])
{ {
parent::__construct($id, $module, $config); parent::__construct($id, $module, $config);
$this->_service = $service; $this->service = $service;
$this->_profile_service = $profile_service; $this->profile_service = $profile_service;
} }
/** /**
@ -66,9 +69,9 @@ class UserController extends Controller
/** /**
* Lists all User models. * Lists all User models.
* @return mixed * @return string
*/ */
public function actionIndex() public function actionIndex(): string
{ {
$searchModel = new UserSearch(); $searchModel = new UserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
@ -85,7 +88,7 @@ class UserController extends Controller
* @return string * @return string
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionView($id) public function actionView($id): string
{ {
return $this->render('view', [ return $this->render('view', [
'model' => $this->findModel($id), 'model' => $this->findModel($id),
@ -95,17 +98,19 @@ class UserController extends Controller
/** /**
* Creates a new User model. * Creates a new User model.
* If creation is successful, the browser will be redirected to the 'view' page. * If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed * @return Response|string
* @throws Exception
* @throws \yii\db\Exception
*/ */
public function actionCreate() public function actionCreate(): Response|string
{ {
$form = new UserForm(); $form = new UserForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) { if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try { try {
$user = $this->_service->create($form); $user = $this->service->create($form);
return $this->redirect(['view', 'id' => $user->id]); return $this->redirect(['view', 'id' => $user->id]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -118,21 +123,22 @@ class UserController extends Controller
/** /**
* @param $id * @param $id
* * @return Response|string
* @return string|\yii\web\Response * @throws Exception
* @throws NotFoundHttpException * @throws NotFoundHttpException
* @throws \yii\db\Exception
*/ */
public function actionUpdate($id) public function actionUpdate($id): Response|string
{ {
$user = $this->findModel($id); $user = $this->findModel($id);
$form = new UserForm($user); $form = new UserForm($user);
if ($form->load(Yii::$app->request->post()) && $form->validate()) { if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try { try {
$this->_service->edit($user->id, $form); $this->service->edit($user->id, $form);
return $this->redirect(['view', 'id' => $user->id]); return $this->redirect(['view', 'id' => $user->id]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -150,16 +156,20 @@ class UserController extends Controller
* *
* @param integer $id * @param integer $id
* *
* @return mixed * @return Response
*/ */
public function actionDelete($id) public function actionDelete(int $id): Response
{ {
$this->_service->remove($id); $this->service->remove($id);
return $this->redirect(['index']); return $this->redirect(['index']);
} }
public function actionProfile() /**
* @return Response|string
* @throws NotFoundHttpException|Exception
*/
public function actionProfile(): Response|string
{ {
$user = $this->findModel(Yii::$app->user->id); $user = $this->findModel(Yii::$app->user->id);
$form = new ProfileEditForm($user); $form = new ProfileEditForm($user);
@ -167,11 +177,11 @@ class UserController extends Controller
if ($form->load(Yii::$app->request->post()) && $form->validate()) { if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try { try {
$form->user_pic = UploadedFile::getInstance($form, 'user_pic'); $form->user_pic = UploadedFile::getInstance($form, 'user_pic');
$this->_profile_service->edit(Yii::$app->user->id, $form); $this->profile_service->edit(Yii::$app->user->id, $form);
Yii::$app->session->setFlash('success', Yii::t('user', 'Profile is saved.')); Yii::$app->session->setFlash('success', Yii::t('user', 'Profile is saved.'));
return $this->redirect(['/user/profile']); return $this->redirect(['/user/profile']);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -192,7 +202,7 @@ class UserController extends Controller
* @return User the loaded model * @return User the loaded model
* @throws NotFoundHttpException if the model cannot be found * @throws NotFoundHttpException if the model cannot be found
*/ */
protected function findModel($id) protected function findModel(int $id): User
{ {
if (($model = User::findOne($id)) !== null) { if (($model = User::findOne($id)) !== null) {
return $model; return $model;

39
backend/controllers/post/CategoryController.php

@ -5,6 +5,7 @@ namespace backend\controllers\post;
use core\entities\post\PostType; use core\entities\post\PostType;
use core\forms\post\PostCategoryForm; use core\forms\post\PostCategoryForm;
use core\services\post\PostCategoryManageService; use core\services\post\PostCategoryManageService;
use DomainException;
use Yii; use Yii;
use core\entities\post\PostCategory; use core\entities\post\PostCategory;
use core\forms\post\search\PostCategorySearch; use core\forms\post\search\PostCategorySearch;
@ -12,10 +13,11 @@ use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\Response;
class CategoryController extends Controller class CategoryController extends Controller
{ {
private $service; private PostCategoryManageService $service;
public function __construct($id, $module, PostCategoryManageService $service, $config = []) public function __construct($id, $module, PostCategoryManageService $service, $config = [])
{ {
@ -27,7 +29,7 @@ class CategoryController extends Controller
{ {
return [ return [
'access' => [ 'access' => [
'class' => AccessControl::className(), 'class' => AccessControl::class,
'rules' => [ 'rules' => [
[ [
'allow' => true, 'allow' => true,
@ -40,7 +42,7 @@ class CategoryController extends Controller
], ],
], ],
'verbs' => [ 'verbs' => [
'class' => VerbFilter::className(), 'class' => VerbFilter::class,
'actions' => [ 'actions' => [
'delete' => ['POST'], 'delete' => ['POST'],
], ],
@ -54,7 +56,7 @@ class CategoryController extends Controller
* @return string * @return string
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionIndex($tid) public function actionIndex($tid): string
{ {
$type = $this->findType($tid); $type = $this->findType($tid);
@ -74,7 +76,7 @@ class CategoryController extends Controller
* @return string * @return string
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionView($id) public function actionView($id): string
{ {
$category = $this->findModel($id); $category = $this->findModel($id);
$type = $this->findType($category->type_id); $type = $this->findType($category->type_id);
@ -87,10 +89,10 @@ class CategoryController extends Controller
/** /**
* @param $tid * @param $tid
* *
* @return string|\yii\web\Response * @return string|Response
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionCreate($tid) public function actionCreate($tid): Response|string
{ {
$type = $this->findType($tid); $type = $this->findType($tid);
$form = new PostCategoryForm(); $form = new PostCategoryForm();
@ -100,7 +102,7 @@ class CategoryController extends Controller
try { try {
$category = $this->service->create($form); $category = $this->service->create($form);
return $this->redirect(['view', 'id' => $category->id]); return $this->redirect(['view', 'id' => $category->id]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -114,10 +116,10 @@ class CategoryController extends Controller
/** /**
* @param $id * @param $id
* *
* @return string|\yii\web\Response * @return string|Response
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionUpdate($id) public function actionUpdate($id): Response|string
{ {
$category = $this->findModel($id); $category = $this->findModel($id);
$type = $this->findType($category->type_id); $type = $this->findType($category->type_id);
@ -126,7 +128,7 @@ class CategoryController extends Controller
try { try {
$this->service->edit($category->id, $form); $this->service->edit($category->id, $form);
return $this->redirect(['view', 'id' => $category->id]); return $this->redirect(['view', 'id' => $category->id]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -141,16 +143,16 @@ class CategoryController extends Controller
/** /**
* @param $id * @param $id
* *
* @return \yii\web\Response * @return Response
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionDelete($id) public function actionDelete($id): Response
{ {
$category = $this->findModel($id); $category = $this->findModel($id);
$type = $this->findType($category->type_id); $type = $this->findType($category->type_id);
try { try {
$this->service->remove($id); $this->service->remove($id);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -163,7 +165,7 @@ class CategoryController extends Controller
* @return PostCategory the loaded model * @return PostCategory the loaded model
* @throws NotFoundHttpException if the model cannot be found * @throws NotFoundHttpException if the model cannot be found
*/ */
protected function findModel($id): PostCategory protected function findModel(int $id): PostCategory
{ {
if (($model = PostCategory::findOne($id)) !== null) { if (($model = PostCategory::findOne($id)) !== null) {
return $model; return $model;
@ -171,7 +173,12 @@ class CategoryController extends Controller
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
} }
protected function findType($id): PostType /**
* @param integer $id
* @return PostType
* @throws NotFoundHttpException
*/
protected function findType(int $id): PostType
{ {
if (($type = PostType::findOne($id)) !== null) { if (($type = PostType::findOne($id)) !== null) {
return $type; return $type;

40
backend/controllers/post/CommentController.php

@ -5,16 +5,18 @@ namespace backend\controllers\post;
use core\forms\post\search\PostCommentSearch; use core\forms\post\search\PostCommentSearch;
use core\forms\post\PostCommentEditForm; use core\forms\post\PostCommentEditForm;
use core\services\post\PostCommentManageService; use core\services\post\PostCommentManageService;
use DomainException;
use Yii; use Yii;
use core\entities\post\Post; use core\entities\post\Post;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\Response;
class CommentController extends Controller class CommentController extends Controller
{ {
private $service; private PostCommentManageService $service;
public function __construct($id, $module, PostCommentManageService $service, $config = []) public function __construct($id, $module, PostCommentManageService $service, $config = [])
{ {
@ -26,7 +28,7 @@ class CommentController extends Controller
{ {
return [ return [
'access' => [ 'access' => [
'class' => AccessControl::className(), 'class' => AccessControl::class,
'rules' => [ 'rules' => [
[ [
'allow' => true, 'allow' => true,
@ -39,7 +41,7 @@ class CommentController extends Controller
], ],
], ],
'verbs' => [ 'verbs' => [
'class' => VerbFilter::className(), 'class' => VerbFilter::class,
'actions' => [ 'actions' => [
'delete' => ['POST'], 'delete' => ['POST'],
], ],
@ -48,9 +50,9 @@ class CommentController extends Controller
} }
/** /**
* @return mixed * @return string
*/ */
public function actionIndex() public function actionIndex(): string
{ {
$searchModel = new PostCommentSearch(); $searchModel = new PostCommentSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
@ -65,10 +67,10 @@ class CommentController extends Controller
* @param $post_id * @param $post_id
* @param $id * @param $id
* *
* @return string|\yii\web\Response * @return string|Response
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionUpdate($post_id, $id) public function actionUpdate($post_id, $id): Response|string
{ {
$post = $this->findModel($post_id); $post = $this->findModel($post_id);
$comment = $post->getComment($id); $comment = $post->getComment($id);
@ -78,7 +80,7 @@ class CommentController extends Controller
try { try {
$this->service->edit($post->id, $comment->id, $form); $this->service->edit($post->id, $comment->id, $form);
return $this->redirect(['view', 'post_id' => $post->id, 'id' => $comment->id]); return $this->redirect(['view', 'post_id' => $post->id, 'id' => $comment->id]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -86,7 +88,7 @@ class CommentController extends Controller
return $this->render('update', [ return $this->render('update', [
'post' => $post, 'post' => $post,
'model' => $form, 'model' => $form,
'comment' => $comment, //'comment' => $comment,
]); ]);
} }
@ -97,7 +99,7 @@ class CommentController extends Controller
* @return string * @return string
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionView($post_id, $id) public function actionView($post_id, $id): string
{ {
$post = $this->findModel($post_id); $post = $this->findModel($post_id);
$comment = $post->getComment($id); $comment = $post->getComment($id);
@ -112,33 +114,33 @@ class CommentController extends Controller
* @param $post_id * @param $post_id
* @param $id * @param $id
* *
* @return \yii\web\Response * @return Response
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionActivate($post_id, $id) public function actionActivate($post_id, $id): Response
{ {
$post = $this->findModel($post_id); $post = $this->findModel($post_id);
try { try {
$this->service->activate($post->id, $id); $this->service->activate($post->id, $id);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
return $this->redirect(['view', 'post_id' => $post_id, 'id' => $id]); return $this->redirect(['view', 'post_id' => $post_id, 'id' => $id]);
} }
/** /**
* @param $post_id * @param integer $post_id
* @param $id * @param integer $id
* *
* @return \yii\web\Response * @return Response
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionDelete($post_id, $id) public function actionDelete(int $post_id, int $id): Response
{ {
$post = $this->findModel($post_id); $post = $this->findModel($post_id);
try { try {
$this->service->remove($post->id, $id); $this->service->remove($post->id, $id);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
return $this->redirect(['index']); return $this->redirect(['index']);
@ -149,7 +151,7 @@ class CommentController extends Controller
* @return Post the loaded model * @return Post the loaded model
* @throws NotFoundHttpException if the model cannot be found * @throws NotFoundHttpException if the model cannot be found
*/ */
protected function findModel($id): Post protected function findModel(int $id): Post
{ {
if (($model = Post::findOne($id)) !== null) { if (($model = Post::findOne($id)) !== null) {
return $model; return $model;

71
backend/controllers/post/PostController.php

@ -6,11 +6,11 @@ use core\entities\post\PostTag;
use core\entities\post\PostType; use core\entities\post\PostType;
use core\forms\post\PostForm; use core\forms\post\PostForm;
use core\services\post\PostManageService; use core\services\post\PostManageService;
use DomainException;
use Yii; use Yii;
use core\entities\post\Post; use core\entities\post\Post;
use core\forms\post\search\PostSearch; use core\forms\post\search\PostSearch;
use yii\helpers\ArrayHelper; use yii\base\Exception;
use yii\log\Logger;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
@ -19,7 +19,7 @@ use yii\web\Response;
class PostController extends Controller class PostController extends Controller
{ {
private $service; private PostManageService $service;
public function __construct($id, $module, PostManageService $service, $config = []) public function __construct($id, $module, PostManageService $service, $config = [])
{ {
@ -31,7 +31,7 @@ class PostController extends Controller
{ {
return [ return [
'access' => [ 'access' => [
'class' => AccessControl::className(), 'class' => AccessControl::class,
'rules' => [ 'rules' => [
[ [
'allow' => true, 'allow' => true,
@ -44,7 +44,7 @@ class PostController extends Controller
], ],
], ],
'verbs' => [ 'verbs' => [
'class' => VerbFilter::className(), 'class' => VerbFilter::class,
'actions' => [ 'actions' => [
'delete' => ['POST'], 'delete' => ['POST'],
'activate' => ['POST'], 'activate' => ['POST'],
@ -63,7 +63,7 @@ class PostController extends Controller
* @return string * @return string
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionIndex($tid) public function actionIndex($tid): string
{ {
$type = $this->findType($tid); $type = $this->findType($tid);
@ -83,7 +83,7 @@ class PostController extends Controller
* @return string * @return string
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionView($id) public function actionView($id): string
{ {
$post = $this->findModel($id); $post = $this->findModel($id);
$type = $this->findType($post->type_id); $type = $this->findType($post->type_id);
@ -93,13 +93,14 @@ class PostController extends Controller
]); ]);
} }
/** /**
* @param $tid * @param $tid
* * @return Response|string
* @return string|\yii\web\Response * @throws NotFoundHttpException
* @throws NotFoundHttpException * @throws Exception
*/ * @throws \yii\db\Exception
public function actionCreate($tid) */
public function actionCreate($tid): Response|string
{ {
$type = $this->findType($tid); $type = $this->findType($tid);
$form = new PostForm(); $form = new PostForm();
@ -109,7 +110,7 @@ class PostController extends Controller
try { try {
$post = $this->service->create($form); $post = $this->service->create($form);
return $this->redirect(['view', 'id' => $post->id, 'tid' => $post->type_id]); return $this->redirect(['view', 'id' => $post->id, 'tid' => $post->type_id]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -120,12 +121,13 @@ class PostController extends Controller
]); ]);
} }
/** /**
* @param $id * @param $id
* * @return string|Response
* @return string|\yii\web\Response * @throws Exception
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ * @throws \yii\db\Exception
*/
public function actionUpdate($id) public function actionUpdate($id)
{ {
$post = $this->findModel($id); $post = $this->findModel($id);
@ -136,7 +138,7 @@ class PostController extends Controller
try { try {
$this->service->edit($post->id, $form); $this->service->edit($post->id, $form);
return $this->redirect(['view', 'id' => $post->id, 'tid' => $post->type_id]); return $this->redirect(['view', 'id' => $post->id, 'tid' => $post->type_id]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -151,16 +153,16 @@ class PostController extends Controller
/** /**
* @param $id * @param $id
* *
* @return \yii\web\Response * @return Response
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionDelete($id) public function actionDelete($id): Response
{ {
$post = $this->findModel($id); $post = $this->findModel($id);
$type = $this->findType($post->type_id); $type = $this->findType($post->type_id);
try { try {
$this->service->remove($id); $this->service->remove($id);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
return $this->redirect(['index', 'tid' => $type->id]); return $this->redirect(['index', 'tid' => $type->id]);
@ -168,13 +170,13 @@ class PostController extends Controller
/** /**
* @param integer $id * @param integer $id
* @return mixed * @return Response
*/ */
public function actionActivate($id) public function actionActivate(int $id): Response
{ {
try { try {
$this->service->activate($id); $this->service->activate($id);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
return $this->redirect(['view', 'id' => $id]); return $this->redirect(['view', 'id' => $id]);
@ -182,13 +184,13 @@ class PostController extends Controller
/** /**
* @param integer $id * @param integer $id
* @return mixed * @return Response
*/ */
public function actionDraft($id) public function actionDraft(int $id): Response
{ {
try { try {
$this->service->draft($id); $this->service->draft($id);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
return $this->redirect(['view', 'id' => $id]); return $this->redirect(['view', 'id' => $id]);
@ -214,7 +216,7 @@ class PostController extends Controller
* @return Post the loaded model * @return Post the loaded model
* @throws NotFoundHttpException if the model cannot be found * @throws NotFoundHttpException if the model cannot be found
*/ */
protected function findModel($id): Post protected function findModel(int $id): Post
{ {
if (($model = Post::findOne($id)) !== null) { if (($model = Post::findOne($id)) !== null) {
return $model; return $model;
@ -222,6 +224,11 @@ class PostController extends Controller
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
} }
/**
* @param $id
* @return PostType
* @throws NotFoundHttpException
*/
protected function findType($id): PostType protected function findType($id): PostType
{ {
if (($type = PostType::findOne($id)) !== null) { if (($type = PostType::findOne($id)) !== null) {

37
backend/controllers/post/TagController.php

@ -5,6 +5,7 @@ namespace backend\controllers\post;
use core\entities\post\PostType; use core\entities\post\PostType;
use core\forms\post\PostTagSingleForm; use core\forms\post\PostTagSingleForm;
use core\services\post\PostTagManageService; use core\services\post\PostTagManageService;
use DomainException;
use Yii; use Yii;
use core\entities\post\PostTag; use core\entities\post\PostTag;
use core\forms\post\search\PostTagSearch; use core\forms\post\search\PostTagSearch;
@ -12,10 +13,11 @@ use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\Response;
class TagController extends Controller class TagController extends Controller
{ {
private $service; private PostTagManageService $service;
public function __construct($id, $module, PostTagManageService $service, $config = []) public function __construct($id, $module, PostTagManageService $service, $config = [])
{ {
@ -27,7 +29,7 @@ class TagController extends Controller
{ {
return [ return [
'access' => [ 'access' => [
'class' => AccessControl::className(), 'class' => AccessControl::class,
'rules' => [ 'rules' => [
[ [
'allow' => true, 'allow' => true,
@ -40,7 +42,7 @@ class TagController extends Controller
], ],
], ],
'verbs' => [ 'verbs' => [
'class' => VerbFilter::className(), 'class' => VerbFilter::class,
'actions' => [ 'actions' => [
'delete' => ['POST'], 'delete' => ['POST'],
], ],
@ -54,7 +56,7 @@ class TagController extends Controller
* @return string * @return string
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionIndex($tid) public function actionIndex($tid): string
{ {
$type = $this->findType($tid); $type = $this->findType($tid);
@ -74,7 +76,7 @@ class TagController extends Controller
* @return string * @return string
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionView($id) public function actionView($id): string
{ {
$tag = $this->findModel($id); $tag = $this->findModel($id);
$type = $this->findType($tag->type_id); $type = $this->findType($tag->type_id);
@ -87,10 +89,10 @@ class TagController extends Controller
/** /**
* @param $tid * @param $tid
* *
* @return string|\yii\web\Response * @return string|Response
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionCreate($tid) public function actionCreate($tid): Response|string
{ {
$type = $this->findType($tid); $type = $this->findType($tid);
$form = new PostTagSingleForm(); $form = new PostTagSingleForm();
@ -99,7 +101,7 @@ class TagController extends Controller
try { try {
$tag = $this->service->create($form); $tag = $this->service->create($form);
return $this->redirect(['view', 'id' => $tag->id]); return $this->redirect(['view', 'id' => $tag->id]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -113,10 +115,10 @@ class TagController extends Controller
/** /**
* @param $id * @param $id
* *
* @return string|\yii\web\Response * @return string|Response
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionUpdate($id) public function actionUpdate($id): Response|string
{ {
$tag = $this->findModel($id); $tag = $this->findModel($id);
$type = $this->findType($tag->type_id); $type = $this->findType($tag->type_id);
@ -125,7 +127,7 @@ class TagController extends Controller
try { try {
$this->service->edit($tag->id, $form); $this->service->edit($tag->id, $form);
return $this->redirect(['view', 'id' => $tag->id]); return $this->redirect(['view', 'id' => $tag->id]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -140,16 +142,16 @@ class TagController extends Controller
/** /**
* @param $id * @param $id
* *
* @return \yii\web\Response * @return Response
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionDelete($id) public function actionDelete($id): Response
{ {
$tag = $this->findModel($id); $tag = $this->findModel($id);
$type = $this->findType($tag->type_id); $type = $this->findType($tag->type_id);
try { try {
$this->service->remove($id); $this->service->remove($id);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -161,7 +163,7 @@ class TagController extends Controller
* @return PostTag the loaded model * @return PostTag the loaded model
* @throws NotFoundHttpException if the model cannot be found * @throws NotFoundHttpException if the model cannot be found
*/ */
protected function findModel($id): PostTag protected function findModel(int $id): PostTag
{ {
if (($model = PostTag::findOne($id)) !== null) { if (($model = PostTag::findOne($id)) !== null) {
return $model; return $model;
@ -169,6 +171,11 @@ class TagController extends Controller
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
} }
/**
* @param $id
* @return PostType
* @throws NotFoundHttpException
*/
protected function findType($id): PostType protected function findType($id): PostType
{ {
if (($type = PostType::findOne($id)) !== null) { if (($type = PostType::findOne($id)) !== null) {

27
backend/controllers/post/TypeController.php

@ -6,11 +6,13 @@ use core\entities\post\PostType;
use core\forms\post\PostTypeForm; use core\forms\post\PostTypeForm;
use core\forms\post\search\PostTypeSearch; use core\forms\post\search\PostTypeSearch;
use core\services\post\PostTypeService; use core\services\post\PostTypeService;
use DomainException;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\web\Controller; use yii\web\Controller;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use Yii; use Yii;
use yii\web\Response;
class TypeController extends Controller class TypeController extends Controller
{ {
@ -26,7 +28,7 @@ class TypeController extends Controller
{ {
return [ return [
'access' => [ 'access' => [
'class' => AccessControl::className(), 'class' => AccessControl::class,
'rules' => [ 'rules' => [
[ [
'allow' => true, 'allow' => true,
@ -39,7 +41,7 @@ class TypeController extends Controller
], ],
], ],
'verbs' => [ 'verbs' => [
'class' => VerbFilter::className(), 'class' => VerbFilter::class,
'actions' => [ 'actions' => [
'delete' => ['POST'], 'delete' => ['POST'],
], ],
@ -50,7 +52,7 @@ class TypeController extends Controller
/** /**
* @return string * @return string
*/ */
public function actionIndex() public function actionIndex(): string
{ {
$searchModel = new PostTypeSearch(); $searchModel = new PostTypeSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
@ -67,7 +69,7 @@ class TypeController extends Controller
* @return string * @return string
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionView($id) public function actionView($id): string
{ {
$type = $this->findModel($id); $type = $this->findModel($id);
return $this->render('view', [ return $this->render('view', [
@ -76,9 +78,9 @@ class TypeController extends Controller
} }
/** /**
* @return string|\yii\web\Response * @return string|Response
*/ */
public function actionCreate() public function actionCreate(): Response|string
{ {
$form = new PostTypeForm(); $form = new PostTypeForm();
@ -86,7 +88,7 @@ class TypeController extends Controller
try { try {
$type = $this->service->create($form); $type = $this->service->create($form);
return $this->redirect(['view', 'id' => $type->id]); return $this->redirect(['view', 'id' => $type->id]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -99,10 +101,10 @@ class TypeController extends Controller
/** /**
* @param $id * @param $id
* *
* @return string|\yii\web\Response * @return string|Response
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionUpdate($id) public function actionUpdate($id): Response|string
{ {
$type = $this->findModel($id); $type = $this->findModel($id);
@ -111,20 +113,21 @@ class TypeController extends Controller
try { try {
$this->service->edit($type->id, $form); $this->service->edit($type->id, $form);
return $this->redirect(['view', 'id' => $type->id]); return $this->redirect(['view', 'id' => $type->id]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
} }
return $this->render('update', [ return $this->render('update', [
'model' => $form, 'model' => $form,
'type' => $type,
]); ]);
} }
/** /**
* @param $id * @param $id
* *
* @return \yii\web\Response * @return Response
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionDelete($id) public function actionDelete($id)
@ -133,7 +136,7 @@ class TypeController extends Controller
try { try {
$this->service->remove($id); $this->service->remove($id);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }

52
backend/controllers/settings/ListController.php

@ -11,22 +11,25 @@ use core\entities\Settings;
use core\forms\FaviconForm; use core\forms\FaviconForm;
use core\forms\SettingsForm; use core\forms\SettingsForm;
use core\services\SettingsService; use core\services\SettingsService;
use DomainException;
use yii\db\ActiveRecord;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\web\Controller; use yii\web\Controller;
use backend\components\ToggleAction; use backend\components\ToggleAction;
use Yii; use Yii;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\web\Response;
use yii\web\UploadedFile; use yii\web\UploadedFile;
class ListController extends Controller class ListController extends Controller
{ {
private $_service; private SettingsService $service;
public function __construct(string $id, $module, SettingsService $service, array $config = []) public function __construct(string $id, $module, SettingsService $service, array $config = [])
{ {
parent::__construct($id, $module, $config); parent::__construct($id, $module, $config);
$this->_service = $service; $this->service = $service;
} }
public function behaviors() public function behaviors()
@ -61,12 +64,11 @@ class ListController extends Controller
'toggle' => [ 'toggle' => [
'class' => ToggleAction::class, 'class' => ToggleAction::class,
'modelClass' => Settings::class, 'modelClass' => Settings::class,
//'setFlash' => true,
] ]
]; ];
} }
public function actionIndex($section = 'site') public function actionIndex($section = 'site'): string
{ {
$searchModel = new SettingsSearch(); $searchModel = new SettingsSearch();
$searchModel->section = $section; $searchModel->section = $section;
@ -82,7 +84,13 @@ class ListController extends Controller
); );
} }
public function actionView($section, $key) /**
* @param $section
* @param $key
* @return string
* @throws NotFoundHttpException
*/
public function actionView($section, $key): string
{ {
return $this->render( return $this->render(
'view', 'view',
@ -92,15 +100,15 @@ class ListController extends Controller
); );
} }
public function actionCreate() public function actionCreate(): Response|string
{ {
$form = new SettingsForm(); $form = new SettingsForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) { if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try { try {
$settings = $this->_service->create($form); $settings = $this->service->create($form);
return $this->redirect(['view', 'section' => $settings->section, 'key' => $settings->key]); return $this->redirect(['view', 'section' => $settings->section, 'key' => $settings->key]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -116,17 +124,23 @@ class ListController extends Controller
); );
} }
public function actionUpdate($section, $key) /**
* @param $section
* @param $key
* @return Response|string
* @throws NotFoundHttpException
*/
public function actionUpdate($section, $key): Response|string
{ {
$settings = $this->findModel($section, $key); $settings = $this->findModel($section, $key);
$form = new SettingsForm($settings); $form = new SettingsForm($settings);
if ($form->load(Yii::$app->request->post()) && $form->validate()) { if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try { try {
$this->_service->edit($settings->section, $settings->key, $form); $this->service->edit($settings->section, $settings->key, $form);
return $this->redirect(['view', 'section' => $settings->section, 'key' => $settings->key]); return $this->redirect(['view', 'section' => $settings->section, 'key' => $settings->key]);
} catch (\DomainException $e) { } catch (DomainException $e) {
Yii::$app->errorHandler->logException($e); Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
@ -141,14 +155,14 @@ class ListController extends Controller
); );
} }
public function actionDelete($section, $key) public function actionDelete($section, $key): Response
{ {
$this->_service->remove($section, $key); $this->service->remove($section, $key);
return $this->redirect(['index']); return $this->redirect(['index']);
} }
public function actionFavicon() public function actionFavicon(): Response|string
{ {
$form = new FaviconForm(); $form = new FaviconForm();
if ($form->load(Yii::$app->request->post())) { if ($form->load(Yii::$app->request->post())) {
@ -159,7 +173,7 @@ class ListController extends Controller
} }
$form->image->saveAs(Yii::getAlias('@staticRoot') . '/origin/favicon/favicon.png'); $form->image->saveAs(Yii::getAlias('@staticRoot') . '/origin/favicon/favicon.png');
$this->_service->newFavicon(); $this->service->newFavicon();
Yii::$app->session->setFlash('success', Yii::t('main', 'Favicon generation complete')); Yii::$app->session->setFlash('success', Yii::t('main', 'Favicon generation complete'));
return $this->redirect(['settings/list/index']); return $this->redirect(['settings/list/index']);
} }
@ -173,7 +187,13 @@ class ListController extends Controller
); );
} }
protected function findModel($section, $key) /**
* @param $section
* @param $key
* @return array|Settings|ActiveRecord|null
* @throws NotFoundHttpException
*/
protected function findModel($section, $key): array|Settings|ActiveRecord|null
{ {
if (($model = Settings::find()->andWhere(['section' => $section])->andWhere(['key' => $key])->one()) !== null) { if (($model = Settings::find()->andWhere(['section' => $section])->andWhere(['key' => $key])->one()) !== null) {
return $model; return $model;

18
backend/forms/SettingsSearch.php

@ -12,14 +12,14 @@ use yii\data\ActiveDataProvider;
class SettingsSearch extends Settings class SettingsSearch extends Settings
{ {
public $id; public ?int $id = null;
public $type; public ?int $type = null;
public $section; public ?string $section = null;
public $key; public ?string $key = null;
public $value; public ?string $value = null;
public $active; public ?int $active = null;
public function rules() public function rules(): array
{ {
return [ return [
[['id'], 'integer'], [['id'], 'integer'],
@ -31,7 +31,7 @@ class SettingsSearch extends Settings
/** /**
* @return array * @return array
*/ */
public function scenarios() public function scenarios(): array
{ {
// bypass scenarios() implementation in the parent class // bypass scenarios() implementation in the parent class
return Model::scenarios(); return Model::scenarios();
@ -42,7 +42,7 @@ class SettingsSearch extends Settings
* *
* @return ActiveDataProvider * @return ActiveDataProvider
*/ */
public function search($params) public function search($params): ActiveDataProvider
{ {
$query = Settings::find(); $query = Settings::find();
$dataProvider = new ActiveDataProvider( $dataProvider = new ActiveDataProvider(

19
backend/forms/UserSearch.php

@ -2,6 +2,7 @@
namespace backend\forms; namespace backend\forms;
use Yii;
use yii\base\Model; use yii\base\Model;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use core\entities\user\User; use core\entities\user\User;
@ -9,15 +10,15 @@ use yii\helpers\ArrayHelper;
class UserSearch extends Model class UserSearch extends Model
{ {
public $id; public ?int $id = null;
public $date_from; public ?string $date_from = null;
public $date_to; public ?string $date_to = null;
public $username; public ?string $username = null;
public $email; public ?string $email = null;
public $status; public ?int $status = null;
public $role; public ?string $role = null;
public function rules() public function rules(): array
{ {
return [ return [
[['id', 'status'], 'integer'], [['id', 'status'], 'integer'],
@ -66,6 +67,6 @@ class UserSearch extends Model
public function rolesList(): array public function rolesList(): array
{ {
return ArrayHelper::map(\Yii::$app->authManager->getRoles(), 'name', 'description'); return ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description');
} }
} }

14
backend/forms/rbac/RbacCreatePermissionForm.php

@ -11,14 +11,14 @@ use Yii;
class RbacCreatePermissionForm extends Model class RbacCreatePermissionForm extends Model
{ {
public $name; public ?string $name = null;
public $description; public ?string $description = null;
public $rule_name; public ?string $rule_name = null;
public $data; public ?string $data = null;
public $created_at; public ?int $created_at = null;
public $updated_at; public ?int $updated_at = null;
public function rules() public function rules(): array
{ {
return [ return [
[['name'], 'required'], [['name'], 'required'],

14
backend/forms/rbac/RbacCreateRoleForm.php

@ -11,14 +11,14 @@ use Yii;
class RbacCreateRoleForm extends Model class RbacCreateRoleForm extends Model
{ {
public $name; public ?string $name = null;
public $description; public ?string $description = null;
public $rule_name; public ?string $rule_name = null;
public $data; public ?string $data = null;
public $created_at; public ?int $created_at = null;
public $updated_at; public ?int $updated_at = null;
public function rules() public function rules(): array
{ {
return [ return [
[['name'], 'required'], [['name'], 'required'],

15
backend/forms/rbac/RbacEditPermissionForm.php

@ -12,13 +12,12 @@ use Yii;
class RbacEditPermissionForm extends Model class RbacEditPermissionForm extends Model
{ {
public $name; public ?string $name = null;
public $description; public ?string $description = null;
public $rule_name; public ?string $rule_name = null;
public $data; public ?string $data = null;
public $created_at; public ?int $created_at = null;
public $updated_at; public ?int $updated_at = null;
public function __construct(Permission $permission, $config = []) public function __construct(Permission $permission, $config = [])
{ {
@ -29,7 +28,7 @@ class RbacEditPermissionForm extends Model
parent::__construct($config); parent::__construct($config);
} }
public function rules() public function rules(): array
{ {
return [ return [
[['name'], 'required'], [['name'], 'required'],

15
backend/forms/rbac/RbacEditRoleForm.php

@ -12,13 +12,12 @@ use Yii;
class RbacEditRoleForm extends Model class RbacEditRoleForm extends Model
{ {
public $name; public ?string $name = null;
public $description; public ?string $description = null;
public $rule_name; public ?string $rule_name = null;
public $data; public ?string $data = null;
public $created_at; public ?int $created_at = null;
public $updated_at; public ?int $updated_at = null;
public function __construct(Role $role, $config = []) public function __construct(Role $role, $config = [])
{ {
@ -29,7 +28,7 @@ class RbacEditRoleForm extends Model
parent::__construct($config); parent::__construct($config);
} }
public function rules() public function rules(): array
{ {
return [ return [
[['name'], 'required'], [['name'], 'required'],

6
backend/forms/rbac/RbacUpdateChildren.php

@ -10,10 +10,10 @@ use yii\base\Model;
class RbacUpdateChildren extends Model class RbacUpdateChildren extends Model
{ {
public $roles; public ?array $roles = null;
public $permissions; public ?array $permissions = null;
public function rules() public function rules(): array
{ {
return [ return [
[['roles', 'permissions'], 'each', 'rule' => ['string']], [['roles', 'permissions'], 'each', 'rule' => ['string']],

13
backend/helpers/DashboardHelper.php

@ -11,7 +11,7 @@ use yii\helpers\Html;
class DashboardHelper class DashboardHelper
{ {
public static function getAllWidgets() public static function getAllWidgets(): array
{ {
$widgetsCounter = ''; // Counters Widgets $widgetsCounter = ''; // Counters Widgets
$widgetsInfo = ''; // Information Widgets $widgetsInfo = ''; // Information Widgets
@ -20,15 +20,7 @@ class DashboardHelper
$path = Yii::getAlias('@backend/widgets/dashboard'); $path = Yii::getAlias('@backend/widgets/dashboard');
$files = scandir($path, 0); $files = scandir($path, 0);
//foreach ($files as $file) {
foreach (Yii::$app->params['dashboard_widgets'] as $idx => $item) { foreach (Yii::$app->params['dashboard_widgets'] as $idx => $item) {
//if (!is_file($path . '/' . $file)) {
// continue;
//}
//$itemFile = $path . '/' . $file;
//$item = require($itemFile);
if (isset($item['rule']) && (Yii::$app->user->can($item['rule']) || Yii::$app->user->can('admin'))) { if (isset($item['rule']) && (Yii::$app->user->can($item['rule']) || Yii::$app->user->can('admin'))) {
} elseif (!isset($item['rule'])) { } elseif (!isset($item['rule'])) {
} else { } else {
@ -47,11 +39,10 @@ class DashboardHelper
$widgetsInfo .= $line; $widgetsInfo .= $line;
} }
} }
return [$widgetsCounter, $widgetsInfo]; return [$widgetsCounter, $widgetsInfo];
} }
public static function getExtColors() public static function getExtColors(): array
{ {
return [ return [
'gray' => Yii::t('main', 'Gray'), 'gray' => Yii::t('main', 'Gray'),

1
backend/messages/ru/menu.php

@ -29,4 +29,5 @@ return [
'Title attribute' => 'Аттрибут Title', 'Title attribute' => 'Аттрибут Title',
'CSS Classes' => 'Классы CSS', 'CSS Classes' => 'Классы CSS',
'CSS Style' => 'Стиль CSS', 'CSS Style' => 'Стиль CSS',
'Url' => 'Ссылка',
]; ];

8
backend/views/auth/login.php

@ -1,11 +1,12 @@
<?php <?php
use common\widgets\Alert; use common\widgets\Alert;
use core\forms\auth\LoginForm;
use yii\helpers\Html; use yii\helpers\Html;
use yii\bootstrap\ActiveForm; use yii\bootstrap\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */ /* @var $form yii\bootstrap\ActiveForm */
/* @var $model \core\forms\auth\LoginForm */ /* @var $model LoginForm */
$this->title = Yii::t('main', 'Sign in'); $this->title = Yii::t('main', 'Sign in');
@ -34,7 +35,10 @@ $fieldOptions2 = [
<?= Alert::widget() ?> <?= Alert::widget() ?>
<?php $form = ActiveForm::begin(['id' => 'login-form', 'enableClientValidation' => false]); ?> <?php $form = ActiveForm::begin([
'id' => 'login-form',
'enableClientValidation' => false
]); ?>
<?= $form <?= $form
->field($model, 'username', $fieldOptions1) ->field($model, 'username', $fieldOptions1)

238
backend/views/layouts/content-origin.php

@ -0,0 +1,238 @@
<?php
use yii\helpers\Html;
use yii\helpers\Inflector;
use yii\widgets\Breadcrumbs;
use dmstr\widgets\Alert;
?>
<div class="content-wrapper">
<section class="content-header">
<?php if (isset($this->blocks['content-header'])) { ?>
<h1><?= $this->blocks['content-header'] ?></h1>
<?php } else { ?>
<h1>
<?php
if ($this->title !== null) {
echo Html::encode($this->title);
} else {
echo Inflector::camel2words(
Inflector::id2camel($this->context->module->id)
);
echo ($this->context->module->id !== \Yii::$app->id) ? '<small>Module</small>' : '';
} ?>
</h1>
<?php } ?>
<?=
Breadcrumbs::widget(
[
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]
) ?>
</section>
<section class="content">
<?= Alert::widget() ?>
<?= $content ?>
</section>
</div>
<footer class="main-footer">
<div class="pull-right hidden-xs">
<b>Version</b> 2.0
</div>
<strong>Copyright &copy; 2017 - <?= date('Y') ?> <a href="http://zertex.ru">Zertex</a>, Dashboard by <a href="http://almsaeedstudio.com">Almsaeed Studio</a>.</strong> All rights
reserved.
</footer>
<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
<!-- Create the tabs -->
<ul class="nav nav-tabs nav-justified control-sidebar-tabs">
<li><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
<li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<!-- Home tab content -->
<div class="tab-pane" id="control-sidebar-home-tab">
<h3 class="control-sidebar-heading">Recent Activity</h3>
<ul class='control-sidebar-menu'>
<li>
<a href='javascript::;'>
<i class="menu-icon fa fa-birthday-cake bg-red"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Langdon's Birthday</h4>
<p>Will be 23 on April 24th</p>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<i class="menu-icon fa fa-user bg-yellow"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Frodo Updated His Profile</h4>
<p>New phone +1(800)555-1234</p>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<i class="menu-icon fa fa-envelope-o bg-light-blue"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Nora Joined Mailing List</h4>
<p>nora@example.com</p>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<i class="menu-icon fa fa-file-code-o bg-green"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Cron Job 254 Executed</h4>
<p>Execution time 5 seconds</p>
</div>
</a>
</li>
</ul>
<!-- /.control-sidebar-menu -->
<h3 class="control-sidebar-heading">Tasks Progress</h3>
<ul class='control-sidebar-menu'>
<li>
<a href='javascript::;'>
<h4 class="control-sidebar-subheading">
Custom Template Design
<span class="label label-danger pull-right">70%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-danger" style="width: 70%"></div>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<h4 class="control-sidebar-subheading">
Update Resume
<span class="label label-success pull-right">95%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-success" style="width: 95%"></div>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<h4 class="control-sidebar-subheading">
Laravel Integration
<span class="label label-waring pull-right">50%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-warning" style="width: 50%"></div>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<h4 class="control-sidebar-subheading">
Back End Framework
<span class="label label-primary pull-right">68%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-primary" style="width: 68%"></div>
</div>
</a>
</li>
</ul>
<!-- /.control-sidebar-menu -->
</div>
<!-- /.tab-pane -->
<!-- Settings tab content -->
<div class="tab-pane" id="control-sidebar-settings-tab">
<form method="post">
<h3 class="control-sidebar-heading">General Settings</h3>
<div class="form-group">
<label class="control-sidebar-subheading">
Report panel usage
<input type="checkbox" class="pull-right" checked/>
</label>
<p>
Some information about this general settings option
</p>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Allow mail redirect
<input type="checkbox" class="pull-right" checked/>
</label>
<p>
Other sets of options are available
</p>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Expose author name in posts
<input type="checkbox" class="pull-right" checked/>
</label>
<p>
Allow the user to show his name in blog posts
</p>
</div>
<!-- /.form-group -->
<h3 class="control-sidebar-heading">Chat Settings</h3>
<div class="form-group">
<label class="control-sidebar-subheading">
Show me as online
<input type="checkbox" class="pull-right" checked/>
</label>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Turn off notifications
<input type="checkbox" class="pull-right"/>
</label>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Delete chat history
<a href="javascript::;" class="text-red pull-right"><i class="fa fa-trash-o"></i></a>
</label>
</div>
<!-- /.form-group -->
</form>
</div>
<!-- /.tab-pane -->
</div>
</aside><!-- /.control-sidebar -->
<!-- Add the sidebar's background. This div must be placed
immediately after the control sidebar -->
<div class='control-sidebar-bg'></div>

289
backend/views/layouts/content.php

@ -1,235 +1,64 @@
<?php <?php
use yii\widgets\Breadcrumbs;
use dmstr\widgets\Alert;
?> use core\components\adminlte3\widgets\Breadcrumbs;
<div class="content-wrapper"> use core\components\adminlte3\widgets\ToastrNotification;
<section class="content-header"> use yii\web\View;
<?php if (isset($this->blocks['content-header'])) { ?> use yii\helpers\Html;
<h1><?= $this->blocks['content-header'] ?></h1> use yii\helpers\Inflector;
<?php } else { ?>
<h1>
<?php
if ($this->title !== null) {
echo \yii\helpers\Html::encode($this->title);
} else {
echo \yii\helpers\Inflector::camel2words(
\yii\helpers\Inflector::id2camel($this->context->module->id)
);
echo ($this->context->module->id !== \Yii::$app->id) ? '<small>Module</small>' : '';
} ?>
</h1>
<?php } ?>
<?= /**
Breadcrumbs::widget( * @var $this View
[ * @var $content string
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], */
]
) ?>
</section>
<section class="content"> ?>
<?= Alert::widget() ?> <div class="content-wrapper">
<?= $content ?> <!-- Content Header (Page header) -->
</section> <div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<?php if (isset($this->blocks['content-header'])) : ?>
<h4 class="m-0 text-dark"><?= $this->blocks['content-header'] ?></h4>
<?php else: ?>
<h4 class="m-0 text-dark">
<?php
if ($this->title !== null) {
echo Html::encode($this->title);
} else {
echo Inflector::camel2words(
Inflector::id2camel($this->context->module->id)
);
echo ($this->context->module->id !== \Yii::$app->id) ? '<small>Module</small>' : '';
} ?>
</h4>
<?php endif; ?>
</div><!-- /.col -->
<div class="col-sm-6">
<?=
Breadcrumbs::widget([
'links' => $this->params['breadcrumbs'] ?? [],
]) ?>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<!-- Main content -->
<div class="content">
<div class="container-fluid">
<section class="content">
<?= ToastrNotification::widget() ?>
<?= $content ?>
</section>
</div>
<!-- /.container-fluid -->
</div>
<!-- /.content -->
</div> </div>
<footer class="main-footer">
<div class="pull-right hidden-xs">
<b>Version</b> 2.0
</div>
<strong>Copyright &copy; 2017 - <?= date('Y') ?> <a href="http://zertex.ru">Zertex</a>, Dashboard by <a href="http://almsaeedstudio.com">Almsaeed Studio</a>.</strong> All rights
reserved.
</footer>
<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
<!-- Create the tabs -->
<ul class="nav nav-tabs nav-justified control-sidebar-tabs">
<li><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
<li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<!-- Home tab content -->
<div class="tab-pane" id="control-sidebar-home-tab">
<h3 class="control-sidebar-heading">Recent Activity</h3>
<ul class='control-sidebar-menu'>
<li>
<a href='javascript::;'>
<i class="menu-icon fa fa-birthday-cake bg-red"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Langdon's Birthday</h4>
<p>Will be 23 on April 24th</p>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<i class="menu-icon fa fa-user bg-yellow"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Frodo Updated His Profile</h4>
<p>New phone +1(800)555-1234</p>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<i class="menu-icon fa fa-envelope-o bg-light-blue"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Nora Joined Mailing List</h4>
<p>nora@example.com</p>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<i class="menu-icon fa fa-file-code-o bg-green"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Cron Job 254 Executed</h4>
<p>Execution time 5 seconds</p>
</div>
</a>
</li>
</ul>
<!-- /.control-sidebar-menu -->
<h3 class="control-sidebar-heading">Tasks Progress</h3>
<ul class='control-sidebar-menu'>
<li>
<a href='javascript::;'>
<h4 class="control-sidebar-subheading">
Custom Template Design
<span class="label label-danger pull-right">70%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-danger" style="width: 70%"></div>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<h4 class="control-sidebar-subheading">
Update Resume
<span class="label label-success pull-right">95%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-success" style="width: 95%"></div>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<h4 class="control-sidebar-subheading">
Laravel Integration
<span class="label label-waring pull-right">50%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-warning" style="width: 50%"></div>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<h4 class="control-sidebar-subheading">
Back End Framework
<span class="label label-primary pull-right">68%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-primary" style="width: 68%"></div>
</div>
</a>
</li>
</ul>
<!-- /.control-sidebar-menu -->
</div>
<!-- /.tab-pane -->
<!-- Settings tab content -->
<div class="tab-pane" id="control-sidebar-settings-tab">
<form method="post">
<h3 class="control-sidebar-heading">General Settings</h3>
<div class="form-group">
<label class="control-sidebar-subheading">
Report panel usage
<input type="checkbox" class="pull-right" checked/>
</label>
<p>
Some information about this general settings option
</p>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Allow mail redirect
<input type="checkbox" class="pull-right" checked/>
</label>
<p>
Other sets of options are available
</p>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Expose author name in posts
<input type="checkbox" class="pull-right" checked/>
</label>
<p>
Allow the user to show his name in blog posts
</p>
</div>
<!-- /.form-group -->
<h3 class="control-sidebar-heading">Chat Settings</h3>
<div class="form-group">
<label class="control-sidebar-subheading">
Show me as online
<input type="checkbox" class="pull-right" checked/>
</label>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Turn off notifications
<input type="checkbox" class="pull-right"/>
</label>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Delete chat history
<a href="javascript::;" class="text-red pull-right"><i class="fa fa-trash-o"></i></a>
</label>
</div>
<!-- /.form-group -->
</form>
</div>
<!-- /.tab-pane -->
</div>
</aside><!-- /.control-sidebar -->
<!-- Add the sidebar's background. This div must be placed
immediately after the control sidebar -->
<div class='control-sidebar-bg'></div>

33
backend/views/layouts/error-origin.php

@ -0,0 +1,33 @@
<?php
use backend\assets\AdminLteSkinAsset;
use backend\assets\AppAsset;
use yii\helpers\Html;
use yii\web\View;
/* @var $this View */
/* @var $content string */
dmstr\web\AdminLteAsset::register($this);
AdminLteSkinAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<?= $content ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

11
backend/views/layouts/error.php

@ -1,12 +1,17 @@
<?php <?php
use core\components\adminlte3\AdminLteAsset;
use core\components\adminlte3\AdminLteFontsAsset;
use backend\assets\AppAsset; use backend\assets\AppAsset;
use yii\helpers\Html; use yii\helpers\Html;
use yii\web\View;
/* @var $this \yii\web\View */ /* @var $this View */
/* @var $content string */ /* @var $content string */
dmstr\web\AdminLteAsset::register($this); AppAsset::register($this);
\backend\assets\AdminLteSkinAsset::register($this); AdminLteAsset::register($this);
AdminLteFontsAsset::register($this);
?> ?>
<?php $this->beginPage() ?> <?php $this->beginPage() ?>
<!DOCTYPE html> <!DOCTYPE html>

265
backend/views/layouts/header-origin.php

@ -0,0 +1,265 @@
<?php
use backend\widgets\NotificationCountWidget;
use core\helpers\LanguageHelper;
use yii\helpers\Html;
use yii\web\View;
/* @var $this View */
/* @var $content string */
?>
<header class="main-header">
<?= Html::a('<span class="logo-mini">' . (Yii::$app->params['settings']['site']['short_name'] ?? 'APP') . '</span><span class="logo-lg">' . (isset(Yii::$app->params['settings']['site']['name']) ? Yii::$app->params['settings']['site']['name'] : Yii::$app->name) . '</span>',
Yii::$app->homeUrl, ['class' => 'logo']) ?>
<nav class="navbar navbar-static-top" role="navigation">
<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
<span class="sr-only">Toggle navigation</span>
</a>
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<!-- Messages: style can be found in dropdown.less-->
<!--
<li class="dropdown messages-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-envelope-o"></i>
<span class="label label-success">4</span>
</a>
<ul class="dropdown-menu">
<li class="header">You have 4 messages</li>
<li>
<ul class="menu">
<li>
<a href="#">
<div class="pull-left">
<img src="< ?= $directoryAsset ?>/img/user2-160x160.jpg" class="img-circle"
alt="User Image"/>
</div>
<h4>
Support Team
<small><i class="fa fa-clock-o"></i> 5 mins</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
<li>
<a href="#">
<div class="pull-left">
<img src="< ?= $directoryAsset ?>/img/user3-128x128.jpg" class="img-circle"
alt="user image"/>
</div>
<h4>
AdminLTE Design Team
<small><i class="fa fa-clock-o"></i> 2 hours</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
<li>
<a href="#">
<div class="pull-left">
<img src="< ?= $directoryAsset ?>/img/user4-128x128.jpg" class="img-circle"
alt="user image"/>
</div>
<h4>
Developers
<small><i class="fa fa-clock-o"></i> Today</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
<li>
<a href="#">
<div class="pull-left">
<img src="< ?= $directoryAsset ?>/img/user3-128x128.jpg" class="img-circle"
alt="user image"/>
</div>
<h4>
Sales Department
<small><i class="fa fa-clock-o"></i> Yesterday</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
<li>
<a href="#">
<div class="pull-left">
<img src="< ?= $directoryAsset ?>/img/user4-128x128.jpg" class="img-circle"
alt="user image"/>
</div>
<h4>
Reviewers
<small><i class="fa fa-clock-o"></i> 2 days</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
</ul>
</li>
<li class="footer"><a href="#">See All Messages</a></li>
</ul>
</li>
-->
<?= NotificationCountWidget::widget() ?>
<!-- Tasks: style can be found in dropdown.less -->
<!--
<li class="dropdown tasks-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-flag-o"></i>
<span class="label label-danger">9</span>
</a>
<ul class="dropdown-menu">
<li class="header">You have 9 tasks</li>
<li>
<ul class="menu">
<li>
<a href="#">
<h3>
Design some buttons
<small class="pull-right">20%</small>
</h3>
<div class="progress xs">
<div class="progress-bar progress-bar-aqua" style="width: 20%"
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">20% Complete</span>
</div>
</div>
</a>
</li>
<li>
<a href="#">
<h3>
Create a nice theme
<small class="pull-right">40%</small>
</h3>
<div class="progress xs">
<div class="progress-bar progress-bar-green" style="width: 40%"
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">40% Complete</span>
</div>
</div>
</a>
</li>
<li>
<a href="#">
<h3>
Some task I need to do
<small class="pull-right">60%</small>
</h3>
<div class="progress xs">
<div class="progress-bar progress-bar-red" style="width: 60%"
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">60% Complete</span>
</div>
</div>
</a>
</li>
<li>
<a href="#">
<h3>
Make beautiful transitions
<small class="pull-right">80%</small>
</h3>
<div class="progress xs">
<div class="progress-bar progress-bar-yellow" style="width: 80%"
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">80% Complete</span>
</div>
</div>
</a>
</li>
</ul>
</li>
<li class="footer">
<a href="#">View all tasks</a>
</li>
</ul>
</li>
-->
<!-- Language Drop Down -->
<li class="dropdown messages-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<!-- <i class="fa fa-language"></i> -->
<span><?= LanguageHelper::getBackendName(Yii::$app->user->identity->user->backend_language) ?>
<i class="caret"></i></span>
</a>
<ul class="dropdown-menu">
<li class="header"><?= Yii::t('main', 'Interface Language') ?></li>
<li>
<!-- inner menu: contains the actual data -->
<ul class="menu">
<?php foreach (Yii::$app->params['backendTranslatedLanguages'] as $language => $language_name): ?>
<li>
<?= Html::a($language_name, ['/site/language', 'language' => $language], [
'data-method' => 'post'
]) ?>
</li>
<?php endforeach; ?>
</ul>
</li>
</ul>
</li>
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="<?= Yii::$app->avatar->show(Yii::$app->user->identity->user->username) ?>"
class="user-image" alt="<?= Yii::$app->user->identity->user->username ?>"/>
<span class="hidden-xs"><?= Yii::$app->user->identity->user->username ?></span>
</a>
<ul class="dropdown-menu">
<!-- User image -->
<li class="user-header">
<img src="<?= Yii::$app->avatar->show(Yii::$app->user->identity->user->username) ?>"
class="img-circle"
alt="<?= Yii::$app->user->identity->user->username ?>"/>
<p>
<?= Yii::$app->user->identity->user->username ?>
<small><?= Yii::t('user', 'Registered: {date}', [
'date' => date('d.m.Y', Yii::$app->user->identity->user->created_at)
]) ?></small>
</p>
</li>
<!-- Menu Footer-->
<li class="user-footer">
<div class="pull-left">
<?= Html::a(
Yii::t('user', 'Profile'),
['/user/profile'],
['class' => 'btn btn-default btn-flat']
)
?>
</div>
<div class="pull-right">
<?= Html::a(
Yii::t('main', 'Sign out'),
['/auth/logout'],
['data-method' => 'post', 'class' => 'btn btn-default btn-flat']
) ?>
</div>
</li>
</ul>
</li>
</ul>
</div>
</nav>
</header>

306
backend/views/layouts/header.php

@ -1,264 +1,56 @@
<?php <?php
use yii\helpers\Html; use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\JsExpression;
use yii\web\View;
use kartik\select2\Select2;
/* @var $this \yii\web\View */ /* @var $this View */
/* @var $content string */ /* @var $content string */
//$avatar = new AvatarGenerator();
?> ?>
<header class="main-header"> <nav class="main-header navbar navbar-expand navbar-white navbar-light">
<!-- Left navbar links -->
<?= Html::a('<span class="logo-mini">' . (isset(Yii::$app->params['settings']['site']['short_name']) ? Yii::$app->params['settings']['site']['short_name'] : 'APP') . '</span><span class="logo-lg">' . (isset(Yii::$app->params['settings']['site']['name']) ? Yii::$app->params['settings']['site']['name'] : Yii::$app->name) . '</span>', <ul class="navbar-nav">
Yii::$app->homeUrl, ['class' => 'logo']) ?> <li class="nav-item">
<a class="nav-link" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a>
<nav class="navbar navbar-static-top" role="navigation"> </li>
<!-- <li class="nav-item d-none d-sm-inline-block">
<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button"> <?= Html::a(Yii::t('links', 'Plans'), ['/links/link/plans'], [
<span class="sr-only">Toggle navigation</span> 'class' => 'nav-link',
</a> ]) ?>
</li> -->
<div class="navbar-custom-menu"> </ul>
<ul class="nav navbar-nav"> <!-- Right navbar links -->
<ul class="navbar-nav ml-auto">
<!-- Messages: style can be found in dropdown.less-->
<!-- <!-- < ?= NotifyContactWidget::widget() ?>
<li class="dropdown messages-menu"> < ?= NotifyOrderWidget::widget() ?>
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> < ?= NotifyReviewWidget::widget() ?> -->
<i class="fa fa-envelope-o"></i>
<span class="label label-success">4</span> <!-- User Menu -->
</a> <li class="nav-item dropdown">
<ul class="dropdown-menu"> <a class="nav-link" data-toggle="dropdown" href="#">
<li class="header">You have 4 messages</li> <i class="far fa-user"></i>
<li> </a>
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
<ul class="menu">
<li> <?= Html::a(
<a href="#"> '<i class="fas fa-user fa-fw"></i> ' . Yii::t('user', 'Profile'),
<div class="pull-left"> ['/user/profile'],
<img src="< ?= $directoryAsset ?>/img/user2-160x160.jpg" class="img-circle" ['class' => 'dropdown-item']
alt="User Image"/> ) ?>
</div> <div class="dropdown-divider"></div>
<h4> <?= Html::a(
Support Team '<i class="fas fa-sign-out-alt fa-fw"></i> ' . Yii::t('user', 'Sign out'),
<small><i class="fa fa-clock-o"></i> 5 mins</small> ['/auth/auth/logout'],
</h4> ['data-method' => 'post', 'class' => 'dropdown-item']
<p>Why not buy a new awesome theme?</p> ) ?>
</a>
</li> </div>
</li>
<li>
<a href="#"> </ul>
<div class="pull-left"> </nav>
<img src="< ?= $directoryAsset ?>/img/user3-128x128.jpg" class="img-circle"
alt="user image"/>
</div>
<h4>
AdminLTE Design Team
<small><i class="fa fa-clock-o"></i> 2 hours</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
<li>
<a href="#">
<div class="pull-left">
<img src="< ?= $directoryAsset ?>/img/user4-128x128.jpg" class="img-circle"
alt="user image"/>
</div>
<h4>
Developers
<small><i class="fa fa-clock-o"></i> Today</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
<li>
<a href="#">
<div class="pull-left">
<img src="< ?= $directoryAsset ?>/img/user3-128x128.jpg" class="img-circle"
alt="user image"/>
</div>
<h4>
Sales Department
<small><i class="fa fa-clock-o"></i> Yesterday</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
<li>
<a href="#">
<div class="pull-left">
<img src="< ?= $directoryAsset ?>/img/user4-128x128.jpg" class="img-circle"
alt="user image"/>
</div>
<h4>
Reviewers
<small><i class="fa fa-clock-o"></i> 2 days</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
</ul>
</li>
<li class="footer"><a href="#">See All Messages</a></li>
</ul>
</li>
-->
<?= \backend\widgets\NotificationCountWidget::widget() ?>
<!-- Tasks: style can be found in dropdown.less -->
<!--
<li class="dropdown tasks-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-flag-o"></i>
<span class="label label-danger">9</span>
</a>
<ul class="dropdown-menu">
<li class="header">You have 9 tasks</li>
<li>
<ul class="menu">
<li>
<a href="#">
<h3>
Design some buttons
<small class="pull-right">20%</small>
</h3>
<div class="progress xs">
<div class="progress-bar progress-bar-aqua" style="width: 20%"
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">20% Complete</span>
</div>
</div>
</a>
</li>
<li>
<a href="#">
<h3>
Create a nice theme
<small class="pull-right">40%</small>
</h3>
<div class="progress xs">
<div class="progress-bar progress-bar-green" style="width: 40%"
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">40% Complete</span>
</div>
</div>
</a>
</li>
<li>
<a href="#">
<h3>
Some task I need to do
<small class="pull-right">60%</small>
</h3>
<div class="progress xs">
<div class="progress-bar progress-bar-red" style="width: 60%"
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">60% Complete</span>
</div>
</div>
</a>
</li>
<li>
<a href="#">
<h3>
Make beautiful transitions
<small class="pull-right">80%</small>
</h3>
<div class="progress xs">
<div class="progress-bar progress-bar-yellow" style="width: 80%"
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">80% Complete</span>
</div>
</div>
</a>
</li>
</ul>
</li>
<li class="footer">
<a href="#">View all tasks</a>
</li>
</ul>
</li>
-->
<!-- Language Drop Down -->
<li class="dropdown messages-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<!-- <i class="fa fa-language"></i> -->
<span><?= \core\helpers\LanguageHelper::getBackendName(Yii::$app->user->identity->user->backend_language) ?>
<i class="caret"></i></span>
</a>
<ul class="dropdown-menu">
<li class="header"><?= Yii::t('main', 'Interface Language') ?></li>
<li>
<!-- inner menu: contains the actual data -->
<ul class="menu">
<?php foreach (Yii::$app->params['backendTranslatedLanguages'] as $language => $language_name): ?>
<li>
<?= Html::a($language_name, ['/site/language', 'language' => $language], [
'data-method' => 'post'
]) ?>
</li>
<?php endforeach; ?>
</ul>
</li>
</ul>
</li>
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="<?= Yii::$app->avatar->show(Yii::$app->user->identity->user->username) ?>"
class="user-image" alt="<?= Yii::$app->user->identity->user->username ?>"/>
<span class="hidden-xs"><?= Yii::$app->user->identity->user->username ?></span>
</a>
<ul class="dropdown-menu">
<!-- User image -->
<li class="user-header">
<img src="<?= Yii::$app->avatar->show(Yii::$app->user->identity->user->username) ?>"
class="img-circle"
alt="<?= Yii::$app->user->identity->user->username ?>"/>
<p>
<?= Yii::$app->user->identity->user->username ?>
<small><?= Yii::t('user', 'Registered: {date}', [
'date' => date('d.m.Y', Yii::$app->user->identity->user->created_at)
]) ?></small>
</p>
</li>
<!-- Menu Footer-->
<li class="user-footer">
<div class="pull-left">
<?= Html::a(
Yii::t('user', 'Profile'),
['/user/profile'],
['class' => 'btn btn-default btn-flat']
)
?>
</div>
<div class="pull-right">
<?= Html::a(
Yii::t('main', 'Sign out'),
['/auth/logout'],
['data-method' => 'post', 'class' => 'btn btn-default btn-flat']
) ?>
</div>
</li>
</ul>
</li>
</ul>
</div>
</nav>
</header>

211
backend/views/layouts/left-origin.php

@ -0,0 +1,211 @@
<?php
use core\entities\post\PostType;
use kartik\form\ActiveForm;
use core\forms\SearchForm;
use yii\helpers\Html;
use yii\helpers\Url;
$model = new SearchForm();
?>
<aside class="main-sidebar">
<section class="sidebar">
<!-- Sidebar user panel -->
<div class="user-panel">
<div class="pull-left image">
<img src="<?= Yii::$app->avatar->show(Yii::$app->user->identity->user->username) ?>" class="img-circle"
alt="<?= Yii::$app->user->identity->user->username ?>"/>
</div>
<div class="pull-left info">
<p><?= Yii::$app->user->identity->user->username ?></p>
<a href="#"><i class="fa fa-circle text-success"></i> <?= Yii::t('main', 'Online') ?></a>
</div>
</div>
<!-- search form -->
<?php $form = ActiveForm::begin([
'action' => Url::to(['/site/search']),
'options' => [
'class' => 'sidebar-form'
],
'enableClientValidation' => false,
'fieldConfig' => [
'options' => [
'tag' => false,
],
],
]); ?>
<?= $form->field($model, 'query', [
'addon' => [
'append' => [
'content' => Html::button('<i class="fa fa-search"></i>', ['class' => 'btn btn-flat', 'id' => 'search-btn']),
'asButton' => true
]
],
'template' => "{input}",
])->textInput(['placeholder' => Yii::t('main', 'Search...')])->label(false)->hint(false); ?>
<?php ActiveForm::end(); ?>
<!-- /.search form -->
<?= dmstr\widgets\Menu::widget(
[
'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'],
'items' => \yii\helpers\ArrayHelper::merge([
['label' => Yii::t('main', 'Menu'), 'options' => ['class' => 'header']],
[
'label' => Yii::t('dashboard', 'Dashboard'),
'icon' => 'dashboard',
'url' => ['/site/index'],
'active' => $this->context->id == '/site/index'
],
[
'label' => Yii::t('user', 'Users'),
'icon' => 'user',
'url' => ['/user/index'],
'active' => $this->context->id == 'user',
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('UserManagement'),
],
[
'label' => Yii::t('user', 'Access Rules'),
'icon' => 'lock',
'items' => [
[
'label' => Yii::t('user', 'Roles'),
'icon' => 'caret-right',
'url' => ['/role/index'],
'active' => \Yii::$app->controller->getUniqueId() == 'role'
],
[
'label' => Yii::t('user', 'Permissions'),
'icon' => 'caret-right',
'url' => ['/permission/index'],
'active' => \Yii::$app->controller->getUniqueId() == 'permission'
],
],
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('UserManagement')
],
[
'label' => Yii::t('menu', 'Menu'),
'icon' => 'bars',
'url' => ['/menu/index'],
'active' => $this->context->id == 'menu',
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('MenuManagement'),
],
[
'label' => Yii::t('main', 'Modules'),
'icon' => 'cubes',
'items' => [
[
'label' => Yii::t('main', 'Modules'),
'icon' => 'caret-right',
'url' => ['/module/list'],
'active' => \Yii::$app->controller->action->getUniqueId() == 'module/list'
],
[
'label' => Yii::t('main', 'Find modules'),
'icon' => 'caret-right',
'url' => ['/module/search'],
'active' => \Yii::$app->controller->action->getUniqueId() == 'module/search'
],
],
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('ModuleManagement')
],
/*[
'label' => Yii::t('pages', 'Pages'),
'icon' => 'file-o', 'url' => ['/page/index'],
'active' => $this->context->id == 'page',
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('PagesManagement'),
],*/
[
'label' => Yii::t('post', 'Posts'),
'icon' => 'newspaper-o',
'items' => array_merge(
array_map(function (PostType $type) {
return [
'label' => $type->plural,
'icon' => 'caret-right',
'items' => [
[
'label' => Yii::t('post', 'Categories'),
'icon' => 'caret-right',
'url' => ['/post/category', 'tid' => $type->id],
'active' => \Yii::$app->controller->getUniqueId() == 'post/category' && \Yii::$app->request->get('tid') == $type->id
],
[
'label' => $type->plural,
'icon' => 'caret-right',
'url' => ['/post/post', 'tid' => $type->id],
'active' => \Yii::$app->controller->getUniqueId() == 'post/post' && \Yii::$app->request->get('tid') == $type->id
],
[
'label' => Yii::t('post', 'Tags'),
'icon' => 'caret-right',
'url' => ['/post/tag', 'tid' => $type->id],
'active' => \Yii::$app->controller->getUniqueId() == 'post/tag' && \Yii::$app->request->get('tid') == $type->id
],
]
];
}, PostType::find()->all()),
[
[
'label' => Yii::t('post', 'Comments'),
'icon' => 'caret-right',
'url' => ['/post/comment'],
'active' => \Yii::$app->controller->getUniqueId() == 'post/comment'
]
],
[
[
'label' => Yii::t('post', 'Types'),
'icon' => 'caret-right',
'url' => ['/post/type'],
'active' => \Yii::$app->controller->getUniqueId() == 'post/type'
]
]
),
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('PostManagement')
],
[
'label' => Yii::t('slider', 'Slider'),
'icon' => 'retweet',
'url' => ['/slider/index'],
'active' => $this->context->id == 'slider',
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('SliderManagement'),
],
[
'label' => Yii::t('main', 'Settings'),
'icon' => 'cog',
'items' => [
[
'label' => Yii::t('main', 'Settings List'),
'icon' => 'caret-right',
'url' => ['/settings/list/index'],
'active' => \Yii::$app->controller->getUniqueId() == 'settings/list'
],
//['label' => Yii::t('main', 'Find modules'), 'icon' => 'caret-right', 'url' => ['/module/search'], 'active' => \Yii::$app->controller->action->getUniqueId() == 'module/search'],
],
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('SettingsManagement')
],
], (isset(Yii::$app->params['adminMenu']) && is_array(Yii::$app->params['adminMenu']) ? Yii::$app->params['adminMenu'] : [])),
]
) ?>
</section>
</aside>

369
backend/views/layouts/left.php

@ -1,210 +1,291 @@
<?php <?php
//use yii\widgets\ActiveForm; use core\components\adminlte3\widgets\Menu;
use kartik\form\ActiveForm; use yii\helpers\ArrayHelper;
use core\forms\SearchForm; use yii\web\View;
use yii\helpers\Html;
$model = new SearchForm(); //use app\modules\customers\entities\CustomerBase;
/**
* @var $this View
*/
//$image = Yii::$app->imager;
$css = <<<CSS
.brand-link .brand-image {
float: none !important;
}
.sidebar-dark-primary .nav-sidebar.nav-legacy > .nav-item > .nav-link.active, .sidebar-light-primary .nav-sidebar.nav-legacy > .nav-item > .nav-link.active {
border-color: #9ed6db;
}
CSS;
$this->registerCss($css);
?> ?>
<aside class="main-sidebar sidebar-dark-primary elevation-4">
<!-- Brand Logo -->
<a href="<?= Yii::$app->homeUrl ?>" class="brand-link">
<img src="<?= Yii::$app->params['staticHostInfo'] ?>/images/ego_white.svg" class="brand-image " style="opacity: .8">
</a>
<!-- Sidebar -->
<div class="sidebar">
<!-- Sidebar user panel (optional) -->
<div class="user-panel mt-3 pb-3 mb-3 d-flex">
<div class="image">
<!-- <img src="< ?= $image->avatar(Yii::$app->user->id) ?>" class="img-circle elevation-2" alt="User Image"> -->
<img src="<?= Yii::$app->avatar->show(Yii::$app->user->identity->user->username . '_' . Yii::$app->user->id, null, null, Yii::$app->user->identity->user->user_pic) ?>?<?= rand(10, 5000) ?>" class="img-circle elevation-2" alt="<?= Yii::$app->user->identity->user->username ?>">
</div>
<div class="info">
<a href="#" class="d-block"><?= Yii::$app->user->identity->user->username ?></a>
</div>
</div>
<aside class="main-sidebar"> <!-- Sidebar Menu -->
<nav class="mt-2">
<section class="sidebar"> <?php
/*$basesMenu = [
<!-- Sidebar user panel --> 'label' => Yii::t('main', 'Customers'),
<div class="user-panel"> 'icon' => 'fas fa-star',
<div class="pull-left image"> 'url' => ['/customers/customer/index'],
<img src="<?= Yii::$app->avatar->show(Yii::$app->user->identity->user->username) ?>" class="img-circle" 'active' => Yii::$app->controller->getUniqueId() == 'customers/customer',
alt="<?= Yii::$app->user->identity->user->username ?>"/> 'visible' => Yii::$app->user->can('admin') ||
</div> Yii::$app->user->can('CustomerManagement')
<div class="pull-left info"> ];
<p><?= Yii::$app->user->identity->user->username ?></p> $bases = CustomerBase::find()->all();
if (count($bases) > 1) {
<a href="#"><i class="fa fa-circle text-success"></i> <?= Yii::t('main', 'Online') ?></a> $baseItems = array_map(function ($base) {
</div> return [
</div> 'label' => $base->name,
'icon' => 'fas fa-caret-right',
<!-- search form --> 'url' => ['/customers/customer/index', 'base_id' => $base->id],
<?php $form = ActiveForm::begin([ 'active' => Yii::$app->controller->getUniqueId() == 'customers/customer' &&
'action' => \yii\helpers\Url::to(['/site/search']), Yii::$app->getRequest()->get('base_id') == $base->id
'options' => [ ];
'class' => 'sidebar-form' }, $bases);
], $basesMenu = [
'enableClientValidation' => false, 'label' => Yii::t('main', 'Customers'),
'fieldConfig' => [ 'icon' => 'fas fa-star',
'options' => [ 'items' => $baseItems,
'tag' => false, 'visible' => Yii::$app->user->can('admin') ||
], Yii::$app->user->can('CustomerManagement')
], ];
]); ?> }*/
?>
<?= $form->field($model, 'query', [
'addon' => [
'append' => [
'content' => Html::button('<i class="fa fa-search"></i>', ['class' => 'btn btn-flat', 'id' => 'search-btn']),
'asButton' => true
]
],
'template' => "{input}",
])->textInput(['placeholder' => Yii::t('main', 'Search...')])->label(false)->hint(false); ?>
<?php ActiveForm::end(); ?>
<!-- /.search form -->
<?= dmstr\widgets\Menu::widget(
[
'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'],
'items' => \yii\helpers\ArrayHelper::merge([
['label' => Yii::t('main', 'Menu'), 'options' => ['class' => 'header']],
<?= Menu::widget([
'items' => ArrayHelper::merge([
//['label' => Yii::t('main', 'Menu'), 'options' => ['class' => 'header']],
[ [
'label' => Yii::t('dashboard', 'Dashboard'), 'label' => Yii::t('dashboard', 'Dashboard'),
'icon' => 'dashboard', 'icon' => 'fas fa-tachometer-alt',
'url' => ['/site/index'], 'url' => ['/site/index'],
'active' => $this->context->id == '/site/index' 'active' => $this->context->id == '/site/index'
], ],
[ [
'label' => Yii::t('user', 'Users'), 'label' => Yii::t('user', 'Users'),
'icon' => 'user', 'icon' => 'fas fa-user',
'url' => ['/user/index'], 'url' => ['/user/index'],
'active' => $this->context->id == 'user', 'active' => $this->context->id == 'user',
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('UserManagement'), 'visible' => Yii::$app->user->can('admin') || Yii::$app->user->can('UserManagement'),
], ],
[ [
'label' => Yii::t('user', 'Access Rules'), 'label' => Yii::t('user', 'Access Rules'),
'icon' => 'lock', 'icon' => 'fas fa-lock',
'items' => [ 'items' => [
[ [
'label' => Yii::t('user', 'Roles'), 'label' => Yii::t('user', 'Roles'),
'icon' => 'caret-right', 'icon' => 'fas fa-caret-right',
'url' => ['/role/index'], 'url' => ['/role/index'],
'active' => \Yii::$app->controller->getUniqueId() == 'role' 'active' => Yii::$app->controller->getUniqueId() == 'role'
], ],
[ [
'label' => Yii::t('user', 'Permissions'), 'label' => Yii::t('user', 'Permissions'),
'icon' => 'caret-right', 'icon' => 'fas fa-caret-right',
'url' => ['/permission/index'], 'url' => ['/permission/index'],
'active' => \Yii::$app->controller->getUniqueId() == 'permission' 'active' => Yii::$app->controller->getUniqueId() == 'permission'
], ],
], ],
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('UserManagement') 'visible' => Yii::$app->user->can('admin') || Yii::$app->user->can('UserManagement')
], ],
[ [
'label' => Yii::t('menu', 'Menu'), 'label' => Yii::t('menu', 'Menu'),
'icon' => 'bars', 'icon' => 'fas fa-bars',
'url' => ['/menu/index'], 'url' => ['/menu/index'],
'active' => $this->context->id == 'menu', 'active' => $this->context->id == 'menu',
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('MenuManagement'), 'visible' => Yii::$app->user->can('admin') || Yii::$app->user->can('MenuManagement'),
], ],
[ [
'label' => Yii::t('main', 'Modules'), 'label' => Yii::t('main', 'Modules'),
'icon' => 'cubes', 'icon' => 'fas fa-cubes',
'items' => [ 'items' => [
[ [
'label' => Yii::t('main', 'Modules'), 'label' => Yii::t('main', 'Modules'),
'icon' => 'caret-right', 'icon' => 'fas fa-caret-right',
'url' => ['/module/list'], 'url' => ['/module/list'],
'active' => \Yii::$app->controller->action->getUniqueId() == 'module/list' 'active' => Yii::$app->controller->action->getUniqueId() == 'module/list'
], ],
[ [
'label' => Yii::t('main', 'Find modules'), 'label' => Yii::t('main', 'Find modules'),
'icon' => 'caret-right', 'icon' => 'fas fa-caret-right',
'url' => ['/module/search'], 'url' => ['/module/search'],
'active' => \Yii::$app->controller->action->getUniqueId() == 'module/search' 'active' => Yii::$app->controller->action->getUniqueId() == 'module/search'
], ],
], ],
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('ModuleManagement') 'visible' => Yii::$app->user->can('admin') || Yii::$app->user->can('ModuleManagement')
],
/*[
'label' => Yii::t('pages', 'Pages'),
'icon' => 'file-o', 'url' => ['/page/index'],
'active' => $this->context->id == 'page',
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('PagesManagement'),
],*/
[
'label' => Yii::t('post', 'Posts'),
'icon' => 'newspaper-o',
'items' => array_merge(
array_map(function (\core\entities\post\PostType $type) {
return [
'label' => $type->plural,
'icon' => 'caret-right',
'items' => [
[
'label' => Yii::t('post', 'Categories'),
'icon' => 'caret-right',
'url' => ['/post/category', 'tid' => $type->id],
'active' => \Yii::$app->controller->getUniqueId() == 'post/category' && \Yii::$app->request->get('tid') == $type->id
],
[
'label' => $type->plural,
'icon' => 'caret-right',
'url' => ['/post/post', 'tid' => $type->id],
'active' => \Yii::$app->controller->getUniqueId() == 'post/post' && \Yii::$app->request->get('tid') == $type->id
],
[
'label' => Yii::t('post', 'Tags'),
'icon' => 'caret-right',
'url' => ['/post/tag', 'tid' => $type->id],
'active' => \Yii::$app->controller->getUniqueId() == 'post/tag' && \Yii::$app->request->get('tid') == $type->id
],
]
];
}, \core\entities\post\PostType::find()->all()),
[
[
'label' => Yii::t('post', 'Comments'),
'icon' => 'caret-right',
'url' => ['/post/comment'],
'active' => \Yii::$app->controller->getUniqueId() == 'post/comment'
]
],
[
[
'label' => Yii::t('post', 'Types'),
'icon' => 'caret-right',
'url' => ['/post/type'],
'active' => \Yii::$app->controller->getUniqueId() == 'post/type'
]
]
),
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('PostManagement')
], ],
[ [
'label' => Yii::t('slider', 'Slider'), 'label' => Yii::t('slider', 'Slider'),
'icon' => 'retweet', 'icon' => 'fa fa-exchange-alt',
'url' => ['/slider/index'], 'url' => ['/slider/index'],
'active' => $this->context->id == 'slider', 'active' => $this->context->id == 'slider',
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('SliderManagement'), 'visible' => Yii::$app->user->can('admin') || Yii::$app->user->can('SliderManagement'),
], ],
[ [
'label' => Yii::t('main', 'Settings'), 'label' => Yii::t('main', 'Settings'),
'icon' => 'cog', 'icon' => 'fas fa-cog',
'items' => [ 'items' => [
[ [
'label' => Yii::t('main', 'Settings List'), 'label' => Yii::t('main', 'Settings List'),
'icon' => 'caret-right', 'icon' => 'fas fa-caret-right',
'url' => ['/settings/list/index'], 'url' => ['/settings/list/index'],
'active' => \Yii::$app->controller->getUniqueId() == 'settings/list' 'active' => Yii::$app->controller->getUniqueId() == 'settings/list'
], ],
//['label' => Yii::t('main', 'Find modules'), 'icon' => 'caret-right', 'url' => ['/module/search'], 'active' => \Yii::$app->controller->action->getUniqueId() == 'module/search'], //['label' => Yii::t('main', 'Find modules'), 'icon' => 'caret-right', 'url' => ['/module/search'], 'active' => \Yii::$app->controller->action->getUniqueId() == 'module/search'],
], ],
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('SettingsManagement') 'visible' => Yii::$app->user->can('admin') || Yii::$app->user->can('SettingsManagement')
], ],
], (isset(Yii::$app->params['adminMenu']) && is_array(Yii::$app->params['adminMenu']) ? Yii::$app->params['adminMenu'] : [])),
]
) ?>
</section>
//[
// 'label' => Yii::t('builder', 'Databases'),
// 'icon' => 'fas fa-database',
// 'items' => \app\modules\base_builder\helpers\BuilderHelper::getBasesMenu()
//],
//$basesMenu,
/*[
'label' => Yii::t('customers', 'Customer bases'),
'icon' => 'fas fa-users',
'url' => ['/customers/customer-base/index'],
'active' => Yii::$app->controller->getUniqueId() == 'customers/customer-base',
'visible' => Yii::$app->user->can('admin') ||
Yii::$app->user->can('CustomerManagement')
],*/
/*[
'label' => Yii::t('deals', 'Deals'),
'icon' => 'fas fa-plug',
'url' => ['/deals/deal/index'],
'active' => Yii::$app->controller->getUniqueId() == 'deals/deal',
'visible' => Yii::$app->user->can('admin') ||
Yii::$app->user->can('DealManagement')
],*/
/*[
'label' => Yii::t('calendar', 'Calendar'),
'icon' => 'fas fa-calendar-alt',
'url' => ['/calendar/events'],
'active' => Yii::$app->controller->getUniqueId() == 'calendar/events',
'visible' => Yii::$app->user->can('admin') ||
Yii::$app->user->can('CalendarManagement')
],*/
/*[
'label' => Yii::t('board', 'ToDo'),
'icon' => 'fas fa-check-square',
'url' => ['/board/cards'],
'active' => Yii::$app->controller->getUniqueId() == 'board/cards',
'visible' => Yii::$app->user->can('admin') ||
Yii::$app->user->can('BoardManagement')
],*/
/*[
'label' => Yii::t('subs', 'Mail Subs'),
'icon' => 'fas fa-envelope',
'items' => [
[
'label' => Yii::t('subs', 'Subs'),
'icon' => 'fas fa-caret-right',
'url' => ['/sub/index'],
'active' => Yii::$app->controller->getUniqueId() == 'sub',
'visible' => Yii::$app->user->can('admin') ||
Yii::$app->user->can('SubManagement')
],
[
'label' => Yii::t('mail-template', 'Mail Templates'),
'icon' => 'fas fa-caret-right',
'url' => ['/mail-template/index'],
'active' => Yii::$app->controller->getUniqueId() == 'mail-template',
'visible' => Yii::$app->user->can('admin') ||
Yii::$app->user->can('MailTemplateManagement')
],
[
'label' => Yii::t('subs', 'Signs'),
'icon' => 'fas fa-caret-right',
'url' => ['/sign/index'],
'active' => Yii::$app->controller->getUniqueId() == 'sign',
'visible' => Yii::$app->user->can('admin') ||
Yii::$app->user->can('SignManagement')
],
[
'label' => Yii::t('subs', 'DKIM'),
'icon' => 'fas fa-caret-right',
'url' => ['/dkim/index'],
'active' => Yii::$app->controller->getUniqueId() == 'dkim',
'visible' => Yii::$app->user->can('admin') ||
Yii::$app->user->can('DkimManagement')
],
]
],*/
/*[
'label' => Yii::t('sms', 'SMS Subs'),
'icon' => 'fas fa-mobile',
'url' => ['/sms/sms/index'],
'active' => Yii::$app->controller->getUniqueId() == 'sms/sms',
'visible' => Yii::$app->user->can('admin') ||
Yii::$app->user->can('SmsManagement')
],*/
/*[
'label' => Yii::t('stat', 'Statistics'),
'icon' => 'fas fa-chart-bar',
'items' => [
[
'label' => Yii::t('stat', 'Deals'),
'icon' => 'fas fa-caret-right',
'url' => ['/stat/stat/deals'],
'active' => Yii::$app->controller->action->getUniqueId() == 'stat/stat/deals',
'visible' => Yii::$app->user->can('admin') ||
Yii::$app->user->can('StatDealsStatistics')
],
[
'label' => Yii::t('stat', 'My Deals'),
'icon' => 'fas fa-caret-right',
'url' => ['/stat/stat/my-deals'],
'active' => Yii::$app->controller->action->getUniqueId() == 'stat/stat/my-deals',
'visible' => Yii::$app->user->can('admin') ||
Yii::$app->user->can('StatMyDealsStatistics')
],
]
],*/
/*[
'label' => 'API',
'icon' => 'fas fa-cogs',
'url' => ['/site/api'],
'active' => Yii::$app->controller->action->getUniqueId() == 'site/api',
'visible' => Yii::$app->user->can('admin') || Yii::$app->user->can('Franchise')
],*/
], (isset(Yii::$app->params['adminMenu']) && is_array(Yii::$app->params['adminMenu']) ? Yii::$app->params['adminMenu'] : [])),
]) ?>
</nav>
<!-- /.sidebar-menu -->
</div>
<!-- /.sidebar -->
</aside> </aside>

31
backend/views/layouts/main-login-origin.php

@ -0,0 +1,31 @@
<?php
use yii\helpers\Html;
/* @var $this \yii\web\View */
/* @var $content string */
dmstr\web\AdminLteAsset::register($this);
\backend\assets\AdminLteSkinAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?= \core\widgets\FaviconWidget::widget() ?>
<?php $this->head() ?>
</head>
<body class="login-page">
<?php $this->beginBody() ?>
<?= $content ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

29
backend/views/layouts/main-login.php

@ -1,12 +1,27 @@
<?php <?php
use core\components\adminlte3\AdminLteAsset;
use core\components\adminlte3\AdminLteICheckAsset;
use core\components\adminlte3\widgets\ToastrNotification;
use cp\assets\AdminLteDarkAsset;
use cp\assets\AdminLteLightAsset;
use cp\assets\AppAsset;
use yii\helpers\Html; use yii\helpers\Html;
use yii\web\View;
/* @var $this \yii\web\View */ /* @var $this View */
/* @var $content string */ /* @var $content string */
dmstr\web\AdminLteAsset::register($this); AppAsset::register($this);
\backend\assets\AdminLteSkinAsset::register($this); AdminLteAsset::register($this);
//if (Yii::$app->params['theme'] == \app\forms\SettingsForm::THEME_BLACK) {
//AdminLteDarkAsset::register($this);
//}
//else {
AdminLteLightAsset::register($this);
//}
//AdminLteICheckAsset::register($this);
?> ?>
<?php $this->beginPage() ?> <?php $this->beginPage() ?>
<!DOCTYPE html> <!DOCTYPE html>
@ -16,13 +31,17 @@ dmstr\web\AdminLteAsset::register($this);
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<?= Html::csrfMetaTags() ?> <?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title> <title><?= Html::encode($this->title) ?></title>
<?= \core\widgets\FaviconWidget::widget() ?>
<?php $this->head() ?> <?php $this->head() ?>
</head> </head>
<body class="login-page"> <body>
<?php $this->beginBody() ?> <?php $this->beginBody() ?>
<?= ToastrNotification::widget() ?>
<div class="text-center mt-4">
<img style="height: 70px;" src="<?= Yii::$app->params['staticHostInfo'] ?>/images/ego_black.png">
<!-- <h4 style="color: #888;">International franchise program</h4> -->
</div>
<?= $content ?> <?= $content ?>
<?php $this->endBody() ?> <?php $this->endBody() ?>

66
backend/views/layouts/main-origin.php

@ -0,0 +1,66 @@
<?php
use yii\helpers\Html;
/* @var $this \yii\web\View */
/* @var $content string */
if (Yii::$app->controller->action->id === 'login') {
/**
* Do not use this code in your template. Remove it.
* Instead, use the code $this->layout = '//main-login'; in your controller.
*/
echo $this->render(
'main-login',
['content' => $content]
);
} else {
if (class_exists('backend\assets\AppAsset')) {
backend\assets\AppAsset::register($this);
} else {
app\assets\AppAsset::register($this);
}
dmstr\web\AdminLteAsset::register($this);
\backend\assets\AdminLteSkinAsset::register($this);
$directoryAsset = Yii::$app->assetManager->getPublishedUrl('@vendor/almasaeed2010/adminlte/dist');
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?= \core\widgets\FaviconWidget::widget() ?>
<?php $this->head() ?>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<?php $this->beginBody() ?>
<div class="wrapper">
<?= $this->render(
'header.php',
['directoryAsset' => $directoryAsset]
) ?>
<?= $this->render(
'left.php',
['directoryAsset' => $directoryAsset]
)
?>
<?= $this->render(
'content.php',
['content' => $content, 'directoryAsset' => $directoryAsset]
) ?>
</div>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
<?php } ?>

140
backend/views/layouts/main.php

@ -1,30 +1,89 @@
<?php <?php
use core\widgets\FaviconWidget;
use core\components\adminlte3\themes\AdminLteLightAsset;
use backend\assets\AppAsset;
use yii\helpers\Html; use yii\helpers\Html;
use yii\web\View;
use core\components\adminlte3\AdminLteAsset;
use core\components\adminlte3\AdminLteFontsAsset;
/* @var $this \yii\web\View */ /* @var $this View */
/* @var $content string */ /* @var $content string */
if (Yii::$app->controller->id == 'auth/auth' && in_array(Yii::$app->controller->action->id, ['login', 'request', 'confirm', 'login-hub', 'login-token', 'reset'])) {
if (Yii::$app->controller->action->id === 'login') {
/**
* Do not use this code in your template. Remove it.
* Instead, use the code $this->layout = '//main-login'; in your controller.
*/
echo $this->render( echo $this->render(
'main-login', 'main-login',
['content' => $content] ['content' => $content]
); );
} else { } else {
if (class_exists('backend\assets\AppAsset')) {
backend\assets\AppAsset::register($this); AppAsset::register($this);
} else { AdminLteAsset::register($this);
app\assets\AppAsset::register($this); AdminLteFontsAsset::register($this);
//if (Yii::$app->params['theme'] == \app\forms\SettingsForm::THEME_BLACK) {
//AdminLteDarkAsset::register($this);
//}
//else {
AdminLteLightAsset::register($this);
//}
$css = <<<CSS
.sidebar .nav .nav-link {
font-weight: 500 !important;
font-family: "Segoe UI", "Source Sans Pro", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"
}
.content-wrapper {
font-size: 0.9rem !important;
font-weight: 400 !important;
font-family: "Segoe UI", "Source Sans Pro", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"
}
.kv-grid-table.table thead th,
.kv-grid-table.table-bordered thead th,
.kv-grid-table.table-bordered thead td {
border-bottom: 0 !important;
}
label:not(.form-check-label):not(.custom-file-label) {
font-weight: 600;
}
.kv-grid-bs4 a.desc:after {
content: '\\f160';
margin-left: 3px;
}
.kv-grid-bs4 a.asc:after {
content: '\\f884';
margin-left: 3px;
}
/*.kv-grid-bs4 a:before {
@extend .fas;
margin-right: 5px;
}
.kv-grid-bs4 a.desc {
@extend .fa-sort-amount-down;
} }
.kv-grid-bs4 a.asc {
@extend .fa-sort-amount-down-alt;
}*/
dmstr\web\AdminLteAsset::register($this); .breadcrumb {
\backend\assets\AdminLteSkinAsset::register($this); font-size: 12px !important;
$directoryAsset = Yii::$app->assetManager->getPublishedUrl('@vendor/almasaeed2010/adminlte/dist'); }
.sp-preview {
margin-right: 0 !important;
}
.sp-dd {
display: none;
}
CSS;
$this->registerCss($css);
?> ?>
<?php $this->beginPage() ?> <?php $this->beginPage() ?>
<!DOCTYPE html> <!DOCTYPE html>
@ -32,35 +91,62 @@ if (Yii::$app->controller->action->id === 'login') {
<head> <head>
<meta charset="<?= Yii::$app->charset ?>"/> <meta charset="<?= Yii::$app->charset ?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<?= FaviconWidget::widget() ?>
<?= Html::csrfMetaTags() ?> <?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title> <title><?= Html::encode($this->title) ?></title>
<?= \core\widgets\FaviconWidget::widget() ?>
<!-- Font Awesome Icons
<link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css"> -->
<!-- IonIcons -->
<link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<!-- Google Font: Source Sans Pro -->
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=swap&subset=cyrillic" rel="stylesheet">
<?php $this->head() ?> <?php $this->head() ?>
</head> </head>
<body class="hold-transition skin-blue sidebar-mini">
<body class="hold-transition sidebar-mini">
<?php $this->beginBody() ?> <?php $this->beginBody() ?>
<div class="wrapper"> <div class="wrapper">
<!-- Navbar -->
<?= $this->render('header.php') ?>
<!-- /.navbar -->
<?= $this->render( <!-- Main Sidebar Container -->
'header.php', <?= $this->render('left.php') ?>
['directoryAsset' => $directoryAsset]
) ?>
<?= $this->render(
'left.php',
['directoryAsset' => $directoryAsset]
)
?>
<!-- Content Wrapper. Contains page content -->
<?= $this->render( <?= $this->render(
'content.php', 'content.php',
['content' => $content, 'directoryAsset' => $directoryAsset] ['content' => $content]
) ?> ) ?>
<!-- /.content-wrapper -->
<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
<!-- Control sidebar content goes here -->
</aside>
<!-- /.control-sidebar -->
<!-- Main Footer -->
<footer class="main-footer">
<strong>ZxCMS &copy; <?= date('Y') ?>
<!--<div class="float-right d-none d-sm-inline-block">
<b><?= Yii::t('main', 'Version') ?></b> 3.0
</div> -->
</footer>
</div> </div>
<!-- ./wrapper -->
<!-- OPTIONAL SCRIPTS -->
<!-- <script src="plugins/chart.js/Chart.min.js"></script> -->
<!-- <script src="dist/js/demo.js"></script>
<script src="dist/js/pages/dashboard3.js"></script> -->
<?php $this->endBody() ?> <?php $this->endBody() ?>
</body> </body>
</html> </html>
<?php $this->endPage() ?> <?php $this->endPage() ?>
<?php } ?> <?php } ?>

18
backend/views/menu/_form.php

@ -1,10 +1,13 @@
<?php <?php
use core\components\bootstrap4\widgets\Tab4;
use core\forms\menu\MenuForm;
use yii\bootstrap\Tabs;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\menu\MenuForm */ /* @var $model MenuForm */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
?> ?>
@ -12,8 +15,8 @@ use yii\widgets\ActiveForm;
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
<div class="box box-default"> <div class="card">
<div class="box-body"> <div class="card-body">
<?php <?php
$items = []; $items = [];
@ -30,16 +33,15 @@ use yii\widgets\ActiveForm;
?> ?>
<div class="nav-tabs-custom"> <div class="nav-tabs-custom">
<?= \yii\bootstrap\Tabs::widget([ <?= Tab4::widget([
'items' => $items 'items' => $items
]) ?> ]) ?>
</div> </div>
</div> </div>
</div> <div class="card-footer text-right">
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-success']) ?>
<div class="form-group"> </div>
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-success']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>

11
backend/views/menu/_form_tab.php

@ -4,14 +4,19 @@
* Date: 24.08.2018 * Date: 24.08.2018
*/ */
use core\forms\menu\MenuForm;
use yii\web\View;
use yii\widgets\ActiveForm;
/** /**
* @var $this \yii\web\View * @var $this View
* @var $form \yii\widgets\ActiveForm * @var $form ActiveForm
* @var $model \core\forms\menu\MenuForm * @var $model MenuForm
* @var $language string * @var $language string
*/ */
$postfix = $language == Yii::$app->params['defaultLanguage'] ? '' : '_' . $language; $postfix = $language == Yii::$app->params['defaultLanguage'] ? '' : '_' . $language;
?> ?>
<div class="mt-2"></div>
<?= $form->field($model, 'name' . $postfix)->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'name' . $postfix)->textInput(['maxlength' => true]) ?>

4
backend/views/menu/create.php

@ -1,7 +1,9 @@
<?php <?php
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\menu\MenuForm */ /* @var $model MenuForm */
use core\forms\menu\MenuForm;
$this->title = Yii::t('menu', 'Create Menu'); $this->title = Yii::t('menu', 'Create Menu');
$this->params['breadcrumbs'][] = ['label' => Yii::t('menu', 'Menu'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => Yii::t('menu', 'Menu'), 'url' => ['index']];

74
backend/views/menu/menu.php

@ -4,14 +4,18 @@
* Date: 10.07.2018 * Date: 10.07.2018
*/ */
use backend\components\menu\widgets\MenuEditorWidget;
use core\entities\menu\Menu;
use core\forms\menu\MenuSelectForm;
use kartik\form\ActiveForm; use kartik\form\ActiveForm;
use yii\helpers\Html; use yii\helpers\Html;
use yii\web\View;
/** /**
* @var $this \yii\web\View * @var $this View
* @var $model \core\forms\menu\MenuSelectForm * @var $model MenuSelectForm
* @var $menus \core\entities\menu\Menu[] * @var $menus Menu[]
* @var $menu \core\entities\menu\Menu * @var $menu Menu
* @var $creator array * @var $creator array
*/ */
@ -41,11 +45,11 @@ $this->registerJs($js, $this::POS_HEAD);
?> ?>
<div class="menu"> <div class="menu">
<div class="box box-default"> <div class="card">
<div class="box-header with-border"><?= Yii::t('menu', 'Current Menu') ?></div> <div class="card-header"><?= Yii::t('menu', 'Current Menu') ?></div>
<div class="box-body"> <div class="card-body">
<div class="row"> <div class="row menu-selector">
<div class="col-md-6"> <div class="col-md-6">
<?php $form = ActiveForm::begin([ <?php $form = ActiveForm::begin([
'enableClientValidation' => false, 'enableClientValidation' => false,
@ -54,6 +58,7 @@ $this->registerJs($js, $this::POS_HEAD);
]); ?> ]); ?>
<?= $form->field($model, 'id')->dropDownList($menus, [ <?= $form->field($model, 'id')->dropDownList($menus, [
'class' => 'form-control mb-1',
//'prompt' => Yii::t('menu', 'Select menu...'), //'prompt' => Yii::t('menu', 'Select menu...'),
'value' => $menu->id, 'value' => $menu->id,
'onchange' => 'this.form.submit()', 'onchange' => 'this.form.submit()',
@ -63,15 +68,15 @@ $this->registerJs($js, $this::POS_HEAD);
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<?= Html::a(Yii::t('menu', 'Create Menu'), ['menu/create'], [ <?= Html::a(Yii::t('menu', 'Create Menu'), ['menu/create'], [
'class' => 'btn btn-success', 'class' => 'btn btn-success d-block d-md-inline-block mb-1',
]) ?> ]) ?>
<?= Html::a(Yii::t('menu', 'Update Menu'), ['menu/update', 'id' => $menu->id], [ <?= Html::a(Yii::t('menu', 'Update Menu'), ['menu/update', 'id' => $menu->id], [
'class' => 'btn btn-primary', 'class' => 'btn btn-primary d-block d-md-inline-block mb-1',
]) ?> ]) ?>
<?= Html::a(Yii::t('menu', 'Delete Menu'), ['menu/delete', 'id' => $menu->id], [ <?= Html::a(Yii::t('menu', 'Delete Menu'), ['menu/delete', 'id' => $menu->id], [
'class' => 'btn btn-danger', 'class' => 'btn btn-danger d-block d-md-inline-block mb-1',
'data' => [ 'data' => [
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'), 'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'),
'method' => 'post', 'method' => 'post',
@ -85,24 +90,25 @@ $this->registerJs($js, $this::POS_HEAD);
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
<div class="box box-default"> <div class="card">
<div class="box-header with-border"><?= Yii::t('menu', 'Available Blocks') ?></div> <div class="card-header"><?= Yii::t('menu', 'Available Blocks') ?></div>
<div class="box-body"> <div class="card-body">
<div class="panel-group" id="accordion"> <div id="accordion">
<?php foreach ($creator as $item) : ?> <?php foreach ($creator as $item) : ?>
<div class="panel panel-default"> <div class="card">
<div class="panel-heading" style="padding-left: 0"> <div class="card-header" style="padding-left: 0; border: 0 !important;">
<h4 class="panel-title"> <h4 class="card-title">
<a data-toggle="collapse" data-parent="#accordion" <a data-toggle="collapse" data-parent="#accordion"
href="#collapse<?= $item['id'] ?>"><?= $item['title'] ?> href="#collapse<?= $item['id'] ?>"><?= $item['title'] ?>
<i class="fa fa-angle-down pull-right" aria-hidden="true"></i></a> <i class="fa fa-angle-down" style="position: absolute; right: 10px; top 10px;" aria-hidden="true"></i>
</a>
</h4> </h4>
</div> </div>
<div id="collapse<?= $item['id'] ?>" class="panel-collapse collapse"> <div id="collapse<?= $item['id'] ?>" class="panel-collapse collapse">
<div class="panel-body"> <div class="card-body">
<?= $item['content'] ?> <?= $item['content'] ?>
</div> </div>
</div> </div>
@ -116,11 +122,11 @@ $this->registerJs($js, $this::POS_HEAD);
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="box box-default"> <div class="card">
<div class="box-header with-border"><?= Yii::t('menu', 'Menu Items') ?></div> <div class="card-header"><?= Yii::t('menu', 'Menu Items') ?></div>
<div class="box-body"> <div class="card-body">
<?= \backend\components\menu\widgets\MenuEditorWidget::widget([ <?= MenuEditorWidget::widget([
'menu_id' => $menu->id 'menu_id' => $menu->id
]) ?> ]) ?>
@ -129,35 +135,37 @@ $this->registerJs($js, $this::POS_HEAD);
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<div class="box box-default"> <div class="card">
<div class="box-header with-border"><?= Yii::t('menu', 'Insert Code') ?></div> <div class="card-header"><?= Yii::t('menu', 'Insert Code') ?></div>
<div class="box-body"> <div class="card-body">
<?php <?php
$code = "<?= \core\widgets\menu\MenuWidget::widget(['menu_id' => " . $menu->id . ']) ?>'; $code = "<?= \core\widgets\menu\MenuWidget::widget(['menu_id' => " . $menu->id . ']) ?>';
?> ?>
<p><?= Yii::t('menu', 'For template') ?></p>
<label for="code_template"><?= Yii::t('menu', 'For template') ?></label>
<div class="input-group"> <div class="input-group">
<?= Html::input('text', 'code_template', $code, [ <?= Html::input('text', 'code_template', $code, [
'class' => 'form-control', 'class' => 'form-control form-control-sm',
'id' => 'code_template', 'id' => 'code_template',
]) ?> ]) ?>
<span class="input-group-btn"> <span class="input-group-btn">
<button id="copyTemplateCodeButton" type="button" class="btn btn-primary btn-flat"><i class="fa fa-files-o" aria-hidden="true"></i></button> <button id="copyTemplateCodeButton" type="button" class="btn btn-default btn-flat btn-sm"><i class="fas fa-copy" aria-hidden="true"></i></button>
</span> </span>
</div> </div>
<?php <?php
$code = "[?= \core\widgets\menu\MenuWidget::widget(['menu_id' => " . $menu->id . ']) ?]'; $code = "[?= \core\widgets\menu\MenuWidget::widget(['menu_id' => " . $menu->id . ']) ?]';
?> ?>
<p><?= Yii::t('menu', 'For editor') ?></p>
<label for="code_template" class="mt-2"><?= Yii::t('menu', 'For editor') ?></label>
<div class="input-group"> <div class="input-group">
<?= Html::input('text', 'code_editor', $code, [ <?= Html::input('text', 'code_editor', $code, [
'class' => 'form-control', 'class' => 'form-control form-control-sm',
'id' => 'code_editor', 'id' => 'code_editor',
]) ?> ]) ?>
<span class="input-group-btn"> <span class="input-group-btn">
<button id="copyEditorCodeButton" type="button" class="btn btn-primary btn-flat"><i class="fa fa-files-o" aria-hidden="true"></i></button> <button id="copyEditorCodeButton" type="button" class="btn btn-default btn-flat btn-sm"><i class="fas fa-copy" aria-hidden="true"></i></button>
</span> </span>
</div> </div>

10
backend/views/menu/select_menu.php

@ -4,14 +4,16 @@
* Date: 10.07.2018 * Date: 10.07.2018
*/ */
use core\entities\menu\Menu;
use core\forms\menu\MenuSelectForm;
use kartik\form\ActiveForm; use kartik\form\ActiveForm;
use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\web\View;
/** /**
* @var $this \yii\web\View * @var $this View
* @var $model \core\forms\menu\MenuSelectForm * @var $model MenuSelectForm
* @var $menus \core\entities\menu\Menu[] * @var $menus Menu[]
*/ */
$this->title = Yii::t('menu', 'Menu'); $this->title = Yii::t('menu', 'Menu');

7
backend/views/menu/update.php

@ -1,8 +1,11 @@
<?php <?php
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $menu \core\entities\menu\Menu */ /* @var $menu Menu */
/* @var $model \core\forms\menu\MenuForm */ /* @var $model MenuForm */
use core\entities\menu\Menu;
use core\forms\menu\MenuForm;
$this->title = Yii::t('menu', 'Update Menu: {name}', ['name' => isset($menu->translation) ? $menu->translation->name : Yii::t('menu', 'Not set')]); $this->title = Yii::t('menu', 'Update Menu: {name}', ['name' => isset($menu->translation) ? $menu->translation->name : Yii::t('menu', 'Not set')]);
$this->params['breadcrumbs'][] = ['label' => Yii::t('menu', 'Menu'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => Yii::t('menu', 'Menu'), 'url' => ['index']];

14
backend/views/module/list.php

@ -4,13 +4,15 @@
* Date: 17.08.2018 * Date: 17.08.2018
*/ */
use core\entities\ModuleRecord;
use yii\helpers\Html; use yii\helpers\Html;
use core\helpers\ModuleHelper; use core\helpers\ModuleHelper;
use kartik\dialog\Dialog; use kartik\dialog\Dialog;
use yii\web\View;
/** /**
* @var $this \yii\web\View * @var $this View
* @var $modules \core\entities\ModuleRecord[] * @var $modules ModuleRecord[]
*/ */
$this->title = Yii::t('main', 'Modules'); $this->title = Yii::t('main', 'Modules');
@ -47,15 +49,15 @@ $this->registerJs($js, $this::POS_READY);
<div class="col-md-4"> <div class="col-md-4">
<div class="box"> <div class="card">
<div class="box-header with-border"> <div class="card-header">
<h3 class="box-title"><i class="fa fa-power-off" aria-hidden="true" <h3 class="box-title"><i class="fa fa-power-off" aria-hidden="true"
style="color: <?= $color ?>"></i> <?= $module_name ?></h3> style="color: <?= $color ?>"></i> <?= $module_name ?></h3>
</div> </div>
<div class="box-body"> <div class="card-body">
<?= $module_description ?> <?= $module_description ?>
</div> </div>
<div class="box-footer" style="text-align: right"> <div class="card-footer" style="text-align: right">
<?php if (!$module->isSystem()) : ?> <?php if (!$module->isSystem()) : ?>
<?php if ($module->isEnabled()) : ?> <?php if ($module->isEnabled()) : ?>
<?= Html::a(Yii::t('main', 'Disable'), ['module/disable', 'id' => $module->id], [ <?= Html::a(Yii::t('main', 'Disable'), ['module/disable', 'id' => $module->id], [

3
backend/views/module/remote-list.php

@ -6,9 +6,10 @@
use yii\helpers\Html; use yii\helpers\Html;
use kartik\dialog\Dialog; use kartik\dialog\Dialog;
use yii\web\View;
/** /**
* @var $this \yii\web\View * @var $this View
* @var $modules array * @var $modules array
* @var $message string * @var $message string
*/ */

14
backend/views/permission/create.php

@ -1,8 +1,9 @@
<?php <?php
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \backend\forms\rbac\RbacCreatePermissionForm */ /* @var $model RbacCreatePermissionForm */
use backend\forms\rbac\RbacCreatePermissionForm;
use yii\bootstrap\ActiveForm; use yii\bootstrap\ActiveForm;
use yii\helpers\Html; use yii\helpers\Html;
@ -15,17 +16,16 @@ $this->params['breadcrumbs'][] = $this->title;
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
<div class="box box-default"> <div class="card">
<div class="box-body"> <div class="card-body">
<?= $form->field($model, 'name')->textInput(['maxLength' => true]) ?> <?= $form->field($model, 'name')->textInput(['maxLength' => true]) ?>
<?= $form->field($model, 'description')->textarea() ?> <?= $form->field($model, 'description')->textarea() ?>
<?= $form->field($model, 'rule_name')->textInput(['maxLength' => true]) ?> <?= $form->field($model, 'rule_name')->textInput(['maxLength' => true]) ?>
<?= $form->field($model, 'data')->textarea() ?> <?= $form->field($model, 'data')->textarea() ?>
</div> </div>
</div> <card class="card-footer text-right">
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-success']) ?>
<div class="form-group"> </card>
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-primary']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>

12
backend/views/permission/index.php

@ -11,13 +11,11 @@ $this->title = Yii::t('user', 'Permissions');
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="users-rbac-permission-index"> <div class="users-rbac-permission-index">
<div class="card">
<p> <div class="card-header">
<?= Html::a(Yii::t('user', 'Create Permission'), ['create'], ['class' => 'btn btn-success']) ?> <?= Html::a(Yii::t('user', 'Create Permission'), ['create'], ['class' => 'btn btn-success btn-sm']) ?>
</p> </div>
<div class="card-body">
<div class="box box-default">
<div class="box-body">
<?= GridView::widget([ <?= GridView::widget([
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'columns' => [ 'columns' => [

18
backend/views/permission/update.php

@ -1,11 +1,12 @@
<?php <?php
/* @var $this yii\web\View */ use backend\forms\rbac\RbacEditPermissionForm;
/* @var $model \backend\forms\rbac\RbacEditPermissionForm */
use yii\bootstrap\ActiveForm; use yii\bootstrap\ActiveForm;
use yii\helpers\Html; use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model RbacEditPermissionForm */
$this->title = Yii::t('user', 'Update Permission: {permission}', ['permission' => $model->name]); $this->title = Yii::t('user', 'Update Permission: {permission}', ['permission' => $model->name]);
$this->params['breadcrumbs'][] = ['label' => Yii::t('user', 'Permissions'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => Yii::t('user', 'Permissions'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->name]]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->name]];
@ -15,17 +16,16 @@ $this->params['breadcrumbs'][] = Yii::t('user', 'Editing');
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
<div class="box box-default"> <div class="card">
<div class="box-body"> <div class="card-body">
<?= $form->field($model, 'name')->textInput(['maxLength' => true]) ?> <?= $form->field($model, 'name')->textInput(['maxLength' => true]) ?>
<?= $form->field($model, 'description')->textarea() ?> <?= $form->field($model, 'description')->textarea() ?>
<?= $form->field($model, 'rule_name')->textInput(['maxLength' => true]) ?> <?= $form->field($model, 'rule_name')->textInput(['maxLength' => true]) ?>
<?= $form->field($model, 'data')->textarea() ?> <?= $form->field($model, 'data')->textarea() ?>
</div> </div>
</div> <card class="card-footer text-right">
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-success']) ?>
<div class="form-group"> </card>
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-primary']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>

14
backend/views/permission/view.php

@ -1,11 +1,11 @@
<?php <?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\rbac\Role;
use yii\widgets\DetailView; use yii\widgets\DetailView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \yii\rbac\Role */ /* @var $model Role */
$this->title = $model->name; $this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('user', 'Permissions'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => Yii::t('user', 'Permissions'), 'url' => ['index']];
@ -14,10 +14,10 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="users-rbac-permission-view"> <div class="users-rbac-permission-view">
<p> <p>
<?= Html::a(Yii::t('user', 'Permissions'), ['index'], ['class' => 'btn btn-default']) ?> <?= Html::a(Yii::t('user', 'Permissions'), ['index'], ['class' => 'btn btn-outline-primary btn-sm']) ?>
<?= Html::a(Yii::t('buttons', 'Edit'), ['update', 'id' => $model->name], ['class' => 'btn btn-primary']) ?> <?= Html::a(Yii::t('buttons', 'Edit'), ['update', 'id' => $model->name], ['class' => 'btn btn-primary btn-sm']) ?>
<?= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'id' => $model->name], [ <?= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'id' => $model->name], [
'class' => 'btn btn-danger', 'class' => 'btn btn-danger btn-sm',
'data' => [ 'data' => [
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'), 'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'),
'method' => 'post', 'method' => 'post',
@ -25,8 +25,8 @@ $this->params['breadcrumbs'][] = $this->title;
]) ?> ]) ?>
</p> </p>
<div class="box box-default"> <div class="card">
<div class="box-body"> <div class="card-body">
<?= DetailView::widget([ <?= DetailView::widget([
'model' => $model, 'model' => $model,
'attributes' => [ 'attributes' => [

18
backend/views/post/articles/_form.php

@ -1,19 +1,25 @@
<?php <?php
use core\forms\post\PostForm;
use kartik\file\FileInput; use kartik\file\FileInput;
use kartik\widgets\DateTimePicker;
use kartik\widgets\Select2;
use mihaildev\ckeditor\CKEditor; use mihaildev\ckeditor\CKEditor;
use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\bootstrap\ActiveForm; use yii\bootstrap\ActiveForm;
use yii\helpers\Json;
use yii\helpers\Url;
use yii\web\JsExpression; use yii\web\JsExpression;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
$fetchUrl = \yii\helpers\Url::to( [ 'tag-search' ] ); $fetchUrl = Url::to( [ 'tag-search' ] );
if (isset($model->_post)) { if (isset($model->_post)) {
$tagsJson = \yii\helpers\Json::encode( \yii\helpers\Json::encode( \yii\helpers\ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) ); $tagsJson = Json::encode( Json::encode( ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) );
$js = <<<JS $js = <<<JS
var arr = {$tagsJson}; var arr = {$tagsJson};
@ -38,7 +44,7 @@ JS;
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div> <div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body"> <div class="box-body">
<?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?> <?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?>
<?= $form->field($model, 'published_at')->widget(\kartik\widgets\DateTimePicker::classname(), [ <?= $form->field($model, 'published_at')->widget(DateTimePicker::class, [
'options' => [], 'options' => [],
'pluginOptions' => [ 'pluginOptions' => [
'autoclose' => true, 'autoclose' => true,
@ -52,7 +58,7 @@ JS;
<div class="box box-default"> <div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div> <div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div>
<div class="box-body"> <div class="box-body">
<?= $form->field($model->tags, 'new_tags')->widget(\kartik\widgets\Select2::classname(), [ <?= $form->field($model->tags, 'new_tags')->widget(Select2::class, [
'options' => [ 'options' => [
'placeholder' => Yii::t('post','Set tags...'), 'placeholder' => Yii::t('post','Set tags...'),
'multiple' => true, 'multiple' => true,
@ -81,7 +87,7 @@ JS;
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->textarea(['rows' => 5]) ?> <?= $form->field($model, 'description')->textarea(['rows' => 5]) ?>
<?= $form->field($model, 'content')->widget(CKEditor::className()) ?> <?= $form->field($model, 'content')->widget(CKEditor::class) ?>
</div> </div>
</div> </div>

7
backend/views/post/articles/create.php

@ -1,8 +1,11 @@
<?php <?php
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
use core\entities\post\PostType;
use core\forms\post\PostForm;
$title = Yii::t('post', 'Create Post'); $title = Yii::t('post', 'Create Post');
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

12
backend/views/post/articles/index.php

@ -1,14 +1,18 @@
<?php <?php
use core\entities\post\Post; use core\entities\post\Post;
use core\entities\post\PostType;
use core\forms\post\search\PostSearch;
use core\helpers\PostHelper; use core\helpers\PostHelper;
use yii\grid\ActionColumn;
use yii\helpers\Html; use yii\helpers\Html;
use yii\grid\GridView; use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostSearch */ /* @var $searchModel PostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'All Posts'); $title = Yii::t('post', 'All Posts');
$this->title = $type->plural .' > '. $title; $this->title = $type->plural .' > '. $title;
@ -67,11 +71,11 @@ $this->params['breadcrumbs'][] = $title;
'contentOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'],
], ],
[ [
'class' => \yii\grid\ActionColumn::class, 'class' => ActionColumn::class,
'urlCreator' => function($action, Post $model, $key, $index, $column) { 'urlCreator' => function($action, Post $model, $key, $index, $column) {
$params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id]; $params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id];
$params[0] = $column->controller ? $column->controller . '/' . $action : $action; $params[0] = $column->controller ? $column->controller . '/' . $action : $action;
return \yii\helpers\Url::toRoute($params); return Url::toRoute($params);
}, },
'options' => ['style' => 'width: 100px;'], 'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'],

13
backend/views/post/articles/update.php

@ -1,11 +1,16 @@
<?php <?php
use core\entities\post\Post;
use core\entities\post\PostType;
use core\forms\post\PostForm;
use yii\helpers\StringHelper;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */ /* @var $post Post */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Update Post: {name}', ['name' => \yii\helpers\StringHelper::truncateWords($post->title, 6, '...')]); $title = Yii::t('post', 'Update Post: {name}', ['name' => StringHelper::truncateWords($post->title, 6, '...')]);
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]]; $this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = ['label' => $type->singular, 'url' => ['view', 'id' => $post->id]]; $this->params['breadcrumbs'][] = ['label' => $type->singular, 'url' => ['view', 'id' => $post->id]];

6
backend/views/post/articles/view.php

@ -1,14 +1,16 @@
<?php <?php
use core\entities\post\Post;
use core\entities\post\PostType;
use core\helpers\PostHelper; use core\helpers\PostHelper;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */ /* @var $post Post */
/* @var $modificationsProvider yii\data\ActiveDataProvider */ /* @var $modificationsProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = $post->title; $title = $post->title;
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

18
backend/views/post/blog/_form.php

@ -1,19 +1,25 @@
<?php <?php
use core\forms\post\PostForm;
use kartik\file\FileInput; use kartik\file\FileInput;
use kartik\widgets\DateTimePicker;
use kartik\widgets\Select2;
use mihaildev\ckeditor\CKEditor; use mihaildev\ckeditor\CKEditor;
use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\bootstrap\ActiveForm; use yii\bootstrap\ActiveForm;
use yii\helpers\Json;
use yii\helpers\Url;
use yii\web\JsExpression; use yii\web\JsExpression;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
$fetchUrl = \yii\helpers\Url::to( [ 'tag-search' ] ); $fetchUrl = Url::to( [ 'tag-search' ] );
if (isset($model->_post)) { if (isset($model->_post)) {
$tagsJson = \yii\helpers\Json::encode( \yii\helpers\Json::encode( \yii\helpers\ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) ); $tagsJson = Json::encode( Json::encode( ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) );
$js = <<<JS $js = <<<JS
var arr = {$tagsJson}; var arr = {$tagsJson};
@ -38,7 +44,7 @@ JS;
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div> <div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body"> <div class="box-body">
<?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?> <?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?>
<?= $form->field($model, 'published_at')->widget(\kartik\widgets\DateTimePicker::classname(), [ <?= $form->field($model, 'published_at')->widget(DateTimePicker::class, [
'options' => [], 'options' => [],
'pluginOptions' => [ 'pluginOptions' => [
'autoclose' => true, 'autoclose' => true,
@ -52,7 +58,7 @@ JS;
<div class="box box-default"> <div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div> <div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div>
<div class="box-body"> <div class="box-body">
<?= $form->field($model->tags, 'new_tags')->widget(\kartik\widgets\Select2::classname(), [ <?= $form->field($model->tags, 'new_tags')->widget(Select2::class, [
'options' => [ 'options' => [
'placeholder' => Yii::t('post','Set tags...'), 'placeholder' => Yii::t('post','Set tags...'),
'multiple' => true, 'multiple' => true,
@ -81,7 +87,7 @@ JS;
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->textarea(['rows' => 5]) ?> <?= $form->field($model, 'description')->textarea(['rows' => 5]) ?>
<?= $form->field($model, 'content')->widget(CKEditor::className()) ?> <?= $form->field($model, 'content')->widget(CKEditor::class) ?>
</div> </div>
</div> </div>

7
backend/views/post/blog/create.php

@ -1,8 +1,11 @@
<?php <?php
use core\entities\post\PostType;
use core\forms\post\PostForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Create Post'); $title = Yii::t('post', 'Create Post');
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

9
backend/views/post/blog/index.php

@ -1,14 +1,17 @@
<?php <?php
use core\entities\post\Post; use core\entities\post\Post;
use core\entities\post\PostType;
use core\forms\post\search\PostSearch;
use core\helpers\PostHelper; use core\helpers\PostHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\grid\GridView; use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostSearch */ /* @var $searchModel PostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'All Posts'); $title = Yii::t('post', 'All Posts');
$this->title = $type->plural .' > '. $title; $this->title = $type->plural .' > '. $title;
@ -71,7 +74,7 @@ $this->params['breadcrumbs'][] = $title;
'urlCreator' => function($action, Post $model, $key, $index, $column) { 'urlCreator' => function($action, Post $model, $key, $index, $column) {
$params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id]; $params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id];
$params[0] = $column->controller ? $column->controller . '/' . $action : $action; $params[0] = $column->controller ? $column->controller . '/' . $action : $action;
return \yii\helpers\Url::toRoute($params); return Url::toRoute($params);
}, },
'options' => ['style' => 'width: 100px;'], 'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'],

13
backend/views/post/blog/update.php

@ -1,11 +1,16 @@
<?php <?php
use core\entities\post\Post;
use core\entities\post\PostType;
use core\forms\post\PostForm;
use yii\helpers\StringHelper;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */ /* @var $post Post */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Update Post: {name}', ['name' => \yii\helpers\StringHelper::truncateWords($post->title, 6, '...')]); $title = Yii::t('post', 'Update Post: {name}', ['name' => StringHelper::truncateWords($post->title, 6, '...')]);
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]]; $this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = ['label' => $type->singular, 'url' => ['view', 'id' => $post->id]]; $this->params['breadcrumbs'][] = ['label' => $type->singular, 'url' => ['view', 'id' => $post->id]];

6
backend/views/post/blog/view.php

@ -1,14 +1,16 @@
<?php <?php
use core\entities\post\Post;
use core\entities\post\PostType;
use core\helpers\PostHelper; use core\helpers\PostHelper;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */ /* @var $post Post */
/* @var $modificationsProvider yii\data\ActiveDataProvider */ /* @var $modificationsProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = $post->title; $title = $post->title;
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

5
backend/views/post/category/_form.php

@ -1,11 +1,12 @@
<?php <?php
use core\forms\post\PostCategoryForm;
use mihaildev\ckeditor\CKEditor; use mihaildev\ckeditor\CKEditor;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostCategoryForm */ /* @var $model PostCategoryForm */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
?> ?>
@ -31,7 +32,7 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->widget(CKEditor::className()) ?> <?= $form->field($model, 'description')->widget(CKEditor::class) ?>
</div> </div>
</div> </div>

7
backend/views/post/category/create.php

@ -1,8 +1,11 @@
<?php <?php
use core\entities\post\PostType;
use core\forms\post\PostCategoryForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostCategoryForm */ /* @var $model PostCategoryForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Create Category'); $title = Yii::t('post', 'Create Category');
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

6
backend/views/post/category/index.php

@ -1,14 +1,16 @@
<?php <?php
use core\entities\post\PostCategory; use core\entities\post\PostCategory;
use core\entities\post\PostType;
use core\forms\post\search\PostCategorySearch;
use yii\grid\ActionColumn; use yii\grid\ActionColumn;
use yii\helpers\Html; use yii\helpers\Html;
use yii\grid\GridView; use yii\grid\GridView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostCategorySearch */ /* @var $searchModel PostCategorySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Categories'); $title = Yii::t('post', 'Categories');
$this->title = $type->plural .' > '. $title; $this->title = $type->plural .' > '. $title;

10
backend/views/post/category/update.php

@ -1,9 +1,13 @@
<?php <?php
use core\entities\post\PostCategory;
use core\entities\post\PostType;
use core\forms\post\PostCategoryForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $category \core\entities\post\PostCategory */ /* @var $category PostCategory */
/* @var $model \core\forms\post\PostCategoryForm */ /* @var $model PostCategoryForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Update: {name}', ['name' => $category->name]); $title = Yii::t('post', 'Update: {name}', ['name' => $category->name]);
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

6
backend/views/post/category/view.php

@ -1,11 +1,13 @@
<?php <?php
use core\entities\post\PostCategory;
use core\entities\post\PostType;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $category \core\entities\post\PostCategory */ /* @var $category PostCategory */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = $category->name; $title = $category->name;
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

3
backend/views/post/comment/index.php

@ -1,12 +1,13 @@
<?php <?php
use core\entities\post\PostComment; use core\entities\post\PostComment;
use core\forms\post\search\PostCommentSearch;
use yii\grid\ActionColumn; use yii\grid\ActionColumn;
use yii\grid\GridView; use yii\grid\GridView;
use yii\helpers\StringHelper; use yii\helpers\StringHelper;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostCommentSearch */ /* @var $searchModel PostCommentSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('post', 'Comments'); $this->title = Yii::t('post', 'Comments');

6
backend/views/post/comment/update.php

@ -1,11 +1,13 @@
<?php <?php
use core\entities\post\Post;
use core\forms\post\PostCommentEditForm;
use yii\helpers\Html; use yii\helpers\Html;
use yii\bootstrap\ActiveForm; use yii\bootstrap\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */ /* @var $post Post */
/* @var $model \core\forms\post\PostCommentEditForm */ /* @var $model PostCommentEditForm */
$this->title = Yii::t('post', 'Update Post Comment: {name}', ['name' => $post->title]); $this->title = Yii::t('post', 'Update Post Comment: {name}', ['name' => $post->title]);
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', 'Comment'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => Yii::t('post', 'Comment'), 'url' => ['index']];

8
backend/views/post/comment/view.php

@ -1,12 +1,14 @@
<?php <?php
use core\entities\post\Post;
use core\entities\post\PostComment;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
use core\entities\user\User; use core\entities\user\User;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */ /* @var $post Post */
/* @var $comment \core\entities\post\PostComment */ /* @var $comment PostComment */
/* @var $modificationsProvider yii\data\ActiveDataProvider */ /* @var $modificationsProvider yii\data\ActiveDataProvider */
$this->title = $post->title; $this->title = $post->title;
@ -47,7 +49,7 @@ $this->params['breadcrumbs'][] = $this->title;
'active:boolean', 'active:boolean',
[ [
'attribute' => 'user_id', 'attribute' => 'user_id',
'value' => function(\core\entities\post\PostComment $comment) { 'value' => function(PostComment $comment) {
return User::findOne($comment->user_id)->username; return User::findOne($comment->user_id)->username;
}, },
], ],

16
backend/views/post/gallery/_form.php

@ -1,18 +1,24 @@
<?php <?php
use core\forms\post\PostForm;
use kartik\file\FileInput; use kartik\file\FileInput;
use kartik\widgets\DateTimePicker;
use kartik\widgets\Select2;
use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\bootstrap\ActiveForm; use yii\bootstrap\ActiveForm;
use yii\helpers\Json;
use yii\helpers\Url;
use yii\web\JsExpression; use yii\web\JsExpression;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
$fetchUrl = \yii\helpers\Url::to( [ 'tag-search' ] ); $fetchUrl = Url::to( [ 'tag-search' ] );
if (isset($model->_post)) { if (isset($model->_post)) {
$tagsJson = \yii\helpers\Json::encode( \yii\helpers\Json::encode( \yii\helpers\ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) ); $tagsJson = Json::encode( Json::encode( ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) );
$js = <<<JS $js = <<<JS
var arr = {$tagsJson}; var arr = {$tagsJson};
@ -37,7 +43,7 @@ JS;
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div> <div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body"> <div class="box-body">
<?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?> <?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?>
<?= $form->field($model, 'published_at')->widget(\kartik\widgets\DateTimePicker::classname(), [ <?= $form->field($model, 'published_at')->widget(DateTimePicker::class, [
'options' => [], 'options' => [],
'pluginOptions' => [ 'pluginOptions' => [
'autoclose' => true, 'autoclose' => true,
@ -51,7 +57,7 @@ JS;
<div class="box box-default"> <div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div> <div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div>
<div class="box-body"> <div class="box-body">
<?= $form->field($model->tags, 'new_tags')->widget(\kartik\widgets\Select2::classname(), [ <?= $form->field($model->tags, 'new_tags')->widget(Select2::class, [
'options' => [ 'options' => [
'placeholder' => Yii::t('post','Set tags...'), 'placeholder' => Yii::t('post','Set tags...'),
'multiple' => true, 'multiple' => true,

7
backend/views/post/gallery/create.php

@ -1,8 +1,11 @@
<?php <?php
use core\entities\post\PostType;
use core\forms\post\PostForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Add Image'); $title = Yii::t('post', 'Add Image');
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

9
backend/views/post/gallery/index.php

@ -1,14 +1,17 @@
<?php <?php
use core\entities\post\Post; use core\entities\post\Post;
use core\entities\post\PostType;
use core\forms\post\search\PostSearch;
use core\helpers\PostHelper; use core\helpers\PostHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\grid\GridView; use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostSearch */ /* @var $searchModel PostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'All Posts'); $title = Yii::t('post', 'All Posts');
$this->title = $type->plural .' > '. $title; $this->title = $type->plural .' > '. $title;
@ -71,7 +74,7 @@ $this->params['breadcrumbs'][] = $title;
'urlCreator' => function($action, Post $model, $key, $index, $column) { 'urlCreator' => function($action, Post $model, $key, $index, $column) {
$params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id]; $params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id];
$params[0] = $column->controller ? $column->controller . '/' . $action : $action; $params[0] = $column->controller ? $column->controller . '/' . $action : $action;
return \yii\helpers\Url::toRoute($params); return Url::toRoute($params);
}, },
'options' => ['style' => 'width: 100px;'], 'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'],

10
backend/views/post/gallery/update.php

@ -1,9 +1,13 @@
<?php <?php
use core\entities\post\Post;
use core\entities\post\PostType;
use core\forms\post\PostForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */ /* @var $post Post */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Update Post: {name}', ['name' => \yii\helpers\StringHelper::truncateWords($post->title, 6, '...')]); $title = Yii::t('post', 'Update Post: {name}', ['name' => \yii\helpers\StringHelper::truncateWords($post->title, 6, '...')]);
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

6
backend/views/post/gallery/view.php

@ -1,14 +1,16 @@
<?php <?php
use core\entities\post\Post;
use core\entities\post\PostType;
use core\helpers\PostHelper; use core\helpers\PostHelper;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */ /* @var $post Post */
/* @var $modificationsProvider yii\data\ActiveDataProvider */ /* @var $modificationsProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = $post->title; $title = $post->title;
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

18
backend/views/post/news/_form.php

@ -1,20 +1,26 @@
<?php <?php
use core\forms\post\PostForm;
use kartik\file\FileInput; use kartik\file\FileInput;
use kartik\widgets\DateTimePicker;
use kartik\widgets\Select2;
use mihaildev\ckeditor\CKEditor; use mihaildev\ckeditor\CKEditor;
use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\bootstrap\ActiveForm; use yii\bootstrap\ActiveForm;
use yii\helpers\Json;
use yii\helpers\Url;
use yii\web\JsExpression; use yii\web\JsExpression;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
$fetchUrl = \yii\helpers\Url::to( [ 'tag-search' ] ); $fetchUrl = Url::to( [ 'tag-search' ] );
if (isset($model->_post)) { if (isset($model->_post)) {
$tagsJson = \yii\helpers\Json::encode( \yii\helpers\Json::encode( \yii\helpers\ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) ); $tagsJson = Json::encode( Json::encode( ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) );
$js = <<<JS $js = <<<JS
var arr = {$tagsJson}; var arr = {$tagsJson};
@ -39,7 +45,7 @@ JS;
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div> <div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body"> <div class="box-body">
<?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?> <?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?>
<?= $form->field($model, 'published_at')->widget(\kartik\widgets\DateTimePicker::classname(), [ <?= $form->field($model, 'published_at')->widget(DateTimePicker::class, [
'options' => [], 'options' => [],
'pluginOptions' => [ 'pluginOptions' => [
'autoclose' => true, 'autoclose' => true,
@ -53,7 +59,7 @@ JS;
<div class="box box-default"> <div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div> <div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div>
<div class="box-body"> <div class="box-body">
<?= $form->field($model->tags, 'new_tags')->widget(\kartik\widgets\Select2::classname(), [ <?= $form->field($model->tags, 'new_tags')->widget(Select2::class, [
'options' => [ 'options' => [
'placeholder' => Yii::t('post','Set tags...'), 'placeholder' => Yii::t('post','Set tags...'),
'multiple' => true, 'multiple' => true,
@ -82,7 +88,7 @@ JS;
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->textarea(['rows' => 5]) ?> <?= $form->field($model, 'description')->textarea(['rows' => 5]) ?>
<?= $form->field($model, 'content')->widget(CKEditor::className()) ?> <?= $form->field($model, 'content')->widget(CKEditor::class) ?>
</div> </div>
</div> </div>

7
backend/views/post/news/create.php

@ -1,8 +1,11 @@
<?php <?php
use core\entities\post\PostType;
use core\forms\post\PostForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Create Post'); $title = Yii::t('post', 'Create Post');
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

12
backend/views/post/news/index.php

@ -1,14 +1,18 @@
<?php <?php
use core\entities\post\Post; use core\entities\post\Post;
use core\entities\post\PostType;
use core\forms\post\search\PostSearch;
use core\helpers\PostHelper; use core\helpers\PostHelper;
use yii\grid\ActionColumn;
use yii\helpers\Html; use yii\helpers\Html;
use yii\grid\GridView; use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostSearch */ /* @var $searchModel PostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'All Posts'); $title = Yii::t('post', 'All Posts');
$this->title = $type->plural .' > '. $title; $this->title = $type->plural .' > '. $title;
@ -67,11 +71,11 @@ $this->params['breadcrumbs'][] = $title;
'contentOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'],
], ],
[ [
'class' => \yii\grid\ActionColumn::class, 'class' => ActionColumn::class,
'urlCreator' => function($action, Post $model, $key, $index, $column) { 'urlCreator' => function($action, Post $model, $key, $index, $column) {
$params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id]; $params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id];
$params[0] = $column->controller ? $column->controller . '/' . $action : $action; $params[0] = $column->controller ? $column->controller . '/' . $action : $action;
return \yii\helpers\Url::toRoute($params); return Url::toRoute($params);
}, },
'options' => ['style' => 'width: 100px;'], 'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'],

13
backend/views/post/news/update.php

@ -1,11 +1,16 @@
<?php <?php
use core\entities\post\Post;
use core\entities\post\PostType;
use core\forms\post\PostForm;
use yii\helpers\StringHelper;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */ /* @var $post Post */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Update Post: {name}', ['name' => \yii\helpers\StringHelper::truncateWords($post->title, 6, '...')]); $title = Yii::t('post', 'Update Post: {name}', ['name' => StringHelper::truncateWords($post->title, 6, '...')]);
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]]; $this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = ['label' => $type->singular, 'url' => ['view', 'id' => $post->id]]; $this->params['breadcrumbs'][] = ['label' => $type->singular, 'url' => ['view', 'id' => $post->id]];

6
backend/views/post/news/view.php

@ -1,14 +1,16 @@
<?php <?php
use core\entities\post\Post;
use core\entities\post\PostType;
use core\helpers\PostHelper; use core\helpers\PostHelper;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */ /* @var $post Post */
/* @var $modificationsProvider yii\data\ActiveDataProvider */ /* @var $modificationsProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = $post->title; $title = $post->title;
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

18
backend/views/post/post/_form.php

@ -1,19 +1,25 @@
<?php <?php
use core\forms\post\PostForm;
use kartik\file\FileInput; use kartik\file\FileInput;
use kartik\widgets\DateTimePicker;
use kartik\widgets\Select2;
use mihaildev\ckeditor\CKEditor; use mihaildev\ckeditor\CKEditor;
use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\bootstrap\ActiveForm; use yii\bootstrap\ActiveForm;
use yii\helpers\Json;
use yii\helpers\Url;
use yii\web\JsExpression; use yii\web\JsExpression;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
$fetchUrl = \yii\helpers\Url::to( [ 'tag-search' ] ); $fetchUrl = Url::to( [ 'tag-search' ] );
if (isset($model->_post)) { if (isset($model->_post)) {
$tagsJson = \yii\helpers\Json::encode( \yii\helpers\Json::encode( \yii\helpers\ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) ); $tagsJson = Json::encode( Json::encode( ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) );
$js = <<<JS $js = <<<JS
var arr = {$tagsJson}; var arr = {$tagsJson};
@ -38,7 +44,7 @@ JS;
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div> <div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body"> <div class="box-body">
<?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?> <?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?>
<?= $form->field($model, 'published_at')->widget(\kartik\widgets\DateTimePicker::classname(), [ <?= $form->field($model, 'published_at')->widget(DateTimePicker::class, [
'options' => [], 'options' => [],
'pluginOptions' => [ 'pluginOptions' => [
'autoclose' => true, 'autoclose' => true,
@ -52,7 +58,7 @@ JS;
<div class="box box-default"> <div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div> <div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div>
<div class="box-body"> <div class="box-body">
<?= $form->field($model->tags, 'new_tags')->widget(\kartik\widgets\Select2::classname(), [ <?= $form->field($model->tags, 'new_tags')->widget(Select2::class, [
'options' => [ 'options' => [
'placeholder' => Yii::t('post','Set tags...'), 'placeholder' => Yii::t('post','Set tags...'),
'multiple' => true, 'multiple' => true,
@ -81,7 +87,7 @@ JS;
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->textarea(['rows' => 5]) ?> <?= $form->field($model, 'description')->textarea(['rows' => 5]) ?>
<?= $form->field($model, 'content')->widget(CKEditor::className()) ?> <?= $form->field($model, 'content')->widget(CKEditor::class) ?>
</div> </div>
</div> </div>

7
backend/views/post/post/create.php

@ -1,8 +1,11 @@
<?php <?php
use core\entities\post\PostType;
use core\forms\post\PostForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Create Post'); $title = Yii::t('post', 'Create Post');
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

12
backend/views/post/post/index.php

@ -1,14 +1,18 @@
<?php <?php
use core\entities\post\Post; use core\entities\post\Post;
use core\entities\post\PostType;
use core\forms\post\search\PostSearch;
use core\helpers\PostHelper; use core\helpers\PostHelper;
use yii\grid\ActionColumn;
use yii\helpers\Html; use yii\helpers\Html;
use yii\grid\GridView; use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostSearch */ /* @var $searchModel PostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'All Posts'); $title = Yii::t('post', 'All Posts');
$this->title = $type->plural .' > '. $title; $this->title = $type->plural .' > '. $title;
@ -67,11 +71,11 @@ $this->params['breadcrumbs'][] = $title;
'contentOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'],
], ],
[ [
'class' => \yii\grid\ActionColumn::class, 'class' => ActionColumn::class,
'urlCreator' => function($action, Post $model, $key, $index, $column) { 'urlCreator' => function($action, Post $model, $key, $index, $column) {
$params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id]; $params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id];
$params[0] = $column->controller ? $column->controller . '/' . $action : $action; $params[0] = $column->controller ? $column->controller . '/' . $action : $action;
return \yii\helpers\Url::toRoute($params); return Url::toRoute($params);
}, },
'options' => ['style' => 'width: 100px;'], 'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'],

13
backend/views/post/post/update.php

@ -1,11 +1,16 @@
<?php <?php
use core\entities\post\Post;
use core\entities\post\PostType;
use core\forms\post\PostForm;
use yii\helpers\StringHelper;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */ /* @var $post Post */
/* @var $model \core\forms\post\PostForm */ /* @var $model PostForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Update Post: {name}', ['name' => \yii\helpers\StringHelper::truncateWords($post->title, 6, '...')]); $title = Yii::t('post', 'Update Post: {name}', ['name' => StringHelper::truncateWords($post->title, 6, '...')]);
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]]; $this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = ['label' => $type->singular, 'url' => ['view', 'id' => $post->id]]; $this->params['breadcrumbs'][] = ['label' => $type->singular, 'url' => ['view', 'id' => $post->id]];

6
backend/views/post/post/view.php

@ -1,14 +1,16 @@
<?php <?php
use core\entities\post\Post;
use core\entities\post\PostType;
use core\helpers\PostHelper; use core\helpers\PostHelper;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */ /* @var $post Post */
/* @var $modificationsProvider yii\data\ActiveDataProvider */ /* @var $modificationsProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = $post->title; $title = $post->title;
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

3
backend/views/post/tag/_form.php

@ -1,10 +1,11 @@
<?php <?php
use core\forms\post\PostTagSingleForm;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostTagSingleForm */ /* @var $model PostTagSingleForm */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
?> ?>

7
backend/views/post/tag/create.php

@ -1,8 +1,11 @@
<?php <?php
use core\entities\post\PostType;
use core\forms\post\PostTagSingleForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostTagSingleForm */ /* @var $model PostTagSingleForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Create Tag'); $title = Yii::t('post', 'Create Tag');
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

6
backend/views/post/tag/index.php

@ -1,14 +1,16 @@
<?php <?php
use core\entities\post\PostTag; use core\entities\post\PostTag;
use core\entities\post\PostType;
use core\forms\post\search\PostTagSearch;
use yii\grid\ActionColumn; use yii\grid\ActionColumn;
use yii\helpers\Html; use yii\helpers\Html;
use yii\grid\GridView; use yii\grid\GridView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostTagSearch */ /* @var $searchModel PostTagSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Tags'); $title = Yii::t('post', 'Tags');
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

10
backend/views/post/tag/update.php

@ -1,9 +1,13 @@
<?php <?php
use core\entities\post\PostTag;
use core\entities\post\PostType;
use core\forms\post\PostTagSingleForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $tag \core\entities\post\PostTag */ /* @var $tag PostTag */
/* @var $model \core\forms\post\PostTagSingleForm */ /* @var $model PostTagSingleForm */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = Yii::t('post', 'Update Tag: {name}', ['name' => $tag->name]); $title = Yii::t('post', 'Update Tag: {name}', ['name' => $tag->name]);
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

6
backend/views/post/tag/view.php

@ -1,11 +1,13 @@
<?php <?php
use core\entities\post\PostTag;
use core\entities\post\PostType;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $tag \core\entities\post\PostTag */ /* @var $tag PostTag */
/* @var $type \core\entities\post\PostType */ /* @var $type PostType */
$title = $tag->name; $title = $tag->name;
$this->title = $type->plural . ' > ' . $title; $this->title = $type->plural . ' > ' . $title;

3
backend/views/post/type/_form.php

@ -1,10 +1,11 @@
<?php <?php
use core\forms\post\PostTypeForm;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostTypeForm */ /* @var $model PostTypeForm */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
?> ?>

4
backend/views/post/type/create.php

@ -1,7 +1,9 @@
<?php <?php
use core\forms\post\PostTypeForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model \core\forms\post\PostTypeForm */ /* @var $model PostTypeForm */
$this->title = Yii::t('post', 'Create Type'); $this->title = Yii::t('post', 'Create Type');
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', 'Types'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => Yii::t('post', 'Types'), 'url' => ['index']];

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save