preview for Dotclear 2.26

This commit is contained in:
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
- use PHP namespace
- use dcPage open/close module
- use Form helpers
- manage modules structure > dc 2.24
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)
[![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.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)
[![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.24
* Dotclear 2.26
* A writable cache directory
* A writable directory to put packages. (can be VAR dir)

View File

@ -12,20 +12,17 @@
*/
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')) {
return null;
}
$this->registerModule(
'pacKman',
'Packages repository',
'Manage your Dotclear packages',
'Jean-Christian Denis',
'2023.03.05-dev',
'2023.03.11',
[
'requires' => [['core', '2.26-dev']],
'requires' => [['core', '2.26']],
'permissions' => null,
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),

View File

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

@ -9,7 +9,6 @@
# 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['Root'] = 'Racine';
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['Plugins root'] = 'Racine des plugins';
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['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é.';

View File

@ -1,18 +1,15 @@
msgid ""
msgstr ""
"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"
"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"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
msgid "Packages repository"
msgstr "Dépôt de paquetages"
msgid "Configuration has been successfully updated."
msgstr "La configuration a été mise à jour avec succès."
@ -97,6 +94,9 @@ msgstr "Racine des plugins"
msgid "Themes root"
msgstr "Racine des thèmes"
msgid "Packages repository"
msgstr "Dépôt de paquetages"
msgid "Cache directory is not writable."
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;
/* dotclear ns */
use dcAdmin;
use dcCore;
use dcFavorites;
@ -23,14 +22,9 @@ use dcNsProcess;
class Backend extends dcNsProcess
{
private static $pid = '';
public static function init(): bool
{
if (defined('DC_CONTEXT_ADMIN')) {
self::$pid = basename(dirname(__DIR__));
self::$init = true;
}
self::$init = defined('DC_CONTEXT_ADMIN');
return self::$init;
}
@ -42,20 +36,20 @@ class Backend extends dcNsProcess
}
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
$favs->register(self::$pid, [
'title' => __('Packages repository'),
'url' => dcCore::app()->adminurl->get('admin.plugin.' . self::$pid, [], '#packman-repository-repository'),
'small-icon' => [dcPage::getPF(self::$pid . '/icon.svg'), dcPage::getPF(self::$pid . '/icon-dark.svg')],
'large-icon' => [dcPage::getPF(self::$pid . '/icon.svg'), dcPage::getPF(self::$pid . '/icon-dark.svg')],
$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')],
//'permissions' => dcCore::app()->auth->isSuperAdmin(),
]);
});
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Packages repository'),
dcCore::app()->adminurl->get('admin.plugin.' . self::$pid) . '#packman-repository-repository',
[dcPage::getPF(self::$pid . '/icon.svg'), dcPage::getPF(self::$pid . '/icon-dark.svg')],
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . self::$pid)) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
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(dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
dcCore::app()->auth->isSuperAdmin()
);

View File

@ -14,35 +14,33 @@ declare(strict_types=1);
namespace Dotclear\Plugin\pacKman;
/* dotclear ns */
use dcCore;
use dcPage;
use dcNsProcess;
/* clearbricks ns */
use form;
use http;
/* php ns */
use Dotclear\Helper\Html\Form\{
Checkbox,
Div,
Fieldset,
Input,
Label,
Legend,
Note,
Para
};
use Exception;
class Config extends dcNsProcess
{
private static $pid = '';
public static function init(): bool
{
if (defined('DC_CONTEXT_ADMIN')) {
self::$pid = basename(dirname(__DIR__));
self::$init = true;
}
self::$init = defined('DC_CONTEXT_ADMIN');
return self::$init;
}
public static function process(): bool
{
if (!self::$init || !defined('DC_CONTEXT_MODULE')) {
if (!self::$init) {
return false;
}
@ -67,7 +65,7 @@ class Config extends dcNsProcess
);
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_fixnewline', $pack_fixnewline);
$s->put('pack_overwrite', $pack_overwrite);
@ -79,10 +77,11 @@ class Config extends dcNsProcess
dcPage::addSuccessNotice(
__('Configuration has been successfully updated.')
);
http::redirect(
dcCore::app()->admin->__get('list')->getURL('module=' . self::$pid . '&conf=1&redir=' .
dcCore::app()->admin->__get('list')->getRedir())
);
dcCore::app()->adminurl->redirect('admin.plugins', [
'module' => My::id(),
'conf' => '1',
'redir' => dcCore::app()->admin->__get('list')->getRedir(),
]);
}
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
@ -98,58 +97,63 @@ class Config extends dcNsProcess
}
# -- Get settings --
$s = dcCore::app()->blog->settings->__get(self::$pid);
$s = dcCore::app()->blog->settings->get(My::id());
# -- Display form --
echo '
<div class="fieldset">
<h4>' . __('Root') . '</h4>
echo
(new Div())->items([
(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') .
'</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>';
]),
])->render();
}
}

View File

@ -14,50 +14,18 @@ declare(strict_types=1);
namespace Dotclear\Plugin\pacKman;
/* dotclear ns */
use dcCore;
use dcModules;
use dcThemes;
/* clearbricks ns */
use Exception;
use files;
use fileUnzip;
use path;
/* packman ns */
/* php ns */
use Exception;
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
{
foreach ($exclude as $k => $v) {
foreach (My::EXCLUDED_FILES as $k => $v) {
$exclude[$k] = '#(^|/)(' . str_replace(
['.', '*'],
['\.', '.*?'],
@ -95,7 +63,6 @@ class Core
'plugin' => clone dcCore::app()->plugins,
];
$i = 0;
foreach ($zip_files as $zip_file) {
$zip_file = $root . DIRECTORY_SEPARATOR . $zip_file;
@ -137,8 +104,8 @@ class Core
// can't load twice _init.php file !
$unlink = false;
if ($zip->hasFile($init)
&& !dcCore::app()->plugins->getDefine(basename($destination))->isDefined()
&& !dcCore::app()->themes->getDefine(basename($destination))->isDefined()
// && !dcCore::app()->plugins->getDefine(basename($destination))->isDefined()
// && !dcCore::app()->themes->getDefine(basename($destination))->isDefined()
) {
$unlink = true;
$zip->unzip($init, $destination . DIRECTORY_SEPARATOR . dcModules::MODULE_FILE_INIT);
@ -164,7 +131,6 @@ class Core
$module = $sandbox->getDefine(basename($destination));
if (!$module->isDefined() || $module->get('type') != $type) {
throw new Exception('bad module type');
}
@ -174,7 +140,6 @@ class Core
$zip->close();
files::deltree($destination);
} catch (Exception $e) {
$zip->close();
files::deltree($destination);
@ -256,7 +221,7 @@ class Core
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);
}

View File

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

View File

@ -14,12 +14,9 @@ declare(strict_types=1);
namespace Dotclear\Plugin\pacKman;
/* dotclear ns */
use dcCore;
use dcNamespace;
use dcNsProcess;
/* php ns */
use Exception;
class Install extends dcNsProcess
@ -72,7 +69,7 @@ class Install extends dcNsProcess
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;
}
@ -89,7 +86,7 @@ class Install extends dcNsProcess
// Set module settings
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[2],
$v[3],
@ -109,7 +106,7 @@ class Install extends dcNsProcess
public static function growUp(): void
{
$current = dcCore::app()->getVersion(Core::id());
$current = dcCore::app()->getVersion(My::id());
// Update settings id, ns
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)) {
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
$cur->setting_id = $match[1];
$cur->setting_ns = Core::id();
$cur->setting_ns = My::id();
$cur->update(
"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) . "' "))

View File

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

44
src/My.php Normal file
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
{
private static $pid = '';
protected static $init = false;
public static function init(): bool
{
self::$pid = basename(dirname(__DIR__));
self::$init = defined('DC_RC_PATH');
return self::$init;
@ -39,7 +37,7 @@ class Uninstall
/* action */
'delete_all',
/* ns */
self::$pid,
My::id(),
/* desc */
__('delete all settings')
);
@ -50,7 +48,7 @@ class Uninstall
/* action */
'delete',
/* ns */
self::$pid,
My::id(),
/* desc */
__('delete plugin files')
);
@ -61,7 +59,7 @@ class Uninstall
/* action */
'delete',
/* ns */
self::$pid,
My::id(),
/* desc */
__('delete the version number')
);
@ -72,9 +70,9 @@ class Uninstall
/* action */
'delete_all',
/* ns */
self::$pid,
My::id(),
/* desc */
sprintf(__('delete all %s settings'), self::$pid)
sprintf(__('delete all %s settings'), My::id())
);
$uninstaller->addDirectAction(
@ -83,9 +81,9 @@ class Uninstall
/* action */
'delete',
/* ns */
self::$pid,
My::id(),
/* desc */
sprintf(__('delete %s plugin files'), self::$pid)
sprintf(__('delete %s plugin files'), My::id())
);
$uninstaller->addDirectAction(
@ -94,9 +92,9 @@ class Uninstall
/* action */
'delete',
/* ns */
self::$pid,
My::id(),
/* desc */
sprintf(__('delete %s version number'), self::$pid)
sprintf(__('delete %s version number'), My::id())
);
return true;

View File

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