From e322b2da1608fc1c88c505d7d1d4eef431bef74d Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 10 Dec 2022 21:28:19 +0100 Subject: [PATCH] use abstract plugin name --- _admin.php | 28 ++++++++++++---------------- _define.php | 6 +++--- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/_admin.php b/_admin.php index 8de335f..aaa044d 100644 --- a/_admin.php +++ b/_admin.php @@ -17,16 +17,14 @@ if (!defined('DC_CONTEXT_ADMIN')) { dcCore::app()->addBehavior( 'adminModulesListGetActions', function ($list, $id, $_) { - if (!in_array($list->getList(), [ + return in_array($list->getList(), [ 'plugin-activate', 'theme-activate', - ])) { - return null; - } - - return - ''; + ]) ? sprintf( + '', + basename(__DIR__), + html::escapeHTML($id) + ) : null; } ); @@ -34,19 +32,14 @@ dcCore::app()->addBehavior( 'adminModulesListDoActions', function ($list, $modules, $type) { # Pack action - if (empty($_POST['tinypacker']) - || !is_array($_POST['tinypacker'])) { + if (empty($_POST[basename(__DIR__)]) + || !is_array($_POST[basename(__DIR__)])) { return null; } - $modules = array_keys($_POST['tinypacker']); - $id = $modules[0]; - # Repository directory $dir = path::real( - dcCore::app()->blog->public_path . '/' . ( - defined('TINYPACKER_SUBDIR') ? TINYPACKER_SUBDIR : 'packages' - ), + dcCore::app()->blog->public_path . '/packages', false ); @@ -58,6 +51,9 @@ dcCore::app()->addBehavior( } # Module to pack + $modules = array_keys($_POST[basename(__DIR__)]); + $id = $modules[0]; + if (!$list->modules->moduleExists($id)) { throw new Exception(__('No such module.')); } diff --git a/_define.php b/_define.php index ae2b2bd..ac78b92 100644 --- a/_define.php +++ b/_define.php @@ -23,8 +23,8 @@ $this->registerModule( 'requires' => [['core', '2.24']], 'permissions' => null, 'type' => 'plugin', - 'support' => 'https://github.com/JcDenis/tinyPacker', - 'details' => 'https://plugins.dotaddict.org/dc2/details/tinyPacker', - 'repository' => 'https://raw.githubudsfsfdsfsercontent.com/JcDenis/tinyPacker/master/dcstore.xml', + 'support' => 'https://github.com/JcDenis/' . basename(__DIR__), + 'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__), + 'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml', ] );