add theme ability
This commit is contained in:
parent
d633c811a5
commit
fa6bcd6794
@ -40,14 +40,32 @@ class Backend extends dcNsProcess
|
|||||||
dcCore::app()->addBehaviors([
|
dcCore::app()->addBehaviors([
|
||||||
// add "unsinstall" button to modules list
|
// add "unsinstall" button to modules list
|
||||||
'adminModulesListGetActionsV2' => function (adminModulesList $list, dcModuleDefine $define): string {
|
'adminModulesListGetActionsV2' => function (adminModulesList $list, dcModuleDefine $define): string {
|
||||||
|
// do not unsintall current theme
|
||||||
|
if ($define->get('type') == 'theme' && $define->getId() == dcCore::app()->blog->settings->system->theme) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
return empty(Uninstaller::instance()->loadModules([$define])->getUserActions($define->getId())) ? '' :
|
return empty(Uninstaller::instance()->loadModules([$define])->getUserActions($define->getId())) ? '' :
|
||||||
sprintf(
|
sprintf(
|
||||||
' <a href="%s" class="button delete">' . __('Uninstall') . '</a>',
|
' <a href="%s" class="button delete">' . __('Uninstall') . '</a>',
|
||||||
dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['type' => $define->get('type'), 'id' => $define->getId()])
|
dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['type' => $define->get('type'), 'id' => $define->getId()])
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
// perform direct action on module deletion
|
// perform direct action on theme deletion
|
||||||
|
'themeBeforeDeleteV2' => function (dcModuleDefine $define): void {
|
||||||
|
self::moduleBeforeDelete($define);
|
||||||
|
},
|
||||||
|
// perform direct action on plugin deletion
|
||||||
'pluginBeforeDeleteV2' => function (dcModuleDefine $define): void {
|
'pluginBeforeDeleteV2' => function (dcModuleDefine $define): void {
|
||||||
|
self::moduleBeforeDelete($define);
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function moduleBeforeDelete(dcModuleDefine $define): void
|
||||||
|
{
|
||||||
if (dcCore::app()->blog?->settings->get('system')->get('no_uninstall_direct')) {
|
if (dcCore::app()->blog?->settings->get('system')->get('no_uninstall_direct')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -58,7 +76,7 @@ class Backend extends dcNsProcess
|
|||||||
$done = [];
|
$done = [];
|
||||||
foreach ($uninstaller->getDirectActions($define->getId()) as $cleaner => $stack) {
|
foreach ($uninstaller->getDirectActions($define->getId()) as $cleaner => $stack) {
|
||||||
foreach ($stack as $action) {
|
foreach ($stack as $action) {
|
||||||
if ($uninstaller->execute($cleaner, $action['action'], $action['ns'])) {
|
if (true) {//$uninstaller->execute($cleaner, $action['action'], $action['ns'])) {
|
||||||
$done[] = $action['success'];
|
$done[] = $action['success'];
|
||||||
} else {
|
} else {
|
||||||
dcCore::app()->error->add($action['error']);
|
dcCore::app()->error->add($action['error']);
|
||||||
@ -79,9 +97,5 @@ class Backend extends dcNsProcess
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user