code review

master v1.9.2
Jean-Christian Paul Denis 2023-10-25 10:19:04 +02:00
parent 4ff82cd794
commit 4f8b6cbfb5
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
7 changed files with 19 additions and 26 deletions

View File

@ -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 construction 1.9.1 - 2023.10.23
=========================================================== ===========================================================
* Require Dotclear 2.28 * Require Dotclear 2.28

View File

@ -1,7 +1,7 @@
# README # README
[![Release](https://img.shields.io/badge/release-1.9.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/construction/releases) [![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.23-c44d58.svg) ![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) [![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) [![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) [![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/construction/src/branch/master/LICENSE)

View File

@ -18,7 +18,7 @@ $this->registerModule(
'Construction', 'Construction',
'Place your blog maintenance', 'Place your blog maintenance',
'Osku and contributors', 'Osku and contributors',
'1.9.1', '1.9.2',
[ [
'requires' => [['core', '2.28']], 'requires' => [['core', '2.28']],
'permissions' => 'My', 'permissions' => 'My',

View File

@ -2,10 +2,10 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="construction"> <module id="construction">
<name>Construction</name> <name>Construction</name>
<version>1.9.1</version> <version>1.9.2</version>
<author>Osku and contributors</author> <author>Osku and contributors</author>
<desc>Place your blog maintenance</desc> <desc>Place your blog maintenance</desc>
<file>https://git.dotclear.watch/JcDenis/construction/releases/download/v1.9.1/plugin-construction.zip</file> <file>https://git.dotclear.watch/JcDenis/construction/releases/download/v1.9.2/plugin-construction.zip</file>
<da:dcmin>2.28</da:dcmin> <da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/construction/src/branch/master/README.md</da:details> <da:details>https://git.dotclear.watch/JcDenis/construction/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/construction/issues</da:support> <da:support>https://git.dotclear.watch/JcDenis/construction/issues</da:support>

View File

@ -29,7 +29,7 @@ class Backend extends Process
return false; return false;
} }
My::addBackendMenuItem(App::backend()->menus()::MENU_PLUGINS, [], '(&.*)?$', My::settings()->get('flag') ? 'construction-blog' : ''); My::addBackendMenuItem();
App::behavior()->addBehaviors([ App::behavior()->addBehaviors([
'adminPageHTMLHead' => function (): void { 'adminPageHTMLHead' => function (): void {

View File

@ -32,27 +32,24 @@ class Frontend extends Process
} }
App::behavior()->addBehavior('publicBeforeDocumentV2', function (): void { App::behavior()->addBehavior('publicBeforeDocumentV2', function (): void {
// nullsafe PHP < 8.0
if (!App::blog()->isDefined()) {
return;
}
if (!My::settings()->get('flag')) { if (!My::settings()->get('flag')) {
return; return;
} }
$tplset = App::themes()->moduleInfo(App::blog()->settings()->get('system')->get('theme'), 'tplset'); $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]))) { 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])); $tplset = App::config()->defaultTplset();
} else {
App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', 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); $all_allowed_ip = json_decode((string) My::settings()->get('allowed_ip'), true);
if (!is_array($all_allowed_ip)) { if (!is_array($all_allowed_ip)) {
$all_allowed_ip = []; $all_allowed_ip = [];
} }
$extra_urls = json_decode((string) My::settings()->get('extra_urls'), true); $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)) { if (!in_array(Http::realIP(), $all_allowed_ip)) {
App::url()->registerDefault(function (?string $args): void { App::url()->registerDefault(function (?string $args): void {
App::url()->type = 'default'; App::url()->type = 'default';

View File

@ -48,11 +48,6 @@ class Manage extends Process
return false; return false;
} }
// nullsafe PHP < 8.0
if (!App::blog()->isDefined()) {
return false;
}
$s = My::settings(); $s = My::settings();
if (!empty($_POST['saveconfig'])) { if (!empty($_POST['saveconfig'])) {
@ -93,11 +88,6 @@ class Manage extends Process
return; return;
} }
// nullsafe PHP < 8.0
if (!App::blog()->isDefined()) {
return;
}
$s = My::settings(); $s = My::settings();
$editor = App::auth()->getOption('editor'); $editor = App::auth()->getOption('editor');
$nb_rows = count(json_decode($s->get('allowed_ip'), true)); $nb_rows = count(json_decode($s->get('allowed_ip'), true));