cope with disabled modules, fix #4
This commit is contained in:
parent
7e4e2ffdf5
commit
a30c43b882
@ -27,6 +27,7 @@ class dcPackman
|
|||||||
'CVS',
|
'CVS',
|
||||||
'.DS_Store',
|
'.DS_Store',
|
||||||
'Thumbs.db',
|
'Thumbs.db',
|
||||||
|
'_disabled',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function quote_exclude(array $exclude): array
|
public static function quote_exclude(array $exclude): array
|
||||||
|
@ -55,6 +55,28 @@ class libPackman
|
|||||||
return !(empty($path) || empty($file) || !is_writable(dirname($path . '/' . $file)));
|
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
|
public static function modules(array $modules, string $type, string $title): ?bool
|
||||||
{
|
{
|
||||||
if (empty($modules) || !is_array($modules)) {
|
if (empty($modules) || !is_array($modules)) {
|
||||||
|
11
index.php
11
index.php
@ -99,11 +99,11 @@ try {
|
|||||||
# Pack
|
# Pack
|
||||||
} elseif ($action == 'packup') {
|
} elseif ($action == 'packup') {
|
||||||
foreach ($_POST['modules'] as $root => $id) {
|
foreach ($_POST['modules'] as $root => $id) {
|
||||||
if (!${$type}->moduleExists($id)) {
|
if (!libPackman::moduleExists($type, $id)) {
|
||||||
throw new Exception('No such module');
|
throw new Exception('No such module');
|
||||||
}
|
}
|
||||||
|
|
||||||
$module = ${$type}->getModules($id);
|
$module = libPackman::getModules($type, $id);
|
||||||
$module['id'] = $id;
|
$module['id'] = $id;
|
||||||
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
|
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
|
||||||
|
|
||||||
@ -261,8 +261,7 @@ dcPage::notices();
|
|||||||
if (dcCore::app()->error->flag() || !$is_configured) {
|
if (dcCore::app()->error->flag() || !$is_configured) {
|
||||||
echo
|
echo
|
||||||
'<div class="warning">' . __('pacKman is not well configured.') . ' ' .
|
'<div class="warning">' . __('pacKman is not well configured.') . ' ' .
|
||||||
'<a href="plugins.php?module=pacKman&conf=1&redir=' .
|
'<a href="' . dcCore::app()->adminurl->get('admin.plugins', ['module' => 'pacKman', 'conf' => '1', 'redir' => dcCore::app()->adminurl->get('admin.plugin.pacKman')]) . '">' . __('Configuration') . '</a>' .
|
||||||
urlencode('plugin.php?p=pacKman') . '">' . __('Configuration') . '</a>' .
|
|
||||||
'</div>';
|
'</div>';
|
||||||
} else {
|
} else {
|
||||||
$repo_path_modules = array_merge(
|
$repo_path_modules = array_merge(
|
||||||
@ -273,13 +272,13 @@ if (dcCore::app()->error->flag() || !$is_configured) {
|
|||||||
$themes_path_modules = dcPackman::getPackages($themes_path);
|
$themes_path_modules = dcPackman::getPackages($themes_path);
|
||||||
|
|
||||||
libPackman::modules(
|
libPackman::modules(
|
||||||
$plugins->getModules(),
|
libPackman::getModules('plugins'),
|
||||||
'plugins',
|
'plugins',
|
||||||
__('Installed plugins')
|
__('Installed plugins')
|
||||||
);
|
);
|
||||||
|
|
||||||
libPackman::modules(
|
libPackman::modules(
|
||||||
$themes->getModules(),
|
libPackman::getModules('themes'),
|
||||||
'themes',
|
'themes',
|
||||||
__('Installed themes')
|
__('Installed themes')
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user