diff --git a/CHANGELOG.md b/CHANGELOG.md index 026ec3a..d27c4b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +2023.01.05 +- harmonise structure (with my plugins) + 2022.12.20 - use shorter settings names - use dotclear VAR as default repository diff --git a/_admin.php b/_admin.php index e811bd4..c4e18d9 100644 --- a/_admin.php +++ b/_admin.php @@ -12,6 +12,7 @@ */ declare(strict_types=1); -if (Dotclear\Plugin\pacKman\Admin::init()) { - Dotclear\Plugin\pacKman\Admin::process(); +$admin = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Admin']); +if ($admin::init()) { + $admin::process(); } diff --git a/_config.php b/_config.php index c344761..ed4dccb 100644 --- a/_config.php +++ b/_config.php @@ -12,11 +12,8 @@ */ declare(strict_types=1); -if (!defined('DC_CONTEXT_MODULE')) { - return null; -} - -if (Dotclear\Plugin\pacKman\Config::init()) { - Dotclear\Plugin\pacKman\Config::process(); - Dotclear\Plugin\pacKman\Config::render(); +$config = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Config']); +if ($config::init()) { + $config::process(); + $config::render(); } diff --git a/_define.php b/_define.php index c380b77..02b6a5e 100644 --- a/_define.php +++ b/_define.php @@ -23,7 +23,7 @@ $this->registerModule( 'pacKman', 'Manage your Dotclear packages', 'Jean-Christian Denis', - '2022.12.20', + '2023.01.05', [ 'requires' => [['core', '2.24']], 'permissions' => null, diff --git a/_install.php b/_install.php index d702d06..aa29807 100644 --- a/_install.php +++ b/_install.php @@ -12,8 +12,9 @@ */ declare(strict_types=1); -if (Dotclear\Plugin\pacKman\Install::init()) { - return Dotclear\Plugin\pacKman\Install::process(); +$install = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Install']); +if ($install::init()) { + return $install::process(); } return null; diff --git a/_prepend.php b/_prepend.php index dc39828..07f7484 100644 --- a/_prepend.php +++ b/_prepend.php @@ -12,10 +12,11 @@ */ declare(strict_types=1); -if (!class_exists('Dotclear\Plugin\pacKman\Prepend')) { - require __DIR__ . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Prepend.php'; +$prepend = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Prepend']); +if (!class_exists($prepend)) { + require implode(DIRECTORY_SEPARATOR, [__DIR__, 'inc', 'Prepend.php']); - if (Dotclear\Plugin\pacKman\Prepend::init()) { - Dotclear\Plugin\pacKman\Prepend::process(); + if ($prepend::init()) { + $prepend::process(); } } diff --git a/_uninstall.php b/_uninstall.php index 00a6eaa..3ba4e4e 100644 --- a/_uninstall.php +++ b/_uninstall.php @@ -12,6 +12,7 @@ */ declare(strict_types=1); -if (Dotclear\Plugin\pacKman\Uninstall::init()) { - Dotclear\Plugin\pacKman\Uninstall::process($this); +$uninstall = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Uninstall']); +if ($uninstall::init()) { + $uninstall::process($this); } diff --git a/dcstore.xml b/dcstore.xml index e3fca58..b52ee05 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,10 +2,10 @@ pacKman - 2022.12.20 + 2023.01.05 Jean-Christian Denis Manage your Dotclear packages - https://github.com/JcDenis/pacKman/releases/download/v2022.12.20/plugin-pacKman.zip + https://github.com/JcDenis/pacKman/releases/download/v2023.01.05/plugin-pacKman.zip 2.24 https://plugins.dotaddict.org/dc2/details/pacKman https://github.com/JcDenis/pacKman diff --git a/inc/Admin.php b/inc/Admin.php index bbe58b9..b7b1164 100644 --- a/inc/Admin.php +++ b/inc/Admin.php @@ -22,19 +22,18 @@ use dcPage; class Admin { - private static $init = false; + protected static $init = false; public static function init(): bool { if (defined('DC_CONTEXT_ADMIN')) { - dcCore::app()->blog->settings->addNamespace(Core::id()); self::$init = true; } return self::$init; } - public static function process() + public static function process(): ?bool { if (!self::$init) { return false; @@ -57,5 +56,7 @@ class Admin preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . Core::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']), dcCore::app()->auth->isSuperAdmin() ); + + return true; } } diff --git a/inc/Config.php b/inc/Config.php index 8c319b9..79071ff 100644 --- a/inc/Config.php +++ b/inc/Config.php @@ -27,26 +27,25 @@ use Exception; class Config { - private static $init = false; + protected static $init = false; public static function init(): bool { - if (defined('DC_CONTEXT_ADMIN')) { - dcCore::app()->blog->settings->addNamespace(Core::id()); + if (defined('DC_CONTEXT_ADMIN') && defined('DC_CONTEXT_MODULE')) { self::$init = true; } return self::$init; } - public static function process(): void + public static function process(): ?bool { if (!self::$init) { - return; + return false; } if (empty($_POST['save'])) { - return; + return null; } # -- 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')->getRedir()) ); + + return true; } } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } + + return null; } public static function render() diff --git a/inc/Install.php b/inc/Install.php index ac844d4..9f3446e 100644 --- a/inc/Install.php +++ b/inc/Install.php @@ -70,7 +70,7 @@ class Install ]; // Nothing to change below - private static $init = false; + protected static $init = false; public static function init(): bool { @@ -79,7 +79,7 @@ class Install return self::$init; } - public static function process() + public static function process(): ?bool { if (!self::$init) { return false; @@ -90,7 +90,6 @@ class Install self::growUp(); // Set module settings - dcCore::app()->blog->settings->addNamespace(Core::id()); foreach (self::$mod_conf as $v) { dcCore::app()->blog->settings->__get(Core::id())->put( $v[0], @@ -110,7 +109,7 @@ class Install } } - public static function growUp() + public static function growUp(): void { $current = dcCore::app()->getVersion(Core::id()); diff --git a/inc/Manage.php b/inc/Manage.php index 32c4fc1..5b90c42 100644 --- a/inc/Manage.php +++ b/inc/Manage.php @@ -31,13 +31,12 @@ class Manage { private static $plugins_path = ''; private static $themes_path = ''; - private static $init = false; + protected static $init = false; public static function init(): bool { if (defined('DC_CONTEXT_ADMIN')) { dcPage::checkSuper(); - dcCore::app()->blog->settings->addNamespace(Core::id()); # Paths $e = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT); diff --git a/inc/Prepend.php b/inc/Prepend.php index 60470d4..5d5e8fb 100644 --- a/inc/Prepend.php +++ b/inc/Prepend.php @@ -30,7 +30,7 @@ class Prepend 'Uninstall', 'Utils', ]; - private static $init = false; + protected static $init = false; public static function init(): bool { @@ -39,14 +39,16 @@ class Prepend return self::$init; } - public static function process() + public static function process(): ?bool { if (!self::$init) { return false; } 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; diff --git a/inc/Uninstall.php b/inc/Uninstall.php index df942e6..86da62e 100644 --- a/inc/Uninstall.php +++ b/inc/Uninstall.php @@ -16,7 +16,7 @@ namespace Dotclear\Plugin\pacKman; class Uninstall { - private static $init = false; + protected static $init = false; public static function init(): bool { @@ -25,7 +25,7 @@ class Uninstall return self::$init; } - public static function process($uninstaller) + public static function process($uninstaller): ?bool { if (!self::$init) { return false; @@ -96,5 +96,7 @@ class Uninstall /* desc */ sprintf(__('delete %s version number'), Core::id()) ); + + return true; } } diff --git a/index.php b/index.php index 38593a4..0cdebae 100644 --- a/index.php +++ b/index.php @@ -12,7 +12,8 @@ */ declare(strict_types=1); -if (Dotclear\Plugin\pacKman\Manage::init()) { - Dotclear\Plugin\pacKman\Manage::process(); - Dotclear\Plugin\pacKman\Manage::render(); +$manage = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Manage']); +if ($manage::init()) { + $manage::process(); + $manage::render(); } diff --git a/locales/fr/main.lang.php b/locales/fr/main.lang.php new file mode 100644 index 0000000..3d37b18 --- /dev/null +++ b/locales/fr/main.lang.php @@ -0,0 +1,54 @@ +