upgrade to Dotclear 2.27
This commit is contained in:
parent
6dd3f2b4ba
commit
5687b72e5f
6 changed files with 33 additions and 83 deletions
|
@ -16,8 +16,8 @@ namespace Dotclear\Plugin\dcLatestVersions;
|
||||||
|
|
||||||
use ArrayObject;
|
use ArrayObject;
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
|
||||||
use dcUpdate;
|
use dcUpdate;
|
||||||
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Label,
|
Label,
|
||||||
|
@ -25,18 +25,16 @@ use Dotclear\Helper\Html\Form\{
|
||||||
};
|
};
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,15 +42,15 @@ class Backend extends dcNsProcess
|
||||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||||
'adminDashboardItemsV2' => function (ArrayObject $__dashboard_items): void {
|
'adminDashboardItemsV2' => function (ArrayObject $__dashboard_items): void {
|
||||||
// nullsafe PHP < 8.0
|
// nullsafe PHP < 8.0
|
||||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs) || is_null(dcCore::app()->blog)) {
|
if (is_null(dcCore::app()->blog)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dcCore::app()->auth->user_prefs->get('dashboard')->get('dcLatestVersionsItems')) {
|
if (!My::prefs()->get('dashboard_items')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$builds = explode(',', (string) dcCore::app()->blog->settings->get(My::id())->get('builds'));
|
$builds = explode(',', (string) My::settings()->get('builds'));
|
||||||
if (empty($builds[0])) {
|
if (empty($builds[0])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -97,14 +95,9 @@ class Backend extends dcNsProcess
|
||||||
},
|
},
|
||||||
|
|
||||||
'adminDashboardOptionsFormV2' => function (): void {
|
'adminDashboardOptionsFormV2' => function (): void {
|
||||||
// nullsafe PHP < 8.0
|
if (!My::prefs()->prefExists('dashboard_items')) {
|
||||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs)) {
|
My::prefs()->put(
|
||||||
return;
|
'dashboard_items',
|
||||||
}
|
|
||||||
|
|
||||||
if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('dcLatestVersionsItems')) {
|
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
|
||||||
'dcLatestVersionsItems',
|
|
||||||
false,
|
false,
|
||||||
'boolean'
|
'boolean'
|
||||||
);
|
);
|
||||||
|
@ -115,10 +108,10 @@ class Backend extends dcNsProcess
|
||||||
'<h4>' . Html::escapeHTML(My::name()) . '</h4>' .
|
'<h4>' . Html::escapeHTML(My::name()) . '</h4>' .
|
||||||
(new Para())
|
(new Para())
|
||||||
->__call('items', [[
|
->__call('items', [[
|
||||||
(new Checkbox('dcLatestVersionsItems', (bool) dcCore::app()->auth->user_prefs->get('dashboard')->get('dcLatestVersionsItems')))
|
(new Checkbox(My::id() . 'dashboard_items', (bool) My::prefs()->get('dashboard_items')))
|
||||||
->__call('value', [1]),
|
->__call('value', [1]),
|
||||||
(new Label(__("Show Dotclear's latest versions on dashboards."), Label::OUTSIDE_LABEL_AFTER))
|
(new Label(__("Show Dotclear's latest versions on dashboards."), Label::OUTSIDE_LABEL_AFTER))
|
||||||
->__call('for', ['dcLatestVersionsItems'])
|
->__call('for', [My::id() . 'dashboard_items'])
|
||||||
->__call('class', ['classic']),
|
->__call('class', ['classic']),
|
||||||
]])
|
]])
|
||||||
->render() .
|
->render() .
|
||||||
|
@ -126,14 +119,9 @@ class Backend extends dcNsProcess
|
||||||
},
|
},
|
||||||
|
|
||||||
'adminAfterDashboardOptionsUpdate' => function (?string $user_id): void {
|
'adminAfterDashboardOptionsUpdate' => function (?string $user_id): void {
|
||||||
// nullsafe PHP < 8.0
|
My::prefs()->put(
|
||||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs)) {
|
'dashboard_items',
|
||||||
return;
|
!empty($_POST[My::id() . 'dashboard_items']),
|
||||||
}
|
|
||||||
|
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
|
||||||
'dcLatestVersionsItems',
|
|
||||||
!empty($_POST['dcLatestVersionsItems']),
|
|
||||||
'boolean'
|
'boolean'
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,20 +15,18 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\dcLatestVersions;
|
namespace Dotclear\Plugin\dcLatestVersions;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
class Frontend extends dcNsProcess
|
class Frontend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_RC_PATH');
|
return self::status(My::checkContext(My::FRONTEND));
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,31 +14,22 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\dcLatestVersions;
|
namespace Dotclear\Plugin\dcLatestVersions;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\Core\Process;
|
||||||
use dcNsProcess;
|
|
||||||
|
|
||||||
class Install extends dcNsProcess
|
class Install extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
return self::status(My::checkContext(My::INSTALL));
|
||||||
&& dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
|
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nullsafe PHP < 8.0
|
My::settings()->put(
|
||||||
if (is_null(dcCore::app()->blog)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dcCore::app()->blog->settings->get(My::id())->put(
|
|
||||||
'builds',
|
'builds',
|
||||||
'stable,unstable,testing',
|
'stable,unstable,testing',
|
||||||
'string',
|
'string',
|
||||||
|
|
29
src/My.php
29
src/My.php
|
@ -14,36 +14,11 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\dcLatestVersions;
|
namespace Dotclear\Plugin\dcLatestVersions;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module definitions.
|
* This module definitions.
|
||||||
*/
|
*/
|
||||||
class My
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* 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\dcLatestVersions;
|
namespace Dotclear\Plugin\dcLatestVersions;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||||
|
|
||||||
class Uninstall extends dcNsProcess
|
class Uninstall extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN');
|
return self::status(My::checkContext(My::UNINSTALL));
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Widgets
|
||||||
{
|
{
|
||||||
$w
|
$w
|
||||||
->create(
|
->create(
|
||||||
'dclatestversionswidget',
|
My::id() . 'widget',
|
||||||
My::name(),
|
My::name(),
|
||||||
[self::class, 'parseWidget'],
|
[self::class, 'parseWidget'],
|
||||||
null,
|
null,
|
||||||
|
@ -59,7 +59,7 @@ class Widgets
|
||||||
}
|
}
|
||||||
|
|
||||||
# Builds to check
|
# Builds to check
|
||||||
$builds = explode(',', (string) dcCore::app()->blog->settings->get(My::id())->get('builds'));
|
$builds = explode(',', (string) My::settings()->get('builds'));
|
||||||
if (empty($builds[0])) {
|
if (empty($builds[0])) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ class Widgets
|
||||||
# Display
|
# Display
|
||||||
return $w->renderDiv(
|
return $w->renderDiv(
|
||||||
(bool) $w->__get('content_only'),
|
(bool) $w->__get('content_only'),
|
||||||
'dclatestversionswidget ' . $w->__get('class'),
|
My::id() . 'widget ' . $w->__get('class'),
|
||||||
'',
|
'',
|
||||||
($w->__get('title') ? $w->renderTitle(Html::escapeHTML($w->__get('title'))) : '') . sprintf('<ul>%s</ul>', implode('', $li))
|
($w->__get('title') ? $w->renderTitle(Html::escapeHTML($w->__get('title'))) : '') . sprintf('<ul>%s</ul>', implode('', $li))
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue