fix module type

This commit is contained in:
Jean-Christian Paul Denis 2023-04-15 22:37:02 +02:00
parent 305d4d8bbd
commit 12f3969cc4
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951

View File

@ -47,19 +47,19 @@ class Manage extends dcNsProcess
return false; return false;
} }
$type = ($_REQUEST['type'] ?? 'theme') == 'theme' ? 'themes' : 'plugins'; $type = ($_REQUEST['type'] ?? 'theme') == 'theme' ? 'theme' : 'plugin';
$redir = $type == 'themes' ? ['admin.blog.theme', [], '#themes'] : ['admin.plugins', [], '#plugins']; $redir = $type == 'theme' ? ['admin.blog.theme', [], '#themes'] : ['admin.plugins', [], '#plugins'];
if (empty($_REQUEST['id'])) { if (empty($_REQUEST['id'])) {
dcCore::app()->adminurl?->redirect($redir[0], $redir[1], $redir[2]); dcCore::app()->adminurl?->redirect($redir[0], $redir[1], $redir[2]);
} }
if ($type == 'themes' && !is_a(dcCore::app()->themes, 'dcThemes')) { if ($type == 'theme' && !is_a(dcCore::app()->themes, 'dcThemes')) {
dcCore::app()->themes = new dcThemes(); dcCore::app()->themes = new dcThemes();
dcCore::app()->themes->loadModules((string) dcCore::app()->blog?->themes_path, null); dcCore::app()->themes->loadModules((string) dcCore::app()->blog?->themes_path);
} }
$define = dcCore::app()->{$type}->getDefine($_REQUEST['id']); $define = dcCore::app()->{$type .'s'}->getDefine($_REQUEST['id']);
if (!$define->isDefined()) { if (!$define->isDefined()) {
dcCore::app()->error->add(__('Unknown module id to uninstall')); dcCore::app()->error->add(__('Unknown module id to uninstall'));
dcCore::app()->adminurl?->redirect($redir[0], $redir[1], $redir[2]); dcCore::app()->adminurl?->redirect($redir[0], $redir[1], $redir[2]);
@ -109,9 +109,9 @@ class Manage extends dcNsProcess
return; return;
} }
$type = $_REQUEST['type'] == 'theme' ? 'themes' : 'plugins'; $type = $_REQUEST['type'] == 'theme' ? 'theme' : 'plugin';
$redir = $type == 'themes' ? ['blog.themes', [], '#themes'] : ['admin.plugins', [], '#plugins']; $redir = $type == 'theme' ? ['admin.blog.theme', [], '#themes'] : ['admin.plugins', [], '#plugins'];
$define = dcCore::app()->{$type}->getDefine($_REQUEST['id']); $define = dcCore::app()->{$type .'s'}->getDefine($_REQUEST['id']);
$uninstaller = Uninstaller::instance()->loadModules([$define]); $uninstaller = Uninstaller::instance()->loadModules([$define]);
$fields = []; $fields = [];
@ -157,7 +157,7 @@ class Manage extends dcNsProcess
// display form // display form
echo (new Div())->items([ echo (new Div())->items([
(new Text('h3', sprintf(($type == 'themes' ? __('Uninstall theme "%s"') : __('Uninstall plugin "%s"')), __($define->get('name'))))), (new Text('h3', sprintf(($type == 'theme' ? __('Uninstall theme "%s"') : __('Uninstall plugin "%s"')), __($define->get('name'))))),
(new Text('p', sprintf(__('The module "%s %s" offers advanced unsintall process:'), $define->getId(), $define->get('version')))), (new Text('p', sprintf(__('The module "%s %s" offers advanced unsintall process:'), $define->getId(), $define->get('version')))),
(new Form('uninstall-form'))->method('post')->action(dcCore::app()->adminurl?->get('admin.plugin.' . My::id()))->fields($fields), (new Form('uninstall-form'))->method('post')->action(dcCore::app()->adminurl?->get('admin.plugin.' . My::id()))->fields($fields),
])->render(); ])->render();