upgrade to Dotclear 2.27
This commit is contained in:
parent
721a12e15c
commit
8e928f448c
@ -16,9 +16,8 @@ namespace Dotclear\Plugin\disclaimer;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use dcNsProcess;
|
||||
use dcSettings;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
@ -32,22 +31,16 @@ use Dotclear\Helper\Html\Form\{
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Exception;
|
||||
|
||||
class Backend extends dcNsProcess
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog) // nullsafe PHP < 8.0
|
||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id);
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::BACKEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -70,7 +63,7 @@ class Backend extends dcNsProcess
|
||||
},
|
||||
|
||||
'adminBlogPreferencesHeaders' => function (): string {
|
||||
return dcPage::jsModuleLoad(My::id() . '/js/backend.js');
|
||||
return My::jsLoad('backend');
|
||||
},
|
||||
|
||||
'adminPostEditorTags' => function (string $editor, string $context, ArrayObject $alt_tags, string $format): void {
|
||||
@ -89,7 +82,7 @@ class Backend extends dcNsProcess
|
||||
|
||||
echo
|
||||
(new Div())->class('fieldset')->items([
|
||||
(new Text('h4', My::name()))->id('disclaimerParam'),
|
||||
(new Text('h4', My::name()))->id(My::id() . 'Param'),
|
||||
(new Div())->class('two-boxes even')->items([
|
||||
(new Para())->items([
|
||||
(new Checkbox('disclaimer_active', (bool) $s->get('disclaimer_active')))->value(1),
|
||||
|
@ -16,31 +16,23 @@ namespace Dotclear\Plugin\disclaimer;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use dcUtils;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
class Frontend extends dcNsProcess
|
||||
class Frontend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_RC_PATH');
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::FRONTEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
# Is active
|
||||
if (!dcCore::app()->blog->settings->get(My::id())->get('disclaimer_active')) {
|
||||
if (!My::settings()->get('disclaimer_active')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -54,12 +46,12 @@ class Frontend extends dcNsProcess
|
||||
dcCore::app()->tpl->addValue('DisclaimerTitle', function (ArrayObject $attr): string {
|
||||
return '<?php echo ' . sprintf(
|
||||
dcCore::app()->tpl->getFilters($attr),
|
||||
'dcCore::app()->blog->settings->get("disclaimer")->get("disclaimer_title")'
|
||||
My::class . '::settings()->get("disclaimer_title")'
|
||||
) . '; ?>';
|
||||
});
|
||||
|
||||
dcCore::app()->tpl->addValue('DisclaimerText', function (ArrayObject $attr): string {
|
||||
return '<?php echo dcCore::app()->blog->settings->get("disclaimer")->get("disclaimer_text"); ?>';
|
||||
return '<?php echo ' . My::class . '::settings()->get("disclaimer_text"); ?>';
|
||||
});
|
||||
|
||||
dcCore::app()->tpl->addValue('DisclaimerFormURL', function (ArrayObject $attr): string {
|
||||
@ -69,7 +61,7 @@ class Frontend extends dcNsProcess
|
||||
# Behaviors
|
||||
dcCore::app()->addBehaviors([
|
||||
'publicHeadContent' => function (): void {
|
||||
echo dcUtils::cssModuleLoad(My::id() . '/css/disclaimer.css');
|
||||
echo My::cssLoad('disclaimer');
|
||||
},
|
||||
'publicBeforeDocumentV2' => [UrlHandler::class, 'publicBeforeDocumentV2'],
|
||||
]);
|
||||
|
@ -15,27 +15,19 @@ declare(strict_types=1);
|
||||
namespace Dotclear\Plugin\disclaimer;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Exception;
|
||||
|
||||
class Install extends dcNsProcess
|
||||
class Install extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::INSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -105,7 +97,7 @@ class Install extends dcNsProcess
|
||||
try {
|
||||
// Settings
|
||||
foreach ($mod_conf as $v) {
|
||||
dcCore::app()->blog->settings->get(My::id())->put(
|
||||
My::settings()->put(
|
||||
$v[0],
|
||||
$v[2],
|
||||
$v[3],
|
||||
|
30
src/My.php
30
src/My.php
@ -14,12 +14,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\disclaimer;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
*/
|
||||
class My
|
||||
class My extends MyPlugin
|
||||
{
|
||||
/** @var array Default list of bots agents */
|
||||
public const DEFAULT_BOTS_AGENTS = [
|
||||
@ -45,30 +45,4 @@ class My
|
||||
|
||||
/** @var string disclaimer specific session prefix */
|
||||
public const SESSION_PREFIX = 'dc_disclaimer_sess_';
|
||||
|
||||
/**
|
||||
* This module id.
|
||||
*/
|
||||
public static function id(): string
|
||||
{
|
||||
return basename(dirname(__DIR__));
|
||||
}
|
||||
|
||||
/**
|
||||
* This module name.
|
||||
*/
|
||||
public static function name(): string
|
||||
{
|
||||
$name = dcCore::app()->plugins->moduleInfo(self::id(), 'name');
|
||||
|
||||
return __(is_string($name) ? $name : self::id());
|
||||
}
|
||||
|
||||
/**
|
||||
* This module path.
|
||||
*/
|
||||
public static function path(): string
|
||||
{
|
||||
return dirname(__DIR__);
|
||||
}
|
||||
}
|
||||
|
@ -15,21 +15,19 @@ declare(strict_types=1);
|
||||
namespace Dotclear\Plugin\disclaimer;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
class Uninstall extends dcNsProcess
|
||||
class Uninstall extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN');
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::UNINSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class UrlHandler extends dcUrlHandlers
|
||||
return;
|
||||
}
|
||||
|
||||
$s = dcCore::app()->blog->settings->get(My::id());
|
||||
$s = My::settings();
|
||||
|
||||
# Test user-agent to see if it is a bot
|
||||
if (!$s->get('disclaimer_bots_unactive')) {
|
||||
|
Loading…
Reference in New Issue
Block a user