use namespace

This commit is contained in:
Jean-Christian Paul Denis 2022-12-23 11:27:35 +01:00
parent e322b2da16
commit 7506fdb918
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951

View File

@ -10,11 +10,50 @@
* @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
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { declare(strict_types=1);
return null;
}
dcCore::app()->addBehavior( namespace Dotclear\Plugin\tinyPacker;
/* dotclear */
use dcCore;
use dcPage;
/* clearbricks */
use files;
use fileZip;
use html;
use http;
use path;
/* php */
use Exception;
/**
* tinyPacker admin class
*
* Add action and button to modules lists.
*/
class Admin
{
private static $init = false;
public static function init(): bool
{
if (defined('DC_CONTEXT_ADMIN')) {
dcPage::checkSuper();
self::$init = true;
}
return self::$init;
}
public static function process(): bool
{
if (!self::$init) {
return false;
}
dcCore::app()->addBehavior(
'adminModulesListGetActions', 'adminModulesListGetActions',
function ($list, $id, $_) { function ($list, $id, $_) {
return in_array($list->getList(), [ return in_array($list->getList(), [
@ -26,9 +65,9 @@ dcCore::app()->addBehavior(
html::escapeHTML($id) html::escapeHTML($id)
) : null; ) : null;
} }
); );
dcCore::app()->addBehavior( dcCore::app()->addBehavior(
'adminModulesListDoActions', 'adminModulesListDoActions',
function ($list, $modules, $type) { function ($list, $modules, $type) {
# Pack action # Pack action
@ -105,4 +144,13 @@ dcCore::app()->addBehavior(
); );
http::redirect($list->getURL()); http::redirect($list->getURL());
} }
); );
return true;
}
}
/* process */
if (Admin::init()) {
Admin::process();
}