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 disclaimer 1.4 - 2023.08.12
=========================================================== ===========================================================
* Require dotclear 2.27 * Require dotclear 2.27

View file

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

View file

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

View file

@ -1,22 +1,12 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\disclaimer; namespace Dotclear\Plugin\disclaimer;
use ArrayObject; use ArrayObject;
use dcCore; use Dotclear\App;
use dcSettings; use Dotclear\Core\BlogSettings;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Checkbox, Checkbox,
@ -31,6 +21,13 @@ use Dotclear\Helper\Html\Form\{
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Exception; 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 class Backend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -44,8 +41,8 @@ class Backend extends Process
return false; return false;
} }
dcCore::app()->addBehaviors([ App::behavior()->addBehaviors([
'adminBeforeBlogSettingsUpdate' => function (dcSettings $blog_settings): void { 'adminBeforeBlogSettingsUpdate' => function (BlogSettings $blog_settings): void {
$s = $blog_settings->get(My::id()); $s = $blog_settings->get(My::id());
try { 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()); $s = $blog_settings->get(My::id());
$disclaimer_bots_agents = $s->get('disclaimer_bots_agents'); $disclaimer_bots_agents = $s->get('disclaimer_bots_agents');

View file

@ -1,23 +1,20 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\disclaimer; namespace Dotclear\Plugin\disclaimer;
use ArrayObject; use ArrayObject;
use dcCore; use Dotclear\App;
use Dotclear\Core\Process; 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 class Frontend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -43,27 +40,27 @@ class Frontend extends Process
__('I disagree'); __('I disagree');
# Templates # Templates
dcCore::app()->tpl->addValue('DisclaimerTitle', function (ArrayObject $attr): string { App::frontend()->template()->addValue('DisclaimerTitle', function (ArrayObject $attr): string {
return '<?php echo ' . sprintf( return '<?php echo ' . sprintf(
dcCore::app()->tpl->getFilters($attr), App::frontend()->template()->getFilters($attr),
My::class . '::settings()->get("disclaimer_title")' 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"); ?>'; return '<?php echo ' . My::class . '::settings()->get("disclaimer_text"); ?>';
}); });
dcCore::app()->tpl->addValue('DisclaimerFormURL', function (ArrayObject $attr): string { App::frontend()->template()->addValue('DisclaimerFormURL', function (ArrayObject $attr): string {
return '<?php dcCore::app()->blog->url; ?>'; return '<?php App::blog()->url(); ?>';
}); });
# Behaviors # Behaviors
dcCore::app()->addBehaviors([ App::behavior()->addBehaviors([
'publicHeadContent' => function (): void { 'publicHeadContent' => function (): void {
echo My::cssLoad('disclaimer'); echo My::cssLoad('disclaimer');
}, },
'publicBeforeDocumentV2' => [UrlHandler::class, 'publicBeforeDocumentV2'], 'publicBeforeDocumentV2' => UrlHandler::publicBeforeDocumentV2(...),
]); ]);
return true; return true;

View file

@ -1,23 +1,20 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\disclaimer; namespace Dotclear\Plugin\disclaimer;
use dcCore; use Dotclear\App;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Exception; 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 class Install extends Process
{ {
public static function init(): bool public static function init(): bool
@ -109,7 +106,7 @@ class Install extends Process
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); App::error()->add($e->getMessage());
} }
return true; return true;

View file

@ -1,15 +1,5 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\disclaimer; namespace Dotclear\Plugin\disclaimer;
@ -17,11 +7,19 @@ namespace Dotclear\Plugin\disclaimer;
use Dotclear\Module\MyPlugin; 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 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 = [ public const DEFAULT_BOTS_AGENTS = [
'bot', 'bot',
'Scooter', 'Scooter',
@ -40,9 +38,19 @@ class My extends MyPlugin
'Crawler', 'Crawler',
]; ];
/** @var string disclaimer specific cookie prefix */ /**
* disclaimer specific cookie prefix.
*
* @var string COOKIE_PREFIX
*/
public const COOKIE_PREFIX = 'dc_disclaimer_cookie_'; 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_'; public const SESSION_PREFIX = 'dc_disclaimer_sess_';
// Use default permissions
} }

View file

@ -1,23 +1,19 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\disclaimer; namespace Dotclear\Plugin\disclaimer;
use dcCore;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller; 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 class Uninstall extends Process
{ {
public static function init(): bool public static function init(): bool
@ -27,7 +23,7 @@ class Uninstall extends Process
public static function process(): bool public static function process(): bool
{ {
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) { if (!self::status()) {
return false; return false;
} }

View file

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