From b3285c4cf6d2af600f3fac15bb0b3ba4da017157 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Fri, 1 Nov 2019 18:02:15 +0100 Subject: [PATCH] [10.0.59.dev] modif algo gestion de la page d'accueil --- core/core.php | 28 +++++++------------------- core/module/page/page.php | 2 +- core/module/page/view/edit/edit.js.php | 10 --------- core/module/page/view/edit/edit.php | 3 +-- 4 files changed, 9 insertions(+), 34 deletions(-) diff --git a/core/core.php b/core/core.php index 97135f8b..fa2c5868 100644 --- a/core/core.php +++ b/core/core.php @@ -31,7 +31,7 @@ class common { const TEMP_DIR = 'site/tmp/'; // Numéro de version - const ZWII_VERSION = '10.0.58.dev'; + const ZWII_VERSION = '10.0.59.dev'; public static $actions = []; public static $coreModuleIds = [ @@ -483,33 +483,19 @@ class common { * @return string */ public function getHomePageId () { - foreach($this->getHierarchy(null, null, null) as $parentPageId => $childrenPageIds) { - if ($this->getData(['page',$parentPageId,"homePageId"]) === true) { + foreach($this->getHierarchy(null, true, false) as $parentPageId => $childrenPageIds) { + if ($this->getData(['page',$parentPageId,'homePageId']) === true) { return ($parentPageId); } foreach($childrenPageIds as $childKey) { - if ($this->getData(['page',$childKey,"homePageId"]) === true) { + if ($this->getData(['page',$childKey,'homePageId']) === true) { return ($childKey); } } } - } - - /** - * Retourne l'Id de la homePage de la langue courante - * @return string - */ - public function resetHomePageId () { - foreach($this->getHierarchy(null, null, null) as $parentPageId => $childrenPageIds) { - if ($this->getData(['page',$parentPageId,"homePageId"]) === true) { - $this->setData(['page',$parentPageId,"homePageId", false]); - } - foreach($childrenPageIds as $childKey) { - if ($this->getData(['page',$childKey,"homePageId"]) === true) { - $this->setData(['page',$childKey,"homePageId", false]); - } - } - } + // Aucune homePage, définir la première page et boucler + $this->setData(['page',current(array_keyS ($this->getHierarchy(null, true, false))),'homePageId',true]); + $this->getHomePageId(); } diff --git a/core/module/page/page.php b/core/module/page/page.php index 95d7bfc4..3d317617 100755 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -241,7 +241,7 @@ class page extends common { } // Reset homePage if ($this->getinput('pageHomePageId', helper::FILTER_BOOLEAN) === true ) { - $this->resetHomePageId(); + $this->setData(['page',$this->getHomePageId(),'homePageId',false]); } // Modifie la page ou en crée une nouvelle si l'id a changé $this->setData([ diff --git a/core/module/page/view/edit/edit.js.php b/core/module/page/view/edit/edit.js.php index 7023907d..9a95b650 100755 --- a/core/module/page/view/edit/edit.js.php +++ b/core/module/page/view/edit/edit.js.php @@ -196,16 +196,6 @@ $( document ).ready(function() { -/** -* Bloque la désactivation du choix de la page d'accueil -*/ -var pageHomePage = $("#pageHomePage"); -pageHomePage.on("change",function() { - if (this.checked) { - $("input[name=pageHomePage]").attr("disabled",true); - } -}); - /** * Cache les options de masquage dans les menus quand la page n'est pas affichée. */ diff --git a/core/module/page/view/edit/edit.php b/core/module/page/view/edit/edit.php index 526c8655..ab5def1d 100755 --- a/core/module/page/view/edit/edit.php +++ b/core/module/page/view/edit/edit.php @@ -82,8 +82,7 @@ echo template::formOpen('pageEditForm'); ?>
$this->getData(['page', $this->getUrl(2), 'homePageId']), - 'disabled' => $this->getData(['page', $this->getUrl(2), 'homePageId']) === true ? true : false , - 'help' => 'Pour sélectionner une autre page d\'accueil, activez l\'option sur une autre page.' + 'help' => 'Activer l\'option sur une page, pour choisir une autre page d\'accueil.', ]); ?>