move var $script in index

This commit is contained in:
Fred Tempez 2021-06-18 19:50:41 +02:00
parent 1b1975b252
commit 117530b8f1
1 changed files with 17 additions and 8 deletions

View File

@ -96,11 +96,11 @@ class translate extends common {
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if($this->isPost()) {
// Désactivation du script Google // Désactivation du script Google
if ($this->getInput('translateScriptGoogle', helper::FILTER_BOOLEAN) === false) { $script = $this->getInput('translateScriptGoogle', helper::FILTER_BOOLEAN);
if ($script === false) {
setrawcookie('googtrans', '/fr/fr', time() + 3600, helper::baseUrl(false,false)); setrawcookie('googtrans', '/fr/fr', time() + 3600, helper::baseUrl(false,false));
$_SESSION['googtrans'] = '/fr/fr'; $_SESSION['googtrans'] = '/fr/fr';
} }
$script = $this->getInput('translateScriptGoogle', helper::FILTER_BOOLEAN);
// Edition des langues // Edition des langues
foreach (self::$i18nList as $keyi18n => $value) { foreach (self::$i18nList as $keyi18n => $value) {
// Effacement d'une langue installée // Effacement d'une langue installée
@ -111,15 +111,24 @@ class translate extends common {
} }
// Installation d'une langue // Installation d'une langue
if ( $this->getInput('translate' . strtoupper($keyi18n)) === 'site' if ( $this->getInput('translate' . strtoupper($keyi18n)) === 'site'
// Pas d'initialisation si la langue existe déjà
AND is_dir(self::DATA_DIR . $keyi18n) === false ) AND is_dir(self::DATA_DIR . $keyi18n) === false )
{ {
// Pas d'initialisation si la langue existe déjà
if (!file_exists( self::DATA_DIR . $keyi18n . '/page.json'))
if (!file_exists( self::DATA_DIR . $keyi18n . '/page.json')) {
echo $keyi18n;
$this->initData('page', $keyi18n, false); $this->initData('page', $keyi18n, false);
if (!file_exists( self::DATA_DIR . $keyi18n . '/module.json')) }
if (!file_exists( self::DATA_DIR . $keyi18n . '/module.json')) {
$this->initData('module', $keyi18n, false); $this->initData('module', $keyi18n, false);
if (!file_exists( self::DATA_DIR . $keyi18n . '/locale.json')) }
if (!file_exists( self::DATA_DIR . $keyi18n . '/locale.json')) {
$this->initData('locale', $keyi18n, false); $this->initData('locale', $keyi18n, false);
}
} }
// Active le script si une langue est en trad auto // Active le script si une langue est en trad auto
if ($script === false if ($script === false
@ -182,13 +191,13 @@ class translate extends common {
*/ */
public function language() { public function language() {
// Activation du drapeau // Activation du drapeau
if ( $this->getInput('ZWII_I18N_' . strtoupper($this->getUrl(3))) !== $this->getUrl(2) ) { if ( $this->getInput('ZWII_I18N_' . strtoupper($this->getUrl(3))) !== $this->getUrl(2) ) {
// Nettoyer et stocker le choix de l'utilisateur // Nettoyer et stocker le choix de l'utilisateur
helper::deleteCookie('ZWII_I18N_SITE'); helper::deleteCookie('ZWII_I18N_SITE');
helper::deleteCookie('ZWII_I18N_SCRIPT'); helper::deleteCookie('ZWII_I18N_SCRIPT');
// Sélectionner // Sélectionner
setcookie('ZWII_I18N_' . strtoupper($this->getUrl(3)) , $this->getUrl(2), time() + 3600, helper::baseUrl(false, false) , '', helper::isHttps(), true); setcookie('ZWII_I18N_' . strtoupper($this->getUrl(3)) , $this->getUrl(2), time() + 3600, helper::baseUrl(false, false) , '', helper::isHttps(), true);
// Désactivation du drapeau, langue FR par défaut // Désactivation du drapeau, langue FR par défaut
} else { } else {
setcookie('ZWII_I18N_SITE' , 'fr', time() + 3600, helper::baseUrl(false, false) , '', helper::isHttps(), true); setcookie('ZWII_I18N_SITE' , 'fr', time() + 3600, helper::baseUrl(false, false) , '', helper::isHttps(), true);