From 51361afc1212770de495990404cd51996a2d7a0c Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Tue, 24 Nov 2020 13:44:31 +0100 Subject: [PATCH] Options pages admin + choix et position des drapeux --- core/core.php | 22 +++++---- core/layout/common.css | 4 ++ core/module/install/ressource/defaultdata.php | 11 ++++- core/module/translate/translate.php | 12 ++++- core/module/translate/view/index/index.php | 46 ++++++++++++++++++- 5 files changed, 81 insertions(+), 14 deletions(-) diff --git a/core/core.php b/core/core.php index 21e8af47..0c97a9a0 100755 --- a/core/core.php +++ b/core/core.php @@ -143,10 +143,10 @@ class common { ]; // Langues proposées public static $i18nList = [ + 'fr' => 'Français (fr)', 'de' => 'Allemand (de)', 'en' => 'Anglais (en)', 'es' => 'Espagnol (es)', - 'fr' => 'Français (fr)', 'it' => 'Italien (it)', 'nl' => 'Néerlandais (nl)', 'pt' => 'Portugais (pt)', @@ -2156,9 +2156,12 @@ class core extends common { } // Librairie googtrans ajouté dynamiquement - if ( substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) !== 'fr' - AND $this->getData(['config','translate','activated']) === true - AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')) { + if ( $this->getData(['config','translate','activated']) === true + AND ( $this->getData(['config','translate','admin']) === true + OR $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD') + ) + ) + { $this->addOutput([ 'vendor' => array_merge($this->output['vendor'], ['i18n']) ]); @@ -2986,13 +2989,14 @@ class layout extends common { * Affiche le cadre avec les drapeaux */ public function showi18n() { - if ( $this->getData(['config','translate','activated']) === true - AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')) { + if ( $this->getData(['config','translate','activated']) === true ) { echo '
'; } diff --git a/core/layout/common.css b/core/layout/common.css index 74c49201..9492d5dc 100755 --- a/core/layout/common.css +++ b/core/layout/common.css @@ -730,6 +730,10 @@ li .menuSideChild { position: relative; } +#i18nContainer img { + width: 80%; +} + diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index b9d9c144..ba87aaa1 100755 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -45,7 +45,16 @@ class init extends common { 'translate' => [ 'activated' => false, 'showCredits' => false, - 'autoDetect' => false + 'autoDetect' => false, + 'admin' => false, + 'translateFlagFR' => true, + 'translateFlagDE' => true, + 'translateFlagEN' => true, + 'translateFlagES' => false, + 'translateFlagIT' => false, + 'translateFlagNL' => false, + 'translateFlagPT' => false + ], ], 'core' => [ diff --git a/core/module/translate/translate.php b/core/module/translate/translate.php index 91697787..d16588c1 100755 --- a/core/module/translate/translate.php +++ b/core/module/translate/translate.php @@ -29,7 +29,15 @@ class translate extends common { $this->setData(['config','translate', [ 'activated' => $this->getInput('translateActivated', helper::FILTER_BOOLEAN), 'showCredits' => $this->getInput('translateCredits', helper::FILTER_BOOLEAN) ? $this->getInput('translateCredits', helper::FILTER_BOOLEAN) : false, - 'autoDetect' => $this->getInput('translateAutoDetect', helper::FILTER_BOOLEAN) + 'autoDetect' => $this->getInput('translateAutoDetect', helper::FILTER_BOOLEAN), + 'admin' => $this->getInput('translateAdmin', helper::FILTER_BOOLEAN), + 'flagFR' => $this->getInput('translateFlagFR', helper::FILTER_BOOLEAN), + 'flagDE' => $this->getInput('translateFlagDE', helper::FILTER_BOOLEAN), + 'flagEN' => $this->getInput('translateFlagEN', helper::FILTER_BOOLEAN), + 'flagES' => $this->getInput('translateFlagES', helper::FILTER_BOOLEAN), + 'flagIT' => $this->getInput('translateFlagIT', helper::FILTER_BOOLEAN), + 'flagNL' => $this->getInput('translateFlagNL', helper::FILTER_BOOLEAN), + 'flagPT' => $this->getInput('translateFlagPT', helper::FILTER_BOOLEAN) ]]); // Valeurs en sortie $this->addOutput([ @@ -53,7 +61,7 @@ class translate extends common { setcookie('ZWII_USER_I18N', $this->getUrl(2), time() + 3600, helper::baseUrl(false, false) , '', helper::isHttps(), true); // Valeurs en sortie sans post $this->addOutput([ - 'redirect' => helper::baseUrl(false) + 'redirect' => helper::baseUrl() . $this->getUrl(3) ]); } } \ No newline at end of file diff --git a/core/module/translate/view/index/index.php b/core/module/translate/view/index/index.php index ee20d4c2..44343b7c 100755 --- a/core/module/translate/view/index/index.php +++ b/core/module/translate/view/index/index.php @@ -22,6 +22,11 @@ 'checked' => $this->getData(['config','translate', 'activated']) ]); ?> +
+ $this->getData(['config','translate', 'admin']) + ]); ?> +
@@ -44,8 +49,45 @@ ]); ?> - -
+
+
+ $this->getData(['config','translate', 'flagFR']) + ]); ?> +
+
+ $this->getData(['config','translate', 'flagDE']) + ]); ?> +
+
+ $this->getData(['config','translate', 'flagEN']) + ]); ?> +
+
+ $this->getData(['config','translate', 'flagES']) + ]); ?> +
+
+
+
+ $this->getData(['config','translate', 'flagIT']) + ]); ?> +
+
+ $this->getData(['config','translate', 'flagNL']) + ]); ?> +
+
+ $this->getData(['config','translate', 'flagPT']) + ]); ?> +
+