From e4916fa9cc34e8df7a4b2ffac3174717c67acfe3 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 29 Aug 2022 22:04:57 +0200 Subject: [PATCH] =?UTF-8?q?dev006=20r=C3=A9organisation=20du=20contenu=20m?= =?UTF-8?q?ultilangues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core.php | 4 +- core/module/config/config.php | 61 ------- core/module/config/view/index/index.php | 9 - core/module/config/view/locale/locale.php | 187 -------------------- core/module/translate/translate.php | 76 +++++++- core/module/translate/view/index/index.php | 192 ++++++++++++++++++++- 6 files changed, 267 insertions(+), 262 deletions(-) delete mode 100644 core/module/config/view/locale/locale.php diff --git a/core/core.php b/core/core.php index 685e5fd0..84b5fe43 100644 --- a/core/core.php +++ b/core/core.php @@ -47,7 +47,7 @@ class common { // Numéro de version const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/'; - const ZWII_VERSION = '11.6.00-dev005'; + const ZWII_VERSION = '11.6.00-dev006'; const ZWII_UPDATE_CHANNEL = "test"; public static $actions = []; @@ -2067,7 +2067,7 @@ class common { 'href' => helper::baseUrl() . 'plugin' ]) . ''; $rightItems .= '
  • ' . template::ico('flag', [ - 'help' => 'Traduction', + 'help' => 'Contenu multilangues', 'href' => helper::baseUrl() . 'translate' ]) . '
  • '; $rightItems .= '
  • ' . template::ico('cog-alt', [ diff --git a/core/module/config/config.php b/core/module/config/config.php index bcc71ede..ee6c36fc 100644 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -193,8 +193,6 @@ class config extends common { public static $i18nSite = 'fr'; // Variable pour construire la liste des pages du site - public static $pagesList = []; - public static $orphansList = []; public static $onlineVersion = ''; public static $updateButtonText = 'Réinstaller'; @@ -444,48 +442,6 @@ class config extends common { $this->setData(['core','lastAutoUpdate',0]); } - // Eviter déconnexion automatique après son activation - if ( $this->getData(['config','connect', 'autoDisconnect']) === false - AND $this->getInput('configAutoDisconnect',helper::FILTER_BOOLEAN) === true ) { - $this->setData(['user',$this->getuser('id'),'accessCsrf',$_SESSION['csrf']]); - } - // Répercuter la suppression de la page dans la configuration du footer - if ( $this->getData(['theme','footer','displaySearch']) === true - AND $this->getInput('configSearchPageId') === 'none' - ){ - $this->setData(['theme', 'footer', 'displaySearch', false]); - } - if ( $this->getData(['theme','footer','displayLegal']) === true - AND $this->getInput('configLegalPageId') === 'none' - ){ - $this->setData(['theme', 'footer', 'displayLegal', false]); - } - - // Sauvegarder les locales - $this->setData([ - 'locale', - [ - 'homePageId' => $this->getInput('localeHomePageId', helper::FILTER_ID, true), - 'page404' => $this->getInput('localePage404'), - 'page403' => $this->getInput('localePage403'), - 'page302' => $this->getInput('localePage302'), - 'legalPageId' => $this->getInput('localeLegalPageId'), - 'searchPageId' => $this->getInput('localeSearchPageId'), - 'searchPageLabel' => empty($this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT)) ? 'Rechercher' : $this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT), - 'legalPageLabel' => empty($this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT)) ? 'Mentions légales' : $this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT), - 'sitemapPageLabel' => empty($this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT)) ? 'Plan du site' : $this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT), - 'metaDescription' => $this->getInput('localeMetaDescription', helper::FILTER_STRING_LONG, true), - 'title' => $this->getInput('localeTitle', helper::FILTER_STRING_SHORT, true), - 'cookies' => [ - // Les champs sont obligatoires si l'option consentement des cookies est active - 'mainLabel' => $this->getInput('localeCookiesZwiiText', helper::FILTER_STRING_LONG, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)), - 'titleLabel' => $this->getInput('localeCookiesTitleText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)), - 'linkLegalLabel' => $this->getInput('localeCookiesLinkMlText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)), - 'cookiesFooterText' => $this->getInput('localeCookiesFooterText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)), - 'buttonValidLabel' =>$this->getInput('localeCookiesButtonText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)) - ] - ] - ]); // Sauvegarder la configuration $this->setData([ @@ -618,23 +574,6 @@ class config extends common { 'state' => true ]); } - // Générer la list des pages disponibles - self::$pagesList = $this->getData(['page']); - foreach(self::$pagesList as $page => $pageId) { - if ($this->getData(['page',$page,'block']) === 'bar' || - $this->getData(['page',$page,'disable']) === true) { - unset(self::$pagesList[$page]); - } - } - - self::$orphansList = $this->getData(['page']); - foreach(self::$orphansList as $page => $pageId) { - if ($this->getData(['page',$page,'block']) === 'bar' || - $this->getData(['page',$page,'disable']) === true || - $this->getdata(['page',$page, 'position']) !== 0) { - unset(self::$orphansList[$page]); - } - } // Variable de version self::$onlineVersion = helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/version'); diff --git a/core/module/config/view/index/index.php b/core/module/config/view/index/index.php index 7c858ee7..2c0584c2 100644 --- a/core/module/config/view/index/index.php +++ b/core/module/config/view/index/index.php @@ -26,12 +26,6 @@ 'value' => 'Configuration', 'class' => 'buttonTab' ]); ?> - - 'Localisation', - 'class' => 'buttonTab' - ]); ?> - 'Référencement', 'class' => 'buttonTab' @@ -48,10 +42,7 @@ ]); ?> - - - diff --git a/core/module/config/view/locale/locale.php b/core/module/config/view/locale/locale.php deleted file mode 100644 index 36fca048..00000000 --- a/core/module/config/view/locale/locale.php +++ /dev/null @@ -1,187 +0,0 @@ -
    -
    -
    -
    -

    Identité du site en - - - 'left']);?> - - -

    -
    -
    - 'Titre du site' , - 'value' => $this->getData(['locale', 'title']), - 'help' => 'Il apparaît dans la barre de titre et les partages sur les réseaux sociaux.' - ]); ?> -
    -
    -
    -
    - 'Description du site', - 'value' => $this->getData(['locale', 'metaDescription']), - 'help' => 'La description d\'une page participe à son référencement, chaque page doit disposer d\'une description différente.' - ]); ?> -
    -
    -
    -
    -
    -
    -
    -
    -

    Assignation des pages spéciales - - - 'left']);?> - - -

    -
    -
    - 'Accueil du site', - 'selected' =>$this->getData(['locale', 'homePageId']), - 'help' => 'La première page que vos visiteurs verront.' - ]); ?> -
    -
    - 'Page par défaut'],helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [ - 'label' => 'Accès interdit, erreur 403', - 'selected' =>$this->getData(['locale', 'page403']), - 'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.' - ]); ?> -
    -
    - 'Page par défaut'],helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [ - 'label' => 'Page inexistante, erreur 404', - 'selected' =>$this->getData(['locale', 'page404']), - 'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.' - ]); ?> -
    -
    -
    -
    - 'Aucune'] , helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ - 'label' => 'Mentions légales', - 'selected' => $this->getData(['locale', 'legalPageId']), - 'help' => 'Les mentions légales sont obligatoires en France. Une option du pied de page ajoute un lien discret vers cette page.' - ]); ?> -
    -
    - 'Aucune'] , helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ - 'label' => 'Recherche dans le site', - 'selected' => $this->getData(['locale', 'searchPageId']), - 'help' => 'Sélectionnez une page contenant le module \'Recherche\'. Une option du pied de page ajoute un lien discret vers cette page.' - ]); ?> -
    -
    - 'Page par défaut'],helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [ - 'label' => 'Site en maintenance', - 'selected' =>$this->getData(['locale', 'page302']), - 'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.' - ]); ?> -
    -
    -
    -
    -
    -
    -
    -
    -

    Etiquettes des pages spéciales - - - 'left']);?> - - -

    -
    -
    - 'Mentions légales', - 'placeholder' => 'Mentions légales', - 'value' => $this->getData(['locale', 'legalPageLabel']) - ]); ?> -
    -
    - 'Rechercher', - 'placeholder' => 'Rechercher', - 'value' => $this->getData(['locale', 'searchPageLabel']) - ]); ?> -
    -
    -
    -
    - 'Plan du site', - 'placeholder' => 'Plan du site', - 'value' => $this->getData(['locale', 'sitemapPageLabel']), - ]); ?> -
    -
    - 'Cookies', - 'value' => $this->getData(['locale', 'cookies', 'cookiesFooterText']), - 'placeHolder' => 'Cookies' - ]); ?> -
    -
    -
    -
    -
    -
    -
    -
    -

    Message d'acceptation des Cookies - - - 'left']);?> - - -

    -
    -
    - 'Saisissez le titre de la fenêtre de gestion des cookies.', - 'label' => 'Titre de la fenêtre', - 'value' => $this->getData(['locale', 'cookies', 'titleLabel']), - 'placeHolder' => 'Gérer les cookies' - ]); ?> -
    -
    - 'Bouton de validation', - 'value' => $this->getData(['locale', 'cookies', 'buttonValidLabel']), - 'placeHolder' => 'J\'ai compris' - ]); ?> -
    -
    -
    -
    - 'Saisissez le message pour les cookies déposés par ZwiiCMS, nécessaires au fonctionnement et qui ne nécessitent pas de consentement.', - 'label' => 'Cookies Zwii', - 'value' => $this->getData(['locale', 'cookies', 'mainLabel']), - 'placeHolder' => 'Ce site utilise des cookies nécessaires à son fonctionnement, ils permettent de fluidifier son fonctionnement par exemple en mémorisant les données de connexion, la langue que vous avez choisie ou la validation de ce message.' - ]); ?> -
    - -
    - 'Saisissez le texte du lien vers les mentions légales,la page doit être définie dans la configuration du site.', - 'label' => 'Lien page des mentions légales.', - 'value' => $this->getData(['locale', 'cookies', 'linkLegalLabel']), - 'placeHolder' => 'Consulter les mentions légales' - ]); ?> -
    -
    -
    -
    -
    -
    \ No newline at end of file diff --git a/core/module/translate/translate.php b/core/module/translate/translate.php index 3b86c0b4..b9ef39cb 100644 --- a/core/module/translate/translate.php +++ b/core/module/translate/translate.php @@ -23,7 +23,9 @@ class translate extends common { ]; public static $translateOptions = []; - + // Page pour la configuration dans la langue + public static $pagesList = []; + public static $orphansList = []; // Liste des langues installées public static $languagesInstalled = []; // Liste des langues cibles @@ -128,6 +130,59 @@ class translate extends common { 'pt' => $this->getInput('translatePT') ]]); + + // Coonfiguration dans des langues spécifiques + // Eviter déconnexion automatique après son activation + if ( $this->getData(['config','connect', 'autoDisconnect']) === false + AND $this->getInput('configAutoDisconnect',helper::FILTER_BOOLEAN) === true ) { + $this->setData(['user',$this->getuser('id'),'accessCsrf',$_SESSION['csrf']]); + } + // Répercuter la suppression de la page dans la configuration du footer + if ( $this->getData(['theme','footer','displaySearch']) === true + AND $this->getInput('configSearchPageId') === 'none' + ){ + $this->setData(['theme', 'footer', 'displaySearch', false]); + } + if ( $this->getData(['theme','footer','displayLegal']) === true + AND $this->getInput('configLegalPageId') === 'none' + ){ + $this->setData(['theme', 'footer', 'displayLegal', false]); + } + + // Sauvegarder les locales + $this->setData([ + 'locale', + [ + 'homePageId' => $this->getInput('localeHomePageId', helper::FILTER_ID, true), + 'page404' => $this->getInput('localePage404'), + 'page403' => $this->getInput('localePage403'), + 'page302' => $this->getInput('localePage302'), + 'legalPageId' => $this->getInput('localeLegalPageId'), + 'searchPageId' => $this->getInput('localeSearchPageId'), + 'searchPageLabel' => empty($this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT)) ? 'Rechercher' : $this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT), + 'legalPageLabel' => empty($this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT)) ? 'Mentions légales' : $this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT), + 'sitemapPageLabel' => empty($this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT)) ? 'Plan du site' : $this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT), + 'metaDescription' => $this->getInput('localeMetaDescription', helper::FILTER_STRING_LONG, true), + 'title' => $this->getInput('localeTitle', helper::FILTER_STRING_SHORT, true), + 'cookies' => [ + // Les champs sont obligatoires si l'option consentement des cookies est active + 'mainLabel' => $this->getInput('localeCookiesZwiiText', helper::FILTER_STRING_LONG, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)), + 'titleLabel' => $this->getInput('localeCookiesTitleText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)), + 'linkLegalLabel' => $this->getInput('localeCookiesLinkMlText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)), + 'cookiesFooterText' => $this->getInput('localeCookiesFooterText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)), + 'buttonValidLabel' =>$this->getInput('localeCookiesButtonText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)) + ] + ] + ]); + // Sauvegarder les langues de contenu + $this->setData(['config', 'i18n', 'fr', $this->getInput('translateFR') ]); + $this->setData(['config', 'i18n', 'de', $this->getInput('translateDE')]); + $this->setData(['config', 'i18n', 'en', $this->getInput('translateEN')]); + $this->setData(['config', 'i18n', 'es', $this->getInput('translateES')]); + $this->setData(['config', 'i18n', 'it', $this->getInput('translateIT')]); + $this->setData(['config', 'i18n', 'nl', $this->getInput('translateNL')]); + $this->setData(['config', 'i18n', 'pt', $this->getInput('translatePT')]); + // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl(), @@ -151,9 +206,26 @@ class translate extends common { ]; } } + // Générer la list des pages disponibles + self::$pagesList = $this->getData(['page']); + foreach(self::$pagesList as $page => $pageId) { + if ($this->getData(['page',$page,'block']) === 'bar' || + $this->getData(['page',$page,'disable']) === true) { + unset(self::$pagesList[$page]); + } + } + + self::$orphansList = $this->getData(['page']); + foreach(self::$orphansList as $page => $pageId) { + if ($this->getData(['page',$page,'block']) === 'bar' || + $this->getData(['page',$page,'disable']) === true || + $this->getdata(['page',$page, 'position']) !== 0) { + unset(self::$orphansList[$page]); + } + } // Valeurs en sortie $this->addOutput([ - 'title' => 'Gestion des langues', + 'title' => 'Contenu du site multilangues', 'view' => 'index' ]); } diff --git a/core/module/translate/view/index/index.php b/core/module/translate/view/index/index.php index 9679894d..af15db57 100644 --- a/core/module/translate/view/index/index.php +++ b/core/module/translate/view/index/index.php @@ -31,7 +31,7 @@
    -

    Mode de traduction et affichage des drapeaux

    +

    Activation des langues du contenu

    'Drapeau masqué','site'=>'Drapeau affiché'], [ @@ -91,4 +91,194 @@
    +
    +
    +

    Configuration du contenu du site en

    +
    +
    +
    +
    +
    +

    Identité du site + + + 'left']);?> + + +

    +
    +
    + 'Titre du site' , + 'value' => $this->getData(['locale', 'title']), + 'help' => 'Il apparaît dans la barre de titre et les partages sur les réseaux sociaux.' + ]); ?> +
    +
    +
    +
    + 'Description du site', + 'value' => $this->getData(['locale', 'metaDescription']), + 'help' => 'La description d\'une page participe à son référencement, chaque page doit disposer d\'une description différente.' + ]); ?> +
    +
    +
    +
    +
    +
    +
    +
    +

    Assignation des pages spéciales + + + 'left']);?> + + +

    +
    +
    + 'Accueil du site', + 'selected' =>$this->getData(['locale', 'homePageId']), + 'help' => 'La première page que vos visiteurs verront.' + ]); ?> +
    +
    + 'Page par défaut'],helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [ + 'label' => 'Accès interdit, erreur 403', + 'selected' =>$this->getData(['locale', 'page403']), + 'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.' + ]); ?> +
    +
    + 'Page par défaut'],helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [ + 'label' => 'Page inexistante, erreur 404', + 'selected' =>$this->getData(['locale', 'page404']), + 'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.' + ]); ?> +
    +
    +
    +
    + 'Aucune'] , helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ + 'label' => 'Mentions légales', + 'selected' => $this->getData(['locale', 'legalPageId']), + 'help' => 'Les mentions légales sont obligatoires en France. Une option du pied de page ajoute un lien discret vers cette page.' + ]); ?> +
    +
    + 'Aucune'] , helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ + 'label' => 'Recherche dans le site', + 'selected' => $this->getData(['locale', 'searchPageId']), + 'help' => 'Sélectionnez une page contenant le module \'Recherche\'. Une option du pied de page ajoute un lien discret vers cette page.' + ]); ?> +
    +
    + 'Page par défaut'],helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [ + 'label' => 'Site en maintenance', + 'selected' =>$this->getData(['locale', 'page302']), + 'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.' + ]); ?> +
    +
    +
    +
    +
    +
    +
    +
    +

    Etiquettes des pages spéciales + + + 'left']);?> + + +

    +
    +
    + 'Mentions légales', + 'placeholder' => 'Mentions légales', + 'value' => $this->getData(['locale', 'legalPageLabel']) + ]); ?> +
    +
    + 'Rechercher', + 'placeholder' => 'Rechercher', + 'value' => $this->getData(['locale', 'searchPageLabel']) + ]); ?> +
    +
    +
    +
    + 'Plan du site', + 'placeholder' => 'Plan du site', + 'value' => $this->getData(['locale', 'sitemapPageLabel']), + ]); ?> +
    +
    + 'Cookies', + 'value' => $this->getData(['locale', 'cookies', 'cookiesFooterText']), + 'placeHolder' => 'Cookies' + ]); ?> +
    +
    +
    +
    +
    +
    +
    +
    +

    Message d'acceptation des Cookies + + + 'left']);?> + + +

    +
    +
    + 'Saisissez le titre de la fenêtre de gestion des cookies.', + 'label' => 'Titre de la fenêtre', + 'value' => $this->getData(['locale', 'cookies', 'titleLabel']), + 'placeHolder' => 'Gérer les cookies' + ]); ?> +
    +
    + 'Bouton de validation', + 'value' => $this->getData(['locale', 'cookies', 'buttonValidLabel']), + 'placeHolder' => 'J\'ai compris' + ]); ?> +
    +
    +
    +
    + 'Saisissez le message pour les cookies déposés par ZwiiCMS, nécessaires au fonctionnement et qui ne nécessitent pas de consentement.', + 'label' => 'Cookies Zwii', + 'value' => $this->getData(['locale', 'cookies', 'mainLabel']), + 'placeHolder' => 'Ce site utilise des cookies nécessaires à son fonctionnement, ils permettent de fluidifier son fonctionnement par exemple en mémorisant les données de connexion, la langue que vous avez choisie ou la validation de ce message.' + ]); ?> +
    + +
    + 'Saisissez le texte du lien vers les mentions légales,la page doit être définie dans la configuration du site.', + 'label' => 'Lien page des mentions légales.', + 'value' => $this->getData(['locale', 'cookies', 'linkLegalLabel']), + 'placeHolder' => 'Consulter les mentions légales' + ]); ?> +
    +
    +
    +
    +