add setting to hide distributed modules from lists

This commit is contained in:
Jean-Christian Paul Denis 2023-03-18 17:18:38 +01:00
parent 3153c4b751
commit 0bd77b1399
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
3 changed files with 15 additions and 0 deletions

View File

@ -88,6 +88,13 @@ class Config extends dcNsProcess
# -- Display form -- # -- Display form --
echo echo
(new Div())->items([ (new Div())->items([
(new Fieldset())->class('fieldset')->legend((new Legend(__('Interface'))))->fields([
// hide_distrib
(new Para())->items([
(new Checkbox('hide_distrib', $s->hide_distrib))->value(1),
(new Label(__('Hide distributed modules from lists'), Label::OUTSIDE_LABEL_AFTER))->for('hide_distrib')->class('classic'),
]),
]),
(new Fieldset())->class('fieldset')->legend((new Legend(__('Root'))))->fields([ (new Fieldset())->class('fieldset')->legend((new Legend(__('Root'))))->fields([
// pack_repository // pack_repository
(new Para())->items([ (new Para())->items([

View File

@ -39,6 +39,9 @@ class Settings
// Extra files to exclude from package // Extra files to exclude from package
public readonly string $pack_excludefiles; public readonly string $pack_excludefiles;
// Hide distributed modules from lists
public readonly bool $hide_distrib;
/** /**
* Constructor set up plugin settings * Constructor set up plugin settings
*/ */
@ -53,6 +56,7 @@ class Settings
$this->secondpack_filename = (string) ($s->get('secondpack_filename') ?? '%type%-%id%-%version%'); $this->secondpack_filename = (string) ($s->get('secondpack_filename') ?? '%type%-%id%-%version%');
$this->pack_repository = (string) ($s->get('pack_repository') ?? ''); $this->pack_repository = (string) ($s->get('pack_repository') ?? '');
$this->pack_excludefiles = (string) ($s->get('pack_excludefiles') ?? '*.zip,*.tar,*.tar.gz,.directory,.hg'); $this->pack_excludefiles = (string) ($s->get('pack_excludefiles') ?? '*.zip,*.tar,*.tar.gz,.directory,.hg');
$this->hide_distrib = (bool) ($s->get('hide_distrib') ?? false);
} }
public function getSetting(string $key): mixed public function getSetting(string $key): mixed

View File

@ -98,6 +98,10 @@ class Utils
$modules = array_merge(dcCore::app()->{$type}->getDisabledModules(), dcCore::app()->{$type}->getModules()); $modules = array_merge(dcCore::app()->{$type}->getDisabledModules(), dcCore::app()->{$type}->getModules());
if ((new Settings())->hide_distrib) {
$modules = array_diff_key($modules, array_flip(array_values(array_merge(explode(',', DC_DISTRIB_PLUGINS), explode(',', DC_DISTRIB_THEMES)))));
}
if (empty($id)) { if (empty($id)) {
return $modules; return $modules;
} elseif (array_key_exists($id, $modules)) { } elseif (array_key_exists($id, $modules)) {