From 87cfd5bd154fcd5ee077d1ca49498d143abd41c9 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Tue, 11 Jan 2022 13:35:26 +0100 Subject: [PATCH] Bug page parent orpheline --- CHANGES.md | 5 +-- core/module/page/page.php | 75 ++++++++++++++++++++++++--------------- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 9b37f67f..e09c486b 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,9 +1,10 @@ # Changelog ## Version 11.2.03 -- Correction : +- Corrections : - Thème ; pied de page ; option pied de page fixe inopérante. -- Modification : + - Edition des pages orphelines : "Ne pas afficher" une page contenant des sous-pages provoquait un bug d'affichage dans le menu, la page était malgré tout affichée en fin de menu. Ce problème était causé par les pages enfants dont l'affichage n'était pas modifié. Le correctif cascade l'option "Ne pas afficher" aux sous-pages. La réciproque n'est pas appliquée, il faudra rendre visible les sous-pages d'une page parente qui devient à nouveau visible. +- Modifications : - Thème ; pied de page ; options pied de page fixe et alignement avec le contenu déplacées dans les paramètres. - Mise à jour en ligne, contrôle de la clé MD5 de l'archive update.tar.gz. diff --git a/core/module/page/page.php b/core/module/page/page.php index 52b9476c..e4cc020a 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -407,6 +407,39 @@ class page extends common { $position = 0; $hideTitle = true; } + // Une page parent devient orpheline, les pages enfants le devienne pour éviter une incohérence + if ( + $position === 0 && + $position !== $this->getData(['page', $this->getUrl(2), 'position']) && + $this->getinput('pageEditBlock') !== 'bar' + ) { + foreach ($this->getHierarchy($pageId) as $parentId=>$childId) { + if ($this->getData(['page',$childId,'parentPageId']) === $pageId) { + $this->setData(['page',$childId,'position', 0]); + } + } + } + + // La page est une barre latérale qui a été renommée : changer le nom de la barre dans les pages qui l'utilisent + if ($this->getinput('pageEditBlock') === 'bar') { + foreach ($this->getHierarchy() as $eachPageId=>$parentId) { + if ($this->getData(['page',$eachPageId,'barRight']) === $this->getUrl(2)) { + $this->setData(['page',$eachPageId,'barRight',$pageId]); + } + if ($this->getData(['page',$eachPageId,'barLeft']) === $this->getUrl(2)) { + $this->setData(['page',$eachPageId,'barLeft',$pageId]); + } + foreach ($parentId as $childId) { + if ($this->getData(['page',$childId,'barRight']) === $this->getUrl(2)) { + $this->setData(['page',$childId,'barRight',$pageId]); + } + if ($this->getData(['page',$childId,'barLeft']) === $this->getUrl(2)) { + $this->setData(['page',$childId,'barLeft',$pageId]); + } + } + } + } + // Modifie la page ou en crée une nouvelle si l'id a changé $this->setData([ 'page', @@ -437,44 +470,28 @@ class page extends common { 'hideMenuChildren' => $this->getinput('pageEditHideMenuChildren', helper::FILTER_BOOLEAN), ] ]); + // Creation du contenu de la page if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) { mkdir(self::DATA_DIR . self::$i18n . '/content', 0755); } $content = empty($this->getInput('pageEditContent', null)) ? '

' : str_replace('

', '

 

', $this->getInput('pageEditContent', null)); - //file_put_contents( self::DATA_DIR . self::$i18n . '/content/' . $pageId . '.html' , $content ); $this->setPage($pageId , $content, self::$i18n); - // Barre renommée : changement le nom de la barre dans les pages mères - if ($this->getinput('pageEditBlock') === 'bar') { - foreach ($this->getHierarchy() as $eachPageId=>$parentId) { - if ($this->getData(['page',$eachPageId,'barRight']) === $this->getUrl(2)) { - $this->setData(['page',$eachPageId,'barRight',$pageId]); - } - if ($this->getData(['page',$eachPageId,'barLeft']) === $this->getUrl(2)) { - $this->setData(['page',$eachPageId,'barLeft',$pageId]); - } - foreach ($parentId as $childId) { - if ($this->getData(['page',$childId,'barRight']) === $this->getUrl(2)) { - $this->setData(['page',$childId,'barRight',$pageId]); - } - if ($this->getData(['page',$childId,'barLeft']) === $this->getUrl(2)) { - $this->setData(['page',$childId,'barLeft',$pageId]); - } - } - } - } + + // Met à jour le site map $this->createSitemap('all'); // Redirection vers la configuration - if($this->getInput('pageEditModuleRedirect', helper::FILTER_BOOLEAN)) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $pageId . '/config', - 'state' => true - ]); - } - // Redirection vers la page - else { + if( + $this->getInput('pageEditModuleRedirect', helper::FILTER_BOOLEAN) + ) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $pageId . '/config', + 'state' => true + ]); + // Redirection vers la page + } else { // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . $pageId,