From 55fc1c543b3943588623127ac892bd2612f68721 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sun, 15 Oct 2023 21:58:21 +0200 Subject: [PATCH] upgrade to Dotclear 2.28 --- CHANGELOG.md | 6 +++++ README.md | 40 +++++++++++++-------------- _define.php | 36 ++++++++++++------------- dcstore.xml | 6 ++--- src/Backend.php | 33 ++++++++++------------- src/Frontend.php | 69 +++++++++++++++++++++-------------------------- src/Install.php | 24 ++++++++--------- src/Manage.php | 33 +++++++++++------------ src/My.php | 20 ++++++-------- src/Uninstall.php | 23 +++++++--------- 10 files changed, 134 insertions(+), 156 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b072d9..239602e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +construction 1.9 - 2023.10.15 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Upgrade to Dotclear 2.28 + construction 1.8 - 2023.08.06 =========================================================== * Require Dotclear 2.27 diff --git a/README.md b/README.md index f4ecb8a..ca4908e 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,22 @@ # README -[![Release](https://img.shields.io/badge/release-1.8-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/construction/releases) -[![Date](https://img.shields.io/badge/date-2023.08.06-c44d58.svg)](https://git.dotclear.watch/JcDenis/construction/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.9-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/construction/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/construction) -[![License](https://img.shields.io/github/license/JcDenis/construction)](https://git.dotclear.watch/JcDenis/construction/blob/master/LICENSE) +[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/construction/src/branch/master/LICENSE) -## WHAT IS DISCLAIMER ? +## ABOUT -_construction_ is a plugin for the open-source -web publishing software called Dotclear. +_dcLog_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -Put your blog on construction mode with a custom message on frontend. -Blog can be accessible to defined IP addresses. +> Put your blog on construction mode with a custom message on frontend. Blog can be accessible to defined IP addresses. ## REQUIREMENTS - _construction_ requires: - - * admin permissions on blog - * Dotclear 2.27 +* Dotclear 2.28 +* PHP 8.1 +* Dotclear admin permissions on blog ## USAGE @@ -30,15 +27,16 @@ You can activate and setup _construction_ from sidebar menu "Construction". ## 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/construction) or [GitHub Page](https://github.com/JcDenis/construction) - * Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/construction/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/construction) - * Help & discuss : [Dotclear forum](http://forum.dotclear.org/viewtopic.php?id=42875) +* [License](https://git.dotclear.watch/JcDenis/construction/src/branch/master/LICENSE) +* [Packages & details](https://git.dotclear.watch/JcDenis/construction/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/construction)) +* [Sources & contributions](https://git.dotclear.watch/JcDenis/construction) (or on [GitHub](https://github.com/JcDenis/construction)) +* [Issues & security](https://git.dotclear.watch/JcDenis/construction/issues) (or on [GitHub](https://github.com/JcDenis/construction/issues)) +* [Help & discuss](http://forum.dotclear.org/viewtopic.php?id=42875) ## CONTRIBUTORS - * Osku (author) - * Pierre Van Glabeke - * Jean-Christian Denis +* Osku (author) +* Pierre Van Glabeke +* Jean-Christian Denis (latest) - You are welcome to contribute to this code. +You are welcome to contribute to this code. diff --git a/_define.php b/_define.php index 89b484c..ebcc806 100644 --- a/_define.php +++ b/_define.php @@ -1,33 +1,31 @@ registerModule( 'Construction', 'Place your blog maintenance', 'Osku and contributors', - '1.8', + '1.9', [ - 'requires' => [['core', '2.27']], - 'permissions' => dcCore::app()->auth->makePermissions([ - dcAuth::PERMISSION_ADMIN, - ]), - 'priority' => 2000, - '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', + 'priority' => 2000, + '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 ac98606..558003b 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ Construction - 1.8 + 1.9 Osku and contributors Place your blog maintenance - https://git.dotclear.watch/JcDenis/construction/releases/download/v1.8/plugin-construction.zip - 2.27 + https://git.dotclear.watch/JcDenis/construction/releases/download/v1.9/plugin-construction.zip + 2.28 https://git.dotclear.watch/JcDenis/construction/src/branch/master/README.md https://git.dotclear.watch/JcDenis/construction/issues diff --git a/src/Backend.php b/src/Backend.php index 60b88a8..ba536f1 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -1,26 +1,21 @@ get('flag') ? 'construction-blog' : ''); + My::addBackendMenuItem(App::backend()->menus()::MENU_PLUGINS, [], '(&.*)?$', My::settings()->get('flag') ? 'construction-blog' : ''); - dcCore::app()->addBehaviors([ + App::behavior()->addBehaviors([ 'adminPageHTMLHead' => function (): void { if (My::settings()->get('flag')) { echo My::cssLoad('backend'); @@ -48,7 +43,7 @@ class Backend extends Process 'url' => My::manageUrl(), 'small-icon' => My::icons(), 'large-icon' => My::icons(), - 'permissions' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]), + 'permissions' => App::auth()->makePermissions([App::auth()::PERMISSION_ADMIN]), ]); }, ]); diff --git a/src/Frontend.php b/src/Frontend.php index 2940077..a27e039 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -1,25 +1,23 @@ addBehavior('publicBeforeDocumentV2', function (): void { + App::behavior()->addBehavior('publicBeforeDocumentV2', function (): void { // nullsafe PHP < 8.0 - if (is_null(dcCore::app()->blog)) { + if (!App::blog()->isDefined()) { return; } @@ -43,11 +41,11 @@ class Frontend extends Process return; } - $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(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) { - dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset])); + App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset])); } else { - dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', DC_DEFAULT_TPLSET])); + App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', App::config()->defaultTplset()])); } $all_allowed_ip = json_decode((string) My::settings()->get('allowed_ip'), true); @@ -56,33 +54,28 @@ class Frontend extends Process } $extra_urls = json_decode((string) My::settings()->get('extra_urls'), true); if (!in_array(Http::realIP(), $all_allowed_ip)) { - dcCore::app()->url->registerDefault(function (?string $args): void { - dcCore::app()->url->type = 'default'; + App::url()->registerDefault(function (?string $args): void { + App::url()->type = 'default'; throw new Exception('Blog under construction', 503); }); - dcCore::app()->url->registerError(function (?string $args, ?string $type, Exception $e): void { - // nullsafe PHP < 8.0 - if (is_null(dcCore::app()->ctx)) { - return; - } - + App::url()->registerError(function (?string $args, ?string $type, Exception $e): void { header('Content-Type: text/html; charset=UTF-8'); Http::head(503, 'Service Unavailable'); - dcCore::app()->url->type = '503'; - dcCore::app()->ctx->__set('current_tpl', '503.html'); - dcCore::app()->ctx->__set('content_type', 'text/html'); + App::url()->type = '503'; + App::frontend()->context()->__set('current_tpl', '503.html'); + App::frontend()->context()->__set('content_type', 'text/html'); - echo dcCore::app()->tpl->getData(dcCore::app()->ctx->__get('current_tpl')); + echo App::frontend()->template()->getData(App::frontend()->context()->__get('current_tpl')); # --BEHAVIOR-- publicAfterDocumentV2 - dcCore::app()->callBehavior('publicAfterDocumentV2'); + App::behavior()->callBehavior('publicAfterDocumentV2'); exit; }); - foreach (dcCore::app()->url->getTypes() as $k => $v) { + foreach (App::url()->getTypes() as $k => $v) { if (($k != 'contactme') && !in_array($k, $extra_urls)) { - dcCore::app()->url->register($k, $v['url'], $v['representation'], function () { + App::url()->register($k, $v['url'], $v['representation'], function () { throw new Exception('Blog under construction', 503); }); } @@ -90,16 +83,16 @@ class Frontend extends Process } }); - dcCore::app()->tpl->addValue('ConstructionMessage', function (ArrayObject $attr): string { + App::frontend()->template()->addValue('ConstructionMessage', function (ArrayObject $attr): string { return 'tpl->getFilters($attr), - 'dcCore::app()->blog->settings->get("' . My::id() . '")->get("message")' + App::frontend()->template()->getFilters($attr), + 'App::blog()->settings()->get("' . My::id() . '")->get("message")' ) . '; ?>'; }); - dcCore::app()->tpl->addValue('ConstructionTitle', function (ArrayObject $attr): string { + App::frontend()->template()->addValue('ConstructionTitle', function (ArrayObject $attr): string { return 'tpl->getFilters($attr), - 'dcCore::app()->blog->settings->get("' . My::id() . '")->get("title")' + App::frontend()->template()->getFilters($attr), + 'App::blog()->settings()->get("' . My::id() . '")->get("title")' ) . '; ?>'; }); diff --git a/src/Install.php b/src/Install.php index 16faf9e..098870e 100644 --- a/src/Install.php +++ b/src/Install.php @@ -1,23 +1,21 @@ error->add($e->getMessage()); + App::error()->add($e->getMessage()); } return true; diff --git a/src/Manage.php b/src/Manage.php index 4cd8500..4c0428b 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -1,20 +1,9 @@ blog)) { + if (!App::blog()->isDefined()) { return false; } @@ -74,7 +71,7 @@ class Manage extends Process $s->put('message', $_POST['construction_message']); $s->put('extra_urls', json_encode($extra_urls)); - dcCore::app()->blog->triggerBlog(); + App::blog()->triggerBlog(); Notices::addSuccessNotice( __('Settings successfully updated.') @@ -82,7 +79,7 @@ class Manage extends Process My::redirect(); } catch (Exception $e) { - dcCore::app()->error->add($e->getMessage()); + App::error()->add($e->getMessage()); } } @@ -96,12 +93,12 @@ class Manage extends Process } // nullsafe PHP < 8.0 - if (is_null(dcCore::app()->blog)) { + if (!App::blog()->isDefined()) { return; } $s = My::settings(); - $editor = dcCore::app()->auth->getOption('editor'); + $editor = App::auth()->getOption('editor'); $nb_rows = count(json_decode($s->get('allowed_ip'), true)); if ($nb_rows < 2) { $nb_rows = 2; @@ -112,7 +109,7 @@ class Manage extends Process Page::openModule( My::name(), Page::jsConfirmClose('opts-forms') . - dcCore::app()->callBehavior('adminPostEditor', $editor['xhtml'], 'construction', ['#construction_message'], 'xhtml') . + App::behavior()->callBehavior('adminPostEditor', $editor['xhtml'], 'construction', ['#construction_message'], 'xhtml') . Page::jsLoad('backend') ); diff --git a/src/My.php b/src/My.php index 71c342d..776381d 100644 --- a/src/My.php +++ b/src/My.php @@ -1,15 +1,5 @@ plugins->moduleExists('Uninstaller')) { + if (!self::status()) { return false; }