Fix bugs pages

This commit is contained in:
Fred Tempez 2023-07-03 19:49:39 +02:00
parent 2cabb31734
commit 38ed0dc1aa
1 changed files with 81 additions and 79 deletions

View File

@ -74,47 +74,41 @@ class page extends common
// Adresse sans le token // Adresse sans le token
$page = $this->getUrl(2); $page = $this->getUrl(2);
// La page n'existe pas // La page n'existe pas
if ($this->getData(['page', $page]) === null) { if (
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true ||
$this->getData(['page', $page]) === null
) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
]); ]);
} // Action interdite } else {
elseif ($this->checkCSRF()) { // Duplication de la page
// Valeurs en sortie $pageTitle = $this->getData(['page', $page, 'title']);
$this->addOutput([ $pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
'redirect' => helper::baseUrl() . 'page/edit/' . $page, $pageId = helper::increment($pageId, self::$coreModuleIds);
'notification' => helper::translate('Jeton invalide') $pageId = helper::increment($pageId, self::$moduleIds);
]);
}
// Duplication de la page
$pageTitle = $this->getData(['page', $page, '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',
$page
]);
// Ecriture
$this->setData(['page', $pageId, $data]);
$notification = helper::translate('Page dupliquée');
// Duplication du module présent
if ($this->getData(['page', $page, 'moduleId'])) {
$data = $this->getData([ $data = $this->getData([
'module', 'page',
$page $page
]); ]);
// Ecriture // Ecriture
$this->setData(['module', $pageId, $data]); $this->setData(['page', $pageId, $data]);
$notification = helper::translate('Page et module dupliqués'); $notification = helper::translate('Page dupliquée');
// Duplication du module présent
if ($this->getData(['page', $page, 'moduleId'])) {
$data = $this->getData(['module', $page]);
$this->setData(['module', $pageId, $data]);
$notification = helper::translate('Page et module dupliqués');
}
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $pageId,
'notification' => $notification,
'state' => true
]);
} }
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $pageId,
'notification' => $notification,
'state' => true
]);
} }
@ -123,55 +117,63 @@ class page extends common
*/ */
public function add() public function add()
{ {
$pageTitle = 'Nouvelle page'; if ($this->getUser('permission', __CLASS__, __FUNCTION__) !== true) {
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page'])); // Valeurs en sortie
$this->setData([ $this->addOutput([
'page', 'access' => false
$pageId, ]);
[ } else {
'typeMenu' => 'text', $pageTitle = 'Nouvelle page';
'iconUrl' => '', $pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
'disable' => false, $this->setData([
'content' => $pageId . '.html', 'page',
'hideTitle' => false, $pageId,
'breadCrumb' => false, [
'metaDescription' => '', 'typeMenu' => 'text',
'metaTitle' => '', 'iconUrl' => '',
'moduleId' => '', 'disable' => false,
'parentPageId' => '', 'content' => $pageId . '.html',
'modulePosition' => 'bottom', 'hideTitle' => false,
'position' => 0, 'breadCrumb' => false,
'group' => self::GROUP_VISITOR, 'metaDescription' => '',
'targetBlank' => false, 'metaTitle' => '',
'title' => $pageTitle, 'moduleId' => '',
'shortTitle' => $pageTitle, 'parentPageId' => '',
'block' => '12', 'modulePosition' => 'bottom',
'barLeft' => '', 'position' => 0,
'barRight' => '', 'group' => self::GROUP_VISITOR,
'displayMenu' => '0', 'targetBlank' => false,
'hideMenuSide' => false, 'title' => $pageTitle,
'hideMenuHead' => false, 'shortTitle' => $pageTitle,
'hideMenuChildren' => false, 'block' => '12',
'js' => '', 'barLeft' => '',
'css' => '' 'barRight' => '',
] 'displayMenu' => '0',
]); 'hideMenuSide' => false,
// Creation du contenu de la page 'hideMenuHead' => false,
if (!is_dir(self::DATA_DIR . self::$i18nContent . '/content')) { 'hideMenuChildren' => false,
mkdir(self::DATA_DIR . self::$i18nContent . '/content', 0755); 'js' => '',
'css' => ''
]
]);
// Creation du contenu de la page
if (!is_dir(self::DATA_DIR . self::$i18nContent . '/content')) {
mkdir(self::DATA_DIR . self::$i18nContent . '/content', 0755);
}
//file_put_contents(self::DATA_DIR . self::$i18nContent . '/content/' . $pageId . '.html', '<p>Contenu de votre nouvelle page.</p>');
$this->setPage($pageId, '<p>Contenu de votre nouvelle page.</p>', self::$i18nContent);
// Met à jour le sitemap
$this->updateSitemap();
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $pageId,
'notification' => helper::translate('Nouvelle page créée'),
'state' => true
]);
} }
//file_put_contents(self::DATA_DIR . self::$i18nContent . '/content/' . $pageId . '.html', '<p>Contenu de votre nouvelle page.</p>');
$this->setPage($pageId, '<p>Contenu de votre nouvelle page.</p>', self::$i18nContent);
// Met à jour le sitemap
$this->updateSitemap();
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $pageId,
'notification' => helper::translate('Nouvelle page créée'),
'state' => true
]);
} }
/** /**