diff --git a/inc/class.dc.packman.php b/inc/class.dc.packman.php index 807c086..7f88807 100644 --- a/inc/class.dc.packman.php +++ b/inc/class.dc.packman.php @@ -27,6 +27,7 @@ class dcPackman 'CVS', '.DS_Store', 'Thumbs.db', + '_disabled', ]; public static function quote_exclude(array $exclude): array diff --git a/inc/lib.packman.php b/inc/lib.packman.php index a4e3ba5..3a3b199 100644 --- a/inc/lib.packman.php +++ b/inc/lib.packman.php @@ -55,6 +55,28 @@ class libPackman return !(empty($path) || empty($file) || !is_writable(dirname($path . '/' . $file))); } + 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; + } + + public static function moduleExists(string $type, ?string $id): bool + { + $type = $type == 'themes' ? 'themes' : 'plugins'; + + return array_key_exists($id, array_merge(dcCore::app()->{$type}->getDisabledModules(), dcCore::app()->{$type}->getModules())); + } + public static function modules(array $modules, string $type, string $title): ?bool { if (empty($modules) || !is_array($modules)) { diff --git a/index.php b/index.php index b331a9b..41b0f18 100644 --- a/index.php +++ b/index.php @@ -99,11 +99,11 @@ try { # Pack } elseif ($action == 'packup') { foreach ($_POST['modules'] as $root => $id) { - if (!${$type}->moduleExists($id)) { + if (!libPackman::moduleExists($type, $id)) { throw new Exception('No such module'); } - $module = ${$type}->getModules($id); + $module = libPackman::getModules($type, $id); $module['id'] = $id; $module['type'] = $type == 'themes' ? 'theme' : 'plugin'; @@ -261,8 +261,7 @@ dcPage::notices(); if (dcCore::app()->error->flag() || !$is_configured) { echo '