diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e23ac7..b8a153c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +disclaimer 1.5 - 2023.10.15 +=========================================================== +* Require dotclear 2.28 +* Require PHP 8.1 +* Upgrade to Dotclear 2.28 + disclaimer 1.4 - 2023.08.12 =========================================================== * Require dotclear 2.27 diff --git a/README.md b/README.md index 116b779..4acc461 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,22 @@ # README -[![Release](https://img.shields.io/badge/release-1.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/disclaimer/releases) -[![Date](https://img.shields.io/badge/date-2023.09.12-c44d58.svg)](https://git.dotclear.watch/JcDenis/disclaimer/releases) -[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) +[![Release](https://img.shields.io/badge/release-1.5-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/disclaimer/releases) +![Date](https://img.shields.io/badge/date-2023.10.15-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/disclaimer) -[![License](https://img.shields.io/github/license/JcDenis/disclaimer)](https://git.dotclear.watch/JcDenis/disclaimer/blob/master/LICENSE) +[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/disclaimer/src/branch/master/LICENSE) -## WHAT IS DISCLAIMER ? +## ABOUT -_disclaimer_ is a plugin for the open-source -web publishing software called Dotclear. +_disclaimer_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -It add a disclaimer to your blog entrance. - -This plugin is inspired from plugin "Private mode" by Osku. +> It add a disclaimer to your blog entrance. This plugin is inspired from plugin "Private mode" by Osku. ## REQUIREMENTS -_disclaimer_ requires: - -* admin permissions on blog -* Dotclear 2.27 -* PHP 7.4+ +* Dotclear 2.28 +* PHP 8.1+ +* Dotclear admin permissions on blog ## USAGE @@ -32,10 +27,11 @@ You can activate and setup _disclaimer_ from blog preferences page. ## 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/disclaimer) or [GitHub Page](https://github.com/JcDenis/disclaimer) -* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/disclaimer/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/disclaimer) -* Help & discuss : [Dotclear forum](http://forum.dotclear.org/viewtopic.php?id=40000) +* [License](https://git.dotclear.watch/JcDenis/disclaimer/src/branch/master/LICENSE) +* [Packages & details](https://git.dotclear.watch/JcDenis/disclaimer/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/disclaimer)) +* [Sources & contributions](https://git.dotclear.watch/JcDenis/disclaimer) (or on [GitHub](https://github.com/JcDenis/disclaimer)) +* [Issues & security](https://git.dotclear.watch/JcDenis/disclaimer/issues) (or on [GitHub](https://github.com/JcDenis/disclaimer/issues)) +* [Help & discuss](http://forum.dotclear.org/viewtopic.php?id=40000) ## CONTRIBUTORS diff --git a/_define.php b/_define.php index 6722307..52c449f 100644 --- a/_define.php +++ b/_define.php @@ -1,35 +1,30 @@ registerModule( 'Disclaimer', 'Add a disclaimer to your blog entrance', 'Jean-Christian Denis, Pierre Van Glabeke', - '1.4', + '1.5', [ - 'requires' => [['core', '2.27']], - 'permissions' => dcCore::app()->auth->makePermissions([ - dcCore::app()->auth::PERMISSION_ADMIN, - ]), - 'settings' => [ - 'blog' => '#params.' . basename(__DIR__) . 'Param', - ], - 'type' => 'plugin', - 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', - 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', - 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml', + 'requires' => [['core', '2.28']], + 'permissions' => 'My', + 'settings' => ['blog' => '#params.' . basename(__DIR__) . 'Param'], + 'type' => 'plugin', + 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', + 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', + 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml', ] ); diff --git a/dcstore.xml b/dcstore.xml index ec788c2..3303a24 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ Disclaimer - 1.4 + 1.5 Jean-Christian Denis, Pierre Van Glabeke Add a disclaimer to your blog entrance - https://git.dotclear.watch/JcDenis/disclaimer/releases/download/v1.4/plugin-disclaimer.zip - 2.27 + https://git.dotclear.watch/JcDenis/disclaimer/releases/download/v1.5/plugin-disclaimer.zip + 2.28 https://git.dotclear.watch/JcDenis/disclaimer/src/branch/master/README.md https://git.dotclear.watch/JcDenis/disclaimer/issues diff --git a/src/Backend.php b/src/Backend.php index 4540963..a4bf1c0 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -1,22 +1,12 @@ addBehaviors([ - 'adminBeforeBlogSettingsUpdate' => function (dcSettings $blog_settings): void { + App::behavior()->addBehaviors([ + 'adminBeforeBlogSettingsUpdate' => function (BlogSettings $blog_settings): void { $s = $blog_settings->get(My::id()); try { @@ -72,7 +69,7 @@ class Backend extends Process } }, - 'adminBlogPreferencesFormV2' => function (dcSettings $blog_settings): void { + 'adminBlogPreferencesFormV2' => function (BlogSettings $blog_settings): void { $s = $blog_settings->get(My::id()); $disclaimer_bots_agents = $s->get('disclaimer_bots_agents'); diff --git a/src/Frontend.php b/src/Frontend.php index f991d0f..316bb1d 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -1,23 +1,20 @@ tpl->addValue('DisclaimerTitle', function (ArrayObject $attr): string { + App::frontend()->template()->addValue('DisclaimerTitle', function (ArrayObject $attr): string { return 'tpl->getFilters($attr), + App::frontend()->template()->getFilters($attr), My::class . '::settings()->get("disclaimer_title")' ) . '; ?>'; }); - dcCore::app()->tpl->addValue('DisclaimerText', function (ArrayObject $attr): string { + App::frontend()->template()->addValue('DisclaimerText', function (ArrayObject $attr): string { return 'get("disclaimer_text"); ?>'; }); - dcCore::app()->tpl->addValue('DisclaimerFormURL', function (ArrayObject $attr): string { - return 'blog->url; ?>'; + App::frontend()->template()->addValue('DisclaimerFormURL', function (ArrayObject $attr): string { + return 'url(); ?>'; }); # Behaviors - dcCore::app()->addBehaviors([ + App::behavior()->addBehaviors([ 'publicHeadContent' => function (): void { echo My::cssLoad('disclaimer'); }, - 'publicBeforeDocumentV2' => [UrlHandler::class, 'publicBeforeDocumentV2'], + 'publicBeforeDocumentV2' => UrlHandler::publicBeforeDocumentV2(...), ]); return true; diff --git a/src/Install.php b/src/Install.php index 3ae6b2d..a5e6bab 100644 --- a/src/Install.php +++ b/src/Install.php @@ -1,23 +1,20 @@ error->add($e->getMessage()); + App::error()->add($e->getMessage()); } return true; diff --git a/src/My.php b/src/My.php index f514806..ecdcd43 100644 --- a/src/My.php +++ b/src/My.php @@ -1,15 +1,5 @@ plugins->moduleExists('Uninstaller')) { + if (!self::status()) { return false; } diff --git a/src/UrlHandler.php b/src/UrlHandler.php index ec5f05a..dba0cca 100644 --- a/src/UrlHandler.php +++ b/src/UrlHandler.php @@ -1,31 +1,23 @@ blog)) { + if (!App::blog()->isDefined()) { return; } @@ -70,37 +61,29 @@ class UrlHandler extends dcUrlHandlers } # Set default-templates path for disclaimer files - $tplset = dcCore::app()->themes->moduleInfo(dcCore::app()->blog->settings->get('system')->get('theme'), 'tplset'); + $tplset = App::themes()->moduleInfo(App::blog()->settings()->get('system')->get('theme'), 'tplset'); if (!empty($tplset) && is_dir(My::path() . '/default-templates/' . $tplset)) { - dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), My::path() . '/default-templates/' . $tplset); + App::frontend()->template()->setPath(App::frontend()->template()->getPath(), My::path() . '/default-templates/' . $tplset); } else { - dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), My::path() . '/default-templates/' . DC_DEFAULT_TPLSET); + App::frontend()->template()->setPath(App::frontend()->template()->getPath(), My::path() . '/default-templates/' . App::config()->defaultTplset()); } # New URL handler $urlHandler = new HelperHandler(); - $urlHandler->mode = dcCore::app()->url->mode; - $urlHandler->registerDefault([ - self::class, - 'overwriteCallbacks', - ]); + $urlHandler->mode = App::url()->mode; + $urlHandler->registerDefault(self::overwriteCallbacks(...)); # Create session - $session = new Session( - dcCore::app()->con, - dcCore::app()->prefix . 'session', - My::SESSION_PREFIX . dcCore::app()->blog->id, - '/' - ); + $session = App::session()->createFromCookieName(My::SESSION_PREFIX . App::blog()->id()); $session->start(); # Remove all URLs representations - foreach (dcCore::app()->url->getTypes() as $k => $v) { + foreach (App::url()->getTypes() as $k => $v) { $urlHandler->register( $k, $v['url'], $v['representation'], - [self::class, 'overwriteCallbacks'] + self::overwriteCallbacks(...) ); } @@ -110,7 +93,7 @@ class UrlHandler extends dcUrlHandlers unset($urlHandler); # Test cookie - $cookie_name = My::COOKIE_PREFIX . dcCore::app()->blog->id; + $cookie_name = My::COOKIE_PREFIX . App::blog()->id(); $cookie_value = empty($_COOKIE[$cookie_name]) || !$s->get('disclaimer_remember') ? false : ($_COOKIE[$cookie_name]) == 1;