From 4f8b6cbfb587a807d26bce0803363631cc65b087 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Wed, 25 Oct 2023 10:19:04 +0200 Subject: [PATCH] code review --- CHANGELOG.md | 6 ++++++ README.md | 4 ++-- _define.php | 2 +- dcstore.xml | 4 ++-- src/Backend.php | 2 +- src/Frontend.php | 17 +++++++---------- src/Manage.php | 10 ---------- 7 files changed, 19 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 476bf03..945e4a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +construction 1.9.2 - 2023.10.25 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Code review + construction 1.9.1 - 2023.10.23 =========================================================== * Require Dotclear 2.28 diff --git a/README.md b/README.md index 95ba4da..c6c6fb9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # README -[![Release](https://img.shields.io/badge/release-1.9.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/construction/releases) -![Date](https://img.shields.io/badge/date-2023.10.23-c44d58.svg) +[![Release](https://img.shields.io/badge/release-1.9.2-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/construction/releases) +![Date](https://img.shields.io/badge/date-2023.10.25-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/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/construction/src/branch/master/LICENSE) diff --git a/_define.php b/_define.php index a377356..af8d044 100644 --- a/_define.php +++ b/_define.php @@ -18,7 +18,7 @@ $this->registerModule( 'Construction', 'Place your blog maintenance', 'Osku and contributors', - '1.9.1', + '1.9.2', [ 'requires' => [['core', '2.28']], 'permissions' => 'My', diff --git a/dcstore.xml b/dcstore.xml index a458da8..9e9bf01 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,10 +2,10 @@ Construction - 1.9.1 + 1.9.2 Osku and contributors Place your blog maintenance - https://git.dotclear.watch/JcDenis/construction/releases/download/v1.9.1/plugin-construction.zip + https://git.dotclear.watch/JcDenis/construction/releases/download/v1.9.2/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 ba536f1..6bc01c8 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -29,7 +29,7 @@ class Backend extends Process return false; } - My::addBackendMenuItem(App::backend()->menus()::MENU_PLUGINS, [], '(&.*)?$', My::settings()->get('flag') ? 'construction-blog' : ''); + My::addBackendMenuItem(); App::behavior()->addBehaviors([ 'adminPageHTMLHead' => function (): void { diff --git a/src/Frontend.php b/src/Frontend.php index a27e039..6660461 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -32,27 +32,24 @@ class Frontend extends Process } App::behavior()->addBehavior('publicBeforeDocumentV2', function (): void { - // nullsafe PHP < 8.0 - if (!App::blog()->isDefined()) { - return; - } - if (!My::settings()->get('flag')) { return; } - $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]))) { - App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset])); - } else { - App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', App::config()->defaultTplset()])); + $tplset = App::themes()->getDefine(App::blog()->settings()->get('system')->get('theme'))->get('tplset'); + if (empty($tplset) || !is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) { + $tplset = App::config()->defaultTplset(); } + App::frontend()->template()->appendPath(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset])); $all_allowed_ip = json_decode((string) My::settings()->get('allowed_ip'), true); if (!is_array($all_allowed_ip)) { $all_allowed_ip = []; } $extra_urls = json_decode((string) My::settings()->get('extra_urls'), true); + if (!is_array($extra_urls)) { + $extra_urls = []; + } if (!in_array(Http::realIP(), $all_allowed_ip)) { App::url()->registerDefault(function (?string $args): void { App::url()->type = 'default'; diff --git a/src/Manage.php b/src/Manage.php index 86d844c..c0fc968 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -48,11 +48,6 @@ class Manage extends Process return false; } - // nullsafe PHP < 8.0 - if (!App::blog()->isDefined()) { - return false; - } - $s = My::settings(); if (!empty($_POST['saveconfig'])) { @@ -93,11 +88,6 @@ class Manage extends Process return; } - // nullsafe PHP < 8.0 - if (!App::blog()->isDefined()) { - return; - } - $s = My::settings(); $editor = App::auth()->getOption('editor'); $nb_rows = count(json_decode($s->get('allowed_ip'), true));