add theme ability
This commit is contained in:
parent
d633c811a5
commit
fa6bcd6794
@ -40,14 +40,32 @@ class Backend extends dcNsProcess
|
||||
dcCore::app()->addBehaviors([
|
||||
// add "unsinstall" button to modules list
|
||||
'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())) ? '' :
|
||||
sprintf(
|
||||
' <a href="%s" class="button delete">' . __('Uninstall') . '</a>',
|
||||
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 {
|
||||
self::moduleBeforeDelete($define);
|
||||
},
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected static function moduleBeforeDelete(dcModuleDefine $define): void
|
||||
{
|
||||
if (dcCore::app()->blog?->settings->get('system')->get('no_uninstall_direct')) {
|
||||
return;
|
||||
}
|
||||
@ -58,7 +76,7 @@ class Backend extends dcNsProcess
|
||||
$done = [];
|
||||
foreach ($uninstaller->getDirectActions($define->getId()) as $cleaner => $stack) {
|
||||
foreach ($stack as $action) {
|
||||
if ($uninstaller->execute($cleaner, $action['action'], $action['ns'])) {
|
||||
if (true) {//$uninstaller->execute($cleaner, $action['action'], $action['ns'])) {
|
||||
$done[] = $action['success'];
|
||||
} else {
|
||||
dcCore::app()->error->add($action['error']);
|
||||
@ -79,9 +97,5 @@ class Backend extends dcNsProcess
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user