testing NsClass

This commit is contained in:
Jean-Christian Paul Denis 2023-01-20 21:54:39 +01:00
parent 4463766a78
commit f155a33fb1
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
12 changed files with 24 additions and 202 deletions

View File

@ -1,18 +0,0 @@
<?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);
$admin = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Admin']);
if ($admin::init()) {
$admin::process();
}

View File

@ -1,19 +0,0 @@
<?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);
$config = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Config']);
if ($config::init()) {
$config::process();
$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',
'2023.01.07', '2023.01.09-dev',
[ [
'requires' => [['core', '2.24']], 'requires' => [['core', '2.24']],
'permissions' => null, 'permissions' => null,

View File

@ -1,20 +0,0 @@
<?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);
$install = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Install']);
if ($install::init()) {
return $install::process();
}
return null;

View File

@ -1,22 +0,0 @@
<?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);
$prepend = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Prepend']);
if (!class_exists($prepend)) {
require implode(DIRECTORY_SEPARATOR, [__DIR__, 'inc', 'Prepend.php']);
if ($prepend::init()) {
$prepend::process();
}
}

View File

@ -1,24 +0,0 @@
<?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);
$uninstall = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Uninstall']);
// cope with disabled plugin
if (!class_exists($uninstall)) {
require implode(DIRECTORY_SEPARATOR, [__DIR__, 'inc', 'Uninstall.php']);
}
if ($uninstall::init()) {
$uninstall::process($this);
}

View File

@ -19,11 +19,11 @@ use dcAdmin;
use dcCore; use dcCore;
use dcFavorites; use dcFavorites;
use dcPage; use dcPage;
use dcNsProcess;
class Admin class Admin extends dcNsProcess
{ {
private static $pid = ''; private static $pid = '';
protected static $init = false;
public static function init(): bool public static function init(): bool
{ {
@ -35,7 +35,7 @@ class Admin
return self::$init; return self::$init;
} }
public static function process(): ?bool public static function process(): bool
{ {
if (!self::$init) { if (!self::$init) {
return false; return false;

View File

@ -17,6 +17,7 @@ namespace Dotclear\Plugin\pacKman;
/* dotclear ns */ /* dotclear ns */
use dcCore; use dcCore;
use dcPage; use dcPage;
use dcNsProcess;
/* clearbricks ns */ /* clearbricks ns */
use form; use form;
@ -25,14 +26,13 @@ use http;
/* php ns */ /* php ns */
use Exception; use Exception;
class Config class Config extends dcNsProcess
{ {
private static $pid = ''; private static $pid = '';
protected static $init = false;
public static function init(): bool public static function init(): bool
{ {
if (defined('DC_CONTEXT_ADMIN') && defined('DC_CONTEXT_MODULE')) { if (defined('DC_CONTEXT_ADMIN')) {
self::$pid = basename(dirname(__DIR__)); self::$pid = basename(dirname(__DIR__));
self::$init = true; self::$init = true;
} }
@ -40,14 +40,14 @@ class Config
return self::$init; return self::$init;
} }
public static function process(): ?bool public static function process(): bool
{ {
if (!self::$init) { if (!self::$init || !defined('DC_CONTEXT_MODULE')) {
return false; return false;
} }
if (empty($_POST['save'])) { if (empty($_POST['save'])) {
return null; return true;
} }
# -- Set settings -- # -- Set settings --
@ -83,20 +83,18 @@ class Config
dcCore::app()->admin->__get('list')->getURL('module=' . self::$pid . '&conf=1&redir=' . dcCore::app()->admin->__get('list')->getURL('module=' . self::$pid . '&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; return true;
} }
public static function render() public static function render(): void
{ {
if (!self::$init) { if (!self::$init) {
return false; return;
} }
# -- Get settings -- # -- Get settings --

View File

@ -17,11 +17,12 @@ namespace Dotclear\Plugin\pacKman;
/* dotclear ns */ /* dotclear ns */
use dcCore; use dcCore;
use dcNamespace; use dcNamespace;
use dcNsProcess;
/* php ns */ /* php ns */
use Exception; use Exception;
class Install class Install extends dcNsProcess
{ {
// Module specs // Module specs
private static $mod_conf = [ private static $mod_conf = [
@ -71,7 +72,6 @@ class Install
// Nothing to change below // Nothing to change below
private static $pid = ''; private static $pid = '';
protected static $init = false;
public static function init(): bool public static function init(): bool
{ {
@ -81,7 +81,7 @@ class Install
return self::$init; return self::$init;
} }
public static function process(): ?bool public static function process(): bool
{ {
if (!self::$init) { if (!self::$init) {
return false; return false;

View File

@ -18,6 +18,7 @@ namespace Dotclear\Plugin\pacKman;
use dcCore; use dcCore;
use dcPage; use dcPage;
use dcThemes; use dcThemes;
use dcNsProcess;
/* clearbricks ns */ /* clearbricks ns */
use files; use files;
@ -27,12 +28,11 @@ use path;
/* php ns */ /* php ns */
use Exception; use Exception;
class Manage class Manage extends dcNsProcess
{ {
private static $plugins_path = ''; private static $plugins_path = '';
private static $themes_path = ''; private static $themes_path = '';
private static $pid = ''; private static $pid = '';
protected static $init = false;
public static function init(): bool public static function init(): bool
{ {
@ -51,10 +51,10 @@ class Manage
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;
} }
# Queries # Queries
@ -279,12 +279,14 @@ class Manage
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
return true;
} }
public static function render() public static function render(): void
{ {
if (!self::$init) { if (!self::$init) {
return false; return;
} }
# Settings # Settings

View File

@ -1,56 +0,0 @@
<?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;
/* clearbricks ns */
use Clearbricks;
class Prepend
{
private const LIBS = [
'Admin',
'Config',
'Core',
'Filezip',
'Install',
'Manage',
'Prepend',
'Uninstall',
'Utils',
];
protected static $init = false;
public static function init(): bool
{
self::$init = defined('DC_RC_PATH');
return self::$init;
}
public static function process(): ?bool
{
if (!self::$init) {
return false;
}
foreach (self::LIBS as $lib) {
Clearbricks::lib()->autoload([
__NAMESPACE__ . '\\' . $lib => __DIR__ . DIRECTORY_SEPARATOR . $lib . '.php',
]);
}
return true;
}
}

View File

@ -1,19 +0,0 @@
<?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);
$manage = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Manage']);
if ($manage::init()) {
$manage::process();
$manage::render();
}