2018-04-02 08:29:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file is part of Zwii.
|
|
|
|
*
|
|
|
|
* For full copyright and license information, please see the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
* @author Rémi Jean <remi.jean@outlook.com>
|
|
|
|
* @copyright Copyright (C) 2008-2018, Rémi Jean
|
2019-01-30 19:38:17 +01:00
|
|
|
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
2020-01-21 08:53:30 +01:00
|
|
|
* @copyright Copyright (C) 2018-2020, Frédéric Tempez
|
2018-04-02 08:29:19 +02:00
|
|
|
* @license GNU General Public License, version 3
|
2020-09-01 20:48:40 +02:00
|
|
|
* @link http://zwiicms.fr/
|
2018-04-02 08:29:19 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
class page extends common {
|
|
|
|
|
|
|
|
public static $actions = [
|
|
|
|
'add' => self::GROUP_MODERATOR,
|
|
|
|
'delete' => self::GROUP_MODERATOR,
|
2020-09-20 16:06:58 +02:00
|
|
|
'edit' => self::GROUP_MODERATOR,
|
|
|
|
'duplicate' => self::GROUP_MODERATOR
|
2018-04-02 08:29:19 +02:00
|
|
|
];
|
|
|
|
public static $pagesNoParentId = [
|
|
|
|
'' => 'Aucune'
|
|
|
|
];
|
2019-01-30 19:38:17 +01:00
|
|
|
public static $pagesBarId = [
|
|
|
|
'' => 'Aucune'
|
2020-06-02 18:49:24 +02:00
|
|
|
];
|
2018-04-02 08:29:19 +02:00
|
|
|
public static $moduleIds = [];
|
2020-04-04 19:15:32 +02:00
|
|
|
// Nom des modules
|
|
|
|
public static $moduleNames = [
|
|
|
|
'news' => 'Nouvelles',
|
|
|
|
'blog' => 'Blog',
|
|
|
|
'form' => 'Formulaire',
|
|
|
|
'gallery' => 'Galerie',
|
2020-08-14 16:09:46 +02:00
|
|
|
'redirection' => 'Redirection',
|
2020-11-19 08:41:19 +01:00
|
|
|
'search' => 'Recherche'
|
2020-04-04 19:15:32 +02:00
|
|
|
];
|
2018-04-02 08:29:19 +02:00
|
|
|
public static $typeMenu = [
|
|
|
|
'text' => 'Texte',
|
|
|
|
'icon' => 'Icône',
|
2020-08-15 10:03:36 +02:00
|
|
|
'icontitle' => 'Icône avec bulle de texte'
|
2018-04-02 08:29:19 +02:00
|
|
|
];
|
2018-10-23 10:21:57 +02:00
|
|
|
// Position du module
|
|
|
|
public static $modulePosition = [
|
2019-01-04 18:53:24 +01:00
|
|
|
'bottom' => 'En bas',
|
2019-03-07 23:23:32 +01:00
|
|
|
'top' => 'En haut',
|
|
|
|
'free' => 'Libre'
|
2018-10-23 10:21:57 +02:00
|
|
|
];
|
2019-01-14 20:54:55 +01:00
|
|
|
public static $pageBlocks = [
|
2019-06-26 19:22:27 +02:00
|
|
|
'12' => 'Page standard',
|
|
|
|
'4-8' => 'Barre 1/3 - page 2/3',
|
2019-07-14 15:34:56 +02:00
|
|
|
'8-4' => 'Page 2/3 - barre 1/3',
|
2019-06-26 19:22:27 +02:00
|
|
|
'3-9' => 'Barre 1/4 - page 3/4',
|
2019-07-14 15:34:56 +02:00
|
|
|
'9-3' => 'Page 3/4 - barre 1/4',
|
2019-06-26 19:22:27 +02:00
|
|
|
'3-6-3' => 'Barre 1/4 - page 1/2 - barre 1/4',
|
|
|
|
'2-7-3' => 'Barre 2/12 - page 7/12 - barre 3/12 ',
|
|
|
|
'3-7-2' => 'Barre 3/12 - page 7/12 - barre 2/12 ',
|
2019-03-07 23:23:32 +01:00
|
|
|
'bar' => 'Barre latérale'
|
2019-01-14 20:54:55 +01:00
|
|
|
];
|
2019-05-02 13:21:48 +02:00
|
|
|
public static $displayMenu = [
|
|
|
|
'none' => 'Aucun',
|
2020-06-07 18:55:38 +02:00
|
|
|
'parents' => 'Le menu',
|
2019-12-03 10:59:17 +01:00
|
|
|
'children' => 'Le sous-menu de la page parente'
|
2019-05-02 13:21:48 +02:00
|
|
|
];
|
2020-06-02 18:49:24 +02:00
|
|
|
|
2020-09-20 16:06:58 +02:00
|
|
|
/**
|
|
|
|
* Duplication
|
|
|
|
*/
|
|
|
|
public function duplicate() {
|
|
|
|
// 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'
|
|
|
|
]);
|
|
|
|
}
|
2020-09-20 17:53:50 +02:00
|
|
|
// Duplication de la page
|
2020-09-20 16:06:58 +02:00
|
|
|
$pageTitle = $this->getData(['page',$url[0],'title']);
|
|
|
|
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
|
|
|
|
$data = $this->getData([
|
|
|
|
'page',
|
|
|
|
$url[0]
|
|
|
|
]);
|
2020-09-20 17:53:50 +02:00
|
|
|
// Ecriture
|
2020-09-20 16:06:58 +02:00
|
|
|
$this->setData (['page',$pageId,$data]);
|
2020-09-20 17:53:50 +02:00
|
|
|
$notification = 'La page a été dupliquée';
|
|
|
|
// Duplication du module présent
|
|
|
|
if ($this->getData(['page',$url[0],'moduleId'])) {
|
|
|
|
$data = $this->getData([
|
|
|
|
'module',
|
|
|
|
$url[0]
|
|
|
|
]);
|
|
|
|
// Ecriture
|
|
|
|
$this->setData (['module',$pageId,$data]);
|
|
|
|
$notification = 'La page et son module ont été dupliqués';
|
|
|
|
}
|
2020-09-20 16:06:58 +02:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'page/edit/' . $pageId,
|
2020-09-20 17:53:50 +02:00
|
|
|
'notification' => $notification,
|
2020-09-20 16:06:58 +02:00
|
|
|
'state' => true
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
/**
|
|
|
|
* Création
|
|
|
|
*/
|
|
|
|
public function add() {
|
|
|
|
$pageTitle = 'Nouvelle page';
|
|
|
|
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
|
|
|
|
$this->setData([
|
|
|
|
'page',
|
|
|
|
$pageId,
|
2020-06-02 18:49:24 +02:00
|
|
|
[
|
2018-04-02 08:29:19 +02:00
|
|
|
'typeMenu' => 'text',
|
|
|
|
'iconUrl' => '',
|
2020-06-02 18:49:24 +02:00
|
|
|
'disable' => false,
|
2018-04-02 08:29:19 +02:00
|
|
|
'content' => 'Contenu de votre nouvelle page.',
|
|
|
|
'hideTitle' => false,
|
2019-02-06 16:54:10 +01:00
|
|
|
'breadCrumb' => false,
|
2018-04-02 08:29:19 +02:00
|
|
|
'metaDescription' => '',
|
|
|
|
'metaTitle' => '',
|
|
|
|
'moduleId' => '',
|
|
|
|
'parentPageId' => '',
|
2018-10-23 10:21:57 +02:00
|
|
|
'modulePosition' => 'bottom',
|
2018-04-02 08:29:19 +02:00
|
|
|
'position' => 0,
|
|
|
|
'group' => self::GROUP_VISITOR,
|
|
|
|
'targetBlank' => false,
|
2019-01-14 20:54:55 +01:00
|
|
|
'title' => $pageTitle,
|
2019-01-30 19:38:17 +01:00
|
|
|
'block' => '12',
|
|
|
|
'barLeft' => '',
|
2019-05-02 13:21:48 +02:00
|
|
|
'barRight' => '',
|
|
|
|
'displayMenu' => '0',
|
|
|
|
'hideMenuSide' => false,
|
|
|
|
'hideMenuHead' => false,
|
|
|
|
'hideMenuChildren' => false
|
2018-04-02 08:29:19 +02:00
|
|
|
]
|
|
|
|
]);
|
2019-05-02 13:21:48 +02:00
|
|
|
// Met à jour le site map
|
|
|
|
$this->createSitemap('all');
|
2018-04-02 08:29:19 +02:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . $pageId,
|
|
|
|
'notification' => 'Nouvelle page créée',
|
|
|
|
'state' => true
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Suppression
|
|
|
|
*/
|
|
|
|
public function delete() {
|
2019-01-04 23:27:35 +01:00
|
|
|
// $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
|
|
|
|
]);
|
2020-09-20 16:06:58 +02:00
|
|
|
} // 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'
|
|
|
|
]);
|
2019-01-04 23:27:35 +01:00
|
|
|
}
|
|
|
|
// Impossible de supprimer la page d'accueil
|
2020-11-21 15:09:10 +01:00
|
|
|
elseif($url[0] === $this->getData(['locale', 'homePageId'])) {
|
2019-01-04 23:27:35 +01:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
2020-09-16 15:04:14 +02:00
|
|
|
'redirect' => helper::baseUrl() . 'config',
|
|
|
|
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
|
2019-01-04 23:27:35 +01:00
|
|
|
]);
|
|
|
|
}
|
2020-09-16 14:59:21 +02:00
|
|
|
// Impossible de supprimer la page de recherche affectée
|
2020-11-21 15:09:10 +01:00
|
|
|
elseif($url[0] === $this->getData(['locale', 'searchPageId'])) {
|
2020-09-16 14:59:21 +02:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
2020-09-16 15:04:14 +02:00
|
|
|
'redirect' => helper::baseUrl() . 'config',
|
|
|
|
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
|
2020-09-16 14:59:21 +02:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Impossible de supprimer la page des mentions légales affectée
|
2020-11-21 15:09:10 +01:00
|
|
|
elseif($url[0] === $this->getData(['locale', 'legalPageId'])) {
|
2020-10-11 05:06:08 +02:00
|
|
|
// 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
|
2020-11-21 15:09:10 +01:00
|
|
|
elseif($url[0] === $this->getData(['locale', 'page404'])) {
|
2020-09-16 15:04:14 +02:00
|
|
|
// 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
|
2020-11-21 15:09:10 +01:00
|
|
|
elseif($url[0] === $this->getData(['locale', 'page403'])) {
|
2020-09-16 15:04:14 +02:00
|
|
|
// 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
|
2020-11-21 15:09:10 +01:00
|
|
|
elseif($url[0] === $this->getData(['locale', 'page302'])) {
|
2020-09-16 15:04:14 +02:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'config',
|
|
|
|
'notification' => 'Désactiver la page dans la configuration avant de la supprimer'
|
2020-09-16 14:59:21 +02:00
|
|
|
]);
|
|
|
|
}
|
2019-01-04 23:27:35 +01:00
|
|
|
// Jeton incorrect
|
2019-01-05 23:03:23 +01:00
|
|
|
elseif(!isset($_GET['csrf'])) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
|
|
|
'notification' => 'Jeton invalide'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
|
2019-01-04 23:27:35 +01:00
|
|
|
// 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
|
2020-06-02 18:49:24 +02:00
|
|
|
else {
|
|
|
|
// Effacer la page
|
2019-01-04 23:27:35 +01:00
|
|
|
$this->deleteData(['page', $url[0]]);
|
|
|
|
$this->deleteData(['module', $url[0]]);
|
2020-10-11 03:49:39 +02:00
|
|
|
// Met à jour le site map
|
|
|
|
$this->createSitemap('all');
|
2019-01-04 23:27:35 +01:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl(false),
|
|
|
|
'notification' => 'Page supprimée',
|
|
|
|
'state' => true
|
|
|
|
]);
|
|
|
|
}
|
2018-04-02 08:29:19 +02:00
|
|
|
}
|
2020-06-02 18:49:24 +02:00
|
|
|
|
2019-01-04 18:53:24 +01:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
/**
|
|
|
|
* Édition
|
|
|
|
*/
|
|
|
|
public function edit() {
|
|
|
|
// La page n'existe pas
|
|
|
|
if($this->getData(['page', $this->getUrl(2)]) === null) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'access' => false
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
// La page existe
|
|
|
|
else {
|
|
|
|
// Soumission du formulaire
|
2020-06-02 18:49:24 +02:00
|
|
|
if($this->isPost()) {
|
2020-08-08 19:41:12 +02:00
|
|
|
// 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);
|
|
|
|
}
|
2019-03-25 09:38:49 +01:00
|
|
|
// un dossier existe du même nom (erreur en cas de redirection)
|
|
|
|
if (file_exists($pageId)) {
|
2020-04-23 07:49:55 +02:00
|
|
|
$pageId = uniqid($pageId);
|
2020-06-02 18:49:24 +02:00
|
|
|
}
|
2018-04-02 08:29:19 +02:00
|
|
|
// Si l'id a changée
|
2019-02-20 12:38:20 +01:00
|
|
|
if ($pageId !== $this->getUrl(2)) {
|
2018-04-02 08:29:19 +02:00
|
|
|
// Incrémente le nouvel id de la page
|
2019-02-20 12:38:20 +01:00
|
|
|
$pageId = helper::increment($pageId, $this->getData(['page']));
|
|
|
|
$pageId = helper::increment($pageId, self::$coreModuleIds);
|
|
|
|
$pageId = helper::increment($pageId, self::$moduleIds);
|
2018-04-02 08:29:19 +02:00
|
|
|
// 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
|
2020-11-21 15:09:10 +01:00
|
|
|
if($this->getData(['locale', 'homePageId']) === $this->getUrl(2)) {
|
|
|
|
$this->setData(['locale', 'homePageId', $pageId]);
|
2018-04-02 08:29:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// 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)]);
|
|
|
|
}
|
2020-09-16 14:59:21 +02:00
|
|
|
// Traitement des pages spéciales affectées dans la config :
|
2020-11-21 15:09:10 +01:00
|
|
|
if ($this->getUrl(2) === $this->getData(['locale', 'legalPageId']) ) {
|
|
|
|
$this->setData(['locale','legalPageId', $pageId]);
|
2020-09-16 14:59:21 +02:00
|
|
|
}
|
2020-11-21 15:09:10 +01:00
|
|
|
if ($this->getUrl(2) === $this->getData(['locale', 'searchPageId']) ) {
|
|
|
|
$this->setData(['locale','searchPageId', $pageId]);
|
2020-09-16 14:59:21 +02:00
|
|
|
}
|
2020-11-21 15:09:10 +01:00
|
|
|
if ($this->getUrl(2) === $this->getData(['locale', 'page404']) ) {
|
|
|
|
$this->setData(['locale','page404', $pageId]);
|
2020-09-16 14:59:21 +02:00
|
|
|
}
|
2020-11-21 15:09:10 +01:00
|
|
|
if ($this->getUrl(2) === $this->getData(['locale', 'page403']) ) {
|
|
|
|
$this->setData(['locale','page403', $pageId]);
|
2020-09-16 14:59:21 +02:00
|
|
|
}
|
2020-11-21 15:09:10 +01:00
|
|
|
if ($this->getUrl(2) === $this->getData(['locale', 'page302']) ) {
|
|
|
|
$this->setData(['locale','page302', $pageId]);
|
2020-09-16 14:59:21 +02:00
|
|
|
}
|
2018-04-02 08:29:19 +02:00
|
|
|
// 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
|
|
|
|
$lastPosition++;
|
|
|
|
}
|
2019-01-30 19:38:17 +01:00
|
|
|
if ($this->getinput('pageEditBlock') !== 'bar') {
|
|
|
|
$barLeft = $this->getinput('pageEditBarLeft');
|
|
|
|
$barRight = $this->getinput('pageEditBarRight');
|
2019-05-02 13:21:48 +02:00
|
|
|
$hideTitle = $this->getInput('pageEditHideTitle', helper::FILTER_BOOLEAN);
|
2019-02-02 12:04:01 +01:00
|
|
|
|
2019-01-30 19:38:17 +01:00
|
|
|
} else {
|
2020-06-02 18:49:24 +02:00
|
|
|
// Une barre ne peut pas avoir de barres
|
2019-01-30 19:38:17 +01:00
|
|
|
$barLeft = "";
|
|
|
|
$barRight = "";
|
2019-02-02 12:04:01 +01:00
|
|
|
// Une barre est masquée
|
|
|
|
$position = 0;
|
2019-05-02 13:21:48 +02:00
|
|
|
$hideTitle = true;
|
2019-01-30 19:38:17 +01:00
|
|
|
}
|
|
|
|
// Modifie la page ou en crée une nouvelle si l'id a changé
|
2018-04-02 08:29:19 +02:00
|
|
|
$this->setData([
|
|
|
|
'page',
|
|
|
|
$pageId,
|
2020-06-02 18:49:24 +02:00
|
|
|
[
|
2018-04-08 21:04:40 +02:00
|
|
|
'typeMenu' => $this->getinput('pageTypeMenu'),
|
|
|
|
'iconUrl' => $this->getinput('pageIconUrl'),
|
2020-06-02 18:49:24 +02:00
|
|
|
'disable'=> $this->getinput('pageEditDisable', helper::FILTER_BOOLEAN),
|
2019-09-26 09:20:02 +02:00
|
|
|
'content' => (empty($this->getInput('pageEditContent', null)) ? '<p> </p>' : $this->getInput('pageEditContent', null)),
|
2019-05-02 13:21:48 +02:00
|
|
|
'hideTitle' => $hideTitle,
|
2019-02-06 16:54:10 +01:00
|
|
|
'breadCrumb' => $this->getInput('pageEditbreadCrumb', helper::FILTER_BOOLEAN),
|
2018-04-02 08:29:19 +02:00
|
|
|
'metaDescription' => $this->getInput('pageEditMetaDescription', helper::FILTER_STRING_LONG),
|
|
|
|
'metaTitle' => $this->getInput('pageEditMetaTitle'),
|
|
|
|
'moduleId' => $this->getInput('pageEditModuleId'),
|
2018-10-23 10:21:57 +02:00
|
|
|
'modulePosition' => $this->getInput('configModulePosition'),
|
2018-04-02 08:29:19 +02:00
|
|
|
'parentPageId' => $this->getInput('pageEditParentPageId'),
|
|
|
|
'position' => $position,
|
2019-12-01 14:51:51 +01:00
|
|
|
'group' => $this->getinput('pageEditBlock') !== 'bar' ? $this->getInput('pageEditGroup', helper::FILTER_INT) : 0,
|
2018-04-02 08:29:19 +02:00
|
|
|
'targetBlank' => $this->getInput('pageEditTargetBlank', helper::FILTER_BOOLEAN),
|
2019-12-03 08:08:59 +01:00
|
|
|
'title' => $this->getInput('pageEditTitle', helper::FILTER_STRING_SHORT),
|
2019-01-30 19:38:17 +01:00
|
|
|
'block' => $this->getinput('pageEditBlock'),
|
|
|
|
'barLeft' => $barLeft,
|
2019-05-02 13:21:48 +02:00
|
|
|
'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),
|
2018-04-02 08:29:19 +02:00
|
|
|
]
|
2020-06-02 18:49:24 +02:00
|
|
|
]);
|
2019-02-10 14:27:31 +01:00
|
|
|
// 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]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-02 13:21:48 +02:00
|
|
|
// Met à jour le site map
|
|
|
|
$this->createSitemap('all');
|
2018-04-02 08:29:19 +02:00
|
|
|
// 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
|
2020-04-07 10:41:41 +02:00
|
|
|
$moduleIds = [];
|
2018-04-02 08:29:19 +02:00
|
|
|
$iterator = new DirectoryIterator('module/');
|
|
|
|
foreach($iterator as $fileInfos) {
|
|
|
|
if(is_file($fileInfos->getPathname() . '/' . $fileInfos->getFilename() . '.php')) {
|
2020-04-04 19:15:32 +02:00
|
|
|
if (array_key_exists($fileInfos->getBasename(),self::$moduleNames)) {
|
|
|
|
$moduleIds[$fileInfos->getBasename()] = self::$moduleNames[$fileInfos->getBasename()];
|
|
|
|
} else {
|
|
|
|
$moduleIds[$fileInfos->getBasename()] = ucfirst($fileInfos->getBasename());
|
|
|
|
}
|
2020-06-02 18:49:24 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-04 19:15:32 +02:00
|
|
|
self::$moduleIds = $moduleIds;
|
|
|
|
asort(self::$moduleIds);
|
2020-04-07 10:41:41 +02:00
|
|
|
self::$moduleIds = array_merge( ['' => 'Aucun'] , self::$moduleIds);
|
2018-04-02 08:29:19 +02:00
|
|
|
// Pages sans parent
|
|
|
|
foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) {
|
|
|
|
if($parentPageId !== $this->getUrl(2)) {
|
|
|
|
self::$pagesNoParentId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
|
|
|
|
}
|
2020-06-02 18:49:24 +02:00
|
|
|
}
|
2019-01-30 19:38:17 +01:00
|
|
|
// 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']);
|
|
|
|
}
|
2020-06-02 18:49:24 +02:00
|
|
|
}
|
2018-04-02 08:29:19 +02:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'title' => $this->getData(['page', $this->getUrl(2), 'title']),
|
|
|
|
'vendor' => [
|
|
|
|
'tinymce'
|
|
|
|
],
|
|
|
|
'view' => 'edit'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-02 09:23:39 +02:00
|
|
|
}
|