[10.0.59.dev] modif algo gestion de la page d'accueil

This commit is contained in:
fredtempez 2019-11-01 18:02:15 +01:00
parent 755db23dd0
commit b3285c4cf6
4 changed files with 9 additions and 34 deletions

View File

@ -31,7 +31,7 @@ class common {
const TEMP_DIR = 'site/tmp/'; const TEMP_DIR = 'site/tmp/';
// Numéro de version // Numéro de version
const ZWII_VERSION = '10.0.58.dev'; const ZWII_VERSION = '10.0.59.dev';
public static $actions = []; public static $actions = [];
public static $coreModuleIds = [ public static $coreModuleIds = [
@ -483,33 +483,19 @@ class common {
* @return string * @return string
*/ */
public function getHomePageId () { public function getHomePageId () {
foreach($this->getHierarchy(null, null, null) as $parentPageId => $childrenPageIds) { foreach($this->getHierarchy(null, true, false) as $parentPageId => $childrenPageIds) {
if ($this->getData(['page',$parentPageId,"homePageId"]) === true) { if ($this->getData(['page',$parentPageId,'homePageId']) === true) {
return ($parentPageId); return ($parentPageId);
} }
foreach($childrenPageIds as $childKey) { foreach($childrenPageIds as $childKey) {
if ($this->getData(['page',$childKey,"homePageId"]) === true) { if ($this->getData(['page',$childKey,'homePageId']) === true) {
return ($childKey); return ($childKey);
} }
} }
} }
} // 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();
* 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]);
}
}
}
} }

View File

@ -241,7 +241,7 @@ class page extends common {
} }
// Reset homePage // Reset homePage
if ($this->getinput('pageHomePageId', helper::FILTER_BOOLEAN) === true ) { 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é // Modifie la page ou en crée une nouvelle si l'id a changé
$this->setData([ $this->setData([

View File

@ -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. * Cache les options de masquage dans les menus quand la page n'est pas affichée.
*/ */

View File

@ -82,8 +82,7 @@ echo template::formOpen('pageEditForm'); ?>
<div class="col3"> <div class="col3">
<?php echo template::checkbox('pageHomePageId', true, 'Page d\'accueil', [ <?php echo template::checkbox('pageHomePageId', true, 'Page d\'accueil', [
'checked' => $this->getData(['page', $this->getUrl(2), 'homePageId']), 'checked' => $this->getData(['page', $this->getUrl(2), 'homePageId']),
'disabled' => $this->getData(['page', $this->getUrl(2), 'homePageId']) === true ? true : false , 'help' => 'Activer l\'option sur une page, pour choisir une autre page d\'accueil.',
'help' => 'Pour sélectionner une autre page d\'accueil, activez l\'option sur une autre page.'
]); ?> ]); ?>
</div> </div>
</div> </div>