release 1.8
This commit is contained in:
parent
009c82c98c
commit
924b96126d
@ -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
|
||||
- require dotclear 2.26
|
||||
- fix non php 7.4 type hint
|
||||
|
@ -3,7 +3,7 @@
|
||||
[![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)
|
||||
[![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)
|
||||
[![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:
|
||||
|
||||
* admin permissions for management
|
||||
* Dotclear 2.26
|
||||
* admin permissions for management
|
||||
* Dotclear 2.27
|
||||
* PHP 7.4+
|
||||
|
||||
## USAGE
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
* @copyright Jean-Christian Denis
|
||||
* @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;
|
||||
}
|
||||
|
||||
@ -18,9 +18,9 @@ $this->registerModule(
|
||||
'alias',
|
||||
"Create aliases of your blog's URLs",
|
||||
'Olivier Meunier and contributors',
|
||||
'1.7.1',
|
||||
'1.8',
|
||||
[
|
||||
'requires' => [['core', '2.26']],
|
||||
'requires' => [['core', '2.27']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_ADMIN,
|
||||
]),
|
||||
|
@ -2,11 +2,11 @@
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="alias">
|
||||
<name>alias</name>
|
||||
<version>1.7.1</version>
|
||||
<version>1.8</version>
|
||||
<author>Olivier Meunier and contributors</author>
|
||||
<desc>Create aliases of your blog's URLs</desc>
|
||||
<file>https://github.com/JcDenis/alias/releases/download/v1.7.1/plugin-alias.zip</file>
|
||||
<da:dcmin>2.26</da:dcmin>
|
||||
<file>https://github.com/JcDenis/alias/releases/download/v1.8/plugin-alias.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<da:details>https://plugins.dotaddict.org/dc2/details/alias</da:details>
|
||||
<da:support>https://github.com/JcDenis/alias</da:support>
|
||||
</module>
|
||||
|
@ -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 ""
|
||||
msgstr ""
|
||||
"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"
|
||||
"PO-Revision-Date: 2023-04-30T22:52:13+00:00\n"
|
||||
"Last-Translator: Jean-Christian Denis\n"
|
||||
"PO-Revision-Date: 2023-07-29T12:49:07+00:00\n"
|
||||
"Last-Translator: Jean-Christain Denis\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: src/Alias.php:75
|
||||
msgid "Invalid aliases definitions"
|
||||
msgstr "Définitions d'alias invalides"
|
||||
|
||||
#: src/Alias.php:116
|
||||
msgid "Alias URL is empty."
|
||||
msgstr "L'URL de l'alias est vide."
|
||||
|
||||
#: src/Alias.php:119
|
||||
msgid "Alias destination is empty."
|
||||
msgstr "La destination de l'alias est vide."
|
||||
|
||||
#: src/Manage.php:74
|
||||
msgid "Aliases successfully updated."
|
||||
msgstr "Alias mis à jour avec succès."
|
||||
|
||||
#: src/Manage.php:85
|
||||
msgid "Alias successfully created."
|
||||
msgstr "Alias créer avec succès."
|
||||
|
||||
#: src/Manage.php:116
|
||||
msgid "New alias"
|
||||
msgstr "Nouvel alias"
|
||||
|
||||
#: src/Manage.php:124
|
||||
msgid "Alias URL:"
|
||||
msgstr "URL de l'alias :"
|
||||
|
||||
#: src/Manage.php:128
|
||||
msgid "Alias destination:"
|
||||
msgstr "Destination de l'alias :"
|
||||
|
||||
#: src/Manage.php:131
|
||||
msgid "Do not put blog URL \"%s\" in fields."
|
||||
msgstr "Ne pas mettre l'URL du blog \"%s\" dans les champs."
|
||||
|
||||
#: src/Manage.php:134
|
||||
msgid "Do visible redirection to destination"
|
||||
msgstr "Faire une redirection visible vers la destination"
|
||||
|
||||
#: src/Manage.php:155
|
||||
msgid "No alias"
|
||||
msgstr "Aucun alias"
|
||||
|
||||
#: src/Manage.php:159
|
||||
msgid "There is %s alias."
|
||||
msgid_plural "There are %s aliases."
|
||||
msgstr[0] "Il y a %s alias."
|
||||
msgstr[1] "Il y a %s alias."
|
||||
|
||||
#: src/Manage.php:162
|
||||
msgid "Aliases list"
|
||||
msgstr "Liste des alias"
|
||||
|
||||
#: src/Manage.php:165
|
||||
msgid "Alias URL"
|
||||
msgstr "URL de l'alias"
|
||||
|
||||
#: src/Manage.php:166
|
||||
msgid "Alias destination"
|
||||
msgstr "Destination de l'alias"
|
||||
|
||||
#: src/Manage.php:167
|
||||
msgid "Alias position"
|
||||
msgstr "Position de l'alias"
|
||||
|
||||
#: src/Manage.php:168
|
||||
msgid "Redrection"
|
||||
msgstr "Redirection"
|
||||
|
||||
#: src/Manage.php:182
|
||||
msgid "visible redirection to %s"
|
||||
msgstr "Redirection visible vers %s"
|
||||
|
||||
#: src/Manage.php:188
|
||||
msgid "To remove an alias, empty its URL or destination."
|
||||
msgstr "Pour supprimer un alias, videz son URL ou sa destination."
|
||||
|
||||
|
@ -14,45 +14,28 @@ declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\alias;
|
||||
|
||||
use dcAdmin;
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use dcPage;
|
||||
use Dotclear\Plugin\importExport\FlatBackupItem;
|
||||
use Dotclear\Plugin\importExport\FlatExport;
|
||||
use Dotclear\Plugin\importExport\FlatImportV2;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\importExport\{
|
||||
FlatBackupItem,
|
||||
FlatExport,
|
||||
FlatImportV2
|
||||
};
|
||||
|
||||
class Backend extends dcNsProcess
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& !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;
|
||||
return self::status(My::checkContext(My::BACKEND));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
);
|
||||
My::addBackendMenuItem();
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'exportFullV2' => function (FlatExport $exp): void {
|
||||
|
@ -15,22 +15,20 @@ declare(strict_types=1);
|
||||
namespace Dotclear\Plugin\alias;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Database\Structure;
|
||||
use Exception;
|
||||
|
||||
class Install extends dcNsProcess
|
||||
class Install extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::INSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,11 @@ declare(strict_types=1);
|
||||
namespace Dotclear\Plugin\alias;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use dcPage;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
Page
|
||||
};
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
@ -36,27 +39,16 @@ use Exception;
|
||||
/**
|
||||
* Manage contributions list
|
||||
*/
|
||||
class Manage extends dcNsProcess
|
||||
class Manage extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& !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;
|
||||
return self::status(My::checkContext(My::MANAGE));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -71,8 +63,8 @@ class Manage extends dcNsProcess
|
||||
if (isset($_POST['a']) && is_array($_POST['a'])) {
|
||||
try {
|
||||
$alias->updateAliases($_POST['a']);
|
||||
dcPage::addSuccessNotice(__('Aliases successfully updated.'));
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id());
|
||||
Notices::addSuccessNotice(__('Aliases successfully updated.'));
|
||||
My::redirect();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
@ -82,8 +74,8 @@ class Manage extends dcNsProcess
|
||||
if (isset($_POST['alias_url'])) {
|
||||
try {
|
||||
$alias->createAlias($_POST['alias_url'], $_POST['alias_destination'], count($aliases) + 1, !empty($_POST['alias_redirect']));
|
||||
dcPage::addSuccessNotice(__('Alias successfully created.'));
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id());
|
||||
Notices::addSuccessNotice(__('Alias successfully created.'));
|
||||
My::redirect();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
@ -94,28 +86,23 @@ class Manage extends dcNsProcess
|
||||
|
||||
public static function render(): void
|
||||
{
|
||||
if (!static::$init) {
|
||||
return;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
if (!self::status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$alias = new Alias();
|
||||
$aliases = $alias->getAliases();
|
||||
|
||||
dcPage::openModule(My::name());
|
||||
Page::openModule(My::name());
|
||||
|
||||
if (($_REQUEST['part'] ?? 'list') == 'new') {
|
||||
echo
|
||||
dcPage::breadcrumb([
|
||||
Page::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'list']),
|
||||
My::name() => My::manageUrl(['part' => 'list']),
|
||||
__('New alias') => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
Notices::getNotices() .
|
||||
|
||||
(new Div())->items([
|
||||
(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 Para())->items([
|
||||
dcCore::app()->formNonce(false),
|
||||
(new Hidden('part', 'new')),
|
||||
(new Submit(['do']))->value(__('Save')),
|
||||
... My::hiddenFields([
|
||||
'part' => 'new',
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
])->render();
|
||||
} else {
|
||||
echo
|
||||
dcPage::breadcrumb([
|
||||
Page::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
My::name() => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
Notices::getNotices() .
|
||||
'<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>';
|
||||
|
||||
if (empty($aliases)) {
|
||||
@ -187,15 +175,16 @@ class Manage extends dcNsProcess
|
||||
'</tbody></table></div>' .
|
||||
'<p class="form-note">' . __('To remove an alias, empty its URL or destination.') . '</p>' .
|
||||
(new Para())->items([
|
||||
dcCore::app()->formNonce(false),
|
||||
(new Hidden('part', 'list')),
|
||||
(new Submit(['upd']))->value(__('Update')),
|
||||
... My::hiddenFields([
|
||||
'part' => 'list',
|
||||
]),
|
||||
])->render() .
|
||||
'</form>';
|
||||
}
|
||||
}
|
||||
|
||||
dcPage::helpBlock('alias');
|
||||
dcPage::closeModule();
|
||||
Page::helpBlock('alias');
|
||||
Page::closeModule();
|
||||
}
|
||||
}
|
||||
|
32
src/My.php
32
src/My.php
@ -15,38 +15,22 @@ declare(strict_types=1);
|
||||
namespace Dotclear\Plugin\alias;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
*/
|
||||
class My
|
||||
class My extends MyPlugin
|
||||
{
|
||||
/** @var string Plugin table name */
|
||||
public const ALIAS_TABLE_NAME = 'alias';
|
||||
|
||||
/**
|
||||
* This module id.
|
||||
*/
|
||||
public static function id(): string
|
||||
public static function checkCustomContext(int $context): ?bool
|
||||
{
|
||||
return basename(dirname(__DIR__));
|
||||
}
|
||||
|
||||
/**
|
||||
* This module name.
|
||||
*/
|
||||
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__);
|
||||
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,
|
||||
]), dcCore::app()->blog->id);
|
||||
}
|
||||
}
|
||||
|
@ -15,22 +15,20 @@ declare(strict_types=1);
|
||||
namespace Dotclear\Plugin\alias;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use dcUrlHandlers;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Network\Http;
|
||||
|
||||
class Prepend extends dcNsProcess
|
||||
class Prepend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_RC_PATH');
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::PREPEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -64,7 +62,7 @@ class Prepend extends dcNsProcess
|
||||
}
|
||||
|
||||
// Use visible redirection
|
||||
if ($redir && !is_null(dcCore::app()->blog)) {
|
||||
if ($redir) {
|
||||
Http::redirect(dcCore::app()->blog->url . $part);
|
||||
}
|
||||
|
||||
|
@ -15,21 +15,19 @@ declare(strict_types=1);
|
||||
namespace Dotclear\Plugin\alias;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
class Uninstall extends dcNsProcess
|
||||
class Uninstall extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN');
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::UNINSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user