Paramètres du module WIP

This commit is contained in:
Fred Tempez 2020-11-22 13:32:20 +01:00
parent 41ae0e18e1
commit dc31fc3ee6
5 changed files with 63 additions and 21 deletions

View File

@ -229,7 +229,7 @@ class common {
} }
// Auto traduction // Auto traduction
if ( $this->getData(['translate','active'])) { if ( $this->getData(['translate','activated'])) {
// Lire la langue du navigateur // Lire la langue du navigateur
$lan = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); $lan = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
@ -1559,7 +1559,9 @@ class common {
$this->setData(['locale','searchPageId',$this->getData(['config','searchPageId'])]); $this->setData(['locale','searchPageId',$this->getData(['config','searchPageId'])]);
$this->setData(['locale','metaDescription',$this->getData(['config','metaDescription'])]); $this->setData(['locale','metaDescription',$this->getData(['config','metaDescription'])]);
$this->setData(['locale','title',$this->getData(['config','title'])]); $this->setData(['locale','title',$this->getData(['config','title'])]);
$this->setData(['translate','activated',false]);
$this->setData(['translate','showCredits',false]);
$this->setData(['translate','autoDetect',false]);
$this->setData(['core', 'dataVersion', 10400]); $this->setData(['core', 'dataVersion', 10400]);
} }
} }
@ -2981,7 +2983,7 @@ class layout extends common {
echo '<div id="i18nContainer"><ul>'; echo '<div id="i18nContainer"><ul>';
foreach (self::$i18nList as $key => $value) { foreach (self::$i18nList as $key => $value) {
echo '<li>'; echo '<li>';
echo '<img class= "flag" src="' . helper::baseUrl(false) . 'core/vendor/i18n/png/' . $key . '.png" />'; echo '<a href="' . helper::baseUrl() . 'translate/language/' . $key . '"><img class= "flag" src="' . helper::baseUrl(false) . 'core/vendor/i18n/png/' . $key . '.png" /></a>';
echo '</li>'; echo '</li>';
} }
echo '</ul></div>'; echo '</ul></div>';

View File

@ -715,7 +715,7 @@ li .menuSideChild {
#i18nContainer { #i18nContainer {
z-index: 100; z-index: 100;
position: absolute ; position: absolute ;
width: 80px; width: auto;
height: 20px; height: 20px;
margin: 5px; margin: 5px;
top: 5px; top: 5px;

View File

@ -81,8 +81,9 @@ class init extends common {
] ]
], ],
'translate' => [ 'translate' => [
'active' => false, 'activated' => false,
'showCredits' => false 'showCredits' => false,
'autoDetect' => false
], ],
'module' => [], 'module' => [],
'user' => [], 'user' => [],

View File

@ -16,7 +16,8 @@ class translate extends common {
public static $actions = [ public static $actions = [
/*'config' => self::GROUP_MODERATOR,*/ /*'config' => self::GROUP_MODERATOR,*/
'index' => self::GROUP_MODERATOR 'index' => self::GROUP_MODERATOR,
'language' => self::GROUP_VISITOR
]; ];
/** /**
@ -26,8 +27,9 @@ class translate extends common {
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if($this->isPost()) {
$this->setData(['translate', [ $this->setData(['translate', [
'active' => $this->getInput('translateActive', helper::FILTER_BOOLEAN), 'activated' => $this->getInput('translateActivated', helper::FILTER_BOOLEAN),
'showCredits' => $this->getInput('translateActive', helper::FILTER_BOOLEAN) ? $this->getInput('translateCredits', helper::FILTER_BOOLEAN) : false, 'showCredits' => $this->getInput('translateCredits', helper::FILTER_BOOLEAN) ? $this->getInput('translateCredits', helper::FILTER_BOOLEAN) : false,
'autoDetect' => $this->getInput('translateAutoDetect', helper::FILTER_BOOLEAN)
]]); ]]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -43,5 +45,26 @@ class translate extends common {
]); ]);
} }
/*
* Traitement du changement de langues
*/
public function language() {
echo $this->getUrl(2);
die();
// Traitement du changement de langue
if (isset($lan)) {
$this->seti18n($lan);
// Valeurs en sortie sans post
$this->addOutput([
'redirect' => helper::baseUrl(false),
'state' => true
]);
} else {
$this->addOutput([
'redirect' => helper::baseUrl(false)
]);
}
}
} }

View File

@ -15,22 +15,38 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4>Configuration</h4> <h4>Paramètres</h4>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::checkbox('translateActive', true, 'Traduction automatique', [ <?php echo template::checkbox('translateActivated', true, 'Activer le mode multi-langues', [
'checked' => $this->getData(['translate', 'active']), 'checked' => $this->getData(['translate', 'activated'])
'help' => 'Traduction automatique du site hors connexion par le script Google Translate selon la langue du navigateur du visiteur.' ]); ?>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>Traduction automatique</h4>
<div class="row">
<div class="col6">
<?php echo template::checkbox('translateAutoDetect', true, 'Détection automatique de langue', [
'checked' => $this->getData(['translate', 'autoDetect']),
'help' => 'Détecte la langue du navigateur et effectue une traduction grâce à Google Translate.'
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::checkbox('translateCredits', true, 'Afficher les crédits', [ <?php echo template::checkbox('translateCredits', true, 'Afficher les crédits du script Google', [
'checked' => $this->getData(['translate', 'showCredits']), 'checked' => $this->getData(['translate', 'showCredits']),
'help' => 'Option vivement recommandée pour le respect du droit d\'auteur' 'help' => 'Option vivement recommandée pour le respect du droit d\'auteur'
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
<div class="row">
</div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>