From c702c41fedfc0a240bc6aedeb85d7c143d85a123 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Tue, 23 Apr 2024 17:42:00 +0200 Subject: [PATCH] Init --- CHANGES.md | 5 ++ core/class/layout.class.php | 8 +-- core/class/router.class.php | 42 +++++++------- core/core.php | 2 +- core/module/page/page.php | 55 ++++++++++++++++--- core/module/page/view/cssEditor/cssEditor.php | 2 +- core/module/page/view/edit/edit.php | 4 +- core/module/page/view/jsEditor/jsEditor.php | 2 +- module/blog/blog.php | 2 +- module/blog/changes.md | 2 + module/blog/view/config/config.php | 2 +- module/form/changes.md | 2 + module/form/form.php | 2 +- module/form/view/config/config.php | 2 +- module/gallery/changes.md | 2 + module/gallery/gallery.php | 2 +- module/gallery/view/config/config.php | 2 +- module/news/changes.md | 2 + module/news/news.php | 2 +- module/news/view/config/config.php | 2 +- module/redirection/changes.md | 2 + module/redirection/redirection.php | 2 +- module/redirection/view/config/config.php | 2 +- module/search/changes.md | 2 + module/search/search.php | 2 +- module/search/view/config/config.php | 2 +- module/slider/changes.md | 2 + module/slider/view/config/config.php | 2 +- 28 files changed, 111 insertions(+), 49 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2b649540..88ecb29b 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # Changelog + +## Version 13.3.00 + +Cette modification évite les problèmes d'édition de langues différentes dans des onglets différents du même navigateur. + ## Version 13.2.02 Corrige un warning quand un module blog ou news ne contient pas d'article. diff --git a/core/class/layout.class.php b/core/class/layout.class.php index 1542f95b..3040f7ff 100644 --- a/core/class/layout.class.php +++ b/core/class/layout.class.php @@ -980,7 +980,7 @@ class layout extends common // Bouton Ajouter une page if ($this->getUser('permission', 'page', 'add')) { $leftItems .= '
  • ' . template::ico('plus', [ - 'href' => helper::baseUrl() . 'page/add', + 'href' => helper::baseUrl() . 'page/add/' . self::$siteContent, 'help' => 'Nouvelle page ou barre latérale' ]) . '
  • '; } @@ -999,7 +999,7 @@ class layout extends common // Bouton Editer une page if ($this->getUser('permission', 'page', 'edit')) { $leftItems .= '
  • ' . template::ico('pencil', [ - 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0) . '/' . self::$siteContent, 'help' => 'Éditer la page' ]) . '
  • '; } @@ -1018,7 +1018,7 @@ class layout extends common $this->getUser('permission', 'page', 'duplicate') ) { $leftItems .= '
  • ' . template::ico('clone', [ - 'href' => helper::baseUrl() . 'page/duplicate/' . $this->getUrl(0), + 'href' => helper::baseUrl() . 'page/duplicate/' . $this->getUrl(0) . '/' . self::$siteContent, 'help' => 'Dupliquer la page' ]) . '
  • '; @@ -1028,7 +1028,7 @@ class layout extends common $this->getUser('permission', 'page', 'delete') ) { $leftItems .= '
  • ' . template::ico('trash', [ - 'href' => helper::baseUrl() . 'page/delete/' . $this->getUrl(0), + 'href' => helper::baseUrl() . 'page/delete/' . $this->getUrl(0) . '/' . self::$siteContent, 'help' => 'Supprimer la page', 'id' => 'pageDelete' ]) diff --git a/core/class/router.class.php b/core/class/router.class.php index 62e44011..f0575d3b 100644 --- a/core/class/router.class.php +++ b/core/class/router.class.php @@ -444,26 +444,6 @@ class core extends common exit(); } - // Pour éviter une 404 sur une langue étrangère, bascule dans la langue correcte. - if (is_null($this->getData(['page', $this->getUrl(0)]))) { - foreach (common::$languages as $key => $value) { - if ( - is_dir(common::DATA_DIR . $key) && - file_exists(common::DATA_DIR . $key . '/page.json') - ) { - $pagesId = json_decode(file_get_contents(common::DATA_DIR . $key . '/page.json'), true); - if ( - is_array($pagesId['page']) && - array_key_exists($this->getUrl(0), $pagesId['page']) - ) { - $_SESSION['ZWII_CONTENT'] = $key; - header('Refresh:0; url=' . helper::baseUrl() . $this->getUrl(0)); - exit(); - } - } - } - } - // Check l'accès à la page $access = null; if ($this->getData(['page', $this->getUrl(0)]) !== null) { @@ -813,6 +793,28 @@ class core extends common } } elseif ($this->output['content'] === '') { http_response_code(404); + // Pour éviter une 404, bascule dans l'espace correct si la page existe dans cette langue. + // Parcourir les espaces + foreach (common::$languages as $langId => $value) {; + if ( + // l'espace existe + is_dir(common::DATA_DIR . $langId) && + file_exists(common::DATA_DIR . $langId . '/page.json') + ) { + // Lire les données des pages + $pagesId = json_decode(file_get_contents(common::DATA_DIR . $langId . '/page.json'), true); + if ( + // La page existe + is_array($pagesId['page']) && + array_key_exists($this->getUrl(0), $pagesId['page']) + ) { + // Basculer + $_SESSION['ZWII_SITE_CONTENT'] = $langId; + header('Refresh:0; url=' . helper::baseUrl() . $this->getUrl()); + exit(); + } + } + } if ( $this->getData(['locale', 'page404']) !== 'none' and $this->getData(['page', $this->getData(['locale', 'page404'])]) diff --git a/core/core.php b/core/core.php index 432df3df..b001109c 100644 --- a/core/core.php +++ b/core/core.php @@ -51,7 +51,7 @@ class common const ACCESS_TIMER = 1800; // Numéro de version - const ZWII_VERSION = '13.2.02'; + const ZWII_VERSION = '13.3.00'; // URL autoupdate const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/cms-update/raw/branch/master/'; diff --git a/core/module/page/page.php b/core/module/page/page.php index 46c868dd..198bb432 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -85,8 +85,19 @@ class page extends common */ public function duplicate() { + // La session ne correspond pas au site ouvert dans cet onglet + if ( + // Contrôle la présence de l'id de langue uniquement si l'id est fourni afin de ne pas bloquer les modules non mis à jour + $this->getUrl(3) && $this->getUrl(3) != self::$siteContent + ) { + $_SESSION['ZWII_SITE_CONTENT'] = $this->getUrl(3); + header('Refresh:0; url=' . helper::baseUrl() . $this->getUrl()); + exit(); + } + // Adresse sans le token $page = $this->getUrl(2); + // La page n'existe pas if ( $this->getUser('permission', __CLASS__, __FUNCTION__) !== true || @@ -118,7 +129,7 @@ class page extends common // Valeurs en sortie $this->addOutput([ - 'redirect' => helper::baseUrl() . 'page/edit/' . $pageId, + 'redirect' => helper::baseUrl() . 'page/edit/' . $pageId . '/' . self::$siteContent, 'notification' => $notification, 'state' => true ]); @@ -131,6 +142,16 @@ class page extends common */ public function add() { + // La session ne correspond pas au site ouvert dans cet onglet + if ( + // Contrôle la présence de l'id de langue uniquement si l'id est fourni afin de ne pas bloquer les modules non mis à jour + $this->getUrl(3) && $this->getUrl(3) != self::$siteContent + ) { + $_SESSION['ZWII_SITE_CONTENT'] = $this->getUrl(3); + header('Refresh:0; url=' . helper::baseUrl() . $this->getUrl()); + exit(); + } + if ($this->getUser('permission', __CLASS__, __FUNCTION__) !== true) { // Valeurs en sortie $this->addOutput([ @@ -198,6 +219,16 @@ class page extends common */ public function delete() { + // La session ne correspond pas au site ouvert dans cet onglet + if ( + // Contrôle la présence de l'id de langue uniquement si l'id est fourni afin de ne pas bloquer les modules non mis à jour + $this->getUrl(3) && $this->getUrl(3) != self::$siteContent + ) { + $_SESSION['ZWII_SITE_CONTENT'] = $this->getUrl(3); + header('Refresh:0; url=' . helper::baseUrl() . $this->getUrl()); + exit(); + } + // $url prend l'adresse sans le token $page = $this->getUrl(2); // La page n'existe pas @@ -262,7 +293,7 @@ class page extends common elseif ($this->getHierarchy($page, null)) { // Valeurs en sortie $this->addOutput([ - 'redirect' => helper::baseUrl() . 'page/edit/' . $page, + 'redirect' => helper::baseUrl() . 'page/edit/' . $page . '/' . self::$siteContent, 'notification' => helper::translate('Impossible de supprimer une page contenant des pages enfants') ]); } @@ -302,6 +333,17 @@ class page extends common */ public function edit() { + + // La session ne correspond pas au site ouvert dans cet onglet + if ( + // Contrôle la présence de l'id de langue uniquement si l'id est fourni afin de ne pas bloquer les modules non mis à jour + $this->getUrl(3) && $this->getUrl(3) != self::$siteContent + ) { + $_SESSION['ZWII_SITE_CONTENT'] = $this->getUrl(3); + header('Refresh:0; url=' . helper::baseUrl() . $this->getUrl()); + exit(); + } + // La page n'existe pas if ( $this->getUser('permission', __CLASS__, __FUNCTION__) !== true || @@ -610,7 +652,7 @@ class page extends common // Valeurs en sortie $this->addOutput([ 'notification' => helper::translate('Modifications enregistrées'), - 'redirect' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2), + 'redirect' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2) . '/' . self::$siteContent, 'state' => true ]); } @@ -645,7 +687,7 @@ class page extends common // Valeurs en sortie $this->addOutput([ 'notification' => helper::translate('Modifications enregistrées'), - 'redirect' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2), + 'redirect' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2) . '/' . self::$siteContent, 'state' => true ]); } @@ -661,16 +703,15 @@ class page extends common /** * Retourne les informations sur les pages en omettant les clés CSS et JS qui occasionnent des bugs d'affichage dans l'éditeur de page - * @return array tableau associatif des pages dans le menu + * @return string tableau associatif des pages dans le menu */ public function getPageInfo() { $p = $this->getData(['page']); $d = array_map(function ($d) { - unset($d["css"], $d["js"]); + unset ($d["css"], $d["js"]); return $d; }, $p); return json_encode($d); - } } \ No newline at end of file diff --git a/core/module/page/view/cssEditor/cssEditor.php b/core/module/page/view/cssEditor/cssEditor.php index b9c62aeb..a468bd34 100644 --- a/core/module/page/view/cssEditor/cssEditor.php +++ b/core/module/page/view/cssEditor/cssEditor.php @@ -3,7 +3,7 @@
    'buttonGrey', - 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2), + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2) . '/' . self::$siteContent, 'value' => template::ico('left') ]); ?>
    diff --git a/core/module/page/view/edit/edit.php b/core/module/page/view/edit/edit.php index ce0f094b..b597d59e 100644 --- a/core/module/page/view/edit/edit.php +++ b/core/module/page/view/edit/edit.php @@ -19,14 +19,14 @@
    'buttonRed', - 'href' => helper::baseUrl() . 'page/delete/' . $this->getUrl(2), + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2) . '/' . self::$siteContent, 'value' => template::ico('trash'), 'help' => 'Effacer la page' ]); ?>
    helper::baseUrl() . 'page/duplicate/' . $this->getUrl(2), + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2) . '/' . self::$siteContent, 'value' => template::ico('clone'), 'help' => 'Dupliquer la page' ]); ?> diff --git a/core/module/page/view/jsEditor/jsEditor.php b/core/module/page/view/jsEditor/jsEditor.php index a14f2693..a7dcf430 100644 --- a/core/module/page/view/jsEditor/jsEditor.php +++ b/core/module/page/view/jsEditor/jsEditor.php @@ -3,7 +3,7 @@
    'buttonGrey', - 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2), + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2) . '/' . self::$siteContent, 'value' => template::ico('left') ]); ?>
    diff --git a/module/blog/blog.php b/module/blog/blog.php index 479721fe..acfbb90a 100755 --- a/module/blog/blog.php +++ b/module/blog/blog.php @@ -16,7 +16,7 @@ class blog extends common { - const VERSION = '7.6'; + const VERSION = '7.7'; const REALNAME = 'Blog'; const DELETE = true; const UPDATE = '0.0'; diff --git a/module/blog/changes.md b/module/blog/changes.md index d5e5fa92..e528a6f4 100755 --- a/module/blog/changes.md +++ b/module/blog/changes.md @@ -1,3 +1,5 @@ +# Version 7.7 +- Contrôle de la variable de session liée au contenu. Evite des erreurs lorsque plusieurs onglets sont ouverts. # Version 7.6 - Mise à jour RSS Feed # Version 7.5 diff --git a/module/blog/view/config/config.php b/module/blog/view/config/config.php index 3be3f753..d87cfea6 100755 --- a/module/blog/view/config/config.php +++ b/module/blog/view/config/config.php @@ -3,7 +3,7 @@
    'buttonGrey', - 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), 'posts', + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0) . '/' . self::$siteContent, 'value' => template::ico('left') ]); ?>
    diff --git a/module/form/changes.md b/module/form/changes.md index 5aebcec7..11c7f513 100644 --- a/module/form/changes.md +++ b/module/form/changes.md @@ -1,3 +1,5 @@ +# Version 4.3 +- Contrôle de la variable de session liée au contenu. Evite des erreurs lorsque plusieurs onglets sont ouverts. # Version 4.2 - Termes des commandes de profils # Version 4.1 diff --git a/module/form/form.php b/module/form/form.php index 2c970426..46a0e410 100644 --- a/module/form/form.php +++ b/module/form/form.php @@ -17,7 +17,7 @@ class form extends common { - const VERSION = '4.2'; + const VERSION = '4.3'; const REALNAME = 'Formulaire'; const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) diff --git a/module/form/view/config/config.php b/module/form/view/config/config.php index 08865dde..b594e5ff 100644 --- a/module/form/view/config/config.php +++ b/module/form/view/config/config.php @@ -53,7 +53,7 @@
    'buttonGrey', - 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0) . '/' . self::$siteContent, 'value' => template::ico('left') ]); ?>
    diff --git a/module/gallery/changes.md b/module/gallery/changes.md index dcce233e..ee0354f3 100644 --- a/module/gallery/changes.md +++ b/module/gallery/changes.md @@ -1,3 +1,5 @@ +# Version 4.2 +- Contrôle de la variable de session liée au contenu. Evite des erreurs lorsque plusieurs onglets sont ouverts. # Version 4.1 - Termes des commandes de profils # Version 4.0 diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index b1559ce6..0f1d437a 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -18,7 +18,7 @@ class gallery extends common { - const VERSION = '4.1'; + const VERSION = '4.2'; const REALNAME = 'Galerie'; const DATADIRECTORY = self::DATA_DIR . 'gallery/'; diff --git a/module/gallery/view/config/config.php b/module/gallery/view/config/config.php index a1f4ac25..483cc519 100644 --- a/module/gallery/view/config/config.php +++ b/module/gallery/view/config/config.php @@ -3,7 +3,7 @@
    'buttonGrey', - 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0) . '/' . self::$siteContent, 'value' => template::ico('left') ]); ?>
    diff --git a/module/news/changes.md b/module/news/changes.md index 99f691bb..fb3d1124 100644 --- a/module/news/changes.md +++ b/module/news/changes.md @@ -1,3 +1,5 @@ +# Version 5.6 +- Contrôle de la variable de session liée au contenu. Evite des erreurs lorsque plusieurs onglets sont ouverts. # Version 5.5 - Mise à jour RSS Feed # Version 5.4 diff --git a/module/news/news.php b/module/news/news.php index 0d2c6ea7..fa91ce9d 100644 --- a/module/news/news.php +++ b/module/news/news.php @@ -16,7 +16,7 @@ class news extends common { - const VERSION = '5.5'; + const VERSION = '5.6'; const REALNAME = 'News'; const DATADIRECTORY = self::DATA_DIR . 'news/'; diff --git a/module/news/view/config/config.php b/module/news/view/config/config.php index 92f7e4b1..49cb9ec2 100644 --- a/module/news/view/config/config.php +++ b/module/news/view/config/config.php @@ -3,7 +3,7 @@
    'buttonGrey', - 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0),'posts', + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0) . '/' . self::$siteContent, 'value' => template::ico('left') ]); ?>
    diff --git a/module/redirection/changes.md b/module/redirection/changes.md index 3f02c3af..6c1ccfb4 100644 --- a/module/redirection/changes.md +++ b/module/redirection/changes.md @@ -1,3 +1,5 @@ +# Version 2.2 +- Contrôle de la variable de session liée au contenu. Evite des erreurs lorsque plusieurs onglets sont ouverts. # Version 2.1 - Edition du module ou de la page impossible. # Version 2.0 diff --git a/module/redirection/redirection.php b/module/redirection/redirection.php index ae77e99b..e96f45fe 100644 --- a/module/redirection/redirection.php +++ b/module/redirection/redirection.php @@ -16,7 +16,7 @@ class redirection extends common { - const VERSION = '2.1'; + const VERSION = '2.2'; const REALNAME = 'Redirection'; const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) diff --git a/module/redirection/view/config/config.php b/module/redirection/view/config/config.php index 9309fb08..d3b6d70f 100644 --- a/module/redirection/view/config/config.php +++ b/module/redirection/view/config/config.php @@ -3,7 +3,7 @@
    'buttonGrey', - 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0) . '/' . self::$siteContent, 'value' => template::ico('left') ]); ?>
    diff --git a/module/search/changes.md b/module/search/changes.md index ed6a703f..556ad9e4 100644 --- a/module/search/changes.md +++ b/module/search/changes.md @@ -1,3 +1,5 @@ +# Version 3.2 +- Contrôle de la variable de session liée au contenu. Evite des erreurs lorsque plusieurs onglets sont ouverts. # Version 3.1 - Initialise un module installé dans une page sans avoir ouvert la page de configuration sans lancer de mise à jour. # Version 3.0 diff --git a/module/search/search.php b/module/search/search.php index 7d9842d2..bcdfddba 100644 --- a/module/search/search.php +++ b/module/search/search.php @@ -20,7 +20,7 @@ class search extends common { - const VERSION = '3.1'; + const VERSION = '3.2'; const REALNAME = 'Recherche'; const DATADIRECTORY = self::DATA_DIR . 'search/'; diff --git a/module/search/view/config/config.php b/module/search/view/config/config.php index 0f515f1b..09c698fb 100644 --- a/module/search/view/config/config.php +++ b/module/search/view/config/config.php @@ -3,7 +3,7 @@
    'buttonGrey', - 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0) . '/' . self::$siteContent, 'value' => template::ico('left') ]); ?>
    diff --git a/module/slider/changes.md b/module/slider/changes.md index 7cdee4f9..7949f1f6 100644 --- a/module/slider/changes.md +++ b/module/slider/changes.md @@ -1,3 +1,5 @@ +# Version 6.5 +- Contrôle de la variable de session liée au contenu. Evite des erreurs lorsque plusieurs onglets sont ouverts. # Version 6.4 - Corrige plusieurs bugs dans les fonctions de tri # Version 6.3 diff --git a/module/slider/view/config/config.php b/module/slider/view/config/config.php index f3ef50cf..6a445f29 100644 --- a/module/slider/view/config/config.php +++ b/module/slider/view/config/config.php @@ -3,7 +3,7 @@
    'buttonGrey', - 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0) . '/' . self::$siteContent, 'value' => template::ico('left') ]); ?>