From 77ba9e00d2380e7f91d8d90911765086f3367640 Mon Sep 17 00:00:00 2001 From: Deltacms Date: Sun, 27 Aug 2023 10:33:56 +0200 Subject: [PATCH] adieu google --- core/class/template.class.php | 17 --- core/core.php | 100 +----------------- core/include/update.inc.php | 3 + .../translate/lang/en/lex_translate.php | 11 +- .../translate/lang/es/lex_translate.php | 13 +-- .../translate/lang/fr/lex_translate.php | 11 +- core/module/translate/translate.php | 67 +----------- core/module/translate/view/index/index.php | 37 ------- 8 files changed, 15 insertions(+), 244 deletions(-) diff --git a/core/class/template.class.php b/core/class/template.class.php index c57a4ee..caee9da 100644 --- a/core/class/template.class.php +++ b/core/class/template.class.php @@ -354,23 +354,6 @@ class template { * @return string */ public static function flag($langId, $size = 'auto') { - /* - switch ($langId) { - case '': - $lang = 'fr'; - break; - case in_array($langId,['fr', 'de', 'en', 'es', 'it', 'nl', 'pt', 'el', 'da', 'fi', 'ga', 'sv']): - $lang = $langId; - break; - case 'site': - if ( isset($_COOKIE['DELTA_I18N_SITE']) - ) { - $lang = $_COOKIE['DELTA_I18N_SITE']; - } else { - $lang = 'fr'; - } - } - */ $lang = $langId; if( ! file_exists( 'core/vendor/i18n/png/' . $lang . '.png')) $lang = 'blanc'; $text = $lang; diff --git a/core/core.php b/core/core.php index 1f2e0f1..ea5019f 100644 --- a/core/core.php +++ b/core/core.php @@ -304,35 +304,6 @@ class common { if( !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) $_SESSION['humanBot'] = 'human'; } - /** - * Traduction du site par script - * Traduction par auto-détection de la langue du navigateur - * - Exclure la traduction manuelle - * - La langue du navigateur est lisible - * - L'auto-détection est active - */ - - if ( $this->getData(['config', 'i18n', 'enable']) === true - AND $this->getData(['config', 'i18n','scriptGoogle']) === true - AND $this->getData(['config', 'i18n','autoDetect']) === true - AND $this->getInput('DELTA_I18N_SITE') !== '' - AND !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) - { - /** - * Le cookie est prioritaire sur le navigateur - * la traduction est celle de la langue du drapeau - **/ - if ( $this->getInput('DELTA_I18N_SCRIPT') !== substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2 ) ) { - setrawcookie('googtrans', '/'.$this->getData(['config', 'i18n', 'langBase']).'/'.substr( $_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2 ), time() + 3600, helper::baseUrl(false, false)); - } else { - // Langue du drapeau si elle est définie - if ( $this->getInput('DELTA_I18N_SCRIPT') !== '' ) { - // Paramètre du script - setrawcookie("googtrans", '/'.$this->getData(['config', 'i18n', 'langBase']). '/'. $this->getInput('DELTA_I18N_SCRIPT') , time() + 3600, helper::baseUrl(false,false)); - } - } - } - // Construit la liste des pages parents/enfants if($this->hierarchy['all'] === []) { $pages = helper::arrayCollumn($this->getData(['page']), 'position', 'SORT_ASC'); @@ -982,7 +953,7 @@ class common { file_put_contents('robots.txt','User-agent: *' . PHP_EOL . 'Disallow: /'); } - // Submit your sitemaps to Google, Yahoo, Bing and Ask.com + // Submit your sitemaps if (empty ($this->getData(['config','proxyType']) . $this->getData(['config','proxyUrl']) . ':' . $this->getData(['config','proxyPort'])) ) { $sitemap->submitSitemap(); } @@ -1370,23 +1341,6 @@ class common { } echo $this->output['content']; - - /** - * Affiche les crédits, conditions requis : - * La traduction automatique est active et La fonction est activée. - */ - if ( $this->getData(['config', 'i18n', 'enable']) === true - AND $this->getData(['config', 'i18n','scriptGoogle']) === true - AND $this->getData(['config', 'i18n','showCredits']) === true - AND - // et la traduction n'est pas manuelle - ( $this->getInput('DELTA_I18N_SCRIPT') - AND $this->getData(['config', 'i18n', $this->getInput('DELTA_I18N_SCRIPT')]) === 'script' - ) - ) - { - echo ''; - } } /** @@ -2441,26 +2395,8 @@ class common { public function showi18n() { foreach (self::$i18nList as $key => $value) { - if ($this->getData(['config', 'i18n', $key]) === 'site' - OR ( - // Le script de traduction est actif et la langue est traduite par script - $this->getData(['config', 'i18n','scriptGoogle']) === true - AND $this->getData(['config', 'i18n', $key]) === 'script' - // Le drapeau n'est pas actif pour les non admin en mode connecté. - AND - ( $this->getUser('password') !== $this->getInput('DELTA_USER_PASSWORD') - OR $this->getUser('group') === self::GROUP_ADMIN - OR $this->getUser('group') === self::GROUP_MEMBER) - ) - ) { - if ( - (isset($_COOKIE['DELTA_I18N_SITE'] ) - AND $_COOKIE['DELTA_I18N_SITE'] === $key - ) - OR - ( isset($_COOKIE['DELTA_I18N_SCRIPT']) - AND $_COOKIE['DELTA_I18N_SCRIPT'] === $key - ) ) { + if ($this->getData(['config', 'i18n', $key]) === 'site') { + if ( isset($_COOKIE['DELTA_I18N_SITE'] ) AND $_COOKIE['DELTA_I18N_SITE'] === $key ) { $select = ' class="i18nFlagSelected" '; } else { $select = ' class="i18nFlag flag" '; @@ -3286,36 +3222,6 @@ class core extends common { } } - // Chargement de la bibliothèque googtrans - - // Le script de traduction est sélectionné - if ($this->getData(['config', 'i18n', 'enable']) === true) { - if ( $this->getData(['config', 'i18n','scriptGoogle']) === true - // et la traduction de la langue courante est automatique - AND ( $this->getInput('DELTA_I18N_SCRIPT') !== '' - // Ou traduction automatique - OR $this->getData(['config', 'i18n','autoDetect']) === true - ) - // Cas des pages d'administration - // Pas connecté - AND $this->getUser('password') !== $this->getInput('DELTA_USER_PASSWORD') - AND $this->getUrl(1) !== 'login' - // Ou connecté avec option active - OR ($this->getUser('password') === $this->getInput('DELTA_USER_PASSWORD') - //AND $this->getData(['config', 'i18n','admin']) === true - AND $this->getUser('group') === self::GROUP_MEMBER - ) - - ) { - - // Chargement de la librairie - $this->addOutput([ - 'vendor' => array_merge($this->output['vendor'], ['i18n']) - ]); - - } - } - // Erreurs // Lexique include('./core/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_core.php'); diff --git a/core/include/update.inc.php b/core/include/update.inc.php index 3aa16a3..f35694d 100644 --- a/core/include/update.inc.php +++ b/core/include/update.inc.php @@ -145,6 +145,9 @@ if ($this->getData(['core', 'dataVersion']) < 4501) { $this->deleteData(['theme', 'menu', 'burgerLogo']); $this->deleteData(['theme', 'menu', 'heightLogo']); $this->deleteData(['theme', 'menu', 'widthLogo']); + $this->setData(['config', 'i18n', 'scriptGoogle', false]); + $this->setData(['config', 'i18n', 'showCredits', false]); + $this->setData(['config', 'i18n', 'autoDetect', false]); $this->setData(['core', 'dataVersion', 4501]); } ?> diff --git a/core/module/translate/lang/en/lex_translate.php b/core/module/translate/lang/en/lex_translate.php index bbf3ae0..56b6282 100644 --- a/core/module/translate/lang/en/lex_translate.php +++ b/core/module/translate/lang/en/lex_translate.php @@ -13,17 +13,9 @@ $text['core_translate_view']['index'][3] = 'Submit'; $text['core_translate_view']['index'][4] = 'Language of administration'; $text['core_translate_view']['index'][5] = 'Original language of the site'; $text['core_translate_view']['index'][6] = 'Languages of origin and administration'; -$text['core_translate_view']['index'][7] = 'Automatic website translation'; -$text['core_translate_view']['index'][8] = 'Activate the automatic translation script'; -$text['core_translate_view']['index'][9] = 'The Google Translate script automatically translates the site. Save the page to take advantage of translation options.'; -$text['core_translate_view']['index'][10] = 'Automatic detection of the browser language'; -$text['core_translate_view']['index'][11] = 'Detects the language of the browser, in this mode it is not necessary to display the flags.'; -$text['core_translate_view']['index'][12] = 'Show Google script credits'; -$text['core_translate_view']['index'][13] = 'Recommended option for copyright compliance'; -$text['core_translate_view']['index'][14] = 'Site translation mode and flag display'; +$text['core_translate_view']['index'][14] = 'Site translation and flag display'; $text['core_translate_view']['index'][15] = 'ISO code for Other language option'; $text['core_translate_view']['index'][16] = 'Enter the ISO language code consisting of 2 lower case letters'; -$text['core_translate_view']['index'][17] = 'The original language of the site is not supported by the machine translation script.'; $text['core_translate']['copy'][0] = 'Something went wrong, check the permissions.'; $text['core_translate']['copy'][1] = 'The languages must be different.'; $text['core_translate']['copy'][2] = 'Copy utility'; @@ -32,7 +24,6 @@ $text['core_translate']['copy'][4] = ' copied to '; $text['core_translate']['copy'][5] = 'Language of origin'; $text['core_translate']['index'][0] = 'Registered changes'; $text['core_translate']['index'][1] = 'Masked flag'; -$text['core_translate']['index'][2] = 'Google translation'; $text['core_translate']['index'][3] = 'Written translation'; $text['core_translate']['index'][4] = 'Delete translation'; $text['core_translate']['index'][5] = 'Flag displayed'; diff --git a/core/module/translate/lang/es/lex_translate.php b/core/module/translate/lang/es/lex_translate.php index f892679..1608001 100644 --- a/core/module/translate/lang/es/lex_translate.php +++ b/core/module/translate/lang/es/lex_translate.php @@ -13,17 +13,9 @@ $text['core_translate_view']['index'][3] = 'Guardar'; $text['core_translate_view']['index'][4] = 'Idioma del administrador'; $text['core_translate_view']['index'][5] = 'Idioma de escritura del sitio original'; $text['core_translate_view']['index'][6] = 'Idiomas originales y de administración'; -$text['core_translate_view']['index'][7] = 'Traducción automática del sitio'; -$text['core_translate_view']['index'][8] = 'Habilitar script de traducción automática'; -$text['core_translate_view']['index'][9] = 'El script de Google Translate garantiza la traducción automática del sitio. Guarde la página para aprovechar las opciones de traducción.'; -$text['core_translate_view']['index'][10] = 'Detectar automáticamente el idioma del navegador'; -$text['core_translate_view']['index'][11] = 'Detectar el idioma del navegador, en este modo no es necesario mostrar banderas.'; -$text['core_translate_view']['index'][12] = 'Ver los créditos del script de Google'; -$text['core_translate_view']['index'][13] = 'Opción recomendada para el cumplimiento de los derechos de autor'; -$text['core_translate_view']['index'][14] = 'Modo de traducción del sitio y visualización de banderas'; +$text['core_translate_view']['index'][14] = 'Traducción del sitio y visualización de banderas'; $text['core_translate_view']['index'][15] = 'Código ISO de otra opción de idioma'; $text['core_translate_view']['index'][16] = 'Ingrese el código ISO del idioma que consta de 2 letras minúsculas'; -$text['core_translate_view']['index'][17] = 'El script de traducción automática no admite el idioma original del sitio.'; $text['core_translate']['copy'][0] = 'Algo salió mal, verifique los permisos.'; $text['core_translate']['copy'][1] = 'Los idiomas deben ser diferentes.'; $text['core_translate']['copy'][2] = 'Utilidad de copia'; @@ -32,11 +24,10 @@ $text['core_translate']['copy'][4] = ' copiado en '; $text['core_translate']['copy'][5] = 'Idioma original'; $text['core_translate']['index'][0] = 'Cambios guardados'; $text['core_translate']['index'][1] = 'Bandera oculta'; -$text['core_translate']['index'][2] = 'Traducción automática'; $text['core_translate']['index'][3] = 'Traducción escrita'; $text['core_translate']['index'][4] = 'Eliminar traducción'; $text['core_translate']['index'][5] = 'Bandera mostrada'; $text['core_translate']['index'][6] = 'Administración de idiomas'; // Select -$i18nList = self::$i18nList; +$i18nList = self::$i18nList_es; ?> \ No newline at end of file diff --git a/core/module/translate/lang/fr/lex_translate.php b/core/module/translate/lang/fr/lex_translate.php index b664dc0..3d5f8fb 100644 --- a/core/module/translate/lang/fr/lex_translate.php +++ b/core/module/translate/lang/fr/lex_translate.php @@ -13,17 +13,9 @@ $text['core_translate_view']['index'][3] = 'Enregistrer'; $text['core_translate_view']['index'][4] = 'Langue d\'administration'; $text['core_translate_view']['index'][5] = 'Langue originale de rédaction du site'; $text['core_translate_view']['index'][6] = 'Langages d\'origine et d\'administration'; -$text['core_translate_view']['index'][7] = 'Traduction automatique du site'; -$text['core_translate_view']['index'][8] = 'Active le script de traduction automatique'; -$text['core_translate_view']['index'][9] = 'Le script Google Translate assure la traduction automatique du site. Enregistrez la page pour pouvoir bénéficier des options de traduction.'; -$text['core_translate_view']['index'][10] = 'Détection automatique de la langue du navigateur'; -$text['core_translate_view']['index'][11] = 'Détecte la langue du navigateur, dans ce mode il n\'est pas nécessaire d\'afficher les drapeaux.'; -$text['core_translate_view']['index'][12] = 'Afficher les crédits du script Google'; -$text['core_translate_view']['index'][13] = 'Option recommandée pour le respect du droit d\'auteur'; -$text['core_translate_view']['index'][14] = 'Mode de traduction du site et affichage des drapeaux'; +$text['core_translate_view']['index'][14] = 'Traduction du site et affichage des drapeaux'; $text['core_translate_view']['index'][15] = 'Code ISO de l\'option Autre langue'; $text['core_translate_view']['index'][16] = 'Saisir le code ISO de la langue constitué de 2 lettres minuscules'; -$text['core_translate_view']['index'][17] = 'La langue originale de rédaction du site n\'est pas prise en charge par le script de traduction automatique.'; $text['core_translate']['copy'][0] = 'Quelque chose n\'a pas fonctionné, vérifiez les permissions.'; $text['core_translate']['copy'][1] = 'Les langues doivent être différentes.'; $text['core_translate']['copy'][2] = 'Utilitaire de copie'; @@ -32,7 +24,6 @@ $text['core_translate']['copy'][4] = ' copiées vers '; $text['core_translate']['copy'][5] = 'Langue d\'origine'; $text['core_translate']['index'][0] = 'Modifications enregistrées'; $text['core_translate']['index'][1] = 'Drapeau masqué'; -$text['core_translate']['index'][2] = 'Traduction automatique'; $text['core_translate']['index'][3] = 'Traduction rédigée'; $text['core_translate']['index'][4] = 'Supprimer la traduction'; $text['core_translate']['index'][5] = 'Drapeau affiché'; diff --git a/core/module/translate/translate.php b/core/module/translate/translate.php index c25c8e9..4dbde5d 100644 --- a/core/module/translate/translate.php +++ b/core/module/translate/translate.php @@ -105,15 +105,6 @@ class translate extends common { // Soumission du formulaire if($this->isPost()) { - // Si la langue originale du site choisie est seulement en traduction rédigée invalider la traduction automatique - $script = $this->getInput('translateScriptGoogle', helper::FILTER_BOOLEAN); - $langBase = $this->getInput('translateLangBase'); - if( array_key_exists( $langBase, self::$i18nListSiteOnly)) $script = false; - // Désactivation du script Google - if ($script === false) { - setrawcookie('googtrans', '/base/base', time() + 3600, helper::baseUrl(false,false)); - $_SESSION['googtrans'] = '/base/base'; - } // Edition des langues foreach (self::$i18nList as $keyi18n => $value) { if ($keyi18n === 'base') continue; @@ -125,11 +116,11 @@ class translate extends common { $this->removeDir( self::DATA_DIR . $keyi18n); // Au cas ou la langue est sélectionnée helper::deleteCookie('DELTA_I18N_SITE'); - helper::deleteCookie('DELTA_I18N_SCRIPT'); } } // 'langBase' mémorise le code ISO de la langue sélectionnée ou de la valeur saisie si la langue sélectionnée est Autre langue $requiredOtherLang = false; + $langBase = $this->getInput('translateLangBase'); if( $langBase === 'none'){ $langBase = $this->getInput('translateOtherBase'); $requiredOtherLang = true; @@ -138,9 +129,6 @@ class translate extends common { // Enregistrement des données $this->setData(['config','i18n', [ 'enable' => $this->getData(['config', 'i18n', 'enable']), - 'scriptGoogle' => $script, - 'showCredits' => $this->getInput('translateScriptGoogle', helper::FILTER_BOOLEAN) ? $this->getInput('translateCredits', helper::FILTER_BOOLEAN) : false, - 'autoDetect' => $this->getInput('translateScriptGoogle', helper::FILTER_BOOLEAN) ? $this->getInput('translateAutoDetect', helper::FILTER_BOOLEAN) : false, 'langAdmin' => $this->getInput('translateLangAdmin'), 'langBase' => $langBase, 'otherLangBase' => $this->getInput('translateOtherBase', helper::FILTER_STRING_SHORT,$requiredOtherLang), @@ -162,12 +150,7 @@ class translate extends common { 'eu' => $this->getInput('translateEU') ]]); - - // Modification de core/vendor/i18n/translation.js - - $translation = "function scriptGoogleElementInit() { new google.translate.TranslateElement({ pageLanguage: '".$this->getData(['config', 'i18n', 'langBase'])."'}, 'google_translate_element');}"; - file_put_contents( './core/vendor/i18n/translation.js', $translation); - + // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl(), @@ -183,27 +166,12 @@ class translate extends common { 'site' => $text['core_translate']['index'][3], 'delete' => $text['core_translate']['index'][4] ]; - if( ! array_key_exists( $key, self::$i18nListSiteOnly) && $this->getData(['config','i18n','scriptGoogle'])){ - self::$translateOptions [$key] = [ - 'none' => $text['core_translate']['index'][1], - 'script' => $text['core_translate']['index'][2], - 'site' => $text['core_translate']['index'][3], - 'delete' => $text['core_translate']['index'][4] - ]; - } self::$siteTranslate = $key !== $this->getData(['config', 'i18n', 'langBase']) ? false : true; } else { self::$translateOptions [$key] = [ 'none' => $text['core_translate']['index'][1], 'site' => $text['core_translate']['index'][3] - ]; - if( ! array_key_exists( $key, self::$i18nListSiteOnly) && $this->getData(['config','i18n','scriptGoogle'])){ - self::$translateOptions [$key] = [ - 'none' => $text['core_translate']['index'][1], - 'script' => $text['core_translate']['index'][2], - 'site' => $text['core_translate']['index'][3] - ]; - } + ]; } // Limitation du choix pour la langue d'origine if ( $key === $this->getData(['config', 'i18n', 'langBase'])){ @@ -230,40 +198,15 @@ class translate extends common { // Activation du drapeau sauf si c'est celui de la langue de base (drapeau utilisé pour revenir à la langue de base) if ( $this->getUrl(2) !== $this->getData(['config', 'i18n', 'langBase']) && $this->getInput('DELTA_I18N_' . strtoupper($this->getUrl(3))) !== $this->getUrl(2) ) { // Nettoyer et stocker le choix de l'utilisateur - helper::deleteCookie('DELTA_I18N_SITE'); - helper::deleteCookie('DELTA_I18N_SCRIPT'); - // Supprimer le cookie de session déposé par google translate, problème avec chrome dans le cas d'un site placé dans un sous domaine - $host = $_SERVER['HTTP_HOST']; - unset($_COOKIE['googtrans']); - setcookie('googtrans', '', time() - 4200, '/',$host); - $tab = explode('.', $host); - if( count($tab) > 2){ - $master = str_replace( $tab[0], '', $host); - setcookie('googtrans', '', time() - 4200, '/',$master); - } + helper::deleteCookie('DELTA_I18N_SITE'); // Sélectionner setcookie('DELTA_I18N_' . strtoupper($this->getUrl(3)) , $this->getUrl(2), time() + 3600, helper::baseUrl(false, false) , '', helper::isHttps(), true); - setrawcookie('googtrans', '/' . $this->getData(['config', 'i18n', 'langBase']) .'/' . $this->getUrl(2), 0, helper::baseUrl(false, false)); - $_SESSION['googtrans'] = '/'.$this->getData(['config', 'i18n', 'langBase']).'/' . $this->getUrl(2); - // Mémorisation de la langue en Frontend et du type de traduction actif (site => rédigée, script => traduction automatique) + // Mémorisation de la langue en Frontend et du type de traduction actif (site => rédigée, none => pas de traduction) $_SESSION['langFrontEnd'] = $this->getUrl(2); $_SESSION['translationType'] = $this->getUrl(3); // Désactivation du drapeau, langue base par défaut } else { setcookie('DELTA_I18N_SITE' , 'base', time() + 3600, helper::baseUrl(false, false) , '', helper::isHttps(), true); - helper::deleteCookie('DELTA_I18N_SCRIPT'); - // Supprimer le cookie de session déposé par google translate, problème avec chrome dans le cas d'un site placé dans un sous domaine - $host = $_SERVER['HTTP_HOST']; - unset($_COOKIE['googtrans']); - setcookie('googtrans', '', time() - 4200, '/',$host); - $tab = explode('.', $host); - if( count($tab) > 2){ - $master = str_replace( $tab[0], '', $host); - setcookie('googtrans', '', time() - 4200, '/',$master); - } - // Désactivation du script Google - setrawcookie('googtrans', '/' . $this->getData(['config', 'i18n', 'langBase']) .'/' . $this->getData(['config', 'i18n', 'langBase']) , 0, helper::baseUrl(false, false)); - $_SESSION['googtrans'] = '/' . $this->getData(['config', 'i18n', 'langBase']) .'/' . $this->getData(['config', 'i18n', 'langBase']); // Mise à jour des données de langue et de traduction en frontend $_SESSION['langFrontEnd'] = $this->getData(['config', 'i18n', 'langBase']); $_SESSION['translationType'] = 'none'; diff --git a/core/module/translate/view/index/index.php b/core/module/translate/view/index/index.php index 97a8d2b..649f076 100644 --- a/core/module/translate/view/index/index.php +++ b/core/module/translate/view/index/index.php @@ -75,43 +75,6 @@ include('./core/module/translate/lang/'. $this->getData(['config', 'i18n', 'lang -
-
-
-
- getData(['config', 'i18n' , 'langBase']), self::$i18nListSiteOnly)) { ?> -
-
- $this->getData(['config','i18n', 'scriptGoogle']), - 'help' => $text['core_translate_view']['index'][9] - ]); ?> -
-
- $this->getData(['config','i18n', 'autoDetect']), - 'class' => 'translateGoogleScriptOption', - 'help' => $text['core_translate_view']['index'][11] - ]); ?> -
-
-
-
- $this->getData(['config','i18n', 'showCredits']), - 'class' => 'translateGoogleScriptOption', - 'help' => $text['core_translate_view']['index'][13] - ]); ?> -
-
- -
- -
- -
-
-