upgrade to Dotclear 2.27
This commit is contained in:
parent
f75e235dee
commit
0a6db67262
@ -14,41 +14,22 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Dotclear\Plugin\testMail;
|
namespace Dotclear\Plugin\testMail;
|
||||||
|
|
||||||
/* dotclear ns */
|
use Dotclear\Core\Process;
|
||||||
use dcAdmin;
|
|
||||||
use dcCore;
|
|
||||||
use dcNsProcess;
|
|
||||||
use dcPage;
|
|
||||||
|
|
||||||
class Backend extends dcNsProcess
|
class Backend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
return self::status(My::checkContext(My::BACKEND));
|
||||||
&& !is_null(dcCore::app()->auth)
|
|
||||||
&& dcCore::app()->auth->isSuperAdmin();
|
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nullsafe
|
My::addBackendMenuItem();
|
||||||
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()
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,11 @@ declare(strict_types=1);
|
|||||||
namespace Dotclear\Plugin\testMail;
|
namespace Dotclear\Plugin\testMail;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Backend\{
|
||||||
use dcPage;
|
Notices,
|
||||||
|
Page
|
||||||
|
};
|
||||||
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Div,
|
Div,
|
||||||
@ -32,25 +35,16 @@ use Dotclear\Helper\Network\Mail\Mail;
|
|||||||
use Dotclear\Helper\Text;
|
use Dotclear\Helper\Text;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
class Manage extends dcNsProcess
|
class Manage extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
return self::status(My::checkContext(My::MANAGE));
|
||||||
&& !is_null(dcCore::app()->auth)
|
|
||||||
&& dcCore::app()->auth->isSuperAdmin();
|
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// nullsafe
|
|
||||||
if (is_null(dcCore::app()->adminurl)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,8 +70,8 @@ class Manage extends dcNsProcess
|
|||||||
} else {
|
} else {
|
||||||
Mail::sendMail($mail_to, $mail_subject, $mail_content);
|
Mail::sendMail($mail_to, $mail_subject, $mail_content);
|
||||||
}
|
}
|
||||||
dcPage::addSuccessNotice(__('Mail successuffly sent.'));
|
Notices::addSuccessNotice(__('Mail successuffly sent.'));
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id());
|
My::redirect();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@ -90,24 +84,24 @@ class Manage extends dcNsProcess
|
|||||||
|
|
||||||
public static function render(): void
|
public static function render(): void
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcpage::openModule(My::name());
|
Page::openModule(My::name());
|
||||||
|
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
__('System') => '',
|
__('System') => '',
|
||||||
My::name() => '',
|
My::name() => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
Notices::GetNotices() .
|
||||||
|
|
||||||
(new Div('mail_testor'))
|
(new Div('mail_testor'))
|
||||||
->__call('items', [[
|
->__call('items', [[
|
||||||
(new Form('mail_form'))
|
(new Form('mail_form'))
|
||||||
->__call('method', ['post'])
|
->__call('method', ['post'])
|
||||||
->__call('action', [dcCore::app()->admin->getPageURL()])
|
->__call('action', [My::manageUrl()])
|
||||||
->__call('fields', [[
|
->__call('fields', [[
|
||||||
(new Para())
|
(new Para())
|
||||||
->__call('items', [[
|
->__call('items', [[
|
||||||
@ -151,13 +145,13 @@ class Manage extends dcNsProcess
|
|||||||
(new Submit('save'))
|
(new Submit('save'))
|
||||||
->__call('accesskey', ['s'])
|
->__call('accesskey', ['s'])
|
||||||
->__call('value', [__('Send')]),
|
->__call('value', [__('Send')]),
|
||||||
dcCore::app()->formNonce(false),
|
... My::hiddenFields(),
|
||||||
]]),
|
]]),
|
||||||
]]),
|
]]),
|
||||||
]])
|
]])
|
||||||
->render();
|
->render();
|
||||||
|
|
||||||
dcPage::closeModule();
|
Page::closeModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getHeaders(): array
|
private static function getHeaders(): array
|
||||||
|
28
src/My.php
28
src/My.php
@ -15,38 +15,18 @@ declare(strict_types=1);
|
|||||||
namespace Dotclear\Plugin\testMail;
|
namespace Dotclear\Plugin\testMail;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module definitions.
|
* This module definitions.
|
||||||
*/
|
*/
|
||||||
class My
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
/** @var string Mailer name */
|
/** @var string Mailer name */
|
||||||
public const X_MAILER = 'Dotclear';
|
public const X_MAILER = 'Dotclear';
|
||||||
|
|
||||||
/**
|
public static function checkXustomContext(int $context): ?bool
|
||||||
* This module id.
|
|
||||||
*/
|
|
||||||
public static function id(): string
|
|
||||||
{
|
{
|
||||||
return basename(dirname(__DIR__));
|
return defined('DC_CONTEXT_ADMIN') && dcCore::app()->auth->isSuperAdmin();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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__);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user