upgrade to Dotclear 2.27

This commit is contained in:
Jean-Christian Paul Denis 2023-08-13 21:46:39 +02:00
parent f75e235dee
commit 0a6db67262
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
3 changed files with 26 additions and 71 deletions

View File

@ -14,41 +14,22 @@ declare(strict_types=1);
namespace Dotclear\Plugin\testMail;
/* dotclear ns */
use dcAdmin;
use dcCore;
use dcNsProcess;
use dcPage;
use Dotclear\Core\Process;
class Backend extends dcNsProcess
class Backend extends Process
{
public static function init(): bool
{
static::$init = defined('DC_CONTEXT_ADMIN')
&& !is_null(dcCore::app()->auth)
&& dcCore::app()->auth->isSuperAdmin();
return static::$init;
return self::status(My::checkContext(My::BACKEND));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}
// nullsafe
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->adminurl)) {
return false;
}
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
My::name(),
dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
dcPage::getPF(My::id() . '/icon.svg'),
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
dcCore::app()->auth->isSuperAdmin()
);
My::addBackendMenuItem();
return true;
}

View File

@ -15,8 +15,11 @@ declare(strict_types=1);
namespace Dotclear\Plugin\testMail;
use dcCore;
use dcNsProcess;
use dcPage;
use Dotclear\Core\Backend\{
Notices,
Page
};
use Dotclear\Core\Process;
use Dotclear\Helper\Html\Form\{
Checkbox,
Div,
@ -32,25 +35,16 @@ use Dotclear\Helper\Network\Mail\Mail;
use Dotclear\Helper\Text;
use Exception;
class Manage extends dcNsProcess
class Manage extends Process
{
public static function init(): bool
{
static::$init = defined('DC_CONTEXT_ADMIN')
&& !is_null(dcCore::app()->auth)
&& dcCore::app()->auth->isSuperAdmin();
return static::$init;
return self::status(My::checkContext(My::MANAGE));
}
public static function process(): bool
{
if (!static::$init) {
return false;
}
// nullsafe
if (is_null(dcCore::app()->adminurl)) {
if (!self::status()) {
return false;
}
@ -76,8 +70,8 @@ class Manage extends dcNsProcess
} else {
Mail::sendMail($mail_to, $mail_subject, $mail_content);
}
dcPage::addSuccessNotice(__('Mail successuffly sent.'));
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id());
Notices::addSuccessNotice(__('Mail successuffly sent.'));
My::redirect();
return true;
} catch (Exception $e) {
@ -90,24 +84,24 @@ class Manage extends dcNsProcess
public static function render(): void
{
if (!static::$init) {
if (!self::status()) {
return;
}
dcpage::openModule(My::name());
Page::openModule(My::name());
echo
dcPage::breadcrumb([
Page::breadcrumb([
__('System') => '',
My::name() => '',
]) .
dcPage::notices() .
Notices::GetNotices() .
(new Div('mail_testor'))
->__call('items', [[
(new Form('mail_form'))
->__call('method', ['post'])
->__call('action', [dcCore::app()->admin->getPageURL()])
->__call('action', [My::manageUrl()])
->__call('fields', [[
(new Para())
->__call('items', [[
@ -151,13 +145,13 @@ class Manage extends dcNsProcess
(new Submit('save'))
->__call('accesskey', ['s'])
->__call('value', [__('Send')]),
dcCore::app()->formNonce(false),
... My::hiddenFields(),
]]),
]]),
]])
->render();
dcPage::closeModule();
Page::closeModule();
}
private static function getHeaders(): array

View File

@ -15,38 +15,18 @@ declare(strict_types=1);
namespace Dotclear\Plugin\testMail;
use dcCore;
use Dotclear\Module\MyPlugin;
/**
* This module definitions.
*/
class My
class My extends MyPlugin
{
/** @var string Mailer name */
public const X_MAILER = 'Dotclear';
/**
* This module id.
*/
public static function id(): string
public static function checkXustomContext(int $context): ?bool
{
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__);
return defined('DC_CONTEXT_ADMIN') && dcCore::app()->auth->isSuperAdmin();
}
}