diff --git a/core/class/layout.class.php b/core/class/layout.class.php index c56a3fe..b399e37 100644 --- a/core/class/layout.class.php +++ b/core/class/layout.class.php @@ -33,7 +33,7 @@ class layout extends common $item .= '

' . $this->getData(['config', 'cookies', 'mainLabel']) . '

'; // Formulaire de réponse if ( - $this->getData(['config', 'homePageId']) === $this->getUrl(0) + $this->homePageId() === $this->getUrl(0) ) { $item .= '
'; } else { @@ -790,7 +790,7 @@ class layout extends common echo '' . $this->core->output['metaTitle'] . ''; echo ''; if ( - $this->getData(['config', 'homePageId']) === $this->getUrl(0) + $this->homePageId() === $this->getUrl(0) ) { echo ''; } else { diff --git a/core/class/router.class.php b/core/class/router.class.php index bfbe4a3..6f39918 100644 --- a/core/class/router.class.php +++ b/core/class/router.class.php @@ -536,7 +536,7 @@ class core extends common ) { $access = true; } else { - if ($this->getUrl(0) === $this->getData(['config', 'homePageId'])) { + if ($this->getUrl(0) === $this->homePageId()) { $access = 'login'; } else { $access = false; diff --git a/core/core.php b/core/core.php index abbe82d..f8a8463 100644 --- a/core/core.php +++ b/core/core.php @@ -401,7 +401,7 @@ class common if ($url = $_SERVER['QUERY_STRING']) { $this->url = $url; } else { - $this->url = $this->getData(['config', 'homePageId']); + $this->url = $this->homePageId(); } } @@ -1051,7 +1051,7 @@ class common // Page désactivée, traiter les sous-pages sans prendre en compte la page parente. if ($this->getData(['page', $parentPageId, 'disable']) !== true) { // Cas de la page d'accueil ne pas dupliquer l'URL - $pageId = ($parentPageId !== $this->getData(['config', 'homePageId'])) ? $parentPageId : ''; + $pageId = ($parentPageId !== $this->homePageId()) ? $parentPageId : ''; $sitemap->addUrl('/' . $pageId, $datetime); } // Articles du blog @@ -1072,7 +1072,7 @@ class common continue; } // Cas de la page d'accueil ne pas dupliquer l'URL - $pageId = ($childKey !== $this->getData(['config', 'homePageId'])) ? $childKey : ''; + $pageId = ($childKey !== $this->homePageId()) ? $childKey : ''; $sitemap->addUrl('/' . $childKey, $datetime); // La sous-page est un blog @@ -1369,6 +1369,21 @@ class common $zip->close(); } + /** + * Retourne l'id de la page d'accueil + * @return string pageId + */ + public function homePageId() + { + switch (self::$siteContent) { + case 'home': + return ($this->getData(['config', 'homePageId'])); + default: + return ($this->getData(['course', self::$siteContent, 'homePageId'])); + } + + } + /** * Journalisation diff --git a/core/module/config/view/locale/locale.php b/core/module/config/view/locale/locale.php index cbd7854..dca3ef2 100644 --- a/core/module/config/view/locale/locale.php +++ b/core/module/config/view/locale/locale.php @@ -46,7 +46,7 @@
'Accueil', - 'selected' => $this->getData(['config', 'homePageId']), + 'selected' => $this->homePageId(), 'help' => 'La première page que vos visiteurs verront.' ]); ?>
diff --git a/core/module/course/course.php b/core/module/course/course.php index ae51425..8205d7d 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -48,18 +48,20 @@ class course extends common public static $swapMessage = []; + public static $pagesList = []; + public function index() { $courseIdShortTitle = helper::arrayColumn($this->getData(['course']), 'shortTitle'); ksort($courseIdShortTitle); foreach ($courseIdShortTitle as $courseId => $courseTitle) { - $categorieUrl = helper::baseUrl(!helper::checkRewrite()) . 'course/swap/' . $courseId ; + $categorieUrl = helper::baseUrl(!helper::checkRewrite()) . 'course/swap/' . $courseId; self::$courses[] = [ $courseTitle, $this->getData(['course', $courseId, 'author']), $this->getData(['course', $courseId, 'description']), - '' . $categorieUrl . '', + '' . $categorieUrl . '', template::button('courseEdit' . $courseId, [ 'href' => helper::baseUrl() . 'course/edit/' . $courseId, 'value' => template::ico('pencil'), @@ -94,14 +96,15 @@ class course extends common $this->isPost() ) { $courseId = uniqid(); - $author = $this->getInput('courseAddAuthor'); $this->setData([ 'course', $courseId, [ 'title' => $this->getInput('courseAddTitle', helper::FILTER_STRING_SHORT, true), 'shortTitle' => $this->getInput('courseAddShortTitle', helper::FILTER_STRING_SHORT, true), - 'author' => $author, + 'author' => $this->getInput('courseAddAuthor'), + 'homePageId' => $this->getInput('courseAddHomePageId'), + 'category' => $this->getInput('courseAddCategories'), 'description' => $this->getInput('courseAddDescription', helper::FILTER_STRING_SHORT, true), 'access' => $this->getInput('courseAddAccess', helper::FILTER_INT), 'openingDate' => $this->getInput('courseOpeningDate', helper::FILTER_DATETIME), @@ -144,6 +147,17 @@ class course extends common // Liste des catégories de cours self::$courseCategories = $this->getData(['category']); + // Liste des pages disponibles + self::$pagesList = $this->getData(['page']); + foreach (self::$pagesList as $page => $pageId) { + if ( + $this->getData(['page', $page, 'block']) === 'bar' || + $this->getData(['page', $page, 'disable']) === true + ) { + unset(self::$pagesList[$page]); + } + } + // Valeurs en sortie $this->addOutput([ 'title' => helper::translate('Ajouter un cours'), @@ -163,14 +177,15 @@ class course extends common $this->isPost() ) { $courseId = $this->getUrl(2); - $author = $this->getInput('courseAddAuthor'); $this->setData([ 'course', $courseId, [ 'title' => $this->getInput('courseEditTitle', helper::FILTER_STRING_SHORT, true), 'shortTitle' => $this->getInput('courseEditShortTitle', helper::FILTER_STRING_SHORT, true), - 'author' => $author, + 'author' => $this->getInput('courseEditAuthor'), + 'homePageId' => $this->getInput('courseEditHomePageId'), + 'category' => $this->getInput('courseEditCategories'), 'description' => $this->getInput('courseEditDescription', helper::FILTER_STRING_SHORT, true), 'access' => $this->getInput('courseEditAccess', helper::FILTER_INT), 'openingDate' => $this->getInput('courseOpeningDate', helper::FILTER_DATETIME), @@ -199,6 +214,17 @@ class course extends common // Liste des catégories de cours self::$courseCategories = $this->getData(['category']); + // Liste des pages disponibles + self::$pagesList = $this->getData(['page']); + foreach (self::$pagesList as $page => $pageId) { + if ( + $this->getData(['page', $page, 'block']) === 'bar' || + $this->getData(['page', $page, 'disable']) === true + ) { + unset(self::$pagesList[$page]); + } + } + // Valeurs en sortie $this->addOutput([ 'title' => helper::translate('Editer un cours'), diff --git a/core/module/course/view/add/add.php b/core/module/course/view/add/add.php index 58dd73b..fe3cd6d 100644 --- a/core/module/course/view/add/add.php +++ b/core/module/course/view/add/add.php @@ -37,10 +37,14 @@
-
- + 'Accueil du cours', + ]); ?> +
+
+ 'Catégorie', - 'value' => $this->getdata(['course', $this->getUrl(2), 'category']) ]); ?>
diff --git a/core/module/course/view/edit/edit.php b/core/module/course/view/edit/edit.php index fed361b..0bfac72 100644 --- a/core/module/course/view/edit/edit.php +++ b/core/module/course/view/edit/edit.php @@ -40,8 +40,14 @@
-
- + 'Accueil du cours', + 'selected' => $this->getdata(['course', $this->getUrl(2), 'homePageId']), + ]); ?> +
+
+ 'Catégorie', 'value' => $this->getdata(['course', $this->getUrl(2), 'category']) ]); ?> @@ -66,7 +72,7 @@ 'datetime-local', 'label' => 'Ouverture', - 'value' => is_null($this->getdata(['course', $this->getUrl(2), 'openingDate'])) ? '' :floor($this->getdata(['course', $this->getUrl(2), 'openingDate']) / 60) * 60 + 'value' => is_null($this->getdata(['course', $this->getUrl(2), 'openingDate'])) ? '' : floor($this->getdata(['course', $this->getUrl(2), 'openingDate']) / 60) * 60 ]); ?>
diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index 09416b3..24802d2 100644 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -682,7 +682,6 @@ class init extends common 'disable' => false, 'content' => 'accueil.html', 'hideTitle' => false, - 'homePageId' => true, 'breadCrumb' => false, 'metaDescription' => '', 'metaTitle' => '', @@ -984,7 +983,6 @@ class init extends common 'disable' => false, 'content' => 'accueil.html', 'hideTitle' => false, - 'homePageId' => true, 'breadCrumb' => false, 'metaDescription' => '', 'metaTitle' => '', diff --git a/core/module/page/page.php b/core/module/page/page.php index 5d8ee96..3d957b0 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -211,7 +211,7 @@ class page extends common ]); } // Impossible de supprimer la page d'accueil - elseif ($page === $this->getData(['config', 'homePageId'])) { + elseif ($page === $this->homePageId()) { // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . 'config', diff --git a/core/module/sitemap/sitemap.php b/core/module/sitemap/sitemap.php index beb947c..8cbad33 100644 --- a/core/module/sitemap/sitemap.php +++ b/core/module/sitemap/sitemap.php @@ -30,7 +30,7 @@ class sitemap extends common foreach ($this->getHierarchy(null, true, null) as $parentId => $childIds) { $items .= '
  • '; if ($this->getData(['page', $parentId, 'disable']) === false && $this->getUser('group') >= $this->getData(['page', $parentId, 'group'])) { - $pageUrl = ($parentId !== $this->getData(['config', 'homePageId'])) ? helper::baseUrl() . $parentId : helper::baseUrl(false); + $pageUrl = ($parentId !== $this->homePageId()) ? helper::baseUrl() . $parentId : helper::baseUrl(false); $items .= '' . $this->getData(['page', $parentId, 'title']) . ''; } else { // page désactivée @@ -67,7 +67,7 @@ class sitemap extends common // Sous-page $items .= '
  • '; if ($this->getData(['page', $childId, 'disable']) === false && $this->getUser('group') >= $this->getData(['page', $parentId, 'group'])) { - $pageUrl = ($childId !== $this->getData(['config', 'homePageId'])) ? helper::baseUrl() . $childId : helper::baseUrl(false); + $pageUrl = ($childId !== $this->homePageId()) ? helper::baseUrl() . $childId : helper::baseUrl(false); $items .= '' . $this->getData(['page', $childId, 'title']) . ''; } else { // page désactivée