preview for Dotclear 2.26

2.28
Jean-Christian Paul Denis 2023-03-11 18:46:23 +01:00
parent 9cd0fc8bbc
commit 17f5ea7111
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
15 changed files with 178 additions and 182 deletions

View File

@ -1,7 +1,8 @@
xxxx.xx.xx 2023.03.11
- require Dotclear 2.26 - require Dotclear 2.26
- use PHP namespace - use PHP namespace
- use dcPage open/close module - use dcPage open/close module
- use Form helpers
- manage modules structure > dc 2.24 - manage modules structure > dc 2.24
2023.01.07 2023.01.07

View File

@ -3,7 +3,7 @@
[![Release](https://img.shields.io/github/v/release/JcDenis/pacKman)](https://github.com/JcDenis/pacKman/releases) [![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) [![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) [![Issues](https://img.shields.io/github/issues/JcDenis/pacKman)](https://github.com/JcDenis/pacKman/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.24-blue.svg)](https://fr.dotclear.org/download) [![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/pacKman) [![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) [![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: pacKman requires:
* Super administrator permissions * Super administrator permissions
* Dotclear 2.24 * Dotclear 2.26
* A writable cache directory * A writable cache directory
* A writable directory to put packages. (can be VAR dir) * A writable directory to put packages. (can be VAR dir)

View File

@ -12,20 +12,17 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
// can not use namespace as it is included inside a class method,
// and also can be included in third party plugins class methods.
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
$this->registerModule( $this->registerModule(
'pacKman', 'Packages repository',
'Manage your Dotclear packages', 'Manage your Dotclear packages',
'Jean-Christian Denis', 'Jean-Christian Denis',
'2023.03.05-dev', '2023.03.11',
[ [
'requires' => [['core', '2.26-dev']], 'requires' => [['core', '2.26']],
'permissions' => null, 'permissions' => null,
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://github.com/JcDenis/' . basename(__DIR__), 'support' => 'https://github.com/JcDenis/' . basename(__DIR__),

View File

@ -1,12 +1,12 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="pacKman"> <module id="pacKman">
<name>pacKman</name> <name>Packages repository</name>
<version>2023.01.07</version> <version>2023.03.11</version>
<author>Jean-Christian Denis</author> <author>Jean-Christian Denis</author>
<desc>Manage your Dotclear packages</desc> <desc>Manage your Dotclear packages</desc>
<file>https://github.com/JcDenis/pacKman/releases/download/v2023.01.07/plugin-pacKman.zip</file> <file>https://github.com/JcDenis/pacKman/releases/download/v2023.03.11/plugin-pacKman.zip</file>
<da:dcmin>2.24</da:dcmin> <da:dcmin>2.26</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/pacKman</da:details> <da:details>https://plugins.dotaddict.org/dc2/details/pacKman</da:details>
<da:support>https://github.com/JcDenis/pacKman</da:support> <da:support>https://github.com/JcDenis/pacKman</da:support>
</module> </module>

View File

@ -9,7 +9,6 @@
# DOT NOT MODIFY THIS FILE ! # DOT NOT MODIFY THIS FILE !
# #
l10n::$locales['Packages repository'] = 'Dépôt de paquetages';
l10n::$locales['Configuration has been successfully updated.'] = 'La configuration a été mise à jour avec succès.'; l10n::$locales['Configuration has been successfully updated.'] = 'La configuration a été mise à jour avec succès.';
l10n::$locales['Root'] = 'Racine'; l10n::$locales['Root'] = 'Racine';
l10n::$locales['Path to repository:'] = 'Chemin vers le dépôt :'; l10n::$locales['Path to repository:'] = 'Chemin vers le dépôt :';
@ -38,6 +37,7 @@ l10n::$locales['pacKman is not well configured.'] = 'pacKman n\'
l10n::$locales['Configuration'] = 'Configuration'; l10n::$locales['Configuration'] = 'Configuration';
l10n::$locales['Plugins root'] = 'Racine des plugins'; l10n::$locales['Plugins root'] = 'Racine des plugins';
l10n::$locales['Themes root'] = 'Racine des thèmes'; l10n::$locales['Themes root'] = 'Racine des thèmes';
l10n::$locales['Packages repository'] = 'Dépôt de paquetages';
l10n::$locales['Cache directory is not writable.'] = 'Le répertoire de cache n\'est pas accessible en écriture.'; l10n::$locales['Cache directory is not writable.'] = 'Le répertoire de cache n\'est pas accessible en écriture.';
l10n::$locales['Path to repository is not writable.'] = 'Le chemin vers le dépôt n\'est pas accessible en écriture.'; l10n::$locales['Path to repository is not writable.'] = 'Le chemin vers le dépôt n\'est pas accessible en écriture.';
l10n::$locales['You must specify the name of package to export.'] = 'Vous devez spécifier le nom du paquetage exporté.'; l10n::$locales['You must specify the name of package to export.'] = 'Vous devez spécifier le nom du paquetage exporté.';

View File

@ -1,18 +1,15 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: pacKman 2022.12.19.3\n" "Project-Id-Version: pacKman 2023.03.11\n"
"POT-Creation-Date: \n" "POT-Creation-Date: \n"
"PO-Revision-Date: 2022-12-20T00:29:17+00:00\n" "PO-Revision-Date: 2023-03-11T17:43:33+00:00\n"
"Last-Translator: Jean-Christian Denis\n" "Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
msgid "Packages repository"
msgstr "Dépôt de paquetages"
msgid "Configuration has been successfully updated." msgid "Configuration has been successfully updated."
msgstr "La configuration a été mise à jour avec succès." msgstr "La configuration a été mise à jour avec succès."
@ -97,6 +94,9 @@ msgstr "Racine des plugins"
msgid "Themes root" msgid "Themes root"
msgstr "Racine des thèmes" msgstr "Racine des thèmes"
msgid "Packages repository"
msgstr "Dépôt de paquetages"
msgid "Cache directory is not writable." msgid "Cache directory is not writable."
msgstr "Le répertoire de cache n'est pas accessible en écriture." msgstr "Le répertoire de cache n'est pas accessible en écriture."

View File

@ -14,7 +14,6 @@ declare(strict_types=1);
namespace Dotclear\Plugin\pacKman; namespace Dotclear\Plugin\pacKman;
/* dotclear ns */
use dcAdmin; use dcAdmin;
use dcCore; use dcCore;
use dcFavorites; use dcFavorites;
@ -23,14 +22,9 @@ use dcNsProcess;
class Backend extends dcNsProcess class Backend extends dcNsProcess
{ {
private static $pid = '';
public static function init(): bool public static function init(): bool
{ {
if (defined('DC_CONTEXT_ADMIN')) { self::$init = defined('DC_CONTEXT_ADMIN');
self::$pid = basename(dirname(__DIR__));
self::$init = true;
}
return self::$init; return self::$init;
} }
@ -42,20 +36,20 @@ class Backend extends dcNsProcess
} }
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void { dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
$favs->register(self::$pid, [ $favs->register(My::id(), [
'title' => __('Packages repository'), 'title' => My::name(),
'url' => dcCore::app()->adminurl->get('admin.plugin.' . self::$pid, [], '#packman-repository-repository'), 'url' => dcCore::app()->adminurl->get('admin.plugin.' . My::id(), [], '#packman-repository-repository'),
'small-icon' => [dcPage::getPF(self::$pid . '/icon.svg'), dcPage::getPF(self::$pid . '/icon-dark.svg')], 'small-icon' => [dcPage::getPF(My::id() . '/icon.svg'), dcPage::getPF(My::id() . '/icon-dark.svg')],
'large-icon' => [dcPage::getPF(self::$pid . '/icon.svg'), dcPage::getPF(self::$pid . '/icon-dark.svg')], 'large-icon' => [dcPage::getPF(My::id() . '/icon.svg'), dcPage::getPF(My::id() . '/icon-dark.svg')],
//'permissions' => dcCore::app()->auth->isSuperAdmin(), //'permissions' => dcCore::app()->auth->isSuperAdmin(),
]); ]);
}); });
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Packages repository'), My::name(),
dcCore::app()->adminurl->get('admin.plugin.' . self::$pid) . '#packman-repository-repository', dcCore::app()->adminurl->get('admin.plugin.' . My::id()) . '#packman-repository-repository',
[dcPage::getPF(self::$pid . '/icon.svg'), dcPage::getPF(self::$pid . '/icon-dark.svg')], [dcPage::getPF(My::id() . '/icon.svg'), dcPage::getPF(My::id() . '/icon-dark.svg')],
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . self::$pid)) . '(&.*)?$/', $_SERVER['REQUEST_URI']), preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
dcCore::app()->auth->isSuperAdmin() dcCore::app()->auth->isSuperAdmin()
); );

View File

@ -14,35 +14,33 @@ declare(strict_types=1);
namespace Dotclear\Plugin\pacKman; namespace Dotclear\Plugin\pacKman;
/* dotclear ns */
use dcCore; use dcCore;
use dcPage; use dcPage;
use dcNsProcess; use dcNsProcess;
use Dotclear\Helper\Html\Form\{
/* clearbricks ns */ Checkbox,
use form; Div,
use http; Fieldset,
Input,
/* php ns */ Label,
Legend,
Note,
Para
};
use Exception; use Exception;
class Config extends dcNsProcess class Config extends dcNsProcess
{ {
private static $pid = '';
public static function init(): bool public static function init(): bool
{ {
if (defined('DC_CONTEXT_ADMIN')) { self::$init = defined('DC_CONTEXT_ADMIN');
self::$pid = basename(dirname(__DIR__));
self::$init = true;
}
return self::$init; return self::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!self::$init || !defined('DC_CONTEXT_MODULE')) { if (!self::$init) {
return false; return false;
} }
@ -67,7 +65,7 @@ class Config extends dcNsProcess
); );
if ($check) { if ($check) {
$s = dcCore::app()->blog->settings->__get(self::$pid); $s = dcCore::app()->blog->settings->get(My::id());
$s->put('pack_nocomment', $pack_nocomment); $s->put('pack_nocomment', $pack_nocomment);
$s->put('pack_fixnewline', $pack_fixnewline); $s->put('pack_fixnewline', $pack_fixnewline);
$s->put('pack_overwrite', $pack_overwrite); $s->put('pack_overwrite', $pack_overwrite);
@ -79,10 +77,11 @@ class Config extends dcNsProcess
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Configuration has been successfully updated.') __('Configuration has been successfully updated.')
); );
http::redirect( dcCore::app()->adminurl->redirect('admin.plugins', [
dcCore::app()->admin->__get('list')->getURL('module=' . self::$pid . '&conf=1&redir=' . 'module' => My::id(),
dcCore::app()->admin->__get('list')->getRedir()) 'conf' => '1',
); 'redir' => dcCore::app()->admin->__get('list')->getRedir(),
]);
} }
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
@ -98,58 +97,63 @@ class Config extends dcNsProcess
} }
# -- Get settings -- # -- Get settings --
$s = dcCore::app()->blog->settings->__get(self::$pid); $s = dcCore::app()->blog->settings->get(My::id());
# -- Display form -- # -- Display form --
echo ' echo
<div class="fieldset"> (new Div())->items([
<h4>' . __('Root') . '</h4> (new Fieldset())->class('fieldset')->legend((new Legend(__('Root'))))->fields([
// pack_repository
(new Para())->items([
(new Label(__('Path to repository:')))->for('pack_repository'),
(new Input('pack_repository'))->class('maximal')->size(65)->maxlenght(255)->value((string) $s->get('pack_repository')),
]),
(new Note())->class('form-note')->text(
sprintf(
__('Preconization: %s'),
dcCore::app()->blog->public_path ?
dcCore::app()->blog->public_path : __("Blog's public directory")
) . ' ' . __('Leave it empty to use Dotclear VAR directory')
),
]),
(new Fieldset())->class('fieldset')->legend((new Legend(__('Files'))))->fields([
// pack_filename
(new Para())->items([
(new Label(__('Name of exported package:')))->for('pack_filename'),
(new Input('pack_filename'))->class('maximal')->size(65)->maxlenght(255)->value((string) $s->get('pack_filename')),
]),
(new Note())->text(sprintf(__('Preconization: %s'), '%type%-%id%'))->class('form-note'),
// secondpack_filename
(new Para())->items([
(new Label(__('Name of second exported package:')))->for('secondpack_filename'),
(new Input('secondpack_filename'))->class('maximal')->size(65)->maxlenght(255)->value((string) $s->get('secondpack_filename')),
]),
(new Note())->text(sprintf(__('Preconization: %s'), '%type%-%id%-%version%'))->class('form-note'),
// pack_overwrite
(new Para())->items([
(new Checkbox('pack_overwrite', (bool) $s->get('pack_overwrite')))->value(1),
(new Label(__('Overwrite existing package'), Label::OUTSIDE_LABEL_AFTER))->for('pack_overwrite')->class('classic'),
]),
]),
(new Fieldset())->class('fieldset')->legend((new Legend(__('Content'))))->fields([
// pack_excludefiles
(new Para())->items([
(new Label(__('Extra files to exclude from package:')))->for('pack_excludefiles'),
(new Input('pack_excludefiles'))->class('maximal')->size(65)->maxlenght(255)->value((string) $s->get('pack_excludefiles')),
]),
(new Note())->text(sprintf(__('Preconization: %s'), '*.zip,*.tar,*.tar.gz'))->class('form-note'),
// pack_nocomment
(new Para())->items([
(new Checkbox('pack_nocomment', (bool) $s->get('pack_nocomment')))->value(1),
(new Label(__('Remove comments from files'), Label::OUTSIDE_LABEL_AFTER))->for('pack_nocomment')->class('classic'),
]),
// pack_fixnewline
(new Para())->items([
(new Checkbox('pack_fixnewline', (bool) $s->get('pack_fixnewline')))->value(1),
(new Label(__('Fix newline style from files content'), Label::OUTSIDE_LABEL_AFTER))->for('pack_fixnewline')->class('classic'),
]),
<p><label for="pack_repository">' . __('Path to repository:') . ' ' . ]),
form::field('pack_repository', 65, 255, (string) $s->get('pack_repository'), 'maximal') . ])->render();
'</label></p>' .
'<p class="form-note">' . sprintf(
__('Preconization: %s'),
dcCore::app()->blog->public_path ?
dcCore::app()->blog->public_path : __("Blog's public directory")
) . '<br />' . __('Leave it empty to use Dotclear VAR directory') . '</p>
</div>
<div class="fieldset">
<h4>' . __('Files') . '</h4>
<p><label for="pack_filename">' . __('Name of exported package:') . ' ' .
form::field('pack_filename', 65, 255, (string) $s->get('pack_filename'), 'maximal') .
'</label></p>
<p class="form-note">' . sprintf(__('Preconization: %s'), '%type%-%id%') . '</p>
<p><label for="secondpack_filename">' . __('Name of second exported package:') . ' ' .
form::field('secondpack_filename', 65, 255, (string) $s->get('secondpack_filename'), 'maximal') .
'</label></p>
<p class="form-note">' . sprintf(__('Preconization: %s'), '%type%-%id%-%version%') . '</p>
<p><label class="classic" for="pack_overwrite">' .
form::checkbox('pack_overwrite', 1, (bool) $s->get('pack_overwrite')) . ' ' .
__('Overwrite existing package') . '</label></p>
</div>
<div class="fieldset">
<h4>' . __('Content') . '</h4>
<p><label for="pack_excludefiles">' . __('Extra files to exclude from package:') . ' ' .
form::field('pack_excludefiles', 65, 255, (string) $s->get('pack_excludefiles'), 'maximal') .
'</label></p>
<p class="form-note">' . sprintf(__('Preconization: %s'), '*.zip,*.tar,*.tar.gz') . '</p>
<p><label class="classic" for="pack_nocomment">' .
form::checkbox('pack_nocomment', 1, (bool) $s->get('pack_nocomment')) . ' ' .
__('Remove comments from files') . '</label></p>
<p><label class="classic" for="pack_fixnewline">' .
form::checkbox('pack_fixnewline', 1, (bool) $s->get('pack_fixnewline')) . ' ' .
__('Fix newline style from files content') . '</label></p>
</div>';
} }
} }

View File

@ -14,50 +14,18 @@ declare(strict_types=1);
namespace Dotclear\Plugin\pacKman; namespace Dotclear\Plugin\pacKman;
/* dotclear ns */
use dcCore; use dcCore;
use dcModules; use dcModules;
use dcThemes; use Exception;
/* clearbricks ns */
use files; use files;
use fileUnzip; use fileUnzip;
use path; use path;
/* packman ns */
/* php ns */
use Exception;
class Core class Core
{ {
/** @var array Excluded files */
public static $exclude = [
'.',
'..',
'__MACOSX',
'.svn',
'.hg*',
'.git*',
'CVS',
'.DS_Store',
'Thumbs.db',
'_disabled',
];
public static function id()
{
return basename(dirname(__DIR__));
}
public static function name()
{
return __('pacKman');
}
public static function quote_exclude(array $exclude): array public static function quote_exclude(array $exclude): array
{ {
foreach ($exclude as $k => $v) { foreach (My::EXCLUDED_FILES as $k => $v) {
$exclude[$k] = '#(^|/)(' . str_replace( $exclude[$k] = '#(^|/)(' . str_replace(
['.', '*'], ['.', '*'],
['\.', '.*?'], ['\.', '.*?'],
@ -95,7 +63,6 @@ class Core
'plugin' => clone dcCore::app()->plugins, 'plugin' => clone dcCore::app()->plugins,
]; ];
$i = 0; $i = 0;
foreach ($zip_files as $zip_file) { foreach ($zip_files as $zip_file) {
$zip_file = $root . DIRECTORY_SEPARATOR . $zip_file; $zip_file = $root . DIRECTORY_SEPARATOR . $zip_file;
@ -137,8 +104,8 @@ class Core
// can't load twice _init.php file ! // can't load twice _init.php file !
$unlink = false; $unlink = false;
if ($zip->hasFile($init) if ($zip->hasFile($init)
&& !dcCore::app()->plugins->getDefine(basename($destination))->isDefined() // && !dcCore::app()->plugins->getDefine(basename($destination))->isDefined()
&& !dcCore::app()->themes->getDefine(basename($destination))->isDefined() // && !dcCore::app()->themes->getDefine(basename($destination))->isDefined()
) { ) {
$unlink = true; $unlink = true;
$zip->unzip($init, $destination . DIRECTORY_SEPARATOR . dcModules::MODULE_FILE_INIT); $zip->unzip($init, $destination . DIRECTORY_SEPARATOR . dcModules::MODULE_FILE_INIT);
@ -164,7 +131,6 @@ class Core
$module = $sandbox->getDefine(basename($destination)); $module = $sandbox->getDefine(basename($destination));
if (!$module->isDefined() || $module->get('type') != $type) { if (!$module->isDefined() || $module->get('type') != $type) {
throw new Exception('bad module type'); throw new Exception('bad module type');
} }
@ -174,7 +140,6 @@ class Core
$zip->close(); $zip->close();
files::deltree($destination); files::deltree($destination);
} catch (Exception $e) { } catch (Exception $e) {
$zip->close(); $zip->close();
files::deltree($destination); files::deltree($destination);
@ -256,7 +221,7 @@ class Core
private static function getExclude(array $exclude): array private static function getExclude(array $exclude): array
{ {
$exclude = array_merge(self::$exclude, $exclude); $exclude = array_merge(My::EXCLUDED_FILES, $exclude);
return self::quote_exclude($exclude); return self::quote_exclude($exclude);
} }

View File

@ -14,7 +14,6 @@ declare(strict_types=1);
namespace Dotclear\Plugin\pacKman; namespace Dotclear\Plugin\pacKman;
/* clearbricks ns */
//use fileZip; //use fileZip;
class Filezip extends \fileZip class Filezip extends \fileZip

View File

@ -14,12 +14,9 @@ declare(strict_types=1);
namespace Dotclear\Plugin\pacKman; namespace Dotclear\Plugin\pacKman;
/* dotclear ns */
use dcCore; use dcCore;
use dcNamespace; use dcNamespace;
use dcNsProcess; use dcNsProcess;
/* php ns */
use Exception; use Exception;
class Install extends dcNsProcess class Install extends dcNsProcess
@ -72,7 +69,7 @@ class Install extends dcNsProcess
public static function init(): bool public static function init(): bool
{ {
self::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->newVersion(Core::id(), dcCore::app()->plugins->moduleInfo(Core::id(), 'version')); self::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
return self::$init; return self::$init;
} }
@ -89,7 +86,7 @@ class Install extends dcNsProcess
// Set module settings // Set module settings
foreach (self::$mod_conf as $v) { foreach (self::$mod_conf as $v) {
dcCore::app()->blog->settings->__get(Core::id())->put( dcCore::app()->blog->settings->get(My::id())->put(
$v[0], $v[0],
$v[2], $v[2],
$v[3], $v[3],
@ -109,7 +106,7 @@ class Install extends dcNsProcess
public static function growUp(): void public static function growUp(): void
{ {
$current = dcCore::app()->getVersion(Core::id()); $current = dcCore::app()->getVersion(My::id());
// Update settings id, ns // Update settings id, ns
if ($current && version_compare($current, '2022.12.19.1', '<=')) { if ($current && version_compare($current, '2022.12.19.1', '<=')) {
@ -122,7 +119,7 @@ class Install extends dcNsProcess
if (preg_match('/^packman_(.*?)$/', $record->setting_id, $match)) { if (preg_match('/^packman_(.*?)$/', $record->setting_id, $match)) {
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME); $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
$cur->setting_id = $match[1]; $cur->setting_id = $match[1];
$cur->setting_ns = Core::id(); $cur->setting_ns = My::id();
$cur->update( $cur->update(
"WHERE setting_id = '" . $record->setting_id . "' and setting_ns = 'pacKman' " . "WHERE setting_id = '" . $record->setting_id . "' and setting_ns = 'pacKman' " .
'AND blog_id ' . (null === $record->blog_id ? 'IS NULL ' : ("= '" . dcCore::app()->con->escape($record->blog_id) . "' ")) 'AND blog_id ' . (null === $record->blog_id ? 'IS NULL ' : ("= '" . dcCore::app()->con->escape($record->blog_id) . "' "))

View File

@ -32,7 +32,6 @@ class Manage extends dcNsProcess
{ {
private static $plugins_path = ''; private static $plugins_path = '';
private static $themes_path = ''; private static $themes_path = '';
private static $pid = '';
public static function init(): bool public static function init(): bool
{ {
@ -44,8 +43,6 @@ class Manage extends dcNsProcess
$p = array_pop($e); $p = array_pop($e);
self::$plugins_path = (string) path::real($p); self::$plugins_path = (string) path::real($p);
self::$themes_path = dcCore::app()->blog->themes_path; self::$themes_path = dcCore::app()->blog->themes_path;
self::$pid = basename(dirname(__DIR__));
self::$init = true;
} }
return self::$init; return self::$init;
@ -62,7 +59,7 @@ class Manage extends dcNsProcess
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : ''; $type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : '';
# Settings # Settings
$s = dcCore::app()->blog->settings->get(self::$pid); $s = dcCore::app()->blog->settings->get(My::id());
$dir = Utils::getRepositoryDir($s->get('pack_repository')); $dir = Utils::getRepositoryDir($s->get('pack_repository'));
# Modules # Modules
@ -129,7 +126,7 @@ class Manage extends dcNsProcess
if (!empty($_POST['redir'])) { if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']); http::redirect($_POST['redir']);
} else { } else {
dcCore::app()->adminurl->redirect('admin.plugin.' . self::$pid, [], '#packman-' . $type); dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), [], '#packman-' . $type);
} }
# Pack # Pack
@ -168,7 +165,7 @@ class Manage extends dcNsProcess
if (!empty($_POST['redir'])) { if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']); http::redirect($_POST['redir']);
} else { } else {
dcCore::app()->adminurl->redirect('admin.plugin.' . self::$pid, [], '#packman-' . $type); dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), [], '#packman-' . $type);
} }
# Delete # Delete
@ -193,7 +190,7 @@ class Manage extends dcNsProcess
if (!empty($_POST['redir'])) { if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']); http::redirect($_POST['redir']);
} else { } else {
dcCore::app()->adminurl->redirect('admin.plugin.' . self::$pid, [], '#packman-repository-' . $type); dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), [], '#packman-repository-' . $type);
} }
# Install # Install
@ -220,7 +217,7 @@ class Manage extends dcNsProcess
if (!empty($_POST['redir'])) { if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']); http::redirect($_POST['redir']);
} else { } else {
dcCore::app()->adminurl->redirect('admin.plugin.' . self::$pid, [], '#packman-repository-' . $type); dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), [], '#packman-repository-' . $type);
} }
# Copy # Copy
@ -246,7 +243,7 @@ class Manage extends dcNsProcess
if (!empty($_POST['redir'])) { if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']); http::redirect($_POST['redir']);
} else { } else {
dcCore::app()->adminurl->redirect('admin.plugin.' . self::$pid, [], '#packman-repository-' . $type); dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), [], '#packman-repository-' . $type);
} }
# Move # Move
@ -273,7 +270,7 @@ class Manage extends dcNsProcess
if (!empty($_POST['redir'])) { if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']); http::redirect($_POST['redir']);
} else { } else {
dcCore::app()->adminurl->redirect('admin.plugin.' . self::$pid, [], '#packman-repository-' . $type); dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), [], '#packman-repository-' . $type);
} }
} }
} catch (Exception $e) { } catch (Exception $e) {
@ -290,7 +287,7 @@ class Manage extends dcNsProcess
} }
# Settings # Settings
$s = dcCore::app()->blog->settings->get(self::$pid); $s = dcCore::app()->blog->settings->get(My::id());
$dir = Utils::getRepositoryDir($s->get('pack_repository')); $dir = Utils::getRepositoryDir($s->get('pack_repository'));
$is_configured = Utils::is_configured( $is_configured = Utils::is_configured(
@ -301,25 +298,25 @@ class Manage extends dcNsProcess
# Display # Display
dcPage::openModule( dcPage::openModule(
Core::name(), My::name(),
dcPage::jsPageTabs() . dcPage::jsPageTabs() .
dcPage::jsModuleLoad(self::$pid . '/js/packman.js') . dcPage::jsModuleLoad(My::id() . '/js/backend.js') .
# --BEHAVIOR-- packmanAdminHeader # --BEHAVIOR-- packmanAdminHeader
dcCore::app()->callBehavior('packmanAdminHeader') dcCore::app()->callBehavior('packmanAdminHeader')
); );
echo echo
dcPage::breadcrumb([ dcPage::breadcrumb([
__('Plugins') => '', __('Plugins') => '',
Core::name() => '', My::name() => '',
]) . ]) .
dcPage::notices(); dcPage::notices();
if (dcCore::app()->error->flag() || !$is_configured) { if (dcCore::app()->error->flag() || !$is_configured) {
echo echo
'<div class="warning">' . __('pacKman is not well configured.') . ' ' . '<div class="warning">' . __('pacKman is not well configured.') . ' ' .
'<a href="' . dcCore::app()->adminurl->get('admin.plugins', ['module' => self::$pid, 'conf' => '1', 'redir' => dcCore::app()->adminurl->get('admin.plugin.' . self::$pid)]) . '">' . __('Configuration') . '</a>' . '<a href="' . dcCore::app()->adminurl->get('admin.plugins', ['module' => My::id(), 'conf' => '1', 'redir' => dcCore::app()->adminurl->get('admin.plugin.' . My::id())]) . '">' . __('Configuration') . '</a>' .
'</div>'; '</div>';
} else { } else {
$repo_path_modules = array_merge( $repo_path_modules = array_merge(

44
src/My.php 100644
View File

@ -0,0 +1,44 @@
<?php
/**
* @brief pacKman, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\pacKman;
use dcCore;
class My
{
/** @var array Excluded files */
public const EXCLUDED_FILES = [
'.',
'..',
'__MACOSX',
'.svn',
'.hg*',
'.git*',
'CVS',
'.DS_Store',
'Thumbs.db',
'_disabled',
];
public static function id()
{
return basename(dirname(__DIR__));
}
public static function name()
{
return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name'));
}
}

View File

@ -16,12 +16,10 @@ namespace Dotclear\Plugin\pacKman;
class Uninstall class Uninstall
{ {
private static $pid = '';
protected static $init = false; protected static $init = false;
public static function init(): bool public static function init(): bool
{ {
self::$pid = basename(dirname(__DIR__));
self::$init = defined('DC_RC_PATH'); self::$init = defined('DC_RC_PATH');
return self::$init; return self::$init;
@ -39,7 +37,7 @@ class Uninstall
/* action */ /* action */
'delete_all', 'delete_all',
/* ns */ /* ns */
self::$pid, My::id(),
/* desc */ /* desc */
__('delete all settings') __('delete all settings')
); );
@ -50,7 +48,7 @@ class Uninstall
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
self::$pid, My::id(),
/* desc */ /* desc */
__('delete plugin files') __('delete plugin files')
); );
@ -61,7 +59,7 @@ class Uninstall
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
self::$pid, My::id(),
/* desc */ /* desc */
__('delete the version number') __('delete the version number')
); );
@ -72,9 +70,9 @@ class Uninstall
/* action */ /* action */
'delete_all', 'delete_all',
/* ns */ /* ns */
self::$pid, My::id(),
/* desc */ /* desc */
sprintf(__('delete all %s settings'), self::$pid) sprintf(__('delete all %s settings'), My::id())
); );
$uninstaller->addDirectAction( $uninstaller->addDirectAction(
@ -83,9 +81,9 @@ class Uninstall
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
self::$pid, My::id(),
/* desc */ /* desc */
sprintf(__('delete %s plugin files'), self::$pid) sprintf(__('delete %s plugin files'), My::id())
); );
$uninstaller->addDirectAction( $uninstaller->addDirectAction(
@ -94,9 +92,9 @@ class Uninstall
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
self::$pid, My::id(),
/* desc */ /* desc */
sprintf(__('delete %s version number'), self::$pid) sprintf(__('delete %s version number'), My::id())
); );
return true; return true;

View File

@ -154,7 +154,7 @@ class Utils
html::escapeHTML($_REQUEST['redir']) html::escapeHTML($_REQUEST['redir'])
) : '' ) : ''
) . ) .
form::hidden(['p'], basename(dirname('../' . __DIR__))) . form::hidden(['p'], My::id()) .
form::hidden(['type'], $type) . form::hidden(['type'], $type) .
form::hidden(['action'], 'packup') . form::hidden(['action'], 'packup') .
'<input type="submit" name="packup" value="' . '<input type="submit" name="packup" value="' .
@ -232,7 +232,7 @@ class Utils
'</td>' . '</td>' .
'<td class="nowrap">' . '<td class="nowrap">' .
'<a class="packman-download" href="' . '<a class="packman-download" href="' .
dcCore::app()->adminurl->get('admin.plugin.' . basename(dirname('../' . __DIR__)), [ dcCore::app()->adminurl->get('admin.plugin.' . My::id(), [
'package' => basename($module['root']), 'package' => basename($module['root']),
'repo' => $type, 'repo' => $type,
]) . '" title="' . __('Download') . '">' . ]) . '" title="' . __('Download') . '">' .
@ -251,7 +251,7 @@ class Utils
'<p class="col right">' . __('Selected modules action:') . ' ' . '<p class="col right">' . __('Selected modules action:') . ' ' .
form::combo(['action'], $combo_action) . form::combo(['action'], $combo_action) .
'<input type="submit" name="packup" value="' . __('ok') . '" />' . '<input type="submit" name="packup" value="' . __('ok') . '" />' .
form::hidden(['p'], basename(dirname('../' . __DIR__))) . form::hidden(['p'], My::id()) .
form::hidden(['tab'], 'repository') . form::hidden(['tab'], 'repository') .
form::hidden(['type'], $type) . form::hidden(['type'], $type) .
dcCore::app()->formNonce() . dcCore::app()->formNonce() .