2022-01-31 09:10:49 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file is part of DeltaCMS.
|
|
|
|
* For full copyright and license information, please see the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
* @author Sylvain Lelièvre <lelievresylvain@free.fr>
|
|
|
|
* @copyright Copyright (C) 2021-2022, Sylvain Lelièvre
|
|
|
|
* @license GNU General Public License, version 3
|
|
|
|
* @link https://deltacms.fr/
|
|
|
|
*
|
|
|
|
* Delta was created from version 11.2.00.24 of ZwiiCMS
|
|
|
|
* @author Rémi Jean <remi.jean@outlook.com>
|
|
|
|
* @copyright Copyright (C) 2008-2018, Rémi Jean
|
|
|
|
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
|
|
|
* @copyright Copyright (C) 2018-2021, Frédéric Tempez
|
|
|
|
*/
|
|
|
|
|
|
|
|
class page extends common {
|
|
|
|
|
|
|
|
public static $actions = [
|
|
|
|
'add' => self::GROUP_MODERATOR,
|
|
|
|
'delete' => self::GROUP_MODERATOR,
|
2022-11-07 16:37:05 +01:00
|
|
|
'edit' => self::GROUP_EDITOR,
|
2022-01-31 09:10:49 +01:00
|
|
|
'duplicate' => self::GROUP_MODERATOR
|
|
|
|
];
|
|
|
|
|
2022-09-11 09:42:42 +02:00
|
|
|
public static $moduleIds = [];
|
|
|
|
public static $pagesBarId = [];
|
|
|
|
public static $pagesNoParentId = [];
|
2022-01-31 09:10:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Duplication
|
|
|
|
*/
|
|
|
|
public function duplicate() {
|
2022-03-06 13:35:21 +01:00
|
|
|
// Lexique
|
2022-09-11 09:42:42 +02:00
|
|
|
include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php');
|
2022-03-06 13:35:21 +01:00
|
|
|
$text = [];
|
|
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
|
|
switch ($val) {
|
|
|
|
case 'fr' :
|
|
|
|
$text[0] = 'Jeton invalide';
|
|
|
|
$text[1] = 'Suppression non autorisée';
|
|
|
|
$text[2] = 'La page a été dupliquée';
|
|
|
|
$text[3] = 'La page et son module ont été dupliqués';
|
|
|
|
break;
|
|
|
|
case 'en' :
|
|
|
|
$text[0] = 'Invalid token';
|
|
|
|
$text[1] = 'Unauthorised deletion';
|
|
|
|
$text[2] = 'The page has been duplicated';
|
|
|
|
$text[3] = 'The page and its module have been duplicated';
|
|
|
|
break;
|
|
|
|
}
|
2022-01-31 09:10:49 +01:00
|
|
|
// 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],
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[0]
|
2022-01-31 09:10:49 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[1]
|
2022-01-31 09:10:49 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Duplication de la page
|
|
|
|
$pageTitle = $this->getData(['page',$url[0],'title']);
|
|
|
|
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
|
|
|
|
$pageId = helper::increment($pageId, self::$coreModuleIds);
|
|
|
|
$pageId = helper::increment($pageId, self::$moduleIds);
|
|
|
|
$data = $this->getData([
|
|
|
|
'page',
|
|
|
|
$url[0]
|
|
|
|
]);
|
|
|
|
// Ecriture
|
|
|
|
$this->setData (['page',$pageId,$data]);
|
2022-03-06 13:35:21 +01:00
|
|
|
$notification = $text[2];
|
2022-01-31 09:10:49 +01:00
|
|
|
// Duplication du module présent
|
|
|
|
if ($this->getData(['page',$url[0],'moduleId'])) {
|
|
|
|
$data = $this->getData([
|
|
|
|
'module',
|
|
|
|
$url[0]
|
|
|
|
]);
|
|
|
|
// Ecriture
|
|
|
|
$this->setData (['module',$pageId,$data]);
|
2022-03-06 13:35:21 +01:00
|
|
|
$notification = $text[3];
|
2022-01-31 09:10:49 +01:00
|
|
|
}
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'page/edit/' . $pageId,
|
|
|
|
'notification' => $notification,
|
|
|
|
'state' => true
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Création
|
|
|
|
*/
|
|
|
|
public function add() {
|
2022-03-06 13:35:21 +01:00
|
|
|
// Lexique
|
2022-09-11 09:42:42 +02:00
|
|
|
include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php');
|
2022-03-06 13:35:21 +01:00
|
|
|
$text = [];
|
|
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
|
|
switch ($val) {
|
|
|
|
case 'fr' :
|
|
|
|
$text[0] = 'Nouvelle page';
|
|
|
|
$text[1] = 'Contenu de votre nouvelle page.';
|
|
|
|
$text[2] = 'Nouvelle page créée';
|
|
|
|
break;
|
|
|
|
case 'en' :
|
|
|
|
$text[0] = 'New page';
|
|
|
|
$text[1] = 'Content of your new page';
|
|
|
|
$text[2] = 'New page created';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$pageTitle = $text[0];
|
2022-01-31 09:10:49 +01:00
|
|
|
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
|
|
|
|
$this->setData([
|
|
|
|
'page',
|
|
|
|
$pageId,
|
|
|
|
[
|
|
|
|
'typeMenu' => 'text',
|
|
|
|
'iconUrl' => '',
|
|
|
|
'disable' => false,
|
|
|
|
'content' => $pageId . '.html',
|
|
|
|
'hideTitle' => false,
|
|
|
|
'breadCrumb' => false,
|
|
|
|
'metaDescription' => '',
|
|
|
|
'metaTitle' => '',
|
|
|
|
'moduleId' => '',
|
|
|
|
'parentPageId' => '',
|
|
|
|
'modulePosition' => 'bottom',
|
2022-07-05 08:16:26 +02:00
|
|
|
'position' => 100,
|
2022-01-31 09:10:49 +01:00
|
|
|
'group' => self::GROUP_VISITOR,
|
|
|
|
'targetBlank' => false,
|
|
|
|
'title' => $pageTitle,
|
2022-07-05 08:16:26 +02:00
|
|
|
'shortTitle' => $pageTitle,
|
2022-01-31 09:10:49 +01:00
|
|
|
'block' => '12',
|
|
|
|
'barLeft' => '',
|
|
|
|
'barRight' => '',
|
|
|
|
'displayMenu' => '0',
|
|
|
|
'hideMenuSide' => false,
|
|
|
|
'hideMenuHead' => false,
|
|
|
|
'hideMenuChildren' => false
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
// Creation du contenu de la page
|
|
|
|
if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) {
|
|
|
|
mkdir(self::DATA_DIR . self::$i18n . '/content', 0755);
|
|
|
|
}
|
2022-03-06 13:35:21 +01:00
|
|
|
$this->setPage($pageId, '<p>'.$text[1].'</p>', self::$i18n);
|
2022-01-31 09:10:49 +01:00
|
|
|
// Met à jour le site map
|
2022-09-02 08:44:18 +02:00
|
|
|
// $this->createSitemap('all');
|
2022-01-31 09:10:49 +01:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . $pageId,
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[2],
|
2022-01-31 09:10:49 +01:00
|
|
|
'state' => true
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Suppression
|
|
|
|
*/
|
|
|
|
public function delete() {
|
2022-03-06 13:35:21 +01:00
|
|
|
// Lexique
|
2022-09-11 09:42:42 +02:00
|
|
|
include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php');
|
2022-03-06 13:35:21 +01:00
|
|
|
$text = [];
|
|
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
|
|
switch ($val) {
|
|
|
|
case 'fr' :
|
|
|
|
$text[0] = 'Jeton invalide';
|
|
|
|
$text[1] = 'Suppression non autorisée';
|
|
|
|
$text[2] = 'Désactiver la page dans la configuration avant de la supprimer';
|
|
|
|
$text[3] = 'Impossible de supprimer une page contenant des enfants';
|
|
|
|
$text[4] = 'Page supprimée';
|
|
|
|
break;
|
|
|
|
case 'en' :
|
|
|
|
$text[0] = 'Invalid token';
|
|
|
|
$text[1] = 'Unauthorised deletion';
|
|
|
|
$text[2] = 'Disable page in configuration before deleting';
|
|
|
|
$text[3] = 'Cannot delete page with children';
|
|
|
|
$text[4] = 'Page deleted';
|
|
|
|
break;
|
|
|
|
}
|
2022-01-31 09:10:49 +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
|
|
|
|
]);
|
|
|
|
} // Jeton incorrect
|
|
|
|
elseif(!isset($_GET['csrf'])) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[0]
|
2022-01-31 09:10:49 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[1]
|
2022-01-31 09:10:49 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Impossible de supprimer la page d'accueil
|
|
|
|
elseif($url[0] === $this->getData(['locale', 'homePageId'])) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'config',
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[2]
|
2022-01-31 09:10:49 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Impossible de supprimer la page de recherche affectée
|
|
|
|
elseif($url[0] === $this->getData(['locale', 'searchPageId'])) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'config',
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[2]
|
2022-01-31 09:10:49 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Impossible de supprimer la page des mentions légales affectée
|
|
|
|
elseif($url[0] === $this->getData(['locale', 'legalPageId'])) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'config',
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[2]
|
2022-01-31 09:10:49 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Impossible de supprimer la page des mentions légales affectée
|
|
|
|
elseif($url[0] === $this->getData(['locale', 'page404'])) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'config',
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[2]
|
2022-01-31 09:10:49 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Impossible de supprimer la page des mentions légales affectée
|
|
|
|
elseif($url[0] === $this->getData(['locale', 'page403'])) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'config',
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[2]
|
2022-01-31 09:10:49 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Impossible de supprimer la page des mentions légales affectée
|
|
|
|
elseif($url[0] === $this->getData(['locale', 'page302'])) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'config',
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[2]
|
2022-01-31 09:10:49 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Jeton incorrect
|
|
|
|
elseif(!isset($_GET['csrf'])) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[0]
|
2022-01-31 09:10:49 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[1]
|
2022-01-31 09:10:49 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Impossible de supprimer une page contenant des enfants
|
|
|
|
elseif($this->getHierarchy($url[0],null)) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[3]
|
2022-01-31 09:10:49 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Suppression
|
|
|
|
else {
|
|
|
|
|
|
|
|
// Effacer le dossier du module
|
|
|
|
$moduleId = $this->getData(['page',$url[0],'moduleId']);
|
|
|
|
$modulesData = helper::getModules();
|
|
|
|
if (is_dir($modulesData[$moduleId]['dataDirectory']. $url[0])) {
|
|
|
|
$this->removeDir( $modulesData[$moduleId]['dataDirectory']. $url[0] );
|
|
|
|
}
|
|
|
|
// Effacer la page
|
|
|
|
$this->deleteData(['page', $url[0]]);
|
|
|
|
if (file_exists(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html')) {
|
|
|
|
unlink(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html');
|
|
|
|
}
|
|
|
|
$this->deleteData(['module', $url[0]]);
|
|
|
|
// Met à jour le site map
|
2022-09-02 08:44:18 +02:00
|
|
|
// $this->createSitemap('all');
|
2022-07-05 08:16:26 +02:00
|
|
|
// Met à jour 'config', 'statislite', 'enable' si aucume page utilise le module Statislite
|
|
|
|
$inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
|
|
|
|
$statislite = 'off';
|
|
|
|
foreach($inPages as $key=>$value){
|
|
|
|
if( $value === 'statislite') $statislite = 'on';
|
|
|
|
}
|
|
|
|
if( $statislite === 'off') $this->setData(['config', 'statislite', 'enable', false ]);
|
2022-01-31 09:10:49 +01:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl(false),
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[4],
|
2022-01-31 09:10:49 +01:00
|
|
|
'state' => true
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Édition
|
|
|
|
*/
|
|
|
|
public function edit() {
|
2022-03-06 13:35:21 +01:00
|
|
|
// Lexique
|
2022-09-11 09:42:42 +02:00
|
|
|
include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php');
|
2022-03-06 13:35:21 +01:00
|
|
|
$text = [];
|
|
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
|
|
switch ($val) {
|
|
|
|
case 'fr' :
|
|
|
|
$text[0] = 'Modifications enregistrées';
|
|
|
|
$text[1] ='Aucun';
|
|
|
|
break;
|
|
|
|
case 'en' :
|
|
|
|
$text[0] = 'Registered changes';
|
|
|
|
$text[1] ='None';
|
|
|
|
break;
|
|
|
|
}
|
2022-01-31 09:10:49 +01:00
|
|
|
// 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
|
|
|
|
if($this->isPost()) {
|
|
|
|
// Si le Title n'est pas vide, premier test pour positionner la notification du champ obligatoire
|
|
|
|
if( $this->getInput('pageEditTitle', helper::FILTER_ID, true) !== null && $this->getInput('pageEditTitle') !== '' ){
|
|
|
|
// 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),null) as $childrenPageId) {
|
|
|
|
$this->setData(['page', $childrenPageId, 'parentPageId', $pageId]);
|
|
|
|
}
|
|
|
|
// Change l'id de page dans les données des modules
|
|
|
|
if ($this->getData(['module', $this->getUrl(2)]) !== null ) {
|
|
|
|
$this->setData(['module', $pageId, $this->getData(['module', $this->getUrl(2)])]);
|
|
|
|
$this->deleteData(['module', $this->getUrl(2)]);
|
|
|
|
// Renommer le dossier du module
|
|
|
|
$moduleId = $this->getData(['page',$this->getUrl(2),'moduleId']);
|
|
|
|
$modulesData = helper::getModules();
|
|
|
|
if (is_dir($modulesData[$moduleId]['dataDirectory']. $this->getUrl(2))) {
|
|
|
|
// Placer la feuille de style dans un dossier au nom de la nouvelle instance
|
|
|
|
mkdir( $modulesData[$moduleId]['dataDirectory']. $pageId, 0755 );
|
|
|
|
copy( $modulesData[$moduleId]['dataDirectory']. $this->getUrl(2), $modulesData[$moduleId]['dataDirectory']. $pageId);
|
|
|
|
$this->removeDir($modulesData[$moduleId]['dataDirectory']. $this->getUrl(2));
|
|
|
|
// Mettre à jour le nom de la feuille de style
|
|
|
|
$this->setData(['module',$pageId,'theme','style', $modulesData[$moduleId]['dataDirectory']. $pageId]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Si la page correspond à la page d'accueil, change l'id dans la configuration du site
|
|
|
|
if($this->getData(['locale', 'homePageId']) === $this->getUrl(2)) {
|
|
|
|
$this->setData(['locale', '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)]);
|
|
|
|
unlink (self::DATA_DIR . self::$i18n . '/content/' . $this->getUrl(2) . '.html');
|
|
|
|
}
|
|
|
|
// Traitement des pages spéciales affectées dans la config :
|
|
|
|
if ($this->getUrl(2) === $this->getData(['locale', 'legalPageId']) ) {
|
|
|
|
$this->setData(['locale','legalPageId', $pageId]);
|
|
|
|
}
|
|
|
|
if ($this->getUrl(2) === $this->getData(['locale', 'searchPageId']) ) {
|
|
|
|
$this->setData(['locale','searchPageId', $pageId]);
|
|
|
|
}
|
|
|
|
if ($this->getUrl(2) === $this->getData(['locale', 'page404']) ) {
|
|
|
|
$this->setData(['locale','page404', $pageId]);
|
|
|
|
}
|
|
|
|
if ($this->getUrl(2) === $this->getData(['locale', 'page403']) ) {
|
|
|
|
$this->setData(['locale','page403', $pageId]);
|
|
|
|
}
|
|
|
|
if ($this->getUrl(2) === $this->getData(['locale', 'page302']) ) {
|
|
|
|
$this->setData(['locale','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
|
|
|
|
$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' => $pageId . '.html',
|
|
|
|
'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),
|
|
|
|
'shortTitle' => $this->getInput('pageEditShortTitle', helper::FILTER_STRING_SHORT, true),
|
|
|
|
'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),
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
// 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)) ? '<p></p>' : str_replace('<p></p>', '<p> </p>', $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
|
2022-09-02 08:44:18 +02:00
|
|
|
// $this->createSitemap('all');
|
2022-01-31 09:10:49 +01: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,
|
2022-03-06 13:35:21 +01:00
|
|
|
'notification' => $text[0],
|
2022-01-31 09:10:49 +01:00
|
|
|
'state' => true
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-03-06 13:35:21 +01:00
|
|
|
self::$moduleIds = array_merge( ['' => $text[1]] , helper::arrayCollumn(helper::getModules(),'realName','SORT_ASC')); // Pages sans parent
|
2022-09-11 09:42:42 +02:00
|
|
|
self::$pagesNoParentId = $pagesNoParentId;
|
2022-01-31 09:10:49 +01:00
|
|
|
foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) {
|
|
|
|
if($parentPageId !== $this->getUrl(2)) {
|
|
|
|
self::$pagesNoParentId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
|
2022-09-11 09:42:42 +02:00
|
|
|
//self::$pagesNoParentId_en[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
|
2022-01-31 09:10:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Pages barre latérales
|
2022-09-11 09:42:42 +02:00
|
|
|
self::$pagesBarId = $pagesBarId;
|
2022-01-31 09:10:49 +01:00
|
|
|
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']);
|
2022-09-11 09:42:42 +02:00
|
|
|
//self::$pagesBarId_en[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
|
2022-01-31 09:10:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Mise à jour de la liste des pages pour TinyMCE
|
|
|
|
$this->pages2Json();
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'title' => $this->getData(['page', $this->getUrl(2), 'title']),
|
|
|
|
'view' => 'edit'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|