release 1.8

This commit is contained in:
Jean-Christian Denis 2023-07-30 08:57:58 +02:00
parent 009c82c98c
commit 924b96126d
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
11 changed files with 77 additions and 146 deletions

View file

@ -1,3 +1,8 @@
1.8 - 2023.07.30
- require Dotclear 2.27
- require PHP 7.4+
- update to Dotclear 2.27-dev
1.7.1 - 2023.06.16 1.7.1 - 2023.06.16
- require dotclear 2.26 - require dotclear 2.26
- fix non php 7.4 type hint - fix non php 7.4 type hint

View file

@ -3,7 +3,7 @@
[![Release](https://img.shields.io/github/v/release/JcDenis/alias)](https://github.com/JcDenis/alias/releases) [![Release](https://img.shields.io/github/v/release/JcDenis/alias)](https://github.com/JcDenis/alias/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/alias)](https://github.com/JcDenis/alias/releases) [![Date](https://img.shields.io/github/release-date/JcDenis/alias)](https://github.com/JcDenis/alias/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/alias)](https://github.com/JcDenis/alias/issues) [![Issues](https://img.shields.io/github/issues/JcDenis/alias)](https://github.com/JcDenis/alias/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download) [![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/alias) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/alias)
[![License](https://img.shields.io/github/license/JcDenis/alias)](https://github.com/JcDenis/alias/blob/master/LICENSE) [![License](https://img.shields.io/github/license/JcDenis/alias)](https://github.com/JcDenis/alias/blob/master/LICENSE)
@ -18,8 +18,9 @@ This plugin creates public aliases of your blog's URLs.
_alias_ requires: _alias_ requires:
* admin permissions for management * admin permissions for management
* Dotclear 2.26 * Dotclear 2.27
* PHP 7.4+
## USAGE ## USAGE

View file

@ -10,7 +10,7 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
@ -18,9 +18,9 @@ $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.7.1', '1.8',
[ [
'requires' => [['core', '2.26']], 'requires' => [['core', '2.27']],
'permissions' => dcCore::app()->auth->makePermissions([ 'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_ADMIN, dcCore::app()->auth::PERMISSION_ADMIN,
]), ]),

View file

@ -2,11 +2,11 @@
<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.7.1</version> <version>1.8</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://github.com/JcDenis/alias/releases/download/v1.7.1/plugin-alias.zip</file> <file>https://github.com/JcDenis/alias/releases/download/v1.8/plugin-alias.zip</file>
<da:dcmin>2.26</da:dcmin> <da:dcmin>2.27</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/alias</da:details> <da:details>https://plugins.dotaddict.org/dc2/details/alias</da:details>
<da:support>https://github.com/JcDenis/alias</da:support> <da:support>https://github.com/JcDenis/alias</da:support>
</module> </module>

View file

@ -1,96 +1,71 @@
# Language: Français
# Module: alias - 1.6
# Date: 2023-04-30 22:52:13
# Author: Jean-Christian Denis
# Translated with translater 2023.04.23
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: alias 1.6\n" "Project-Id-Version: alias 1.7.1\n"
"POT-Creation-Date: \n" "POT-Creation-Date: \n"
"PO-Revision-Date: 2023-04-30T22:52:13+00:00\n" "PO-Revision-Date: 2023-07-29T12:49:07+00:00\n"
"Last-Translator: Jean-Christian Denis\n" "Last-Translator: Jean-Christain Denis\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: src/Alias.php:75
msgid "Invalid aliases definitions" msgid "Invalid aliases definitions"
msgstr "Définitions d'alias invalides" msgstr "Définitions d'alias invalides"
#: src/Alias.php:116
msgid "Alias URL is empty." msgid "Alias URL is empty."
msgstr "L'URL de l'alias est vide." msgstr "L'URL de l'alias est vide."
#: src/Alias.php:119
msgid "Alias destination is empty." msgid "Alias destination is empty."
msgstr "La destination de l'alias est vide." msgstr "La destination de l'alias est vide."
#: src/Manage.php:74
msgid "Aliases successfully updated." msgid "Aliases successfully updated."
msgstr "Alias mis à jour avec succès." msgstr "Alias mis à jour avec succès."
#: src/Manage.php:85
msgid "Alias successfully created." msgid "Alias successfully created."
msgstr "Alias créer avec succès." msgstr "Alias créer avec succès."
#: src/Manage.php:116
msgid "New alias" msgid "New alias"
msgstr "Nouvel alias" msgstr "Nouvel alias"
#: src/Manage.php:124
msgid "Alias URL:" msgid "Alias URL:"
msgstr "URL de l'alias :" msgstr "URL de l'alias :"
#: src/Manage.php:128
msgid "Alias destination:" msgid "Alias destination:"
msgstr "Destination de l'alias :" msgstr "Destination de l'alias :"
#: src/Manage.php:131
msgid "Do not put blog URL \"%s\" in fields." msgid "Do not put blog URL \"%s\" in fields."
msgstr "Ne pas mettre l'URL du blog \"%s\" dans les champs." msgstr "Ne pas mettre l'URL du blog \"%s\" dans les champs."
#: src/Manage.php:134
msgid "Do visible redirection to destination" msgid "Do visible redirection to destination"
msgstr "Faire une redirection visible vers la destination" msgstr "Faire une redirection visible vers la destination"
#: src/Manage.php:155
msgid "No alias" msgid "No alias"
msgstr "Aucun alias" msgstr "Aucun alias"
#: src/Manage.php:159
msgid "There is %s alias." msgid "There is %s alias."
msgid_plural "There are %s aliases." msgid_plural "There are %s aliases."
msgstr[0] "Il y a %s alias." msgstr[0] "Il y a %s alias."
msgstr[1] "Il y a %s alias." msgstr[1] "Il y a %s alias."
#: src/Manage.php:162
msgid "Aliases list" msgid "Aliases list"
msgstr "Liste des alias" msgstr "Liste des alias"
#: src/Manage.php:165
msgid "Alias URL" msgid "Alias URL"
msgstr "URL de l'alias" msgstr "URL de l'alias"
#: src/Manage.php:166
msgid "Alias destination" msgid "Alias destination"
msgstr "Destination de l'alias" msgstr "Destination de l'alias"
#: src/Manage.php:167
msgid "Alias position" msgid "Alias position"
msgstr "Position de l'alias" msgstr "Position de l'alias"
#: src/Manage.php:168
msgid "Redrection" msgid "Redrection"
msgstr "Redirection" msgstr "Redirection"
#: src/Manage.php:182
msgid "visible redirection to %s" msgid "visible redirection to %s"
msgstr "Redirection visible vers %s" msgstr "Redirection visible vers %s"
#: src/Manage.php:188
msgid "To remove an alias, empty its URL or destination." msgid "To remove an alias, empty its URL or destination."
msgstr "Pour supprimer un alias, videz son URL ou sa destination." msgstr "Pour supprimer un alias, videz son URL ou sa destination."

View file

@ -14,45 +14,28 @@ declare(strict_types=1);
namespace Dotclear\Plugin\alias; namespace Dotclear\Plugin\alias;
use dcAdmin;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
use dcPage; use Dotclear\Plugin\importExport\{
use Dotclear\Plugin\importExport\FlatBackupItem; FlatBackupItem,
use Dotclear\Plugin\importExport\FlatExport; FlatExport,
use Dotclear\Plugin\importExport\FlatImportV2; FlatImportV2
};
class Backend extends dcNsProcess class Backend extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN') return self::status(My::checkContext(My::BACKEND));
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog) //nullsafe PHP < 8.0
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_ADMIN,
]), dcCore::app()->blog->id);
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init) { if (!self::status()) {
return false; return false;
} }
// nullsafe PHP < 8.0 My::addBackendMenuItem();
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
return false;
}
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
My::name(),
dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
dcPage::getPF(My::id() . '/icon.svg'),
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]), dcCore::app()->blog->id)
);
dcCore::app()->addBehaviors([ dcCore::app()->addBehaviors([
'exportFullV2' => function (FlatExport $exp): void { 'exportFullV2' => function (FlatExport $exp): void {

View file

@ -15,22 +15,20 @@ declare(strict_types=1);
namespace Dotclear\Plugin\alias; namespace Dotclear\Plugin\alias;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
use Dotclear\Database\Structure; use Dotclear\Database\Structure;
use Exception; use Exception;
class Install extends dcNsProcess class Install extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version')); return self::status(My::checkContext(My::INSTALL));
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init) { if (!self::status()) {
return false; return false;
} }

View file

@ -15,8 +15,11 @@ declare(strict_types=1);
namespace Dotclear\Plugin\alias; namespace Dotclear\Plugin\alias;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
use dcPage; use Dotclear\Core\Backend\{
Notices,
Page
};
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Checkbox, Checkbox,
Div, Div,
@ -36,27 +39,16 @@ use Exception;
/** /**
* Manage contributions list * Manage contributions list
*/ */
class Manage extends dcNsProcess class Manage extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN') return self::status(My::checkContext(My::MANAGE));
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog) //nullsafe PHP < 8.0
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_ADMIN,
]), dcCore::app()->blog->id);
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init) { if (!self::status()) {
return false;
}
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
return false; return false;
} }
@ -71,8 +63,8 @@ class Manage extends dcNsProcess
if (isset($_POST['a']) && is_array($_POST['a'])) { if (isset($_POST['a']) && is_array($_POST['a'])) {
try { try {
$alias->updateAliases($_POST['a']); $alias->updateAliases($_POST['a']);
dcPage::addSuccessNotice(__('Aliases successfully updated.')); Notices::addSuccessNotice(__('Aliases successfully updated.'));
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id()); My::redirect();
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
@ -82,8 +74,8 @@ class Manage extends dcNsProcess
if (isset($_POST['alias_url'])) { if (isset($_POST['alias_url'])) {
try { try {
$alias->createAlias($_POST['alias_url'], $_POST['alias_destination'], count($aliases) + 1, !empty($_POST['alias_redirect'])); $alias->createAlias($_POST['alias_url'], $_POST['alias_destination'], count($aliases) + 1, !empty($_POST['alias_redirect']));
dcPage::addSuccessNotice(__('Alias successfully created.')); Notices::addSuccessNotice(__('Alias successfully created.'));
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id()); My::redirect();
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
@ -94,28 +86,23 @@ class Manage extends dcNsProcess
public static function render(): void public static function render(): void
{ {
if (!static::$init) { if (!self::status()) {
return;
}
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
return; return;
} }
$alias = new Alias(); $alias = new Alias();
$aliases = $alias->getAliases(); $aliases = $alias->getAliases();
dcPage::openModule(My::name()); Page::openModule(My::name());
if (($_REQUEST['part'] ?? 'list') == 'new') { if (($_REQUEST['part'] ?? 'list') == 'new') {
echo echo
dcPage::breadcrumb([ Page::breadcrumb([
__('Plugins') => '', __('Plugins') => '',
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'list']), My::name() => My::manageUrl(['part' => 'list']),
__('New alias') => '', __('New alias') => '',
]) . ]) .
dcPage::notices() . Notices::getNotices() .
(new Div())->items([ (new Div())->items([
(new Text('h3', __('New alias'))), (new Text('h3', __('New alias'))),
@ -134,21 +121,22 @@ class Manage extends dcNsProcess
(new Label(__('Do visible redirection to destination'), Label::OUTSIDE_LABEL_AFTER))->for('alias_redirect')->class('classic'), (new Label(__('Do visible redirection to destination'), Label::OUTSIDE_LABEL_AFTER))->for('alias_redirect')->class('classic'),
]), ]),
(new Para())->items([ (new Para())->items([
dcCore::app()->formNonce(false),
(new Hidden('part', 'new')),
(new Submit(['do']))->value(__('Save')), (new Submit(['do']))->value(__('Save')),
... My::hiddenFields([
'part' => 'new',
]),
]), ]),
]), ]),
])->render(); ])->render();
} else { } else {
echo echo
dcPage::breadcrumb([ Page::breadcrumb([
__('Plugins') => '', __('Plugins') => '',
My::name() => '', My::name() => '',
]) . ]) .
dcPage::notices() . Notices::getNotices() .
'<p class="top-add"><a class="button add" href="' . '<p class="top-add"><a class="button add" href="' .
dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'new']) . My::manageUrl(['part' => 'new']) .
'">' . __('New alias') . '</a></p>'; '">' . __('New alias') . '</a></p>';
if (empty($aliases)) { if (empty($aliases)) {
@ -187,15 +175,16 @@ class Manage extends dcNsProcess
'</tbody></table></div>' . '</tbody></table></div>' .
'<p class="form-note">' . __('To remove an alias, empty its URL or destination.') . '</p>' . '<p class="form-note">' . __('To remove an alias, empty its URL or destination.') . '</p>' .
(new Para())->items([ (new Para())->items([
dcCore::app()->formNonce(false),
(new Hidden('part', 'list')),
(new Submit(['upd']))->value(__('Update')), (new Submit(['upd']))->value(__('Update')),
... My::hiddenFields([
'part' => 'list',
]),
])->render() . ])->render() .
'</form>'; '</form>';
} }
} }
dcPage::helpBlock('alias'); Page::helpBlock('alias');
dcPage::closeModule(); Page::closeModule();
} }
} }

View file

@ -15,38 +15,22 @@ declare(strict_types=1);
namespace Dotclear\Plugin\alias; namespace Dotclear\Plugin\alias;
use dcCore; use dcCore;
use Dotclear\Module\MyPlugin;
/** /**
* This module definitions. * This module definitions.
*/ */
class My class My extends MyPlugin
{ {
/** @var string Plugin table name */ /** @var string Plugin table name */
public const ALIAS_TABLE_NAME = 'alias'; public const ALIAS_TABLE_NAME = 'alias';
/** public static function checkCustomContext(int $context): ?bool
* This module id.
*/
public static function id(): string
{ {
return basename(dirname(__DIR__)); return !in_array($context, [My::BACKEND, My::MANAGE, My::MENU]) ? null :
} defined('DC_CONTEXT_ADMIN')
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
/** dcCore::app()->auth::PERMISSION_ADMIN,
* This module name. ]), dcCore::app()->blog->id);
*/
public static function name(): string
{
$name = dcCore::app()->plugins->moduleInfo(self::id(), 'name');
return __(is_string($name) ? $name : self::id());
}
/**
* This module path.
*/
public static function path(): string
{
return dirname(__DIR__);
} }
} }

View file

@ -15,22 +15,20 @@ declare(strict_types=1);
namespace Dotclear\Plugin\alias; namespace Dotclear\Plugin\alias;
use dcCore; use dcCore;
use dcNsProcess;
use dcUrlHandlers; use dcUrlHandlers;
use Dotclear\Core\Process;
use Dotclear\Helper\Network\Http; use Dotclear\Helper\Network\Http;
class Prepend extends dcNsProcess class Prepend extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_RC_PATH'); return self::status(My::checkContext(My::PREPEND));
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init) { if (!self::status()) {
return false; return false;
} }
@ -64,7 +62,7 @@ class Prepend extends dcNsProcess
} }
// Use visible redirection // Use visible redirection
if ($redir && !is_null(dcCore::app()->blog)) { if ($redir) {
Http::redirect(dcCore::app()->blog->url . $part); Http::redirect(dcCore::app()->blog->url . $part);
} }

View file

@ -15,21 +15,19 @@ declare(strict_types=1);
namespace Dotclear\Plugin\alias; namespace Dotclear\Plugin\alias;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller; use Dotclear\Plugin\Uninstaller\Uninstaller;
class Uninstall extends dcNsProcess class Uninstall extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN'); return self::status(My::checkContext(My::UNINSTALL));
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) { if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
return false; return false;
} }