From 35b0d4a0bc083fa8ea3547a17b04c767e7dfd271 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Tue, 24 Oct 2023 11:43:11 +0200 Subject: [PATCH] code review --- CHANGELOG.md | 7 +++++++ README.md | 4 ++-- _define.php | 2 +- dcstore.xml | 4 ++-- src/Alias.php | 4 ++-- src/AliasRow.php | 3 +-- src/Manage.php | 4 ++-- src/PluginImportExportBehaviors.php | 4 ++-- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72b337b..8e8f7f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ alias 1.10 - 2023.10.15 =========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Use class for alias row +* Code review + +alias 1.11 - 2023.10.23 +=========================================================== * require Dotclear 2.28 * require PHP 8.1 * Upgrade to Dotclear 2.28 diff --git a/README.md b/README.md index 331eed6..cc633a0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # README -[![Release](https://img.shields.io/badge/release-1.10-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/alias/releases) -![Date](https://img.shields.io/badge/date-2023.10.15-c44d58.svg) +[![Release](https://img.shields.io/badge/release-1.11-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/alias/releases) +![Date](https://img.shields.io/badge/date-2023.10.23-c44d58.svg) [![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/alias) [![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/alias/src/branch/master/LICENSE) diff --git a/_define.php b/_define.php index c766234..11f0d06 100644 --- a/_define.php +++ b/_define.php @@ -18,7 +18,7 @@ $this->registerModule( 'alias', "Create aliases of your blog's URLs", 'Olivier Meunier and contributors', - '1.10', + '1.11', [ 'requires' => [['core', '2.28']], 'permissions' => 'My', diff --git a/dcstore.xml b/dcstore.xml index 35a9fbd..4f43479 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,10 +2,10 @@ alias - 1.10 + 1.11 Olivier Meunier and contributors Create aliases of your blog's URLs - https://git.dotclear.watch/JcDenis/alias/releases/download/v1.10/plugin-alias.zip + https://git.dotclear.watch/JcDenis/alias/releases/download/v1.11/plugin-alias.zip 2.28 https://git.dotclear.watch/JcDenis/alias/src/branch/master/README.md https://git.dotclear.watch/JcDenis/alias/issues diff --git a/src/Alias.php b/src/Alias.php index cdf9bca..0086d76 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -104,7 +104,7 @@ class Alias * * @param AliasRow $alias The new Alias descriptor */ - public function createAlias(AliasRow $alias):void + public function createAlias(AliasRow $alias): void { if (!App::blog()->isDefined()) { return; @@ -123,7 +123,7 @@ class Alias $cur = App::con()->openCursor(App::con()->prefix() . Alias::ALIAS_TABLE_NAME); $cur->setField('blog_id', App::blog()->id()); $cur->setField('alias_url', $url); - $cur->setField('alias_destination',$destination); + $cur->setField('alias_destination', $destination); $cur->setField('alias_position', $alias->position); $cur->setField('alias_redirect', (int) $alias->redirect); $cur->insert(); diff --git a/src/AliasRow.php b/src/AliasRow.php index e370e49..07d5972 100644 --- a/src/AliasRow.php +++ b/src/AliasRow.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace Dotclear\Plugin\alias; -use Dotclear\App; use Dotclear\Database\MetaRecord; /** @@ -39,4 +38,4 @@ class AliasRow !empty($rs->field('alias_redirect')) ); } -} \ No newline at end of file +} diff --git a/src/Manage.php b/src/Manage.php index f5d4939..48c9705 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -58,9 +58,9 @@ class Manage extends Process if (isset($_POST['a']) && is_array($_POST['a'])) { try { $stack = []; - foreach($_POST['a'] as $alias) { + foreach ($_POST['a'] as $alias) { $stack[] = new AliasRow( - $alias['alias_url'] ?? '', + $alias['alias_url'] ?? '', $alias['alias_destination'] ?? '', (int) ($alias['alias_position'] ?? 0), !empty($alias['alias_redirect']), diff --git a/src/PluginImportExportBehaviors.php b/src/PluginImportExportBehaviors.php index 1e7c8b5..49d8bba 100644 --- a/src/PluginImportExportBehaviors.php +++ b/src/PluginImportExportBehaviors.php @@ -56,7 +56,7 @@ class PluginImportExportBehaviors $bk->__get('cur_alias')->insert(); } } - + public static function importSingleV2(bool|FlatBackupItem $line, FlatImportV2 $bk): void { if (!is_bool($line) && $line->__name == Alias::ALIAS_TABLE_NAME) { @@ -72,4 +72,4 @@ class PluginImportExportBehaviors $bk->__get('alias')->createAlias(new AliasRow($line->f('alias_url'), $line->f('alias_destination'), $line->f('alias_position'), $line->f('alias_redirect'))); } } -} \ No newline at end of file +}