From 6ef61cdb8a70ddefe6f0bdb3996b0d61d3acc844 Mon Sep 17 00:00:00 2001 From: tinect Date: Thu, 14 Nov 2019 20:32:42 +0100 Subject: [PATCH] clearfiy structure --- data/web/inc/functions.presets.inc.php | 17 ++++++++++------- .../{rspamd => admin-rspamd}/preset_1.yml | 0 .../{rspamd => admin-rspamd}/preset_2.yml | 0 .../{sieve => mailbox-sieve}/sieve_1.yml | 0 .../{sieve => mailbox-sieve}/sieve_2.yml | 0 5 files changed, 10 insertions(+), 7 deletions(-) rename data/web/inc/presets/{rspamd => admin-rspamd}/preset_1.yml (100%) rename data/web/inc/presets/{rspamd => admin-rspamd}/preset_2.yml (100%) rename data/web/inc/presets/{sieve => mailbox-sieve}/sieve_1.yml (100%) rename data/web/inc/presets/{sieve => mailbox-sieve}/sieve_2.yml (100%) diff --git a/data/web/inc/functions.presets.inc.php b/data/web/inc/functions.presets.inc.php index 149ea939..2c902b89 100644 --- a/data/web/inc/functions.presets.inc.php +++ b/data/web/inc/functions.presets.inc.php @@ -17,22 +17,25 @@ function presets($_action, $_data = null) global $lang; if ($_action === 'get') { $kind = strtolower(trim($_data)); - if (!in_array($kind, ['rspamd', 'sieve'], true)) { + $langSection = 'admin'; + + if (!in_array($kind, ['admin-rspamd', 'mailbox-sieve'], true)) { return []; } + if ($kind === 'mailbox-sieve') { + $langSection = 'mailbox'; + } + $presets = []; foreach (glob(__DIR__ . '/presets/' . $kind . '/*.yml') as $filename) { $preset = Spyc::YAMLLoad($filename); /* get translated headlines */ if (isset($preset['headline']) && strpos($preset['headline'], 'lang.') === 0) { - $textName = trim(substr($preset['headline'], 5)); - - if ($kind === 'rspamd') { - $preset['headline'] = $lang['admin'][$textName]; - } elseif ($kind === 'sieve') { - $preset['headline'] = $lang['mailbox'][$textName]; + $langTextName = trim(substr($preset['headline'], 5)); + if (isset($lang[$langSection][$langTextName])) { + $preset['headline'] = $lang[$langSection][$langTextName]; } } diff --git a/data/web/inc/presets/rspamd/preset_1.yml b/data/web/inc/presets/admin-rspamd/preset_1.yml similarity index 100% rename from data/web/inc/presets/rspamd/preset_1.yml rename to data/web/inc/presets/admin-rspamd/preset_1.yml diff --git a/data/web/inc/presets/rspamd/preset_2.yml b/data/web/inc/presets/admin-rspamd/preset_2.yml similarity index 100% rename from data/web/inc/presets/rspamd/preset_2.yml rename to data/web/inc/presets/admin-rspamd/preset_2.yml diff --git a/data/web/inc/presets/sieve/sieve_1.yml b/data/web/inc/presets/mailbox-sieve/sieve_1.yml similarity index 100% rename from data/web/inc/presets/sieve/sieve_1.yml rename to data/web/inc/presets/mailbox-sieve/sieve_1.yml diff --git a/data/web/inc/presets/sieve/sieve_2.yml b/data/web/inc/presets/mailbox-sieve/sieve_2.yml similarity index 100% rename from data/web/inc/presets/sieve/sieve_2.yml rename to data/web/inc/presets/mailbox-sieve/sieve_2.yml