code review
This commit is contained in:
parent
bdd295d5ce
commit
11796eb948
11 changed files with 28 additions and 30 deletions
|
@ -5,7 +5,7 @@
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @author Jean-Christian Denis and contributors
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @author Jean-Christian Denis and contributors
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @author Jean-Christian Denis and contributors
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @author Jean-Christian Denis and contributors
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @author Jean-Christian Denis and contributors
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
|
@ -55,6 +55,7 @@ class Install
|
||||||
try {
|
try {
|
||||||
self::update_0_8_0();
|
self::update_0_8_0();
|
||||||
self::putSettings();
|
self::putSettings();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
|
|
|
@ -36,16 +36,16 @@ use Exception;
|
||||||
*/
|
*/
|
||||||
class Manage
|
class Manage
|
||||||
{
|
{
|
||||||
/** @var improve $improve improve core instance */
|
/** @var Core $improve improve core instance */
|
||||||
private static $improve = null;
|
private static $improve = null;
|
||||||
/** @var string $type Current module(s) type */
|
/** @var string $type Current module(s) type */
|
||||||
private static $type = 'plugin';
|
private static $type = 'plugin';
|
||||||
/** @var string $module Current module id */
|
/** @var string $module Current module id */
|
||||||
private static $module = '-';
|
private static $module = '-';
|
||||||
/** @var action|null $action Current action module */
|
/** @var Action|null $action Current action module */
|
||||||
private static $action = null;
|
private static $action = null;
|
||||||
|
|
||||||
private static $init = false;
|
private static $init = false;
|
||||||
|
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ class Manage
|
||||||
self::$type = self::getType();
|
self::$type = self::getType();
|
||||||
self::$module = self::getModule();
|
self::$module = self::getModule();
|
||||||
self::$action = self::getAction();
|
self::$action = self::getAction();
|
||||||
self::$init = true;
|
self::$init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$init;
|
return self::$init;
|
||||||
|
@ -77,7 +77,7 @@ class Manage
|
||||||
return $module;
|
return $module;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getAction(): ?action
|
private static function getAction(): ?Action
|
||||||
{
|
{
|
||||||
return empty($_REQUEST['config']) ? null : self::$improve->module($_REQUEST['config']);
|
return empty($_REQUEST['config']) ? null : self::$improve->module($_REQUEST['config']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ use Clearbricks;
|
||||||
*
|
*
|
||||||
* Manage autoload and some action module helpers.
|
* Manage autoload and some action module helpers.
|
||||||
*/
|
*/
|
||||||
class prepend
|
class Prepend
|
||||||
{
|
{
|
||||||
private static $init = false;
|
private static $init = false;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Core
|
||||||
'php', 'xml', 'js', 'css', 'csv', 'html', 'htm', 'txt', 'md', 'po',
|
'php', 'xml', 'js', 'css', 'csv', 'html', 'htm', 'txt', 'md', 'po',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var array<action> $actions Loaded actions modules */
|
/** @var array<Action> $actions Loaded actions modules */
|
||||||
private $actions = [];
|
private $actions = [];
|
||||||
|
|
||||||
/** @var array<string> $disabled Disabled actions modules */
|
/** @var array<string> $disabled Disabled actions modules */
|
||||||
|
@ -60,7 +60,7 @@ class Core
|
||||||
dcCore::app()->callBehavior('improveAddAction', $list);
|
dcCore::app()->callBehavior('improveAddAction', $list);
|
||||||
|
|
||||||
foreach ($list as $action) {
|
foreach ($list as $action) {
|
||||||
if ($action instanceof action && !isset($this->actions[$action->id()])) {
|
if ($action instanceof Action && !isset($this->actions[$action->id()])) {
|
||||||
if (in_array($action->id(), $disabled)) {
|
if (in_array($action->id(), $disabled)) {
|
||||||
$this->disabled[$action->id()] = $action->name();
|
$this->disabled[$action->id()] = $action->name();
|
||||||
} else {
|
} else {
|
||||||
|
@ -154,9 +154,9 @@ class Core
|
||||||
*
|
*
|
||||||
* @param string $id Module id
|
* @param string $id Module id
|
||||||
*
|
*
|
||||||
* @return action action instance
|
* @return Action action instance
|
||||||
*/
|
*/
|
||||||
public function module(string $id): ?action
|
public function module(string $id): ?Action
|
||||||
{
|
{
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -168,7 +168,7 @@ class Core
|
||||||
/**
|
/**
|
||||||
* Get all loaded action modules
|
* Get all loaded action modules
|
||||||
*
|
*
|
||||||
* @return action[] action instance
|
* @return Action[] action instance
|
||||||
*/
|
*/
|
||||||
public function modules(): array
|
public function modules(): array
|
||||||
{
|
{
|
||||||
|
@ -338,12 +338,12 @@ class Core
|
||||||
/**
|
/**
|
||||||
* Sort modules by priority then name
|
* Sort modules by priority then name
|
||||||
*
|
*
|
||||||
* @param action $a ImproveAction instance
|
* @param Action $a ImproveAction instance
|
||||||
* @param action $b ImproveAction instance
|
* @param Action $b ImproveAction instance
|
||||||
*
|
*
|
||||||
* @return integer Is higher
|
* @return integer Is higher
|
||||||
*/
|
*/
|
||||||
private function sortModules(action $a, action $b): int
|
private function sortModules(Action $a, Action $b): int
|
||||||
{
|
{
|
||||||
if ($a->priority() == $b->priority()) {
|
if ($a->priority() == $b->priority()) {
|
||||||
return strcasecmp($a->name(), $b->name());
|
return strcasecmp($a->name(), $b->name());
|
||||||
|
|
|
@ -29,16 +29,13 @@ class po2php extends Action
|
||||||
{
|
{
|
||||||
/** @var string License bloc */
|
/** @var string License bloc */
|
||||||
private $license = <<<EOF
|
private $license = <<<EOF
|
||||||
/**
|
/**
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
*
|
*
|
||||||
* @copyright Olivier Meunier & Association Dotclear
|
* @copyright Olivier Meunier & Association Dotclear
|
||||||
* @copyright GPL-2.0-only
|
* @copyright GPL-2.0-only
|
||||||
*/
|
*/
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
/** @var string Settings dcstore zip url pattern */
|
|
||||||
private $pattern = '';
|
|
||||||
|
|
||||||
protected function init(): bool
|
protected function init(): bool
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @author Jean-Christian Denis and contributors
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
Loading…
Reference in a new issue