From 0bd77b1399ff6935e8dfd8cfc9f83398f7a9f993 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 18 Mar 2023 17:18:38 +0100 Subject: [PATCH] add setting to hide distributed modules from lists --- src/Config.php | 7 +++++++ src/Settings.php | 4 ++++ src/Utils.php | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/src/Config.php b/src/Config.php index 7495ba1..30792f3 100644 --- a/src/Config.php +++ b/src/Config.php @@ -88,6 +88,13 @@ class Config extends dcNsProcess # -- Display form -- echo (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([ // pack_repository (new Para())->items([ diff --git a/src/Settings.php b/src/Settings.php index ecfccfa..5b212b1 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -39,6 +39,9 @@ class Settings // Extra files to exclude from package public readonly string $pack_excludefiles; + // Hide distributed modules from lists + public readonly bool $hide_distrib; + /** * Constructor set up plugin settings */ @@ -53,6 +56,7 @@ class Settings $this->secondpack_filename = (string) ($s->get('secondpack_filename') ?? '%type%-%id%-%version%'); $this->pack_repository = (string) ($s->get('pack_repository') ?? ''); $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 diff --git a/src/Utils.php b/src/Utils.php index 9325817..4023daf 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -98,6 +98,10 @@ class Utils $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)) { return $modules; } elseif (array_key_exists($id, $modules)) {