release 2023.01.05 (cosmetic code structure)

This commit is contained in:
Jean-Christian Paul Denis 2023-01-06 01:17:08 +01:00
parent 9158682366
commit e27984b4a6
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
16 changed files with 108 additions and 43 deletions

View File

@ -1,3 +1,6 @@
2023.01.05
- harmonise structure (with my plugins)
2022.12.20 2022.12.20
- use shorter settings names - use shorter settings names
- use dotclear VAR as default repository - use dotclear VAR as default repository

View File

@ -12,6 +12,7 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
if (Dotclear\Plugin\pacKman\Admin::init()) { $admin = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Admin']);
Dotclear\Plugin\pacKman\Admin::process(); if ($admin::init()) {
$admin::process();
} }

View File

@ -12,11 +12,8 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
if (!defined('DC_CONTEXT_MODULE')) { $config = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Config']);
return null; if ($config::init()) {
} $config::process();
$config::render();
if (Dotclear\Plugin\pacKman\Config::init()) {
Dotclear\Plugin\pacKman\Config::process();
Dotclear\Plugin\pacKman\Config::render();
} }

View File

@ -23,7 +23,7 @@ $this->registerModule(
'pacKman', 'pacKman',
'Manage your Dotclear packages', 'Manage your Dotclear packages',
'Jean-Christian Denis', 'Jean-Christian Denis',
'2022.12.20', '2023.01.05',
[ [
'requires' => [['core', '2.24']], 'requires' => [['core', '2.24']],
'permissions' => null, 'permissions' => null,

View File

@ -12,8 +12,9 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
if (Dotclear\Plugin\pacKman\Install::init()) { $install = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Install']);
return Dotclear\Plugin\pacKman\Install::process(); if ($install::init()) {
return $install::process();
} }
return null; return null;

View File

@ -12,10 +12,11 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
if (!class_exists('Dotclear\Plugin\pacKman\Prepend')) { $prepend = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Prepend']);
require __DIR__ . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Prepend.php'; if (!class_exists($prepend)) {
require implode(DIRECTORY_SEPARATOR, [__DIR__, 'inc', 'Prepend.php']);
if (Dotclear\Plugin\pacKman\Prepend::init()) { if ($prepend::init()) {
Dotclear\Plugin\pacKman\Prepend::process(); $prepend::process();
} }
} }

View File

@ -12,6 +12,7 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
if (Dotclear\Plugin\pacKman\Uninstall::init()) { $uninstall = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Uninstall']);
Dotclear\Plugin\pacKman\Uninstall::process($this); if ($uninstall::init()) {
$uninstall::process($this);
} }

View File

@ -2,10 +2,10 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="pacKman"> <module id="pacKman">
<name>pacKman</name> <name>pacKman</name>
<version>2022.12.20</version> <version>2023.01.05</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/v2022.12.20/plugin-pacKman.zip</file> <file>https://github.com/JcDenis/pacKman/releases/download/v2023.01.05/plugin-pacKman.zip</file>
<da:dcmin>2.24</da:dcmin> <da:dcmin>2.24</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>

View File

@ -22,19 +22,18 @@ use dcPage;
class Admin class Admin
{ {
private static $init = false; protected static $init = false;
public static function init(): bool public static function init(): bool
{ {
if (defined('DC_CONTEXT_ADMIN')) { if (defined('DC_CONTEXT_ADMIN')) {
dcCore::app()->blog->settings->addNamespace(Core::id());
self::$init = true; self::$init = true;
} }
return self::$init; return self::$init;
} }
public static function process() public static function process(): ?bool
{ {
if (!self::$init) { if (!self::$init) {
return false; return false;
@ -57,5 +56,7 @@ class Admin
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . Core::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']), preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . Core::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
dcCore::app()->auth->isSuperAdmin() dcCore::app()->auth->isSuperAdmin()
); );
return true;
} }
} }

View File

@ -27,26 +27,25 @@ use Exception;
class Config class Config
{ {
private static $init = false; protected static $init = false;
public static function init(): bool public static function init(): bool
{ {
if (defined('DC_CONTEXT_ADMIN')) { if (defined('DC_CONTEXT_ADMIN') && defined('DC_CONTEXT_MODULE')) {
dcCore::app()->blog->settings->addNamespace(Core::id());
self::$init = true; self::$init = true;
} }
return self::$init; return self::$init;
} }
public static function process(): void public static function process(): ?bool
{ {
if (!self::$init) { if (!self::$init) {
return; return false;
} }
if (empty($_POST['save'])) { if (empty($_POST['save'])) {
return; return null;
} }
# -- Set settings -- # -- Set settings --
@ -82,10 +81,14 @@ class Config
dcCore::app()->admin->__get('list')->getURL('module=' . Core::id() . '&conf=1&redir=' . dcCore::app()->admin->__get('list')->getURL('module=' . Core::id() . '&conf=1&redir=' .
dcCore::app()->admin->__get('list')->getRedir()) dcCore::app()->admin->__get('list')->getRedir())
); );
return true;
} }
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
return null;
} }
public static function render() public static function render()

View File

@ -70,7 +70,7 @@ class Install
]; ];
// Nothing to change below // Nothing to change below
private static $init = false; protected static $init = false;
public static function init(): bool public static function init(): bool
{ {
@ -79,7 +79,7 @@ class Install
return self::$init; return self::$init;
} }
public static function process() public static function process(): ?bool
{ {
if (!self::$init) { if (!self::$init) {
return false; return false;
@ -90,7 +90,6 @@ class Install
self::growUp(); self::growUp();
// Set module settings // Set module settings
dcCore::app()->blog->settings->addNamespace(Core::id());
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(Core::id())->put(
$v[0], $v[0],
@ -110,7 +109,7 @@ class Install
} }
} }
public static function growUp() public static function growUp(): void
{ {
$current = dcCore::app()->getVersion(Core::id()); $current = dcCore::app()->getVersion(Core::id());

View File

@ -31,13 +31,12 @@ class Manage
{ {
private static $plugins_path = ''; private static $plugins_path = '';
private static $themes_path = ''; private static $themes_path = '';
private static $init = false; protected static $init = false;
public static function init(): bool public static function init(): bool
{ {
if (defined('DC_CONTEXT_ADMIN')) { if (defined('DC_CONTEXT_ADMIN')) {
dcPage::checkSuper(); dcPage::checkSuper();
dcCore::app()->blog->settings->addNamespace(Core::id());
# Paths # Paths
$e = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT); $e = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);

View File

@ -30,7 +30,7 @@ class Prepend
'Uninstall', 'Uninstall',
'Utils', 'Utils',
]; ];
private static $init = false; protected static $init = false;
public static function init(): bool public static function init(): bool
{ {
@ -39,14 +39,16 @@ class Prepend
return self::$init; return self::$init;
} }
public static function process() public static function process(): ?bool
{ {
if (!self::$init) { if (!self::$init) {
return false; return false;
} }
foreach (self::LIBS as $lib) { foreach (self::LIBS as $lib) {
Clearbricks::lib()->autoload(['Dotclear\\Plugin\\pacKman\\' . $lib => __DIR__ . DIRECTORY_SEPARATOR . $lib . '.php']); Clearbricks::lib()->autoload([
implode('\\', ['Dotclear','Plugin', basename(__NAMESPACE__), $lib]) => __DIR__ . DIRECTORY_SEPARATOR . $lib . '.php',
]);
} }
return true; return true;

View File

@ -16,7 +16,7 @@ namespace Dotclear\Plugin\pacKman;
class Uninstall class Uninstall
{ {
private static $init = false; protected static $init = false;
public static function init(): bool public static function init(): bool
{ {
@ -25,7 +25,7 @@ class Uninstall
return self::$init; return self::$init;
} }
public static function process($uninstaller) public static function process($uninstaller): ?bool
{ {
if (!self::$init) { if (!self::$init) {
return false; return false;
@ -96,5 +96,7 @@ class Uninstall
/* desc */ /* desc */
sprintf(__('delete %s version number'), Core::id()) sprintf(__('delete %s version number'), Core::id())
); );
return true;
} }
} }

View File

@ -12,7 +12,8 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
if (Dotclear\Plugin\pacKman\Manage::init()) { $manage = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Manage']);
Dotclear\Plugin\pacKman\Manage::process(); if ($manage::init()) {
Dotclear\Plugin\pacKman\Manage::render(); $manage::process();
$manage::render();
} }

54
locales/fr/main.lang.php Normal file
View File

@ -0,0 +1,54 @@
<?php
/**
* @package Dotclear
*
* @copyright Olivier Meunier & Association Dotclear
* @copyright GPL-2.0-only
*/
#
# 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 :';
l10n::$locales['Preconization: %s'] = 'Préconisation : %s';
l10n::$locales['Blog\'s public directory'] = 'Répertoire public du blog';
l10n::$locales['Leave it empty to use Dotclear VAR directory'] = 'Laisser vide pour utiliser le répertoire VAR de Dotclear';
l10n::$locales['Files'] = 'Fichiers';
l10n::$locales['Name of exported package:'] = 'Nom du paquetage exporté :';
l10n::$locales['Name of second exported package:'] = 'Nom du second paquetage exporté :';
l10n::$locales['Overwrite existing package'] = 'Écraser les paquetages existants';
l10n::$locales['Content'] = 'Contenu';
l10n::$locales['Extra files to exclude from package:'] = 'Fichiers supplémentaires à exclure du paquetage :';
l10n::$locales['Remove comments from files'] = 'Retirer les commentaires des fichiers';
l10n::$locales['Fix newline style from files content'] = 'Corriger les retour chariot du contenu des fichiers';
l10n::$locales['Directory is not writable'] = 'Le répertoire n\'est pas accessible en écriture';
l10n::$locales['Failed to get module info'] = 'Impossible de retrouver les informations du module';
l10n::$locales['Failed to get temporary directory'] = 'Impossible de retrouver le répertoire temporaire';
l10n::$locales['No modules selected.'] = 'Aucun module sélectionné.';
l10n::$locales['Package successfully created.'] = 'Paquetage créé avec succès.';
l10n::$locales['Undeletable file "%s"'] = 'Impossible de supprimer le fichier "%s"';
l10n::$locales['Package successfully deleted.'] = 'Paquetage effacé avec succès.';
l10n::$locales['Package successfully installed.'] = 'Paquetage installé avec succès.';
l10n::$locales['Package successfully copied.'] = 'Paquetage copié avec succès.';
l10n::$locales['Package successfully moved.'] = 'Paquetage déplacé avec succès.';
l10n::$locales['pacKman is not well configured.'] = 'pacKman n\'est pas correctement configuré.';
l10n::$locales['Configuration'] = 'Configuration';
l10n::$locales['Plugins root'] = 'Racine des plugins';
l10n::$locales['Themes root'] = 'Racine des thèmes';
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é.';
l10n::$locales['Path to first export package is not writable.'] = 'Le chemin vers le premier paquetage exporté n\'est pas accessible en écriture.';
l10n::$locales['Path to second export package is not writable.'] = 'Le chemin vers le second paquetage exporté n\'est pas accessible en écriture.';
l10n::$locales['Pack up selected modules'] = 'Emballer les modules sélectionnés';
l10n::$locales['install'] = 'installer';
l10n::$locales['copy to %s directory'] = 'copier dans le répertoire des %s';
l10n::$locales['plugins'] = 'extensions';
l10n::$locales['move to %s directory'] = 'déplacer dans le repertoire des %s';
l10n::$locales['themes'] = 'thèmes';
l10n::$locales['repository'] = 'dépôt';
l10n::$locales['File'] = 'Fichier';
l10n::$locales['Selected modules action:'] = 'Action sur les modules sélectionnés :';