use abstract plugin name

This commit is contained in:
Jean-Christian Denis 2022-12-10 21:28:19 +01:00
parent f5c59b638c
commit e322b2da16
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
2 changed files with 15 additions and 19 deletions

View file

@ -17,16 +17,14 @@ if (!defined('DC_CONTEXT_ADMIN')) {
dcCore::app()->addBehavior( dcCore::app()->addBehavior(
'adminModulesListGetActions', 'adminModulesListGetActions',
function ($list, $id, $_) { function ($list, $id, $_) {
if (!in_array($list->getList(), [ return in_array($list->getList(), [
'plugin-activate', 'plugin-activate',
'theme-activate', 'theme-activate',
])) { ]) ? sprintf(
return null; '<input type="submit" name="%s[%s]" value="Pack" />',
} basename(__DIR__),
html::escapeHTML($id)
return ) : null;
'<input type="submit" name="tinypacker[' .
html::escapeHTML($id) . ']" value="Pack" />';
} }
); );
@ -34,19 +32,14 @@ dcCore::app()->addBehavior(
'adminModulesListDoActions', 'adminModulesListDoActions',
function ($list, $modules, $type) { function ($list, $modules, $type) {
# Pack action # Pack action
if (empty($_POST['tinypacker']) if (empty($_POST[basename(__DIR__)])
|| !is_array($_POST['tinypacker'])) { || !is_array($_POST[basename(__DIR__)])) {
return null; return null;
} }
$modules = array_keys($_POST['tinypacker']);
$id = $modules[0];
# Repository directory # Repository directory
$dir = path::real( $dir = path::real(
dcCore::app()->blog->public_path . '/' . ( dcCore::app()->blog->public_path . '/packages',
defined('TINYPACKER_SUBDIR') ? TINYPACKER_SUBDIR : 'packages'
),
false false
); );
@ -58,6 +51,9 @@ dcCore::app()->addBehavior(
} }
# Module to pack # Module to pack
$modules = array_keys($_POST[basename(__DIR__)]);
$id = $modules[0];
if (!$list->modules->moduleExists($id)) { if (!$list->modules->moduleExists($id)) {
throw new Exception(__('No such module.')); throw new Exception(__('No such module.'));
} }

View file

@ -23,8 +23,8 @@ $this->registerModule(
'requires' => [['core', '2.24']], 'requires' => [['core', '2.24']],
'permissions' => null, 'permissions' => null,
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://github.com/JcDenis/tinyPacker', 'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
'details' => 'https://plugins.dotaddict.org/dc2/details/tinyPacker', 'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
'repository' => 'https://raw.githubudsfsfdsfsercontent.com/JcDenis/tinyPacker/master/dcstore.xml', 'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
] ]
); );