Skip to content

Commit

Permalink
Minor bug fixies
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-wdmg committed Aug 6, 2019
1 parent 5d3ac60 commit e9e7047
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Yii2 Pages
*
* @category Module
* @version 1.1.2
* @version 1.1.3
* @author Alexsander Vyshnyvetskyy <[email protected]>
* @link https://github.com/wdmg/yii2-pages
* @copyright Copyright (c) 2019 W.D.M.Group, Ukraine
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -35,7 +35,7 @@
"extra": {
"options": {
"routePrefix": "admin",
"pagesRoute": "pages",
"pagesRoute": "/pages",
"pagesLayout": "@app/views/layouts/main"
}
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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], '/');
Expand Down
4 changes: 1 addition & 3 deletions controllers/PagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion messages/ru-RU/app/modules/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.' => "Произошла ошибка при добавлении страницы.",

];
29 changes: 28 additions & 1 deletion migrations/m190725_005152_pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
}

}

Expand All @@ -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}}');
}

Expand Down

0 comments on commit e9e7047

Please sign in to comment.