code review

This commit is contained in:
Jean-Christian Denis 2023-10-20 21:28:21 +02:00
parent 4150bf1b19
commit 5e7765d395
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
9 changed files with 33 additions and 52 deletions

View file

@ -1,3 +1,10 @@
simplyFavicon 2023.10.20
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Fix use of interface
* Use default permissions
simplyFavicon 2023.10.14
===========================================================
* Require Dotclear 2.28

View file

@ -1,14 +1,14 @@
# README
[![Release](https://img.shields.io/badge/release-2023.10.14-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/simplyFavicon/releases)
![Date](https://img.shields.io/badge/date-2023.10.13-c44d58.svg)
[![Release](https://img.shields.io/badge/release-2023.10.20-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/simplyFavicon/releases)
![Date](https://img.shields.io/badge/date-2023.10.20-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/simplyFavicon)
[![License](https://img.shields.io/github/license/JcDenis/simplyFavicon)](https://git.dotclear.watch/JcDenis/simplyFavicon/blob/master/LICENSE)
## ABOUT
_pacKman_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
_simplyFavicon_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
> Add a favicon to your blog.
@ -17,7 +17,7 @@ _pacKman_ is a plugin for the open-source web publishing software called [Dotcle
* Dotclear 2.28
* PHP 8.1+
* A readable public directory
* Administrator permissions
* Dotclear admin permissions
## USAGE

View file

@ -1,16 +1,5 @@
<?php
/**
* @brief simplyFavicon, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
/*
* @file
* @brief The simplyFavicon pacKman definition
* @ingroup simplyFavicon
@ -28,16 +17,14 @@ $this->registerModule(
'Simply favicon',
'Multi-agents favicon',
'Jean-Christian Denis',
'2023.10.14',
'2023.10.20',
[
'requires' => [['core', '2.28']],
'permissions' => 'My',
'settings' => [
'blog' => '#params.' . basename(__DIR__) . '_params',
],
'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',
'settings' => ['blog' => '#params.' . basename(__DIR__) . '_params'],
'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',
]
);

View file

@ -2,10 +2,10 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="simplyFavicon">
<name>Simply favicon</name>
<version>2023.10.14</version>
<version>2023.10.20</version>
<author>Jean-Christian Denis</author>
<desc>Multi-agents favicon</desc>
<file>https://git.dotclear.watch/JcDenis/simplyFavicon/releases/download/v2023.10.14/plugin-simplyFavicon.zip</file>
<file>https://git.dotclear.watch/JcDenis/simplyFavicon/releases/download/v2023.10.20/plugin-simplyFavicon.zip</file>
<da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/simplyFavicon/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/simplyFavicon/issues</da:support>

View file

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Dotclear\Plugin\simplyFavicon;
use Dotclear\App;
use Dotclear\Core\BlogSettings;
use Dotclear\Core\Process;
use Dotclear\Helper\File\Path;
use Dotclear\Helper\Html\Form\{
@ -15,10 +14,11 @@ use Dotclear\Helper\Html\Form\{
Note,
Para
};
use Dotclear\Interface\Core\BlogSettingsInterface;
/**
* @brief simplyFavicon backend class.
* @ingroup simplyFavicon
* @brief simplyFavicon backend class.
* @ingroup simplyFavicon
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
@ -37,7 +37,7 @@ class Backend extends Process
}
App::behavior()->addBehaviors([
'adminBlogPreferencesFormV2' => function (BlogSettings $blog_settings): void {
'adminBlogPreferencesFormV2' => function (BlogSettingsInterface $blog_settings): void {
if (!App::blog()->isDefined()) {
return;
}
@ -78,7 +78,7 @@ class Backend extends Process
) .
'</div></div><br class="clear" /></div>';
},
'adminBeforeBlogSettingsUpdate' => function (BlogSettings $blog_settings): void {
'adminBeforeBlogSettingsUpdate' => function (BlogSettingsInterface $blog_settings): void {
$blog_settings->get('system')->put('simply_favicon', !empty($_POST['simply_favicon']));
},
]);

View file

@ -9,8 +9,8 @@ use Dotclear\Core\Process;
use Dotclear\Helper\File\Path;
/**
* @brief simplyFavicon frontend class.
* @ingroup simplyFavicon
* @brief simplyFavicon frontend class.
* @ingroup simplyFavicon
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html

View file

@ -4,29 +4,16 @@ declare(strict_types=1);
namespace Dotclear\Plugin\simplyFavicon;
use Dotclear\App;
use Dotclear\Module\MyPlugin;
/**
* @brief simplyFavicon My helper.
* @ingroup simplyFavicon
* @brief simplyFavicon My helper.
* @ingroup simplyFavicon
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class My extends MyPlugin
{
protected static function checkCustomContext(int $context): ?bool
{
return match ($context) {
// Limit BACKEND to admin
self::BACKEND => App::task()->checkContext('BACKEND')
&& App::blog()->isDefined()
&& App::auth()->check(App::auth()->makePermissions([
App::auth()::PERMISSION_ADMIN,
]), App::blog()->id()),
default => null,
};
}
// Use default permissions
}

View file

@ -8,8 +8,8 @@ use Dotclear\App;
use Dotclear\Core\Process;
/**
* @brief simplyFavicon prepend class.
* @ingroup simplyFavicon
* @brief simplyFavicon prepend class.
* @ingroup simplyFavicon
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html

View file

@ -9,8 +9,8 @@ use Dotclear\Core\Frontend\Url;
use Dotclear\Helper\File\Path;
/**
* @brief simplyFavicon frontend URL handler.
* @ingroup simplyFavicon
* @brief simplyFavicon frontend URL handler.
* @ingroup simplyFavicon
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html