From c5ce39d983981ea3422ceff618e0c34736a842ef Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 7 Oct 2023 23:59:48 +0200 Subject: [PATCH] release 2023.10.07 --- CHANGELOG.md | 84 +++++++++++++++++++++++-------------------- README.md | 27 +++++++------- _define.php | 10 +++--- dcstore.xml | 2 +- src/Backend.php | 6 ++-- src/Install.php | 13 ++++--- src/Manage.php | 15 +++++--- src/MyUrlHandlers.php | 55 ++++++++++++++++------------ src/Uninstall.php | 3 +- 9 files changed, 115 insertions(+), 100 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b2b999..dded805 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,40 +1,46 @@ -myUrlHandlers 2023.08.13 -=========================================================== -* Require Dotclear 2.27 -* Require PHP 7.4 -* Move third party repository -* Use Dotclear style for CHANGELOG - -myUrlHandlers 2023.07.29 -=========================================================== -* require dotclear 2.27 -* require PHP 7.4+ -* update to dotclear 2.27-dev - -myUrlHandlers 2023.05.13 -=========================================================== -* require dotclear 2.26 -* cleanup for dc2.26 stable - -myUrlHandlers 2023.04.22 -=========================================================== -* require dotclear 2.26 -* add plugin Uninstaller features -* fix nullsafe warnings - -myUrlHandlers 2023.03.27 -=========================================================== -* require dotclear 2.26 -* use dotclear Helper - -myUrlHandlers 2023.03.11 -=========================================================== -* Update to Dotclear 2.26 -* use abstract plugin id -* use php namespace -* use json instead of serialize -* rename settings - -myUrlHandlers 2022.11.26 -=========================================================== +myUrlHandlers 2023.10.07 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Upgrade to Dotclear 2.28 + +myUrlHandlers 2023.08.13 +=========================================================== +* Require Dotclear 2.27 +* Require PHP 7.4 +* Move third party repository +* Use Dotclear style for CHANGELOG + +myUrlHandlers 2023.07.29 +=========================================================== +* require dotclear 2.27 +* require PHP 7.4+ +* update to dotclear 2.27-dev + +myUrlHandlers 2023.05.13 +=========================================================== +* require dotclear 2.26 +* cleanup for dc2.26 stable + +myUrlHandlers 2023.04.22 +=========================================================== +* require dotclear 2.26 +* add plugin Uninstaller features +* fix nullsafe warnings + +myUrlHandlers 2023.03.27 +=========================================================== +* require dotclear 2.26 +* use dotclear Helper + +myUrlHandlers 2023.03.11 +=========================================================== +* Update to Dotclear 2.26 +* use abstract plugin id +* use php namespace +* use json instead of serialize +* rename settings + +myUrlHandlers 2022.11.26 +=========================================================== * update to Dotclear 2.24 \ No newline at end of file diff --git a/README.md b/README.md index efd4098..c6f7da1 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,22 @@ # README [![Release](https://img.shields.io/badge/release-2023.08.13-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/myUrlHandlers/releases) -[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/myUrlHandlers/releases) +![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg) [![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/myUrlHandlers) -[![License](https://img.shields.io/github/license/JcDenis/myUrlHandlers)](https://git.dotclear.watch/JcDenis/myUrlHandlers/blob/master/LICENSE) +[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/myUrlHandlers/src/branch/master/LICENSE) -## WHAT IS MYURLHANLDERS ? +## ABOUT -_myUrlHandlers_ is a plugin for the open-source -web publishing software called Dotclear. +_myUrlHandlers_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -You can change public URL of each Dotclear parts, -like post, category, etc and some plugins having public parts. +> You can change public URL of each Dotclear parts, like post, category, etc and some plugins having public parts. ## REQUIREMENTS -_myUrlHandlers_ requires: - * contentadmin permissions for management -* Dotclear 2.27 -* PHP 7.4+ +* Dotclear 2.28 +* PHP 8.1+ ## USAGE @@ -32,10 +28,11 @@ or you can add dashboard icon. ## LINKS -* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html) -* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/myUrlHandlers) or [GitHub Page](https://github.com/JcDenis/myUrlHandlers) -* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/myUrlHandlers/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/myUrlHandlers) -* Discuss and help : [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=40893) +* [License](https://git.dotclear.watch/JcDenis/myUrlHandlers/src/branch/master/LICENSE) +* [Packages & details](https://git.dotclear.watch/JcDenis/myUrlHandlers/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/myUrlHandlers/alias)) +* [Sources & contributions](https://git.dotclear.watch/JcDenis/myUrlHandlers) (or on [GitHub](https://github.com/JcDenis/myUrlHandlers)) +* [Issues & security](https://git.dotclear.watch/JcDenis/myUrlHandlers/issues) (or on [GitHub](https://github.com/JcDenis/myUrlHandlers/issues)) +* [Discuss and help](https://forum.dotclear.org/viewtopic.php?id=40893) ## CONTRIBUTORS diff --git a/_define.php b/_define.php index 5447b65..62d7b97 100644 --- a/_define.php +++ b/_define.php @@ -10,9 +10,7 @@ * @copyright Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html */ -if (!defined('DC_RC_PATH')) { - return null; -} +use Dotclear\App; $this->registerModule( 'URL handlers', @@ -20,9 +18,9 @@ $this->registerModule( 'Alex Pirine and contributors', '2023.08.13', [ - 'requires' => [['core', '2.27']], - 'permissions' => dcCore::app()->auth->makePermissions([ - dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, + 'requires' => [['core', '2.28']], + 'permissions' => App::auth()->makePermissions([ + App::auth()::PERMISSION_CONTENT_ADMIN, ]), 'priority' => 150000, 'type' => 'plugin', diff --git a/dcstore.xml b/dcstore.xml index d00e0fc..9d05a4b 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -5,7 +5,7 @@ 2023.08.13 Alex Pirine and contributors Change Dotclear URL handlers - https://git.dotclear.watch/JcDenis/myUrlHandlers/releases/download/v2023.08.13/plugin-myUrlHandlers.zip + https://github.com/JcDenis/myUrlHandlers/releases/download/v2023.08.13/plugin-myUrlHandlers.zip 2.27 https://git.dotclear.watch/JcDenis/myUrlHandlers/src/branch/master/README.md https://git.dotclear.watch/JcDenis/myUrlHandlers/issues diff --git a/src/Backend.php b/src/Backend.php index 9ec55be..41ee57b 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -14,7 +14,7 @@ declare(strict_types=1); namespace Dotclear\Plugin\myUrlHandlers; -use dcCore; +use Dotclear\App; use Dotclear\Core\Process; use Dotclear\Core\Backend\Favorites; @@ -34,13 +34,13 @@ class Backend extends Process My::addBackendMenuItem(); // register user backend dashboard icon - dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (Favorites $favs): void { + App::behavior()->addBehavior('adminDashboardFavoritesV2', function (Favorites $favs): void { $favs->register(My::id(), [ 'title' => My::name(), 'url' => My::manageUrl(), 'small-icon' => My::icons(), 'large-icon' => My::icons(), - 'permissions' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]), + 'permissions' => App::auth()->makePermissions([App::auth()::PERMISSION_CONTENT_ADMIN]), ]); }); diff --git a/src/Install.php b/src/Install.php index 47bfe43..4213ad3 100644 --- a/src/Install.php +++ b/src/Install.php @@ -14,8 +14,7 @@ declare(strict_types=1); namespace Dotclear\Plugin\myUrlHandlers; -use dcCore; -use dcNamespace; +use Dotclear\App; use Dotclear\Core\Process; class Install extends Process @@ -46,24 +45,24 @@ class Install extends Process private static function growUp(): void { - $current = dcCore::app()->getVersion(My::id()); + $current = App::version()->getVersion(My::id()); // Update settings id, ns, value if ($current && version_compare($current, '2023.03.11', '<')) { - $record = dcCore::app()->con->select( - 'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' . + $record = App::con()->select( + 'SELECT * FROM ' . App::con()->prefix() . App::blogWorkspace()::NS_TABLE_NAME . ' ' . "WHERE setting_ns = 'myurlhandlers' AND setting_id = 'url_handlers' " ); while ($record->fetch()) { $value = @unserialize($record->f('setting_value')); - $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME); + $cur = App::blogWorkspace()->openBlogWorkspaceCursor(); $cur->setField('setting_id', My::NS_SETTING_ID); $cur->setField('setting_ns', My::id()); $cur->setField('setting_value', json_encode(is_array($value) ? $value : [])); $cur->update( "WHERE setting_id = '" . $record->f('setting_id') . "' and setting_ns = '" . $record->f('setting_ns') . "' " . - 'AND blog_id ' . (null === $record->f('blog_id') ? 'IS NULL ' : ("= '" . dcCore::app()->con->escapeStr((string) $record->f('blog_id')) . "' ")) + 'AND blog_id ' . (null === $record->f('blog_id') ? 'IS NULL ' : ("= '" . App::con()->escapeStr((string) $record->f('blog_id')) . "' ")) ); } } diff --git a/src/Manage.php b/src/Manage.php index c56a3d8..c52e9c8 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -14,7 +14,7 @@ declare(strict_types=1); namespace Dotclear\Plugin\myUrlHandlers; -use dcCore; +use Dotclear\App; use Dotclear\Core\Process; use Dotclear\Core\Backend\{ Notices, @@ -103,7 +103,7 @@ class Manage extends Process My::redirect(); } } catch (Exception $e) { - dcCore::app()->error->add($e->getMessage()); + App::error()->add($e->getMessage()); } return true; @@ -122,8 +122,8 @@ class Manage extends Process echo Page::breadcrumb( [ - Html::escapeHTML(dcCore::app()->blog->name) => '', - My::name() => '', + Html::escapeHTML(App::blog()->name()) => '', + My::name() => '', ] ) . Notices::getNotices(); @@ -133,7 +133,7 @@ class Manage extends Process '

' . __('No URL handler to configure.') . '

'; } else { echo - '
' . + '' . '
' . '' . '' . @@ -168,6 +168,11 @@ class Manage extends Process Page::closeModule(); } + /** + * Get handlers. + * + * @return array The handlers + */ private static function getHandlers(): array { # Read default handlers diff --git a/src/MyUrlHandlers.php b/src/MyUrlHandlers.php index 31a2964..f785fcc 100644 --- a/src/MyUrlHandlers.php +++ b/src/MyUrlHandlers.php @@ -14,17 +14,30 @@ declare(strict_types=1); namespace Dotclear\Plugin\myUrlHandlers; -use dcCore; +use Dotclear\App; +use Dotclear\Core\PostType; class MyUrlHandlers { - /** @var array $defaults The default URLs handlers */ + /** + * The default URLs handlers. + * + * @var array> $defaults + */ private static array $defaults = []; - /** @var array $url2post The posts types URLs */ + /** + * The posts types URLs. + * + * @var array $url2post + */ private static array $url2post = []; - /** @var array $post_adm_url The posts types admin URLs */ + /** + * The posts types admin URLs. + * + * @var array $post_adm_url + */ private static array $post_adm_url = []; /** @@ -33,7 +46,7 @@ class MyUrlHandlers public static function init(): void { # Set defaults - foreach (dcCore::app()->url->getTypes() as $k => $v) { + foreach (App::url()->getTypes() as $k => $v) { if (empty($v['url'])) { continue; } @@ -47,9 +60,9 @@ class MyUrlHandlers } } - foreach (dcCore::app()->getPostTypes() as $k => $v) { - self::$url2post[$v['public_url']] = $k; - self::$post_adm_url[$k] = $v['admin_url']; + foreach (App::postTypes()->dump() as $pt) { + self::$url2post[$pt->public_url] = $pt->type; + self::$post_adm_url[$pt->type] = $pt->admin_url; } # Read user settings @@ -70,7 +83,7 @@ class MyUrlHandlers return; } - dcCore::app()->url->register( + App::url()->register( $name, $url, sprintf(self::$defaults[$name]['representation'], $url), @@ -80,14 +93,18 @@ class MyUrlHandlers $k = self::$url2post[self::$defaults[$name]['url'] . '/%s'] ?? ''; if ($k) { - dcCore::app()->setPostType($k, self::$post_adm_url[$k], dcCore::app()->url->getBase($name) . '/%s'); + App::postTypes()->set(new PostType( + $k, + self::$post_adm_url[$k], + App::url()->getBase($name) . '/%s' + )); } } /** - * Get default URLs handlers + * Get default URLs handlers. * - * @return array The default URLs handlers + * @return array The default URLs handlers */ public static function getDefaults(): array { @@ -102,29 +119,23 @@ class MyUrlHandlers /** * Get custom blog URLs handlers. * - * @return array The blog URLs handlers + * @return array The blog URLs handlers */ public static function getBlogHandlers(): array { - if (is_null(dcCore::app()->blog)) { - return []; - } $handlers = json_decode((string) My::settings()->get(My::NS_SETTING_ID), true); return is_array($handlers) ? $handlers : []; } /** - * Save custom URLs handlers + * Save custom URLs handlers. * - * @param array $handlers The custom URLs handlers + * @param array $handlers The custom URLs handlers */ public static function saveBlogHandlers(array $handlers): void { - if (is_null(dcCore::app()->blog)) { - return; - } My::settings()->put(My::NS_SETTING_ID, json_encode($handlers)); - dcCore::app()->blog->triggerBlog(); + App::blog()->triggerBlog(); } } diff --git a/src/Uninstall.php b/src/Uninstall.php index 71c2486..3c6901e 100644 --- a/src/Uninstall.php +++ b/src/Uninstall.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace Dotclear\Plugin\myUrlHandlers; -use dcCore; use Dotclear\Core\Process; use Dotclear\Plugin\Uninstaller\Uninstaller; @@ -27,7 +26,7 @@ class Uninstall extends Process public static function process(): bool { - if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) { + if (!self::status()) { return false; }
' . __('URL handlers list') . '