code review

This commit is contained in:
Jean-Christian Paul Denis 2023-10-24 11:43:11 +02:00
parent de46d49d77
commit 35b0d4a0bc
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
8 changed files with 19 additions and 13 deletions

View File

@ -1,5 +1,12 @@
alias 1.10 - 2023.10.15 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 Dotclear 2.28
* require PHP 8.1 * require PHP 8.1
* Upgrade to Dotclear 2.28 * Upgrade to Dotclear 2.28

View File

@ -1,7 +1,7 @@
# README # README
[![Release](https://img.shields.io/badge/release-1.10-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/alias/releases) [![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.15-c44d58.svg) ![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) [![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) [![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) [![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/alias/src/branch/master/LICENSE)

View File

@ -18,7 +18,7 @@ $this->registerModule(
'alias', 'alias',
"Create aliases of your blog's URLs", "Create aliases of your blog's URLs",
'Olivier Meunier and contributors', 'Olivier Meunier and contributors',
'1.10', '1.11',
[ [
'requires' => [['core', '2.28']], 'requires' => [['core', '2.28']],
'permissions' => 'My', 'permissions' => 'My',

View File

@ -2,10 +2,10 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="alias"> <module id="alias">
<name>alias</name> <name>alias</name>
<version>1.10</version> <version>1.11</version>
<author>Olivier Meunier and contributors</author> <author>Olivier Meunier and contributors</author>
<desc>Create aliases of your blog's URLs</desc> <desc>Create aliases of your blog's URLs</desc>
<file>https://git.dotclear.watch/JcDenis/alias/releases/download/v1.10/plugin-alias.zip</file> <file>https://git.dotclear.watch/JcDenis/alias/releases/download/v1.11/plugin-alias.zip</file>
<da:dcmin>2.28</da:dcmin> <da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/alias/src/branch/master/README.md</da:details> <da:details>https://git.dotclear.watch/JcDenis/alias/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/alias/issues</da:support> <da:support>https://git.dotclear.watch/JcDenis/alias/issues</da:support>

View File

@ -104,7 +104,7 @@ class Alias
* *
* @param AliasRow $alias The new Alias descriptor * @param AliasRow $alias The new Alias descriptor
*/ */
public function createAlias(AliasRow $alias):void public function createAlias(AliasRow $alias): void
{ {
if (!App::blog()->isDefined()) { if (!App::blog()->isDefined()) {
return; return;
@ -123,7 +123,7 @@ class Alias
$cur = App::con()->openCursor(App::con()->prefix() . Alias::ALIAS_TABLE_NAME); $cur = App::con()->openCursor(App::con()->prefix() . Alias::ALIAS_TABLE_NAME);
$cur->setField('blog_id', App::blog()->id()); $cur->setField('blog_id', App::blog()->id());
$cur->setField('alias_url', $url); $cur->setField('alias_url', $url);
$cur->setField('alias_destination',$destination); $cur->setField('alias_destination', $destination);
$cur->setField('alias_position', $alias->position); $cur->setField('alias_position', $alias->position);
$cur->setField('alias_redirect', (int) $alias->redirect); $cur->setField('alias_redirect', (int) $alias->redirect);
$cur->insert(); $cur->insert();

View File

@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Dotclear\Plugin\alias; namespace Dotclear\Plugin\alias;
use Dotclear\App;
use Dotclear\Database\MetaRecord; use Dotclear\Database\MetaRecord;
/** /**

View File

@ -58,9 +58,9 @@ class Manage extends Process
if (isset($_POST['a']) && is_array($_POST['a'])) { if (isset($_POST['a']) && is_array($_POST['a'])) {
try { try {
$stack = []; $stack = [];
foreach($_POST['a'] as $alias) { foreach ($_POST['a'] as $alias) {
$stack[] = new AliasRow( $stack[] = new AliasRow(
$alias['alias_url'] ?? '', $alias['alias_url'] ?? '',
$alias['alias_destination'] ?? '', $alias['alias_destination'] ?? '',
(int) ($alias['alias_position'] ?? 0), (int) ($alias['alias_position'] ?? 0),
!empty($alias['alias_redirect']), !empty($alias['alias_redirect']),