upgrade to Dotclear 2.28

This commit is contained in:
Jean-Christian Denis 2023-10-16 21:29:31 +02:00
parent 1670e45982
commit e24be7c3f9
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
10 changed files with 130 additions and 155 deletions

View file

@ -1,3 +1,9 @@
disclaimer 1.5 - 2023.10.15
===========================================================
* Require dotclear 2.28
* Require PHP 8.1
* Upgrade to Dotclear 2.28
disclaimer 1.4 - 2023.08.12
===========================================================
* Require dotclear 2.27

View file

@ -1,27 +1,22 @@
# README
[![Release](https://img.shields.io/badge/release-1.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/disclaimer/releases)
[![Date](https://img.shields.io/badge/date-2023.09.12-c44d58.svg)](https://git.dotclear.watch/JcDenis/disclaimer/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.5-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/disclaimer/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/disclaimer)
[![License](https://img.shields.io/github/license/JcDenis/disclaimer)](https://git.dotclear.watch/JcDenis/disclaimer/blob/master/LICENSE)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/disclaimer/src/branch/master/LICENSE)
## WHAT IS DISCLAIMER ?
## ABOUT
_disclaimer_ is a plugin for the open-source
web publishing software called Dotclear.
_disclaimer_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
It add a disclaimer to your blog entrance.
This plugin is inspired from plugin "Private mode" by Osku.
> It add a disclaimer to your blog entrance. This plugin is inspired from plugin "Private mode" by Osku.
## REQUIREMENTS
_disclaimer_ requires:
* admin permissions on blog
* Dotclear 2.27
* PHP 7.4+
* Dotclear 2.28
* PHP 8.1+
* Dotclear admin permissions on blog
## USAGE
@ -32,10 +27,11 @@ You can activate and setup _disclaimer_ from blog preferences page.
## 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/disclaimer) or [GitHub Page](https://github.com/JcDenis/disclaimer)
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/disclaimer/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/disclaimer)
* Help & discuss : [Dotclear forum](http://forum.dotclear.org/viewtopic.php?id=40000)
* [License](https://git.dotclear.watch/JcDenis/disclaimer/src/branch/master/LICENSE)
* [Packages & details](https://git.dotclear.watch/JcDenis/disclaimer/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/disclaimer))
* [Sources & contributions](https://git.dotclear.watch/JcDenis/disclaimer) (or on [GitHub](https://github.com/JcDenis/disclaimer))
* [Issues & security](https://git.dotclear.watch/JcDenis/disclaimer/issues) (or on [GitHub](https://github.com/JcDenis/disclaimer/issues))
* [Help & discuss](http://forum.dotclear.org/viewtopic.php?id=40000)
## CONTRIBUTORS

View file

@ -1,35 +1,30 @@
<?php
/**
* @brief disclaimer, a plugin for Dotclear 2
* @file
* @brief The plugin disclaimer definition
* @ingroup disclaimer
*
* @package Dotclear
* @subpackage Plugin
* @defgroup disclaimer Plugin disclaimer.
*
* @author Jean-Christian Denis, Pierre Van Glabeke
* Add a disclaimer to your blog entrance.
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
declare(strict_types=1);
$this->registerModule(
'Disclaimer',
'Add a disclaimer to your blog entrance',
'Jean-Christian Denis, Pierre Van Glabeke',
'1.4',
'1.5',
[
'requires' => [['core', '2.27']],
'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_ADMIN,
]),
'settings' => [
'blog' => '#params.' . basename(__DIR__) . 'Param',
],
'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',
'settings' => ['blog' => '#params.' . basename(__DIR__) . 'Param'],
'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,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="disclaimer">
<name>Disclaimer</name>
<version>1.4</version>
<version>1.5</version>
<author>Jean-Christian Denis, Pierre Van Glabeke</author>
<desc>Add a disclaimer to your blog entrance</desc>
<file>https://git.dotclear.watch/JcDenis/disclaimer/releases/download/v1.4/plugin-disclaimer.zip</file>
<da:dcmin>2.27</da:dcmin>
<file>https://git.dotclear.watch/JcDenis/disclaimer/releases/download/v1.5/plugin-disclaimer.zip</file>
<da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/disclaimer/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/disclaimer/issues</da:support>
</module>

View file

@ -1,22 +1,12 @@
<?php
/**
* @brief disclaimer, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\disclaimer;
use ArrayObject;
use dcCore;
use dcSettings;
use Dotclear\App;
use Dotclear\Core\BlogSettings;
use Dotclear\Core\Process;
use Dotclear\Helper\Html\Form\{
Checkbox,
@ -31,6 +21,13 @@ use Dotclear\Helper\Html\Form\{
use Dotclear\Helper\Html\Html;
use Exception;
/**
* @brief disclaimer backend class.
* @ingroup disclaimer
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Backend extends Process
{
public static function init(): bool
@ -44,8 +41,8 @@ class Backend extends Process
return false;
}
dcCore::app()->addBehaviors([
'adminBeforeBlogSettingsUpdate' => function (dcSettings $blog_settings): void {
App::behavior()->addBehaviors([
'adminBeforeBlogSettingsUpdate' => function (BlogSettings $blog_settings): void {
$s = $blog_settings->get(My::id());
try {
@ -72,7 +69,7 @@ class Backend extends Process
}
},
'adminBlogPreferencesFormV2' => function (dcSettings $blog_settings): void {
'adminBlogPreferencesFormV2' => function (BlogSettings $blog_settings): void {
$s = $blog_settings->get(My::id());
$disclaimer_bots_agents = $s->get('disclaimer_bots_agents');

View file

@ -1,23 +1,20 @@
<?php
/**
* @brief disclaimer, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\disclaimer;
use ArrayObject;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
/**
* @brief disclaimer frontend class.
* @ingroup disclaimer
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Frontend extends Process
{
public static function init(): bool
@ -43,27 +40,27 @@ class Frontend extends Process
__('I disagree');
# Templates
dcCore::app()->tpl->addValue('DisclaimerTitle', function (ArrayObject $attr): string {
App::frontend()->template()->addValue('DisclaimerTitle', function (ArrayObject $attr): string {
return '<?php echo ' . sprintf(
dcCore::app()->tpl->getFilters($attr),
App::frontend()->template()->getFilters($attr),
My::class . '::settings()->get("disclaimer_title")'
) . '; ?>';
});
dcCore::app()->tpl->addValue('DisclaimerText', function (ArrayObject $attr): string {
App::frontend()->template()->addValue('DisclaimerText', function (ArrayObject $attr): string {
return '<?php echo ' . My::class . '::settings()->get("disclaimer_text"); ?>';
});
dcCore::app()->tpl->addValue('DisclaimerFormURL', function (ArrayObject $attr): string {
return '<?php dcCore::app()->blog->url; ?>';
App::frontend()->template()->addValue('DisclaimerFormURL', function (ArrayObject $attr): string {
return '<?php App::blog()->url(); ?>';
});
# Behaviors
dcCore::app()->addBehaviors([
App::behavior()->addBehaviors([
'publicHeadContent' => function (): void {
echo My::cssLoad('disclaimer');
},
'publicBeforeDocumentV2' => [UrlHandler::class, 'publicBeforeDocumentV2'],
'publicBeforeDocumentV2' => UrlHandler::publicBeforeDocumentV2(...),
]);
return true;

View file

@ -1,23 +1,20 @@
<?php
/**
* @brief disclaimer, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\disclaimer;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
use Exception;
/**
* @brief disclaimer install class.
* @ingroup disclaimer
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Install extends Process
{
public static function init(): bool
@ -109,7 +106,7 @@ class Install extends Process
return true;
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
App::error()->add($e->getMessage());
}
return true;

View file

@ -1,15 +1,5 @@
<?php
/**
* @brief disclaimer, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\disclaimer;
@ -17,11 +7,19 @@ namespace Dotclear\Plugin\disclaimer;
use Dotclear\Module\MyPlugin;
/**
* This module definitions.
* @brief disclaimer My helper.
* @ingroup disclaimer
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class My extends MyPlugin
{
/** @var array Default list of bots agents */
/**
* Default list of bots agents.
*
* @var array DEFAULT_BOTS_AGENTS
*/
public const DEFAULT_BOTS_AGENTS = [
'bot',
'Scooter',
@ -40,9 +38,19 @@ class My extends MyPlugin
'Crawler',
];
/** @var string disclaimer specific cookie prefix */
/**
* disclaimer specific cookie prefix.
*
* @var string COOKIE_PREFIX
*/
public const COOKIE_PREFIX = 'dc_disclaimer_cookie_';
/** @var string disclaimer specific session prefix */
/**
* disclaimer specific session prefix.
*
* @var string SESSION_PREFIX
*/
public const SESSION_PREFIX = 'dc_disclaimer_sess_';
// Use default permissions
}

View file

@ -1,23 +1,19 @@
<?php
/**
* @brief disclaimer, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\disclaimer;
use dcCore;
use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller;
/**
* @brief disclaimer uninstall class.
* @ingroup disclaimer
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Uninstall extends Process
{
public static function init(): bool
@ -27,7 +23,7 @@ class Uninstall extends Process
public static function process(): bool
{
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
if (!self::status()) {
return false;
}

View file

@ -1,31 +1,23 @@
<?php
/**
* @brief disclaimer, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\disclaimer;
use dcCore;
use dcUrlHandlers;
use Dotclear\App;
use Dotclear\Core\Frontend\Url;
use Dotclear\Database\Session;
use Dotclear\Helper\Network\Http;
use Dotclear\Helper\Network\UrlHandler as HelperHandler;
/**
* @ingroup DC_PLUGIN_DISCLAIMER
* @brief Public disclaimer - URL handler.
* @since 2.6
* @brief disclaimer frontend URL handler class.
* @ingroup disclaimer
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class UrlHandler extends dcUrlHandlers
class UrlHandler extends Url
{
/**
* Remove public callbacks (and serve disclaimer css)
@ -45,8 +37,7 @@ class UrlHandler extends dcUrlHandlers
*/
public static function publicBeforeDocumentV2(): void
{
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) {
if (!App::blog()->isDefined()) {
return;
}
@ -70,37 +61,29 @@ class UrlHandler extends dcUrlHandlers
}
# Set default-templates path for disclaimer files
$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(My::path() . '/default-templates/' . $tplset)) {
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), My::path() . '/default-templates/' . $tplset);
App::frontend()->template()->setPath(App::frontend()->template()->getPath(), My::path() . '/default-templates/' . $tplset);
} else {
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), My::path() . '/default-templates/' . DC_DEFAULT_TPLSET);
App::frontend()->template()->setPath(App::frontend()->template()->getPath(), My::path() . '/default-templates/' . App::config()->defaultTplset());
}
# New URL handler
$urlHandler = new HelperHandler();
$urlHandler->mode = dcCore::app()->url->mode;
$urlHandler->registerDefault([
self::class,
'overwriteCallbacks',
]);
$urlHandler->mode = App::url()->mode;
$urlHandler->registerDefault(self::overwriteCallbacks(...));
# Create session
$session = new Session(
dcCore::app()->con,
dcCore::app()->prefix . 'session',
My::SESSION_PREFIX . dcCore::app()->blog->id,
'/'
);
$session = App::session()->createFromCookieName(My::SESSION_PREFIX . App::blog()->id());
$session->start();
# Remove all URLs representations
foreach (dcCore::app()->url->getTypes() as $k => $v) {
foreach (App::url()->getTypes() as $k => $v) {
$urlHandler->register(
$k,
$v['url'],
$v['representation'],
[self::class, 'overwriteCallbacks']
self::overwriteCallbacks(...)
);
}
@ -110,7 +93,7 @@ class UrlHandler extends dcUrlHandlers
unset($urlHandler);
# Test cookie
$cookie_name = My::COOKIE_PREFIX . dcCore::app()->blog->id;
$cookie_name = My::COOKIE_PREFIX . App::blog()->id();
$cookie_value = empty($_COOKIE[$cookie_name]) || !$s->get('disclaimer_remember') ?
false : ($_COOKIE[$cookie_name]) == 1;