diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e91962..84cefe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ Changelog ========= +## 1.1.3 (2019-08-06) + * Minor bug fixies + ## 1.1.2 (2019-07-29) * Bugfix in composer.json, controllers and view diff --git a/Module.php b/Module.php index f677355..ff39728 100644 --- a/Module.php +++ b/Module.php @@ -6,7 +6,7 @@ * Yii2 Pages * * @category Module - * @version 1.1.2 + * @version 1.1.3 * @author Alexsander Vyshnyvetskyy * @link https://github.com/wdmg/yii2-pages * @copyright Copyright (c) 2019 W.D.M.Group, Ukraine @@ -46,7 +46,7 @@ class Module extends BaseModule /** * @var string the module version */ - private $version = "1.1.2"; + private $version = "1.1.3"; /** * @var integer, priority of initialization diff --git a/README.md b/README.md index ec095aa..f7125e5 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,6 @@ Use the `Module::dashboardNavItems()` method of the module to generate a navigat ?> # Status and version [in progress development] +* v.1.1.3 - Minor bug fixies * v.1.1.2 - Bugfix in composer.json, controllers and view * v.1.1.1 - Added support of redirects, fixing route detection and added sluggable behavior for aliases -* v.1.1.0 - Added routing functionality \ No newline at end of file diff --git a/composer.json b/composer.json index 7f09777..2d18961 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "keywords": ["yii2", "yii2-pages", "static", "pages", "wdmg"], "type": "yii2-extension", "license": "MIT", - "version": "1.1.2", + "version": "1.1.3", "homepage": "https://github.com/wdmg/yii2-pages", "support": { "source": "https://github.com/wdmg/yii2-pages", @@ -35,7 +35,7 @@ "extra": { "options": { "routePrefix": "admin", - "pagesRoute": "pages", + "pagesRoute": "/pages", "pagesLayout": "@app/views/layouts/main" } } diff --git a/controllers/DefaultController.php b/controllers/DefaultController.php index 35dbcc9..6b21544 100644 --- a/controllers/DefaultController.php +++ b/controllers/DefaultController.php @@ -46,7 +46,7 @@ public function actionIndex($page, $route = null) return Yii::$app->redirects->check(Yii::$app->request->getUrl()); } - // Separate route from page alias from request URL + // Separate route from request URL if (is_null($route) && preg_match('/^([\/]+[A-Za-z0-9_\-\_\/]+[\/])*([A-Za-z0-9_\-\_]*)/i', Yii::$app->request->url,$matches)) { if ($page == $matches[2]) $route = rtrim($matches[1], '/'); diff --git a/controllers/PagesController.php b/controllers/PagesController.php index 5c2625e..1aafe21 100644 --- a/controllers/PagesController.php +++ b/controllers/PagesController.php @@ -105,7 +105,7 @@ public function actionCreate() if($model->save()) Yii::$app->getSession()->setFlash( 'success', - Yii::t('app/modules/pages', 'Page has been successfully addedet!') + Yii::t('app/modules/pages', 'Page has been successfully added!') ); else Yii::$app->getSession()->setFlash( @@ -124,8 +124,6 @@ public function actionCreate() } - - /** * Updates an existing Page model. * If update is successful, the browser will be redirected to the 'view' page. diff --git a/messages/ru-RU/app/modules/pages.php b/messages/ru-RU/app/modules/pages.php index c72c1af..743c385 100644 --- a/messages/ru-RU/app/modules/pages.php +++ b/messages/ru-RU/app/modules/pages.php @@ -53,7 +53,7 @@ 'The requested page does not exist.' => "Запрошенная страница не существует.", - 'Page has been successfully addedet!' => "Страница была успешно добавлена!", + 'Page has been successfully added!' => "Страница была успешно добавлена!", 'An error occurred while add the page.' => "Произошла ошибка при добавлении страницы.", ]; \ No newline at end of file diff --git a/migrations/m190725_005152_pages.php b/migrations/m190725_005152_pages.php index 3e9ab73..7a1bc1b 100644 --- a/migrations/m190725_005152_pages.php +++ b/migrations/m190725_005152_pages.php @@ -38,6 +38,21 @@ public function safeUp() $this->createIndex('{{%idx-pages-alias}}', '{{%pages}}', ['name', 'alias']); $this->createIndex('{{%idx-pages-status}}', '{{%pages}}', ['alias', 'status']); + $this->createIndex('{{%idx-pages-author}}','{{%pages}}', ['created_by', 'updated_by'],false); + + // If exist module `Users` set foreign key `created_by`, `updated_by` to `users.id` + if(class_exists('\wdmg\users\models\Users') && isset(Yii::$app->modules['users'])) { + $userTable = \wdmg\users\models\Users::tableName(); + $this->addForeignKey( + 'fk_pages_to_users', + '{{%pages}}', + 'created_by, updated_by', + $userTable, + 'id', + 'NO ACTION', + 'CASCADE' + ); + } } @@ -46,9 +61,21 @@ public function safeUp() */ public function safeDown() { - $this->truncateTable('{{%pages}}'); $this->dropIndex('{{%idx-pages-alias}}', '{{%pages}}'); $this->dropIndex('{{%idx-pages-status}}', '{{%pages}}'); + $this->dropIndex('{{%idx-pages-author}}', '{{%pages}}'); + + if(class_exists('\wdmg\users\models\Users') && isset(Yii::$app->modules['users'])) { + $userTable = \wdmg\users\models\Users::tableName(); + if (!(Yii::$app->db->getTableSchema($userTable, true) === null)) { + $this->dropForeignKey( + 'fk_pages_to_users', + '{{%pages}}' + ); + } + } + + $this->truncateTable('{{%pages}}'); $this->dropTable('{{%pages}}'); }