From 771d71231f8b55e24a9b97e697b5a6c3bc35f9a4 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 3 Dec 2022 21:45:56 +0100 Subject: [PATCH] allow to improve disabled modules too --- index.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index bbf1e20..6ffabcc 100644 --- a/index.php +++ b/index.php @@ -134,7 +134,7 @@ class index } $combo_modules = []; - $modules = $this->type == 'plugin' ? dcCore::app()->plugins->getModules() : dcCore::app()->themes->getModules(); + $modules = self::getModules($this->type == 'plugin' ? 'plugins' : 'themes'); foreach ($modules as $id => $m) { if (!$m['root_writable'] || !$allow_distrib && in_array($id, $official[$this->type])) { continue; @@ -146,6 +146,21 @@ class index return array_merge([__('Select a module') => '-'], $combo_modules); } + public static function getModules(string $type, ?string $id = null): ?array + { + $type = $type == 'themes' ? 'themes' : 'plugins'; + + $modules = array_merge(dcCore::app()->{$type}->getDisabledModules(), dcCore::app()->{$type}->getModules()); + + if (empty($id)) { + return $modules; + } elseif (array_key_exists($id, $modules)) { + return $modules[$id]; + } + + return null; + } + private function doAction(): void { $log_id = ''; @@ -161,7 +176,7 @@ class index $time = $this->improve->fixModule( $this->type, $this->module, - $this->type == 'plugin' ? dcCore::app()->plugins->getModules($this->module) : dcCore::app()->themes->getModules($this->module), + self::getModules($this->type == 'plugin' ? 'plugins' : 'themes',$this->module), $_POST['actions'] ); $log_id = $this->improve->writeLogs();