upgrade to Dotclear 2.27
This commit is contained in:
parent
a373865945
commit
fe891d504f
@ -14,37 +14,37 @@ declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\licenseBootstrap;
|
||||
|
||||
use dcAdmin;
|
||||
use dcCore;
|
||||
use dcFavorites;
|
||||
use dcNsProcess;
|
||||
use dcPage;
|
||||
use Dotclear\Core\Backend\Favorites;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
class Backend extends dcNsProcess
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& 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;
|
||||
}
|
||||
|
||||
My::addBackendMenuItem();
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
|
||||
$favs->register(My::id(), [
|
||||
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
|
||||
$favs->register(
|
||||
My::id(),
|
||||
[
|
||||
'title' => My::name(),
|
||||
'url' => dcCore::app()->adminurl?->get('admin.plugin.' . My::id()),
|
||||
'small-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||
'large-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||
//'permissions' => dcCore::app()->auth->isSuperAdmin(),
|
||||
]);
|
||||
'url' => My::manageUrl(),
|
||||
'small-icon' => My::icons(),
|
||||
'large-icon' => My::icons(),
|
||||
//'permissions' => null,
|
||||
]
|
||||
);
|
||||
},
|
||||
'packmanBeforeCreatePackage' => function ($module) {
|
||||
if (Settings::init()->behavior_packman) {
|
||||
@ -53,14 +53,6 @@ class Backend extends dcNsProcess
|
||||
},
|
||||
]);
|
||||
|
||||
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((string) dcCore::app()->adminurl?->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
||||
dcCore::app()->auth?->isSuperAdmin()
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ declare(strict_types=1);
|
||||
namespace Dotclear\Plugin\licenseBootstrap;
|
||||
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Backend\Notices;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
@ -29,19 +29,16 @@ use Dotclear\Helper\Html\Form\{
|
||||
};
|
||||
use Exception;
|
||||
|
||||
class Config extends dcNsProcess
|
||||
class Config extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init == defined('DC_CONTEXT_ADMIN')
|
||||
&& dcCore::app()->auth?->isSuperAdmin();
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::CONFIG));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -68,10 +65,10 @@ class Config extends dcNsProcess
|
||||
$s->writeSetting('license_name', Utils::getName($license_name));
|
||||
$s->writeSetting('license_head', Utils::encode($license_head));
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
Notices::addSuccessNotice(
|
||||
__('Configuration has been successfully updated.')
|
||||
);
|
||||
dcCore::app()->adminurl?->redirect('admin.plugins', [
|
||||
dcCore::app()->admin->url->redirect('admin.plugins', [
|
||||
'module' => My::id(),
|
||||
'conf' => '1',
|
||||
'redir' => dcCore::app()->admin->__get('list')->getRedir(),
|
||||
@ -85,7 +82,7 @@ class Config extends dcNsProcess
|
||||
|
||||
public static function render(): void
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -16,22 +16,19 @@ namespace Dotclear\Plugin\licenseBootstrap;
|
||||
|
||||
use dcCore;
|
||||
use dcNamespace;
|
||||
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) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,12 @@ declare(strict_types=1);
|
||||
namespace Dotclear\Plugin\licenseBootstrap;
|
||||
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use dcThemes;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
Page
|
||||
};
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
@ -31,19 +34,16 @@ use Dotclear\Helper\File\Path;
|
||||
use Dotclear\Helper\Network\Http;
|
||||
use Exception;
|
||||
|
||||
class Manage extends dcNsProcess
|
||||
class Manage extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& dcCore::app()->auth?->isSuperAdmin();
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::MANAGE));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -75,13 +75,14 @@ class Manage extends dcNsProcess
|
||||
Utils::addLicense($module);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
Notices::addSuccessNotice(
|
||||
__('License successfully added.')
|
||||
);
|
||||
Http::redirect(
|
||||
empty($_POST['redir']) ?
|
||||
dcCore::app()->admin->getPageURL() : $_POST['redir']
|
||||
);
|
||||
if (empty($_POST['redir'])) {
|
||||
My::redirect();
|
||||
} else {
|
||||
Http::redirect($_POST['redir']);
|
||||
};
|
||||
} catch(Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
@ -91,28 +92,28 @@ class Manage extends dcNsProcess
|
||||
|
||||
public static function render(): void
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$m = self::loadModules();
|
||||
|
||||
# Display
|
||||
dcPage::openModule(
|
||||
Page::openModule(
|
||||
My::name(),
|
||||
dcPage::jsPageTabs() .
|
||||
dcPage::jsModuleLoad(My::id() . '/js/licensebootstrap.js') .
|
||||
Page::jsPageTabs() .
|
||||
My::jsLoad('licensebootstrap') .
|
||||
|
||||
# --BEHAVIOR-- licenseBootstrapAdminHeader
|
||||
dcCore::app()->callBehavior('licenseBootstrapAdminHeader')
|
||||
);
|
||||
|
||||
echo
|
||||
dcPage::breadcrumb([
|
||||
Page::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
My::name() => '',
|
||||
]) .
|
||||
dcPage::notices();
|
||||
Notices::getNotices();
|
||||
|
||||
self::displayModulesList(
|
||||
$m['plugins']->getModules(),
|
||||
@ -126,9 +127,9 @@ class Manage extends dcNsProcess
|
||||
__('Installed themes')
|
||||
);
|
||||
|
||||
dcPage::helpBlock('licenseBootstrap');
|
||||
Page::helpBlock('licenseBootstrap');
|
||||
|
||||
dcPage::closeModule();
|
||||
Page::closeModule();
|
||||
}
|
||||
|
||||
private static function displayModulesList(array $modules, string $type, string $title): void
|
||||
@ -185,6 +186,7 @@ class Manage extends dcNsProcess
|
||||
'<p class="checkboxes-helpers"></p>' .
|
||||
(new Para())->items([
|
||||
(new Hidden(['redir'], empty($_REQUEST['redir']) ? '' : Html::escapeHTML($_REQUEST['redir']))),
|
||||
(new Hidden(['process'], 'Plugin')),
|
||||
(new Hidden(['p'], My::id())),
|
||||
(new Hidden(['type'], $type)),
|
||||
(new Hidden(['action'], 'addlicense')),
|
||||
|
29
src/My.php
29
src/My.php
@ -15,38 +15,19 @@ declare(strict_types=1);
|
||||
namespace Dotclear\Plugin\licenseBootstrap;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
*/
|
||||
class My
|
||||
class My extends MyPlugin
|
||||
{
|
||||
/** @var string Licenses default templates folder name */
|
||||
public const TEMPLATE_FOLDER = 'licenses';
|
||||
|
||||
/**
|
||||
* This module id.
|
||||
*/
|
||||
public static function id(): string
|
||||
protected static function checkCustomContext(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 $context === My::INSTALL ? null :
|
||||
defined('DC_CONTEXT_ADMIN') && dcCore::app()->auth->isSuperAdmin();
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\licenseBootstrap;
|
||||
|
||||
use dcCore;
|
||||
|
||||
class Settings
|
||||
{
|
||||
/** @var Settings self instance */
|
||||
@ -53,7 +51,7 @@ class Settings
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$s = dcCore::app()->blog?->settings->get(My::id());
|
||||
$s = My::settings();
|
||||
|
||||
$this->hide_distrib = (bool) ($s?->get('hide_distrib') ?? false);
|
||||
$this->overwrite = (bool) ($s?->get('overwrite') ?? false);
|
||||
@ -91,8 +89,8 @@ class Settings
|
||||
public function writeSetting(string $key, mixed $value): bool
|
||||
{
|
||||
if (property_exists($this, $key) && settype($value, gettype($this->{$key})) === true) {
|
||||
dcCore::app()->blog?->settings->get(My::id())->drop($key);
|
||||
dcCore::app()->blog?->settings->get(My::id())->put($key, $value, gettype($this->{$key}), '', true, true);
|
||||
My::settings()->drop($key);
|
||||
My::settings()->put($key, $value, gettype($this->{$key}), '', true, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -15,21 +15,19 @@ declare(strict_types=1);
|
||||
namespace Dotclear\Plugin\licenseBootstrap;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user