testing NsClass
parent
24ee3c5f6f
commit
d54e07fc16
20
_admin.php
20
_admin.php
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief improve, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @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()) {
|
||||
return $admin::process();
|
||||
}
|
||||
|
||||
return null;
|
19
_config.php
19
_config.php
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief improve, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @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();
|
||||
}
|
20
_install.php
20
_install.php
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief improve, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @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;
|
22
_prepend.php
22
_prepend.php
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief improve, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @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();
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief improve, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @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);
|
||||
}
|
|
@ -83,7 +83,7 @@ abstract class Action
|
|||
*/
|
||||
final public function __construct()
|
||||
{
|
||||
$this->class_name = str_replace(Prepend::getActionsNS(), '', get_called_class());
|
||||
$this->class_name = str_replace(Utils::getActionsNS(), '', get_called_class());
|
||||
|
||||
$settings = dcCore::app()->blog->settings->get(Core::id())->get('settings_' . $this->class_name);
|
||||
if (null != $settings) {
|
||||
|
|
|
@ -19,6 +19,7 @@ use dcAdmin;
|
|||
use dcCore;
|
||||
use dcPage;
|
||||
use dcFavorites;
|
||||
use dcNsProcess;
|
||||
|
||||
/* clearbricks */
|
||||
use Clearbricks;
|
||||
|
@ -29,10 +30,8 @@ use files;
|
|||
*
|
||||
* Add menu and dashboard icons, load Improve action modules.
|
||||
*/
|
||||
class Admin
|
||||
class Admin extends dcNsProcess
|
||||
{
|
||||
protected static $init = false;
|
||||
|
||||
public static function init(): bool
|
||||
{
|
||||
if (defined('DC_CONTEXT_ADMIN')) {
|
||||
|
@ -42,7 +41,7 @@ class Admin
|
|||
return self::$init;
|
||||
}
|
||||
|
||||
public static function process()
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::$init) {
|
||||
return false;
|
||||
|
@ -69,11 +68,13 @@ class Admin
|
|||
dcCore::app()->auth->isSuperAdmin()
|
||||
);
|
||||
|
||||
foreach (files::scandir(Prepend::getActionsDir()) as $file) {
|
||||
if (is_file(Prepend::getActionsDir() . $file) && '.php' == substr($file, -4)) {
|
||||
Clearbricks::lib()->autoload([Prepend::getActionsNS() . substr($file, 0, -4) => Prepend::getActionsDir() . $file]);
|
||||
dcCore::app()->addBehavior('improveAddAction', [Prepend::getActionsNS() . substr($file, 0, -4), 'create']); /* @phpstan-ignore-line */
|
||||
foreach (files::scandir(Utils::getActionsDir()) as $file) {
|
||||
if (is_file(Utils::getActionsDir() . $file) && '.php' == substr($file, -4)) {
|
||||
Clearbricks::lib()->autoload([Utils::getActionsNS() . substr($file, 0, -4) => Utils::getActionsDir() . $file]);
|
||||
dcCore::app()->addBehavior('improveAddAction', [Utils::getActionsNS() . substr($file, 0, -4), 'create']); /* @phpstan-ignore-line */
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace Dotclear\Plugin\improve;
|
|||
/* dotclear */
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use dcNsProcess;
|
||||
|
||||
/* clearbricks */
|
||||
use form;
|
||||
|
@ -29,10 +30,8 @@ use Exception;
|
|||
*
|
||||
* Set preference for this plugin.
|
||||
*/
|
||||
class Config
|
||||
class Config extends dcNsProcess
|
||||
{
|
||||
protected static $init = false;
|
||||
|
||||
public static function init(): bool
|
||||
{
|
||||
if (defined('DC_CONTEXT_ADMIN')) {
|
||||
|
@ -43,14 +42,14 @@ class Config
|
|||
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 true;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -70,9 +69,11 @@ class Config
|
|||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function render()
|
||||
public static function render(): void
|
||||
{
|
||||
if (!self::$init) {
|
||||
return;
|
||||
|
|
|
@ -76,7 +76,7 @@ class Core
|
|||
|
||||
public static function id()
|
||||
{
|
||||
return basename(dirname(dirname(__DIR__)));
|
||||
return basename(dirname(__DIR__));
|
||||
}
|
||||
|
||||
public function getLogs(): array
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Dotclear\Plugin\improve;
|
|||
|
||||
/* dotclear */
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
|
||||
/* php */
|
||||
use Exception;
|
||||
|
@ -26,7 +27,7 @@ use Exception;
|
|||
* Set default settings and version
|
||||
* and manage changes on updates.
|
||||
*/
|
||||
class Install
|
||||
class Install extends dcNsProcess
|
||||
{
|
||||
/** @var array Improve default settings */
|
||||
private static $default_settings = [[
|
||||
|
@ -36,9 +37,6 @@ class Install
|
|||
'string',
|
||||
]];
|
||||
|
||||
// Nothing to change below
|
||||
protected static $init = false;
|
||||
|
||||
public static function init(): bool
|
||||
{
|
||||
self::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->newVersion(Core::id(), dcCore::app()->plugins->moduleInfo(Core::id(), 'version'));
|
||||
|
@ -46,7 +44,7 @@ class Install
|
|||
return self::$init;
|
||||
}
|
||||
|
||||
public static function process(): ?bool
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::$init) {
|
||||
return false;
|
||||
|
|
|
@ -20,6 +20,7 @@ use dcPage;
|
|||
use dcAdminNotices;
|
||||
use dcThemes;
|
||||
use dcUtils;
|
||||
use dcNsProcess;
|
||||
|
||||
/* clearbricks */
|
||||
use html;
|
||||
|
@ -34,7 +35,7 @@ use Exception;
|
|||
* Display page and configure modules
|
||||
* and launch action.
|
||||
*/
|
||||
class Manage
|
||||
class Manage extends dcNsProcess
|
||||
{
|
||||
/** @var Core $improve improve core instance */
|
||||
private static $improve = null;
|
||||
|
@ -162,10 +163,10 @@ class Manage
|
|||
return null;
|
||||
}
|
||||
|
||||
public static function process(): void
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::$init) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$log_id = '';
|
||||
|
@ -209,6 +210,8 @@ class Manage
|
|||
if ($done) {
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), ['type' => self::$type, 'module' => self::$module, 'upd' => $log_id]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function render(): void
|
||||
|
|
|
@ -14,40 +14,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use Clearbricks;
|
||||
|
||||
/**
|
||||
* Improve prepend class
|
||||
*
|
||||
* Manage autoload and some action module helpers.
|
||||
* Improve utils class
|
||||
*/
|
||||
class Prepend
|
||||
class Utils
|
||||
{
|
||||
protected static $init = false;
|
||||
|
||||
public static function init(): bool
|
||||
{
|
||||
self::$init = defined('DC_RC_PATH') && defined('DC_CONTEXT_ADMIN');
|
||||
|
||||
return self::$init;
|
||||
}
|
||||
|
||||
public static function process()
|
||||
{
|
||||
if (!self::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Core plugin class
|
||||
foreach (['Core', 'Action', 'Module'] as $class) {
|
||||
Clearbricks::lib()->autoload([__NAMESPACE__ . '\\' . $class => implode(DIRECTORY_SEPARATOR, [__DIR__, 'core', $class . '.php'])]);
|
||||
}
|
||||
|
||||
// Dotclear plugin class
|
||||
foreach (['Admin', 'Config', 'Install', 'Manage', 'Prepend', 'Uninstall'] as $class) {
|
||||
Clearbricks::lib()->autoload([__NAMESPACE__ . '\\' . $class => implode(DIRECTORY_SEPARATOR, [__DIR__, $class . '.php'])]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getActionsDir(): string
|
||||
{
|
||||
|
|
19
index.php
19
index.php
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief improve, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @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();
|
||||
}
|
Loading…
Reference in New Issue