From e6f0d1b16746a3c74930376c79af643872effb0d Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Wed, 11 Oct 2023 22:17:24 +0200 Subject: [PATCH] release 2.5 --- CHANGELOG.md | 6 ++++++ README.md | 31 ++++++++++++++---------------- _define.php | 43 ++++++++++++++++++++---------------------- dcstore.xml | 6 +++--- src/Backend.php | 21 +++++++++++++-------- src/Frontend.php | 33 +++++++++++++++----------------- src/Install.php | 28 +++++++++++++-------------- src/Manage.php | 48 +++++++++++++++++++++++------------------------ src/My.php | 37 +++++++++++++++++++----------------- src/Prepend.php | 26 ++++++++++++------------- src/Uninstall.php | 23 ++++++++++------------- 11 files changed, 149 insertions(+), 153 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9493315..7baedb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +moreCSS 2.5 - 2023.10.11 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Upgrade to Dotclear 2.28 + moreCSS 2.4 - 2023.08.13 =========================================================== * Require Dotclear 2.27 diff --git a/README.md b/README.md index afc0786..b8f1c4a 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,22 @@ # README -[![Release](https://img.shields.io/badge/release-2.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/moreCSS/releases) -[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/moreCSS/releases) -[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) +[![Release](https://img.shields.io/badge/release-2.5-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/moreCSS/releases) +![Date](https://img.shields.io/badge/date-2023.10.11-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/moreCSS) [![License](https://img.shields.io/github/license/JcDenis/moreCSS)](https://git.dotclear.watch/JcDenis/moreCSS/blob/master/LICENSE) -## WHAT IS MORECSS ? +## ABOUT -_moreCSS_ is a plugin for the open-source -web publishing software called Dotclear. +_moreCSS_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -It helps admin to add more CSS rules to current theme -without editing it. +> It helps admin to add more CSS rules to current theme without editing it. ## REQUIREMENTS -_moreCSS_ requires: - +* Dotclear 2.28 +* PHP 8.1+ * content admin permissions to manage CSS -* Dotclear 2.27 -* PHP 7.4+ ## USAGE @@ -32,16 +28,17 @@ or by adding a favorites icon on dashboard. ## 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/moreCSS) or [GitHub Page](https://github.com/JcDenis/moreCSS) -* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/moreCSS/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/moreCSS) -* Discuss & help : [Dotclear forum](http://forum.dotclear.org/viewtopic.php?id=44908) +* [License](https://git.dotclear.watch/JcDenis/moreCSS/src/branch/master/LICENSE) +* [Packages & details](https://git.dotclear.watch/JcDenis/moreCSS/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/moreCSS)) +* [Sources & contributions](https://git.dotclear.watch/JcDenis/moreCSS) (or on [GitHub](https://github.com/JcDenis/moreCSS)) +* [Issues & security](https://git.dotclear.watch/JcDenis/moreCSS/issues) (or on [GitHub](https://github.com/JcDenis/moreCSS/issues)) +* [Discuss & help](http://forum.dotclear.org/viewtopic.php?id=44908) ## CONTRIBUTORS * Osku (author) * Pierre Van Glabeke -* Jean-Christian Denis +* Jean-Christian Denis (latest) You are welcome to contribute to this code. diff --git a/_define.php b/_define.php index 7cb31fd..f73ea66 100644 --- a/_define.php +++ b/_define.php @@ -1,32 +1,29 @@ registerModule( 'Style sheet', 'Another CSS stylesheet for the active theme', 'Osku and contributors', - '2.4', + '2.5', [ - 'requires' => [['core', '2.27']], - 'permissions' => dcCore::app()->auth->makePermissions([ - dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, - ]), - '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', + '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 a043cf6..eac5a85 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ Style sheet - 2.4 + 2.5 Osku and contributors Another CSS stylesheet for the active theme - https://git.dotclear.watch/JcDenis/moreCSS/releases/download/v2.4/plugin-moreCSS.zip - 2.27 + https://git.dotclear.watch/JcDenis/moreCSS/releases/download/v2.5/plugin-moreCSS.zip + 2.28 https://git.dotclear.watch/JcDenis/moreCSS/src/branch/master/README.md https://git.dotclear.watch/JcDenis/moreCSS/issues diff --git a/src/Backend.php b/src/Backend.php index fc8ef90..d69b301 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -14,13 +14,18 @@ declare(strict_types=1); namespace Dotclear\Plugin\moreCSS; -use dcCore; +use Dotclear\App; use Dotclear\Core\Process; -use Dotclear\Core\Backend\{ - Favorites, - Menus -}; +use Dotclear\Core\Backend\Favorites; +/** + * @brief moreCSS manage class. + * @ingroup moreCSS + * + * @author Osku (author) + * @author Jean-Christian Denis (latest) + * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html + */ class Backend extends Process { public static function init(): bool @@ -34,15 +39,15 @@ class Backend extends Process return false; } - My::addBackendMenuItem(Menus::MENU_BLOG); + My::addBackendMenuItem(App::backend()->menus::MENU_BLOG); - 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/Frontend.php b/src/Frontend.php index 617cc65..516f298 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -1,23 +1,20 @@ blog->settings->get('themes')->get('morecss_active')) { + if (!self::status() || !App::blog()->settings()->get('themes')->get('morecss_active')) { return false; } - dcCore::app()->addBehavior('publicHeadContent', function (): void { - $css = (string) base64_decode((string) dcCore::app()->blog->settings->get('themes')->get('morecss_min')); + App::behavior()->addBehavior('publicHeadContent', function (): void { + $css = (string) base64_decode((string) App::blog()->settings()->get('themes')->get('morecss_min')); if (!empty($css)) { - echo dcUtils::cssLoad( - dcCore::app()->blog->url . dcCore::app()->url->getURLFor(My::id()), + echo App::plugins()->cssLoad( + App::blog()->url() . App::url()->getURLFor(My::id()), 'screen', md5($css) //no cache on content change ); diff --git a/src/Install.php b/src/Install.php index 0339cc9..4f8138e 100644 --- a/src/Install.php +++ b/src/Install.php @@ -1,23 +1,21 @@ blog)) { + if (!self::status() || !App::blog()->isDefined()) { return false; } try { - $s = dcCore::app()->blog->settings->get('themes'); + $s = App::blog()->settings()->get('themes'); $s->put('morecss_active', true, 'boolean', 'Enable additionnal CSS for the active theme', false, true); $s->put('morecss', '', 'string', 'Additionnal CSS for the active theme', false, true); $s->put('morecss_min', '', 'string', 'Minified addtionnal CSS for the active theme', false, true); return true; } catch (Exception $e) { - dcCore::app()->error->add($e->getMessage()); + App::error()->add($e->getMessage()); } return true; diff --git a/src/Manage.php b/src/Manage.php index 4f4de29..40e6156 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -1,20 +1,10 @@ blog->settings->get('themes'); + $s = App::blog()->settings()->get('themes'); if (isset($_POST['morecss'])) { try { @@ -70,7 +68,7 @@ class Manage extends Process ); My::redirect(); } catch (Exception $e) { - dcCore::app()->error->add($e->getMessage()); + App::error()->add($e->getMessage()); } } @@ -83,26 +81,26 @@ class Manage extends Process return; } - $s = dcCore::app()->blog->settings->get('themes'); + $s = App::blog()->settings()->get('themes'); Page::openModule( My::name(), ( - dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax') ? - Page::jsJson('dotclear_colorsyntax', ['colorsyntax' => dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax')]) . - Page::jsLoadCodeMirror(dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme')) + App::auth()->prefs()->get('interface')->get('colorsyntax') ? + Page::jsJson('dotclear_colorsyntax', ['colorsyntax' => App::auth()->prefs()->get('interface')->get('colorsyntax')]) . + Page::jsLoadCodeMirror(App::auth()->prefs()->get('interface')->get('colorsyntax_theme')) : '' ) ); echo Page::breadcrumb([ - Html::escapeHTML(dcCore::app()->blog->name) => '', - My::name() => '', + Html::escapeHTML(App::blog()->name()) => '', + My::name() => '', ]) . Notices::getNotices() . - (new Form('file-form'))->method('post')->action(dcCore::app()->admin->getPageURL())->fields([ + (new Form('file-form'))->method('post')->action(App::backend()->getPageURL())->fields([ (new Para())->items([ (new Label(__('Style sheet:')))->for('morecss'), (new Textarea('morecss', Html::escapeHTML((string) base64_decode((string) $s->get('morecss')))))->class('maximal')->cols(72)->rows(25), @@ -112,17 +110,17 @@ class Manage extends Process (new Label(__('Enable additionnal CSS for the active theme'), Label::OUTSIDE_LABEL_AFTER))->for('morecss_active')->class('classic'), ]), (new Para())->items([ - dcCore::app()->formNonce(false), + App::nonce()->formNonce(), (new Hidden('p', 'moreCSS')), (new Submit(['write']))->value(__('Save') . ' (s)')->accesskey('s'), ]), ])->render(); - if (dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax')) { + if (App::auth()->prefs()->get('interface')->get('colorsyntax')) { echo Page::jsJson('theme_editor_mode', ['mode' => 'css']) . - Page::jsLoad(dcCore::app()->blog->getPF('themeEditor/js/mode.js')) . - Page::jsRunCodeMirror('editor', 'morecss', 'dotclear', dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme')); + Page::jsLoad(App::blog()->getPF('themeEditor/js/mode.js')) . + Page::jsRunCodeMirror('editor', 'morecss', 'dotclear', App::auth()->prefs()->get('interface')->get('colorsyntax_theme')); } Page::closeModule(); diff --git a/src/My.php b/src/My.php index 010702c..a6b1485 100644 --- a/src/My.php +++ b/src/My.php @@ -1,31 +1,34 @@ auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id) - : null; + return match ($context) { + // Allow BACKEND and MANAGE and MENU to also content admin + self::MANAGE, self::MENU => App::task()->checkContext('BACKEND') + && App::blog()->isDefined() + && App::auth()->check(App::auth()->makePermissions([ + App::auth()::PERMISSION_ADMIN, + App::auth()::PERMISSION_CONTENT_ADMIN, + ]), App::blog()->id()), + + default => null, + }; } } diff --git a/src/Prepend.php b/src/Prepend.php index 0e65772..1c411f0 100644 --- a/src/Prepend.php +++ b/src/Prepend.php @@ -1,22 +1,20 @@ url->register( + App::url()->register( My::id(), 'morecss.css', '^morecss\.css(.*?)$', @@ -38,7 +36,7 @@ class Prepend extends Process header('Content-Type: text/css; charset=UTF-8'); echo "/* CSS for plugin moreCss */ \n"; - echo (string) base64_decode((string) dcCore::app()->blog->settings->get('themes')->get('morecss_min')); + echo (string) base64_decode((string) App::blog()->settings()->get('themes')->get('morecss_min')); exit; } diff --git a/src/Uninstall.php b/src/Uninstall.php index a33d25c..c7a4ddb 100644 --- a/src/Uninstall.php +++ b/src/Uninstall.php @@ -1,23 +1,20 @@ plugins->moduleExists('Uninstaller')) { + if (!self::status()) { return false; }