release 2023.07.29

This commit is contained in:
Jean-Christian Denis 2023-07-29 16:01:47 +02:00
parent cb56a4715b
commit 1d3eca3a9c
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
12 changed files with 86 additions and 122 deletions

View file

@ -1,3 +1,8 @@
2023.07.29
- require Dotclear 2.27
- require php 8.1+
- update to Dotclear 2.27-dev
2023.05.29
- require dotclear 2.26
- require php 8.1+

View file

@ -3,7 +3,7 @@
[![Release](https://img.shields.io/github/v/release/JcDenis/pacKman)](https://github.com/JcDenis/pacKman/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/pacKman)](https://github.com/JcDenis/pacKman/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/pacKman)](https://github.com/JcDenis/pacKman/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/pacKman)
[![License](https://img.shields.io/github/license/JcDenis/pacKman)](https://github.com/JcDenis/pacKman/blob/master/LICENSE)
@ -20,7 +20,7 @@ themes and plugins from Dotclear administration pages.
pacKman requires:
* Super administrator permissions
* Dotclear 2.26
* Dotclear 2.27
* PHP 8.1+
* A writable cache directory
* A writable directory to put packages. (can be VAR dir)

View file

@ -20,11 +20,11 @@ $this->registerModule(
'Packages repository',
'Manage your Dotclear packages',
'Jean-Christian Denis',
'2023.05.29',
'2023.07.29',
[
'requires' => [
['php', '8.1'],
['core', '2.26'],
['core', '2.27'],
],
'permissions' => null,
'type' => 'plugin',

View file

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="pacKman">
<name>Packages repository</name>
<version>2023.05.29</version>
<version>2023.07.29</version>
<author>Jean-Christian Denis</author>
<desc>Manage your Dotclear packages</desc>
<file>https://github.com/JcDenis/pacKman/releases/download/v2023.05.29/plugin-pacKman.zip</file>
<da:dcmin>2.26</da:dcmin>
<file>https://github.com/JcDenis/pacKman/releases/download/v2023.07.29/plugin-pacKman.zip</file>
<da:dcmin>2.27</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/pacKman</da:details>
<da:support>https://github.com/JcDenis/pacKman</da:support>
</module>

View file

@ -14,46 +14,35 @@ declare(strict_types=1);
namespace Dotclear\Plugin\pacKman;
use dcAdmin;
use dcCore;
use dcFavorites;
use dcPage;
use dcNsProcess;
use Dotclear\Core\Process;
use Dotclear\Core\Backend\Favorites;
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;
}
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
My::addBackendMenuItem();
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (Favorites $favs): void {
$favs->register(My::id(), [
'title' => My::name(),
'url' => dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), [], '#packman-repository-repository'),
'small-icon' => [dcPage::getPF(My::id() . '/icon.svg'), dcPage::getPF(My::id() . '/icon-dark.svg')],
'large-icon' => [dcPage::getPF(My::id() . '/icon.svg'), dcPage::getPF(My::id() . '/icon-dark.svg')],
'url' => My::manageUrl(),
'small-icon' => My::icons(),
'large-icon' => My::icons(),
//'permissions' => dcCore::app()->auth->isSuperAdmin(),
]);
});
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
My::name(),
dcCore::app()->adminurl?->get('admin.plugin.' . My::id()) . '#packman-repository-repository',
[dcPage::getPF(My::id() . '/icon.svg'), dcPage::getPF(My::id() . '/icon-dark.svg')],
preg_match('/' . preg_quote((string) dcCore::app()->adminurl?->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
dcCore::app()->auth?->isSuperAdmin()
);
return true;
}
}

View file

@ -15,8 +15,8 @@ declare(strict_types=1);
namespace Dotclear\Plugin\pacKman;
use dcCore;
use dcPage;
use dcNsProcess;
use Dotclear\Core\Process;
use Dotclear\Core\Backend\Notices;
use Dotclear\Helper\Html\Form\{
Checkbox,
Div,
@ -30,19 +30,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;
}
@ -62,10 +59,10 @@ class Config extends dcNsProcess
}
}
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(),
@ -79,7 +76,7 @@ class Config extends dcNsProcess
public static function render(): void
{
if (!static::$init) {
if (!self::status()) {
return;
}

View file

@ -16,22 +16,19 @@ namespace Dotclear\Plugin\pacKman;
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;
}

View file

@ -16,9 +16,12 @@ namespace Dotclear\Plugin\pacKman;
/* dotclear ns */
use dcCore;
use dcPage;
use dcThemes;
use dcNsProcess;
use Dotclear\Core\Process;
use Dotclear\Core\Backend\{
Notices,
Page
};
use Dotclear\Helper\File\Files;
use Dotclear\Helper\Html\Form\{
Div,
@ -27,19 +30,16 @@ use Dotclear\Helper\Html\Form\{
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;
}
@ -104,14 +104,14 @@ class Manage extends dcNsProcess
Http::head(404, 'Not Found');
exit;
} elseif (!empty($action) && !$is_editable) {
dcPage::addErrorNotice(
Notices::addErrorNotice(
__('No modules selected.')
);
if (!empty($_POST['redir'])) {
Http::redirect($_POST['redir']);
} else {
dcCore::app()->adminurl?->redirect('admin.plugin.' . My::id(), [], '#packman-' . $type);
My::redirect([], '#packman-' . $type);
}
# Pack
@ -140,14 +140,14 @@ class Manage extends dcNsProcess
dcCore::app()->callBehavior('packmanAfterCreatePackage', $module->dump());
}
dcPage::addSuccessNotice(
Notices::addSuccessNotice(
__('Package successfully created.')
);
if (!empty($_POST['redir'])) {
Http::redirect($_POST['redir']);
} else {
dcCore::app()->adminurl?->redirect('admin.plugin.' . My::id(), [], '#packman-' . $type);
My::redirect([], '#packman-' . $type);
}
# Delete
@ -155,7 +155,7 @@ class Manage extends dcNsProcess
$del_success = false;
foreach ($_POST['modules'] as $root => $id) {
if (!file_exists($root) || !Files::isDeletable($root)) {
dcPage::addWarningNotice(sprintf(__('Undeletable file "%s"', $root)));
Notices::addWarningNotice(sprintf(__('Undeletable file "%s"', $root)));
} else {
$del_success = true;
}
@ -164,7 +164,7 @@ class Manage extends dcNsProcess
}
if ($del_success) {
dcPage::addSuccessNotice(
Notices::addSuccessNotice(
__('Package successfully deleted.')
);
}
@ -172,7 +172,7 @@ class Manage extends dcNsProcess
if (!empty($_POST['redir'])) {
Http::redirect($_POST['redir']);
} else {
dcCore::app()->adminurl?->redirect('admin.plugin.' . My::id(), [], '#packman-repository-' . $type);
My::redirect([], '#packman-repository-' . $type);
}
# Install
@ -192,14 +192,14 @@ class Manage extends dcNsProcess
dcCore::app()->callBehavior('packmanAfterInstallPackage', $type, $id, $root);
}
dcPage::addSuccessNotice(
Notices::addSuccessNotice(
__('Package successfully installed.')
);
if (!empty($_POST['redir'])) {
Http::redirect($_POST['redir']);
} else {
dcCore::app()->adminurl?->redirect('admin.plugin.' . My::id(), [], '#packman-repository-' . $type);
My::redirect([], '#packman-repository-' . $type);
}
# Copy
@ -218,14 +218,14 @@ class Manage extends dcNsProcess
);
}
dcPage::addSuccessNotice(
Notices::addSuccessNotice(
__('Package successfully copied.')
);
if (!empty($_POST['redir'])) {
Http::redirect($_POST['redir']);
} else {
dcCore::app()->adminurl?->redirect('admin.plugin.' . My::id(), [], '#packman-repository-' . $type);
My::redirect([], '#packman-repository-' . $type);
}
# Move
@ -245,14 +245,14 @@ class Manage extends dcNsProcess
unlink($root);
}
dcPage::addSuccessNotice(
Notices::addSuccessNotice(
__('Package successfully moved.')
);
if (!empty($_POST['redir'])) {
Http::redirect($_POST['redir']);
} else {
dcCore::app()->adminurl?->redirect('admin.plugin.' . My::id(), [], '#packman-repository-' . $type);
My::redirect([], '#packman-repository-' . $type);
}
}
} catch (Exception $e) {
@ -264,7 +264,7 @@ class Manage extends dcNsProcess
public static function render(): void
{
if (!static::$init) {
if (!self::status()) {
return;
}
@ -295,21 +295,21 @@ class Manage extends dcNsProcess
}
# Display
dcPage::openModule(
Page::openModule(
My::name(),
dcPage::jsPageTabs() .
dcPage::jsModuleLoad(My::id() . '/js/backend.js') .
Page::jsPageTabs() .
My::jsLoad('backend') .
# --BEHAVIOR-- packmanAdminHeader
dcCore::app()->callBehavior('packmanAdminHeader')
);
echo
dcPage::breadcrumb([
Page::breadcrumb([
__('Plugins') => '',
My::name() => '',
]) .
dcPage::notices();
Notices::GetNotices();
if (dcCore::app()->error->flag() || !$is_configured || !$is_plugins_configured || !$is_themes_configured) {
echo
@ -377,7 +377,7 @@ class Manage extends dcNsProcess
# --BEHAVIOR-- packmanAdminTabs
dcCore::app()->callBehavior('packmanAdminTabs');
dcPage::helpBlock('pacKman');
dcPage::closeModule();
Page::helpBlock('pacKman');
Page::closeModule();
}
}

View file

@ -15,11 +15,12 @@ declare(strict_types=1);
namespace Dotclear\Plugin\pacKman;
use dcCore;
use Dotclear\Module\MyPlugin;
/**
* This module definitions.
*/
class My
class My extends MyPlugin
{
/** @var array Excluded files */
public const EXCLUDED_FILES = [
@ -35,29 +36,8 @@ class My
'_disabled',
];
/**
* This module id.
*/
public static function id(): string
public 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 dcCore::app()->auth->isSuperAdmin();
}
}

View file

@ -14,8 +14,6 @@ declare(strict_types=1);
namespace Dotclear\Plugin\pacKman;
use dcCore;
class Settings
{
// Remove comments from files
@ -50,7 +48,7 @@ class Settings
*/
public function __construct()
{
$s = dcCore::app()->blog?->settings->get(My::id());
$s = My::settings();
$this->pack_nocomment = (bool) ($s?->get('pack_nocomment') ?? false);
$this->pack_fixnewline = (bool) ($s?->get('pack_fixnewline') ?? false);
@ -79,8 +77,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;
}

View file

@ -15,21 +15,19 @@ declare(strict_types=1);
namespace Dotclear\Plugin\pacKman;
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;
}

View file

@ -140,7 +140,7 @@ class Utils
(new Text('h3', $title)),
(new Form('packman-form-' . $type))
->method('post')
->action('plugin.php')
->action(My::manageUrl())
->fields([
(new Para(null, 'table'))
->class('clear')
@ -163,13 +163,13 @@ class Utils
->class('checkboxes-helpers'),
(new Para())
->items([
(new Hidden(['redir'], Html::escapeHTML($_REQUEST['redir'] ?? ''))),
(new Hidden(['p'], My::id())),
(new Hidden(['type'], $type)),
(new Hidden(['action'], 'packup')),
(new Submit(['packup']))
->value(__('Pack up selected modules')),
dcCore::app()->formNonce(false),
... My::hiddenFields([
'type' => $type,
'action' => 'packup',
'redir' => Html::escapeHTML($_REQUEST['redir'] ?? ''),
]),
]),
]),
])
@ -279,7 +279,7 @@ class Utils
(new Text('h3', $title)),
(new Form('packman-form-repository-' . $type))
->method('post')
->action('plugin.php')
->action(My::manageUrl())
->fields([
(new Para(null, 'table'))
->class('clear')
@ -311,10 +311,10 @@ class Utils
->items($combo_action),
(new Submit(['packup']))
->value(__('ok')),
(new Hidden(['p'], My::id())),
(new Hidden(['tab'], 'repository')),
(new Hidden(['type'], $type)),
dcCore::app()->formNonce(false),
... My::hiddenFields([
'tab' => 'repository',
'type' => $type,
]),
]),
]),
])