diff --git a/backend/controllers/ModuleController.php b/backend/controllers/ModuleController.php
new file mode 100644
index 0000000..230ee87
--- /dev/null
+++ b/backend/controllers/ModuleController.php
@@ -0,0 +1,92 @@
+service = $service;
+ }
+
+ public function behaviors(): array
+ {
+ return [
+ 'access' => [
+ 'class' => AccessControl::class,
+ 'rules' => [
+ [
+ 'actions' => ['list', 'disable', 'enable', 'delete'],
+ 'allow' => true,
+ 'roles' => ['ModuleManagement'],
+ ],
+ [ // all the action are accessible to admin
+ 'allow' => true,
+ 'roles' => ['admin'],
+ ],
+ ],
+ ],
+ 'verbs' => [
+ 'class' => VerbFilter::class,
+ 'actions' => [
+ 'delete' => ['POST'],
+ 'disable' => ['POST'],
+ 'enable' => ['POST'],
+ ],
+ ],
+ ];
+ }
+
+ public function actionList()
+ {
+ //$modules = ModuleRecord::find()->all();
+ $modules = \Yii::$app->moduleManager->getModules();
+
+ return $this->render('list', [
+ 'modules' => $modules,
+ ]);
+ }
+
+ public function actionDelete($id)
+ {
+ $module = $this->findModel($id);
+ $this->service->delete($module);
+ return $this->redirect(['module/list']);
+ }
+
+ public function actionDisable($id)
+ {
+ $module = $this->findModel($id);
+ $this->service->disable($module);
+ return $this->redirect(['module/list']);
+ }
+
+ public function actionEnable($id)
+ {
+ $module = $this->findModel($id);
+ $this->service->enable($module);
+ return $this->redirect(['module/list']);
+ }
+
+ protected function findModel($id): ModuleRecord
+ {
+ if (($model = ModuleRecord::findOne($id)) !== null) {
+ return $model;
+ }
+ throw new NotFoundHttpException('The requested module does not exist.');
+ }
+}
\ No newline at end of file
diff --git a/backend/messages/ru/main.php b/backend/messages/ru/main.php
index ab7246a..70d7c09 100644
--- a/backend/messages/ru/main.php
+++ b/backend/messages/ru/main.php
@@ -32,4 +32,8 @@ return [
'Url' => 'Ссылка',
'Sign in to start your session' => 'Вход в панель управления',
'You have {count} notifications' => 'Новых уведомлений: {count}',
+ 'Modules' => 'Модули',
+ 'Find modules' => 'Поиск модулей',
+ 'Enable' => 'Включить',
+ 'Disable' => 'Отключить'
];
\ No newline at end of file
diff --git a/backend/tests/functional/LoginCest.php b/backend/tests/functional/LoginCest.php
index 7346999..4fc860b 100644
--- a/backend/tests/functional/LoginCest.php
+++ b/backend/tests/functional/LoginCest.php
@@ -22,7 +22,7 @@ class LoginCest
{
return [
'user' => [
- 'class' => UserFixture::className(),
+ 'class' => UserFixture::class,
'dataFile' => codecept_data_dir() . 'login_data.php'
]
];
diff --git a/backend/views/layouts/left.php b/backend/views/layouts/left.php
index bf890e7..c21b92f 100644
--- a/backend/views/layouts/left.php
+++ b/backend/views/layouts/left.php
@@ -83,8 +83,13 @@ $model = new SearchForm();
'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('page', 'Pages'),
+ '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'),
diff --git a/backend/views/module/list.php b/backend/views/module/list.php
new file mode 100644
index 0000000..6872c8d
--- /dev/null
+++ b/backend/views/module/list.php
@@ -0,0 +1,70 @@
+title = Yii::t('main', 'Modules');
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
+
+
+ isEnabled() ? '#00aced' : '#cccccc';
+ if ($module->isDisabled()) {
+ ModuleHelper::addModuleAdminTranslation($module->name);
+ }
+
+ ?>
+
+
+
+
+
+
+ = Yii::t($module->name, $module->description) ?>
+
+
+
+
+
+
diff --git a/common/config/main.php b/common/config/main.php
index 70a843d..5ce84ec 100644
--- a/common/config/main.php
+++ b/common/config/main.php
@@ -5,6 +5,15 @@ return [
'@npm' => '@vendor/npm-asset',
],
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
+ 'controllerMap' => [
+ // Common migrations for the whole application
+ 'migrate' => [
+ 'class' => 'yii\console\controllers\MigrateController',
+ 'migrationPath' => [
+ '@console/migrations',
+ ],
+ ],
+ ],
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
@@ -35,5 +44,8 @@ return [
'texture_over_image' => false,
'text_over_image' => false,
],
+ 'moduleManager' => [
+ 'class' => \core\components\modules\ModuleManager::class,
+ ],
],
];
diff --git a/common/modules/banners/BannersModule.php b/common/modules/banners/BannersModule.php
new file mode 100644
index 0000000..d022e41
--- /dev/null
+++ b/common/modules/banners/BannersModule.php
@@ -0,0 +1,63 @@
+controllerMap['migrate']['migrationPath'][] = '@common/modules/banners/migrations';
+
+ // add search rules
+ $app->params['search_rules'][] = "SELECT title, CONCAT('/banners/manage/banner/view/', id) AS url FROM {{banners}}";
+
+ $app->getUrlManager()->addRules([
+ 'banners/manage/banner/view/' => 'banners/manage/banner/view',
+ ]);
+
+ // add languages
+ $app->getI18n()->translations = ArrayHelper::merge($app->getI18n()->translations, [
+ 'banners' => [
+ 'class' => 'yii\i18n\PhpMessageSource',
+ 'basePath' => '@common/modules/banners/messages',
+ ],
+ 'banners_public' => [
+ 'class' => 'yii\i18n\PhpMessageSource',
+ 'basePath' => '@common/modules/banners/messages',
+ ],
+ ]);
+
+ // add menu items
+ if (basename($app->getBasePath()) === 'backend') {
+ $app->params['adminMenu'][] = [
+ 'label' => \Yii::t( 'banners', 'Banners' ),
+ 'icon' => 'flag',
+ 'url' => [ '/banners/manage/banner/index' ],
+ 'visible' => \Yii::$app->user->can( 'admin' ) || \Yii::$app->user->can( 'BannersManagement' )
+ ];
+ }
+ }
+}
diff --git a/common/modules/banners/manifest.php b/common/modules/banners/manifest.php
new file mode 100644
index 0000000..185c75e
--- /dev/null
+++ b/common/modules/banners/manifest.php
@@ -0,0 +1,8 @@
+ '1.0.1',
+ 'name' => 'banners',
+ 'description' => 'Banners widget for site',
+ 'module' => 'BannersModule',
+];
\ No newline at end of file
diff --git a/common/modules/blog/BlogModule.php b/common/modules/blog/BlogModule.php
index bd76084..0ca7c56 100644
--- a/common/modules/blog/BlogModule.php
+++ b/common/modules/blog/BlogModule.php
@@ -22,12 +22,14 @@ class BlogModule extends \yii\base\Module implements ModuleInterface
public function init()
{
parent::init();
-
// custom initialization code goes here
}
public function bootstrap($app)
{
+ // add migration path
+ $app->controllerMap['migrate']['migrationPath'][] = '@common/modules/blog/migrations';
+
// add search rules
$app->params['search_rules'][] = "SELECT title, content, CONCAT('/blog/manage/post/view/', id) AS url FROM {{blog_posts}}";
diff --git a/common/modules/blog/forms/BlogPostForm.php b/common/modules/blog/forms/BlogPostForm.php
index ba7772b..ea265bd 100644
--- a/common/modules/blog/forms/BlogPostForm.php
+++ b/common/modules/blog/forms/BlogPostForm.php
@@ -108,7 +108,7 @@ class BlogPostForm extends CompositeForm
public function attributeHints() {
return [
'published_at' => Yii::t('blog', 'The article will be published after the specified date if its status is not a draft'),
- 'slug' => Yii::t('page', 'SEO link will be generated automatically if not specified'),
+ 'slug' => Yii::t('pages', 'SEO link will be generated automatically if not specified'),
];
}
diff --git a/common/modules/blog/forms/BlogTagSingleForm.php b/common/modules/blog/forms/BlogTagSingleForm.php
index e03f881..50f5fdb 100644
--- a/common/modules/blog/forms/BlogTagSingleForm.php
+++ b/common/modules/blog/forms/BlogTagSingleForm.php
@@ -45,7 +45,7 @@ class BlogTagSingleForm extends Model
public function attributeHints() {
return [
- 'slug' => Yii::t('page', 'SEO link will be generated automatically if not specified'),
+ 'slug' => Yii::t('pages', 'SEO link will be generated automatically if not specified'),
];
}
}
\ No newline at end of file
diff --git a/common/modules/blog/manifest.php b/common/modules/blog/manifest.php
new file mode 100644
index 0000000..a575267
--- /dev/null
+++ b/common/modules/blog/manifest.php
@@ -0,0 +1,8 @@
+ '1.0.1',
+ 'name' => 'blog',
+ 'description' => 'Blog system for site with comments and slug',
+ 'module' => 'BlogModule',
+];
\ No newline at end of file
diff --git a/common/modules/blog/messages/ru/blog.php b/common/modules/blog/messages/ru/blog.php
index 714f4e9..b7e6406 100644
--- a/common/modules/blog/messages/ru/blog.php
+++ b/common/modules/blog/messages/ru/blog.php
@@ -1,5 +1,7 @@
'Блог',
+ 'Blog system for site with comments and slug' => 'Публикация статей на сайте в виде ленты. Статьи разделены по категориям',
'All Posts' => 'Все статьи',
'Posts' => 'Статьи',
'Categories' => 'Категории',
diff --git a/common/modules/forms/FormsModule.php b/common/modules/forms/FormsModule.php
index 8dc03ec..de0d0cd 100644
--- a/common/modules/forms/FormsModule.php
+++ b/common/modules/forms/FormsModule.php
@@ -31,6 +31,9 @@ class FormsModule extends \yii\base\Module implements ModuleInterface
public function bootstrap($app)
{
+ // add migration path
+ $app->controllerMap['migrate']['migrationPath'][] = '@common/modules/forms/migrations';
+
// prepare rules
$app->getUrlManager()->addRules([
'forms/manage/form/view/' => 'forms/manage/form/view',
@@ -38,7 +41,7 @@ class FormsModule extends \yii\base\Module implements ModuleInterface
// add languages
$app->getI18n()->translations = ArrayHelper::merge($app->getI18n()->translations, [
- 'form' => [
+ 'forms' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@common/modules/forms/messages',
],
@@ -47,16 +50,16 @@ class FormsModule extends \yii\base\Module implements ModuleInterface
// add menu items
if (basename($app->getBasePath()) === 'backend') {
$app->params['adminMenu'][] = [
- 'label' => \Yii::t( 'form', 'Forms' ),
+ 'label' => \Yii::t( 'forms', 'Forms' ),
'icon' => 'address-card-o',
'items' => [
[
- 'label' => \Yii::t( 'form', 'Forms' ),
+ 'label' => \Yii::t( 'forms', 'Forms' ),
'icon' => 'caret-right',
'url' => [ '/forms/manage/form/index' ]
],
[
- 'label' => \Yii::t( 'form', 'Messages' ),
+ 'label' => \Yii::t( 'forms', 'Messages' ),
'icon' => 'caret-right',
'url' => [ '/forms/manage/form-message/index' ]
],
@@ -72,7 +75,7 @@ class FormsModule extends \yii\base\Module implements ModuleInterface
'icon' => 'address-card-o',
'color' => 'yellow',
'message' => 'New forms messages: {count}',
- 'message_file' => 'form',
+ 'message_file' => 'forms',
'url' => '/forms/manage/form-message/index',
'count' => $new_messages_count,
];
diff --git a/common/modules/forms/controllers/manage/FormMessageController.php b/common/modules/forms/controllers/manage/FormMessageController.php
index dd30637..3b06a8f 100644
--- a/common/modules/forms/controllers/manage/FormMessageController.php
+++ b/common/modules/forms/controllers/manage/FormMessageController.php
@@ -115,7 +115,7 @@ class FormMessageController extends Controller
];
}
}
- Yii::$app->session->setFlash('success', Yii::t('form', 'Selected messages deleted'));
+ Yii::$app->session->setFlash('success', Yii::t('forms', 'Selected messages deleted'));
return [
'result' => 'success',
];
diff --git a/common/modules/forms/entities/Form.php b/common/modules/forms/entities/Form.php
index 97de8c3..3eefb7e 100644
--- a/common/modules/forms/entities/Form.php
+++ b/common/modules/forms/entities/Form.php
@@ -97,16 +97,16 @@ class Form extends ActiveRecord
public function attributeLabels() {
return [
- 'name' => Yii::t('form', 'Name'),
- 'data' => Yii::t('form', 'Form'),
- 'subject' => Yii::t('form', 'Subject'),
- 'from' => Yii::t('form', 'From E-mail'),
- 'reply' => Yii::t('form', 'Reply E-mail'),
- 'return' => Yii::t('form', 'Return E-mail'),
- 'complete_text' => Yii::t('form', 'Complete Text'),
- 'complete_page_id' => Yii::t('form', 'Complete Page'),
- 'status' => Yii::t('form', 'Status'),
- 'captcha' => Yii::t('form', 'Use Captcha'),
+ 'name' => Yii::t('forms', 'Name'),
+ 'data' => Yii::t('forms', 'Form'),
+ 'subject' => Yii::t('forms', 'Subject'),
+ 'from' => Yii::t('forms', 'From E-mail'),
+ 'reply' => Yii::t('forms', 'Reply E-mail'),
+ 'return' => Yii::t('forms', 'Return E-mail'),
+ 'complete_text' => Yii::t('forms', 'Complete Text'),
+ 'complete_page_id' => Yii::t('forms', 'Complete Page'),
+ 'status' => Yii::t('forms', 'Status'),
+ 'captcha' => Yii::t('forms', 'Use Captcha'),
];
}
diff --git a/common/modules/forms/entities/FormMessage.php b/common/modules/forms/entities/FormMessage.php
index d44b05d..2983cb4 100644
--- a/common/modules/forms/entities/FormMessage.php
+++ b/common/modules/forms/entities/FormMessage.php
@@ -64,8 +64,8 @@ class FormMessage extends ActiveRecord
public function attributeLabels() {
return [
- 'form_id' => Yii::t('form', 'Form'),
- 'data' => Yii::t('form', 'Form Data'),
+ 'form_id' => Yii::t('forms', 'Form'),
+ 'data' => Yii::t('forms', 'Form Data'),
];
}
diff --git a/common/modules/forms/forms/FormForm.php b/common/modules/forms/forms/FormForm.php
index f5f475e..b16eb90 100644
--- a/common/modules/forms/forms/FormForm.php
+++ b/common/modules/forms/forms/FormForm.php
@@ -58,16 +58,16 @@ class FormForm extends Model
public function attributeLabels() {
return [
- 'name' => Yii::t('form', 'Name'),
- 'data' => Yii::t('form', 'Form'),
- 'subject' => Yii::t('form', 'Subject'),
- 'from' => Yii::t('form', 'From E-mail'),
- 'reply' => Yii::t('form', 'Reply E-mail'),
- 'return' => Yii::t('form', 'Return E-mail'),
- 'complete_text' => Yii::t('form', 'Complete Text'),
- 'complete_page_id' => Yii::t('form', 'Complete Page'),
- 'status' => Yii::t('form', 'Status'),
- 'captcha' => Yii::t('form', 'Use Captcha'),
+ 'name' => Yii::t('forms', 'Name'),
+ 'data' => Yii::t('forms', 'Form'),
+ 'subject' => Yii::t('forms', 'Subject'),
+ 'from' => Yii::t('forms', 'From E-mail'),
+ 'reply' => Yii::t('forms', 'Reply E-mail'),
+ 'return' => Yii::t('forms', 'Return E-mail'),
+ 'complete_text' => Yii::t('forms', 'Complete Text'),
+ 'complete_page_id' => Yii::t('forms', 'Complete Page'),
+ 'status' => Yii::t('forms', 'Status'),
+ 'captcha' => Yii::t('forms', 'Use Captcha'),
];
}
}
\ No newline at end of file
diff --git a/common/modules/forms/helpers/FormHelper.php b/common/modules/forms/helpers/FormHelper.php
index 1690ed7..0a62cd2 100644
--- a/common/modules/forms/helpers/FormHelper.php
+++ b/common/modules/forms/helpers/FormHelper.php
@@ -16,8 +16,8 @@ class FormHelper {
public static function statusList(): array
{
return [
- Form::STATUS_DRAFT => Yii::t('form', 'Draft'),
- Form::STATUS_ACTIVE => Yii::t('form', 'Active'),
+ Form::STATUS_DRAFT => Yii::t('forms', 'Draft'),
+ Form::STATUS_ACTIVE => Yii::t('forms', 'Active'),
];
}
diff --git a/common/modules/forms/mail/form-html.php b/common/modules/forms/mail/form-html.php
index 0bf625c..50b867a 100644
--- a/common/modules/forms/mail/form-html.php
+++ b/common/modules/forms/mail/form-html.php
@@ -10,7 +10,7 @@
*/
?>
-= Yii::t('form', 'Message from site') ?>
+= Yii::t('forms', 'Message from site') ?>
= $item['key'] ?>: = $item['value'] ?>
diff --git a/common/modules/forms/mail/form-text.php b/common/modules/forms/mail/form-text.php
index 1068ef0..4ec8c6c 100644
--- a/common/modules/forms/mail/form-text.php
+++ b/common/modules/forms/mail/form-text.php
@@ -10,7 +10,7 @@
*/
?>
-= Yii::t('form', 'Message from site') ?>
+= Yii::t('forms', 'Message from site') ?>
-------
diff --git a/common/modules/forms/manifest.php b/common/modules/forms/manifest.php
new file mode 100644
index 0000000..fea09de
--- /dev/null
+++ b/common/modules/forms/manifest.php
@@ -0,0 +1,8 @@
+ '1.0.1',
+ 'name' => 'forms',
+ 'description' => 'Form widget generator for site',
+ 'module' => 'FormsModule',
+];
\ No newline at end of file
diff --git a/common/modules/forms/messages/ru/form.php b/common/modules/forms/messages/ru/forms.php
similarity index 90%
rename from common/modules/forms/messages/ru/form.php
rename to common/modules/forms/messages/ru/forms.php
index 593f1da..13df562 100644
--- a/common/modules/forms/messages/ru/form.php
+++ b/common/modules/forms/messages/ru/forms.php
@@ -1,5 +1,7 @@
'Формы',
+ 'Form widget generator for site' => 'Создание различных форм для сайта с отправкой на e-mail и уведомлениями',
'Form' => 'Форма',
'Forms' => 'Формы',
'Messages' => 'Сообщения',
diff --git a/common/modules/forms/views/manage/form-message/index.php b/common/modules/forms/views/manage/form-message/index.php
index 212833c..7c76bd7 100644
--- a/common/modules/forms/views/manage/form-message/index.php
+++ b/common/modules/forms/views/manage/form-message/index.php
@@ -13,7 +13,7 @@ use backend\widgets\grid\CheckBoxColumn;
/* @var $searchModel \common\modules\forms\forms\FormMessageSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
-$this->title = Yii::t('form', 'Messages');
+$this->title = Yii::t('forms', 'Messages');
$this->params['breadcrumbs'][] = $this->title;
$js = <<registerJs($js, $this::POS_READY);
-$deleteConfirmMessage = Yii::t('form', 'Are you sure you want to delete selected messages?');
+$deleteConfirmMessage = Yii::t('forms', 'Are you sure you want to delete selected messages?');
$deleteSelectedUrl = Url::to(['delete-selected']);
$unreadSelectedUrl = Url::to(['unread-selected']);
$readSelectedUrl = Url::to(['read-selected']);
@@ -89,7 +89,7 @@ $this->registerJs($js2, $this::POS_HEAD);
- = Html::a(Yii::t('form', 'Group actions {caret}', ['caret' => '
']), '#', [
+ = Html::a(Yii::t('forms', 'Group actions {caret}', ['caret' => '']), '#', [
'class' => 'btn btn-default dropdown-toggle disabled',
'id' => 'groupActions',
'disabled' => 'disabled',
@@ -99,14 +99,14 @@ $this->registerJs($js2, $this::POS_HEAD);
]) ?>
@@ -128,7 +128,7 @@ $this->registerJs($js2, $this::POS_HEAD);
'contentOptions' => ['class' => 'text-center'],
],
[
- 'label' => Yii::t('form', 'Date'),
+ 'label' => Yii::t('forms', 'Date'),
'attribute' => 'created_at',
'value' => function(FormMessage $model) {
return date('d.m.Y H:i', $model->created_at);
@@ -136,7 +136,7 @@ $this->registerJs($js2, $this::POS_HEAD);
'options' => ['style' => 'width: 100px;'],
],
[
- 'label' => Yii::t('form', 'Form'),
+ 'label' => Yii::t('forms', 'Form'),
'filter' => ArrayHelper::map(Form::find()->all(), 'id', 'name'),
'attribute' => 'form_id',
'value' => function (FormMessage $model) {
diff --git a/common/modules/forms/views/manage/form-message/view.php b/common/modules/forms/views/manage/form-message/view.php
index 24a1ed5..b0c8066 100644
--- a/common/modules/forms/views/manage/form-message/view.php
+++ b/common/modules/forms/views/manage/form-message/view.php
@@ -9,7 +9,7 @@ use yii\helpers\Json;
/* @var $message FormMessage */
$this->title = $message->form->name . ': ' . date('d.m.Y H:i', $message->created_at);
-$this->params['breadcrumbs'][] = ['label' => Yii::t('form', 'Messages'), 'url' => ['index']];
+$this->params['breadcrumbs'][] = ['label' => Yii::t('forms', 'Messages'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$data = Json::decode($message->data, true);
@@ -17,7 +17,7 @@ $data = Json::decode($message->data, true);
- = Html::a(Yii::t('form','Messages'), ['index'], ['class' => 'btn btn-default']) ?>
+ = Html::a(Yii::t('forms','Messages'), ['index'], ['class' => 'btn btn-default']) ?>
= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'id' => $message->id], [
'class' => 'btn btn-danger',
'data' => [
@@ -50,7 +50,7 @@ $data = Json::decode($message->data, true);