Revert "Revert "permission changement de module + réécriture test dans les fonctions page""

This reverts commit 3a5b0afe74.
This commit is contained in:
Fred Tempez 2020-10-11 14:21:12 +02:00
parent 3a5b0afe74
commit 96041f1842
2 changed files with 340 additions and 340 deletions

View File

@ -140,46 +140,46 @@ class page extends common {
$this->addOutput([
'access' => false
]);
} else {
$pageTitle = 'Nouvelle page';
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
$this->setData([
'page',
$pageId,
[
'typeMenu' => 'text',
'iconUrl' => '',
'disable' => false,
'content' => 'Contenu de votre nouvelle page.',
'hideTitle' => false,
'breadCrumb' => false,
'metaDescription' => '',
'metaTitle' => '',
'moduleId' => '',
'parentPageId' => '',
'modulePosition' => 'bottom',
'position' => 0,
'group' => self::GROUP_VISITOR,
'targetBlank' => false,
'title' => $pageTitle,
'block' => '12',
'barLeft' => '',
'barRight' => '',
'displayMenu' => '0',
'hideMenuSide' => false,
'hideMenuHead' => false,
'hideMenuChildren' => false
]
]);
// Met à jour le site map
$this->createSitemap('all');
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $pageId,
'notification' => 'Nouvelle page créée',
'state' => true
]);
return;
}
$pageTitle = 'Nouvelle page';
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
$this->setData([
'page',
$pageId,
[
'typeMenu' => 'text',
'iconUrl' => '',
'disable' => false,
'content' => 'Contenu de votre nouvelle page.',
'hideTitle' => false,
'breadCrumb' => false,
'metaDescription' => '',
'metaTitle' => '',
'moduleId' => '',
'parentPageId' => '',
'modulePosition' => 'bottom',
'position' => 0,
'group' => self::GROUP_VISITOR,
'targetBlank' => false,
'title' => $pageTitle,
'block' => '12',
'barLeft' => '',
'barRight' => '',
'displayMenu' => '0',
'hideMenuSide' => false,
'hideMenuHead' => false,
'hideMenuChildren' => false
]
]);
// Met à jour le site map
$this->createSitemap('all');
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $pageId,
'notification' => 'Nouvelle page créée',
'state' => true
]);
}
/**
@ -192,115 +192,115 @@ class page extends common {
$this->addOutput([
'access' => false
]);
} else {
// $url prend l'adresse sans le token
$url = explode('&',$this->getUrl(2));
// La page n'existe pas
if($this->getData(['page', $url[0]]) === null) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
} // Jeton incorrect
elseif(!isset($_GET['csrf'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
'notification' => 'Jeton invalide'
]);
}
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
'notification' => 'Suppression non autorisée'
]);
}
// Impossible de supprimer la page d'accueil
elseif($url[0] === $this->getData(['config', 'homePageId'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config',
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
]);
}
// Impossible de supprimer la page de recherche affectée
elseif($url[0] === $this->getData(['config', 'searchPageId'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config',
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
]);
}
// Impossible de supprimer la page des mentions légales affectée
elseif($url[0] === $this->getData(['config', 'legalPageId'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config',
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
]);
}
// Impossible de supprimer la page des mentions légales affectée
elseif($url[0] === $this->getData(['config', 'page404'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config',
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
]);
}
// Impossible de supprimer la page des mentions légales affectée
elseif($url[0] === $this->getData(['config', 'page403'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config',
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
]);
}
// Impossible de supprimer la page des mentions légales affectée
elseif($url[0] === $this->getData(['config', 'page302'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config',
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
]);
}
// Jeton incorrect
elseif(!isset($_GET['csrf'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
'notification' => 'Jeton invalide'
]);
}
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
'notification' => 'Suppression non autorisée'
]);
}
// Impossible de supprimer une page contenant des enfants
elseif($this->getHierarchy($url[0])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
'notification' => 'Impossible de supprimer une page contenant des enfants'
]);
}
// Suppression
else {
// Effacer la page
$this->deleteData(['page', $url[0]]);
$this->deleteData(['module', $url[0]]);
// Met à jour le site map
$this->createSitemap('all');
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl(false),
'notification' => 'Page supprimée',
'state' => true
]);
}
return;
}
// $url prend l'adresse sans le token
$url = explode('&',$this->getUrl(2));
// La page n'existe pas
if($this->getData(['page', $url[0]]) === null) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
} // Jeton incorrect
elseif(!isset($_GET['csrf'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
'notification' => 'Jeton invalide'
]);
}
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
'notification' => 'Suppression non autorisée'
]);
}
// Impossible de supprimer la page d'accueil
elseif($url[0] === $this->getData(['config', 'homePageId'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config',
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
]);
}
// Impossible de supprimer la page de recherche affectée
elseif($url[0] === $this->getData(['config', 'searchPageId'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config',
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
]);
}
// Impossible de supprimer la page des mentions légales affectée
elseif($url[0] === $this->getData(['config', 'legalPageId'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config',
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
]);
}
// Impossible de supprimer la page des mentions légales affectée
elseif($url[0] === $this->getData(['config', 'page404'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config',
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
]);
}
// Impossible de supprimer la page des mentions légales affectée
elseif($url[0] === $this->getData(['config', 'page403'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config',
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
]);
}
// Impossible de supprimer la page des mentions légales affectée
elseif($url[0] === $this->getData(['config', 'page302'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config',
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
]);
}
// Jeton incorrect
elseif(!isset($_GET['csrf'])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
'notification' => 'Jeton invalide'
]);
}
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
'notification' => 'Suppression non autorisée'
]);
}
// Impossible de supprimer une page contenant des enfants
elseif($this->getHierarchy($url[0])) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
'notification' => 'Impossible de supprimer une page contenant des enfants'
]);
}
// Suppression
else {
// Effacer la page
$this->deleteData(['page', $url[0]]);
$this->deleteData(['module', $url[0]]);
// Met à jour le site map
$this->createSitemap('all');
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl(false),
'notification' => 'Page supprimée',
'state' => true
]);
}
}
@ -315,199 +315,198 @@ class page extends common {
$this->addOutput([
'access' => false
]);
return;
}
// La page existe
else {
// Soumission du formulaire
if($this->isPost()) {
// Génére l'ID si le titre de la page a changé
if ( $this->getInput('pageEditTitle') !== $this->getData(['page',$this->getUrl(2),'title']) ) {
$pageId = $this->getInput('pageEditTitle', helper::FILTER_ID, true);
} else {
$pageId = $this->getUrl(2);
// Soumission du formulaire
if($this->isPost()) {
// Génére l'ID si le titre de la page a changé
if ( $this->getInput('pageEditTitle') !== $this->getData(['page',$this->getUrl(2),'title']) ) {
$pageId = $this->getInput('pageEditTitle', helper::FILTER_ID, true);
} else {
$pageId = $this->getUrl(2);
}
// un dossier existe du même nom (erreur en cas de redirection)
if (file_exists($pageId)) {
$pageId = uniqid($pageId);
}
// Si l'id a changée
if ($pageId !== $this->getUrl(2)) {
// Incrémente le nouvel id de la page
$pageId = helper::increment($pageId, $this->getData(['page']));
$pageId = helper::increment($pageId, self::$coreModuleIds);
$pageId = helper::increment($pageId, self::$moduleIds);
// Met à jour les enfants
foreach($this->getHierarchy($this->getUrl(2)) as $childrenPageId) {
$this->setData(['page', $childrenPageId, 'parentPageId', $pageId]);
}
// un dossier existe du même nom (erreur en cas de redirection)
if (file_exists($pageId)) {
$pageId = uniqid($pageId);
// Change l'id de page dans les données des modules
$this->setData(['module', $pageId, $this->getData(['module', $this->getUrl(2)])]);
$this->deleteData(['module', $this->getUrl(2)]);
// Si la page correspond à la page d'accueil, change l'id dans la configuration du site
if($this->getData(['config', 'homePageId']) === $this->getUrl(2)) {
$this->setData(['config', 'homePageId', $pageId]);
}
// Si l'id a changée
if ($pageId !== $this->getUrl(2)) {
// Incrémente le nouvel id de la page
$pageId = helper::increment($pageId, $this->getData(['page']));
$pageId = helper::increment($pageId, self::$coreModuleIds);
$pageId = helper::increment($pageId, self::$moduleIds);
// Met à jour les enfants
foreach($this->getHierarchy($this->getUrl(2)) as $childrenPageId) {
$this->setData(['page', $childrenPageId, 'parentPageId', $pageId]);
}
// Change l'id de page dans les données des modules
$this->setData(['module', $pageId, $this->getData(['module', $this->getUrl(2)])]);
$this->deleteData(['module', $this->getUrl(2)]);
// Si la page correspond à la page d'accueil, change l'id dans la configuration du site
if($this->getData(['config', 'homePageId']) === $this->getUrl(2)) {
$this->setData(['config', 'homePageId', $pageId]);
}
}
// Supprime les données du module en cas de changement de module
if($this->getInput('pageEditModuleId') !== $this->getData(['page', $this->getUrl(2), 'moduleId'])) {
$this->deleteData(['module', $pageId]);
}
// Supprime l'ancienne page si l'id a changée
if($pageId !== $this->getUrl(2)) {
$this->deleteData(['page', $this->getUrl(2)]);
}
// Traitement des pages spéciales affectées dans la config :
if ($this->getUrl(2) === $this->getData(['config', 'legalPageId']) ) {
$this->setData(['config','legalPageId', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'searchPageId']) ) {
$this->setData(['config','searchPageId', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'page404']) ) {
$this->setData(['config','page404', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'page403']) ) {
$this->setData(['config','page403', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'page302']) ) {
$this->setData(['config','page302', $pageId]);
}
// Si la page est une page enfant, actualise les positions des autres enfants du parent, sinon actualise les pages sans parents
$lastPosition = 1;
$hierarchy = $this->getInput('pageEditParentPageId') ? $this->getHierarchy($this->getInput('pageEditParentPageId')) : array_keys($this->getHierarchy());
$position = $this->getInput('pageEditPosition', helper::FILTER_INT);
foreach($hierarchy as $hierarchyPageId) {
// Ignore la page en cours de modification
if($hierarchyPageId === $this->getUrl(2)) {
continue;
}
// Supprime les données du module en cas de changement de module
if($this->getInput('pageEditModuleId') !== $this->getData(['page', $this->getUrl(2), 'moduleId'])) {
$this->deleteData(['module', $pageId]);
}
// Supprime l'ancienne page si l'id a changée
if($pageId !== $this->getUrl(2)) {
$this->deleteData(['page', $this->getUrl(2)]);
}
// Traitement des pages spéciales affectées dans la config :
if ($this->getUrl(2) === $this->getData(['config', 'legalPageId']) ) {
$this->setData(['config','legalPageId', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'searchPageId']) ) {
$this->setData(['config','searchPageId', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'page404']) ) {
$this->setData(['config','page404', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'page403']) ) {
$this->setData(['config','page403', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'page302']) ) {
$this->setData(['config','page302', $pageId]);
}
// Si la page est une page enfant, actualise les positions des autres enfants du parent, sinon actualise les pages sans parents
$lastPosition = 1;
$hierarchy = $this->getInput('pageEditParentPageId') ? $this->getHierarchy($this->getInput('pageEditParentPageId')) : array_keys($this->getHierarchy());
$position = $this->getInput('pageEditPosition', helper::FILTER_INT);
foreach($hierarchy as $hierarchyPageId) {
// Ignore la page en cours de modification
if($hierarchyPageId === $this->getUrl(2)) {
continue;
}
// Incrémente de +1 pour laisser la place à la position de la page en cours de modification
if($lastPosition === $position) {
$lastPosition++;
}
// Change la position
$this->setData(['page', $hierarchyPageId, 'position', $lastPosition]);
// Incrémente pour la prochaine position
// Incrémente de +1 pour laisser la place à la position de la page en cours de modification
if($lastPosition === $position) {
$lastPosition++;
}
if ($this->getinput('pageEditBlock') !== 'bar') {
$barLeft = $this->getinput('pageEditBarLeft');
$barRight = $this->getinput('pageEditBarRight');
$hideTitle = $this->getInput('pageEditHideTitle', helper::FILTER_BOOLEAN);
// Change la position
$this->setData(['page', $hierarchyPageId, 'position', $lastPosition]);
// Incrémente pour la prochaine position
$lastPosition++;
}
if ($this->getinput('pageEditBlock') !== 'bar') {
$barLeft = $this->getinput('pageEditBarLeft');
$barRight = $this->getinput('pageEditBarRight');
$hideTitle = $this->getInput('pageEditHideTitle', helper::FILTER_BOOLEAN);
} else {
// Une barre ne peut pas avoir de barres
$barLeft = "";
$barRight = "";
// Une barre est masquée
$position = 0;
$hideTitle = true;
}
// Modifie la page ou en crée une nouvelle si l'id a changé
$this->setData([
'page',
$pageId,
[
'typeMenu' => $this->getinput('pageTypeMenu'),
'iconUrl' => $this->getinput('pageIconUrl'),
'disable'=> $this->getinput('pageEditDisable', helper::FILTER_BOOLEAN),
'content' => (empty($this->getInput('pageEditContent', null)) ? '<p>&nbsp;</p>' : $this->getInput('pageEditContent', null)),
'hideTitle' => $hideTitle,
'breadCrumb' => $this->getInput('pageEditbreadCrumb', helper::FILTER_BOOLEAN),
'metaDescription' => $this->getInput('pageEditMetaDescription', helper::FILTER_STRING_LONG),
'metaTitle' => $this->getInput('pageEditMetaTitle'),
'moduleId' => $this->getInput('pageEditModuleId'),
'modulePosition' => $this->getInput('configModulePosition'),
'parentPageId' => $this->getInput('pageEditParentPageId'),
'position' => $position,
'group' => $this->getinput('pageEditBlock') !== 'bar' ? $this->getInput('pageEditGroup', helper::FILTER_INT) : 0,
'targetBlank' => $this->getInput('pageEditTargetBlank', helper::FILTER_BOOLEAN),
'title' => $this->getInput('pageEditTitle', helper::FILTER_STRING_SHORT),
'block' => $this->getinput('pageEditBlock'),
'barLeft' => $barLeft,
'barRight' => $barRight,
'displayMenu' => $this->getinput('pageEditDisplayMenu'),
'hideMenuSide' => $this->getinput('pageEditHideMenuSide', helper::FILTER_BOOLEAN),
'hideMenuHead' => $this->getinput('pageEditHideMenuHead', helper::FILTER_BOOLEAN),
'hideMenuChildren' => $this->getinput('pageEditHideMenuChildren', helper::FILTER_BOOLEAN),
]
]);
// 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 {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $pageId,
'notification' => 'Modifications enregistrées',
'state' => true
]);
}
} else {
// Une barre ne peut pas avoir de barres
$barLeft = "";
$barRight = "";
// Une barre est masquée
$position = 0;
$hideTitle = true;
}
// Liste des modules
$moduleIds = [];
$iterator = new DirectoryIterator('module/');
foreach($iterator as $fileInfos) {
if(is_file($fileInfos->getPathname() . '/' . $fileInfos->getFilename() . '.php')) {
if (array_key_exists($fileInfos->getBasename(),self::$moduleNames)) {
$moduleIds[$fileInfos->getBasename()] = self::$moduleNames[$fileInfos->getBasename()];
} else {
$moduleIds[$fileInfos->getBasename()] = ucfirst($fileInfos->getBasename());
}
}
}
self::$moduleIds = $moduleIds;
asort(self::$moduleIds);
self::$moduleIds = array_merge( ['' => 'Aucun'] , self::$moduleIds);
// Pages sans parent
foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) {
if($parentPageId !== $this->getUrl(2)) {
self::$pagesNoParentId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
}
}
// Pages barre latérales
foreach($this->getHierarchy(null,false,true) as $parentPageId => $childrenPageIds) {
if($parentPageId !== $this->getUrl(2) &&
$this->getData(['page', $parentPageId, 'block']) === 'bar') {
self::$pagesBarId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
}
}
// Valeurs en sortie
$this->addOutput([
'title' => $this->getData(['page', $this->getUrl(2), 'title']),
'vendor' => [
'tinymce'
],
'view' => 'edit'
// Modifie la page ou en crée une nouvelle si l'id a changé
$this->setData([
'page',
$pageId,
[
'typeMenu' => $this->getinput('pageTypeMenu'),
'iconUrl' => $this->getinput('pageIconUrl'),
'disable'=> $this->getinput('pageEditDisable', helper::FILTER_BOOLEAN),
'content' => (empty($this->getInput('pageEditContent', null)) ? '<p>&nbsp;</p>' : $this->getInput('pageEditContent', null)),
'hideTitle' => $hideTitle,
'breadCrumb' => $this->getInput('pageEditbreadCrumb', helper::FILTER_BOOLEAN),
'metaDescription' => $this->getInput('pageEditMetaDescription', helper::FILTER_STRING_LONG),
'metaTitle' => $this->getInput('pageEditMetaTitle'),
'moduleId' => $this->getInput('pageEditModuleId'),
'modulePosition' => $this->getInput('configModulePosition'),
'parentPageId' => $this->getInput('pageEditParentPageId'),
'position' => $position,
'group' => $this->getinput('pageEditBlock') !== 'bar' ? $this->getInput('pageEditGroup', helper::FILTER_INT) : 0,
'targetBlank' => $this->getInput('pageEditTargetBlank', helper::FILTER_BOOLEAN),
'title' => $this->getInput('pageEditTitle', helper::FILTER_STRING_SHORT),
'block' => $this->getinput('pageEditBlock'),
'barLeft' => $barLeft,
'barRight' => $barRight,
'displayMenu' => $this->getinput('pageEditDisplayMenu'),
'hideMenuSide' => $this->getinput('pageEditHideMenuSide', helper::FILTER_BOOLEAN),
'hideMenuHead' => $this->getinput('pageEditHideMenuHead', helper::FILTER_BOOLEAN),
'hideMenuChildren' => $this->getinput('pageEditHideMenuChildren', helper::FILTER_BOOLEAN),
]
]);
// 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 {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $pageId,
'notification' => 'Modifications enregistrées',
'state' => true
]);
}
}
// Liste des modules
$moduleIds = [];
$iterator = new DirectoryIterator('module/');
foreach($iterator as $fileInfos) {
if(is_file($fileInfos->getPathname() . '/' . $fileInfos->getFilename() . '.php')) {
if (array_key_exists($fileInfos->getBasename(),self::$moduleNames)) {
$moduleIds[$fileInfos->getBasename()] = self::$moduleNames[$fileInfos->getBasename()];
} else {
$moduleIds[$fileInfos->getBasename()] = ucfirst($fileInfos->getBasename());
}
}
}
self::$moduleIds = $moduleIds;
asort(self::$moduleIds);
self::$moduleIds = array_merge( ['' => 'Aucun'] , self::$moduleIds);
// Pages sans parent
foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) {
if($parentPageId !== $this->getUrl(2)) {
self::$pagesNoParentId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
}
}
// Pages barre latérales
foreach($this->getHierarchy(null,false,true) as $parentPageId => $childrenPageIds) {
if($parentPageId !== $this->getUrl(2) &&
$this->getData(['page', $parentPageId, 'block']) === 'bar') {
self::$pagesBarId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
}
}
// Valeurs en sortie
$this->addOutput([
'title' => $this->getData(['page', $this->getUrl(2), 'title']),
'vendor' => [
'tinymce'
],
'view' => 'edit'
]);
}
}

View File

@ -50,16 +50,17 @@ echo template::formOpen('pageEditForm');
<div class="col4">
<div class="row">
<div class="col9">
<?php echo template::hidden('pageEditModuleRedirect'); ?>
<?php echo template::select('pageEditModuleId', $module::$moduleIds, [
'help' => 'En cas de changement de module, les données du module précédent seront supprimées.',
'label' => 'Module',
'selected' => $this->getData(['page', $this->getUrl(2), 'moduleId'])
]); ?>
<?php echo template::hidden('pageEditModuleIdOld',['value' => $this->getData(['page', $this->getUrl(2), 'moduleId'])]); ?>
<?php echo template::hidden('pageEditModuleIdOldText',[
'value' => array_key_exists($this->getData(['page', $this->getUrl(2), 'moduleId']),$module::$moduleNames)? $module::$moduleNames[$this->getData(['page', $this->getUrl(2), 'moduleId'])] : ucfirst($this->getData(['page', $this->getUrl(2), 'moduleId']))
]); ?>
<?php echo template::hidden('pageEditModuleRedirect'); ?>
<?php echo template::select('pageEditModuleId', $module::$moduleIds, [
'help' => 'En cas de changement de module, les données du module précédent seront supprimées.',
'label' => 'Module',
'selected' => $this->getData(['page', $this->getUrl(2), 'moduleId']),
'disabled' => !($module::$actions['delete'] < $this->getUser('group'))
]); ?>
<?php echo template::hidden('pageEditModuleIdOld',['value' => $this->getData(['page', $this->getUrl(2), 'moduleId'])]); ?>
<?php echo template::hidden('pageEditModuleIdOldText',[
'value' => array_key_exists($this->getData(['page', $this->getUrl(2), 'moduleId']),$module::$moduleNames)? $module::$moduleNames[$this->getData(['page', $this->getUrl(2), 'moduleId'])] : ucfirst($this->getData(['page', $this->getUrl(2), 'moduleId']))
]); ?>
</div>
<div class="col3 verticalAlignBottom">
<?php echo template::button('pageEditModuleConfig', [