2018-04-02 08:29:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2021-02-17 13:51:12 +01:00
|
|
|
* This file is part of Zwii.
|
2018-04-02 08:29:19 +02:00
|
|
|
* 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
|
2021-02-17 13:49:58 +01:00
|
|
|
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
|
|
|
* @copyright Copyright (C) 2018-2021, 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
|
|
|
*/
|
|
|
|
|
2021-12-10 15:39:09 +01:00
|
|
|
class sitemap extends common
|
|
|
|
{
|
|
|
|
public static $actions = [
|
|
|
|
'index' => self::GROUP_VISITOR
|
|
|
|
];
|
2018-04-02 08:29:19 +02:00
|
|
|
|
2021-12-10 15:39:09 +01:00
|
|
|
public static $siteMap = '';
|
2018-04-02 08:29:19 +02:00
|
|
|
|
2021-12-10 15:39:09 +01:00
|
|
|
/**
|
|
|
|
* Plan du site
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$items = '<ul>';
|
|
|
|
foreach ($this->getHierarchy(null, true, null) as $parentId => $childIds) {
|
2021-12-10 15:57:51 +01:00
|
|
|
$items .= ' <li>';
|
|
|
|
if ($this->getData(['page', $parentId, 'disable']) === false && $this->getUser('group') >= $this->getData(['page', $parentId, 'group'])) {
|
2021-12-11 09:58:12 +01:00
|
|
|
$pageUrl = ($parentId !== $this->getData(['locale', 'homePageId'])) ? helper::baseUrl() . $parentId : helper::baseUrl(false);
|
|
|
|
$items .= '<a href="' . $pageUrl .'">' .$this->getData(['page', $parentId, 'title']) . '</a>';
|
2021-12-10 15:39:09 +01:00
|
|
|
} else {
|
|
|
|
// page désactivée
|
2021-12-10 15:57:51 +01:00
|
|
|
$items .= $this->getData(['page', $parentId, 'title']);
|
2021-12-10 15:39:09 +01:00
|
|
|
}
|
2021-12-10 15:57:51 +01:00
|
|
|
// ou articles d'un blog
|
|
|
|
|
|
|
|
if ($this->getData(['page', $parentId, 'moduleId']) === 'blog' &&
|
|
|
|
!empty($this->getData(['module',$parentId, 'posts' ]))) {
|
|
|
|
$items .= '<ul>';
|
2021-12-10 15:39:09 +01:00
|
|
|
// Ids des articles par ordre de publication
|
2021-12-10 15:57:51 +01:00
|
|
|
$articleIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $parentId,'posts']), 'publishedOn', 'SORT_DESC');
|
|
|
|
$articleIdsStates = helper::arrayCollumn($this->getData(['module', $parentId, 'posts']), 'state', 'SORT_DESC');
|
2021-12-10 15:39:09 +01:00
|
|
|
$articleIds = [];
|
|
|
|
foreach ($articleIdsPublishedOns as $articleId => $articlePublishedOn) {
|
|
|
|
if ($articlePublishedOn <= time() and $articleIdsStates[$articleId]) {
|
|
|
|
$articleIds[] = $articleId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach ($articleIds as $articleId => $article) {
|
2021-12-10 15:57:51 +01:00
|
|
|
if ($this->getData(['module',$parentId,'posts',$article,'state']) === true) {
|
|
|
|
$items .= ' <li>';
|
|
|
|
$items .= '<a href="' . helper::baseUrl() . $parentId. '/' . $article . '">' . $this->getData(['module',$parentId,'posts',$article,'title']) . '</a>';
|
2021-12-10 15:39:09 +01:00
|
|
|
$items .= '</li>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$items .= '</ul>';
|
2021-12-10 15:57:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($childIds as $childId) {
|
|
|
|
$items .= '<ul>';
|
|
|
|
// Sous-page
|
|
|
|
$items .= ' <li>';
|
|
|
|
if ($this->getData(['page', $childId, 'disable']) === false && $this->getUser('group') >= $this->getData(['page', $parentId, 'group'])) {
|
2021-12-11 09:58:12 +01:00
|
|
|
$pageUrl = ($childId !== $this->getData(['locale', 'homePageId'])) ? helper::baseUrl() . $childId : helper::baseUrl(false) ;
|
|
|
|
$items .= '<a href="' . $pageUrl . '">' . $this->getData(['page', $childId, 'title']) . '</a>';
|
2021-12-10 15:57:51 +01:00
|
|
|
} else {
|
|
|
|
// page désactivée
|
|
|
|
$items .= $this->getData(['page', $childId, 'title']);
|
|
|
|
}
|
|
|
|
$items .= '</li>';
|
|
|
|
|
|
|
|
// Articles d'une sous-page blog
|
|
|
|
if ($this->getData(['page', $childId, 'moduleId']) === 'blog' &&
|
|
|
|
!empty($this->getData(['module', $childId, 'posts' ]))) {
|
|
|
|
$items .= '<ul>';
|
|
|
|
// Ids des articles par ordre de publication
|
|
|
|
$articleIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $childId,'posts']), 'publishedOn', 'SORT_DESC');
|
|
|
|
$articleIdsStates = helper::arrayCollumn($this->getData(['module', $childId, 'posts']), 'state', 'SORT_DESC');
|
|
|
|
$articleIds = [];
|
|
|
|
foreach ($articleIdsPublishedOns as $articleId => $articlePublishedOn) {
|
|
|
|
if ($articlePublishedOn <= time() and $articleIdsStates[$articleId]) {
|
|
|
|
$articleIds[] = $articleId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach ($articleIds as $articleId => $article) {
|
|
|
|
if ($this->getData(['module',$childId,'posts',$article,'state']) === true) {
|
|
|
|
$items .= ' <li>';
|
|
|
|
$items .= '<a href="' . helper::baseUrl() . $childId . '/' . $article . '">' . $this->getData(['module',$childId,'posts',$article,'title']) . '</a>';
|
|
|
|
$items .= '</li>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$items .= '</ul>';
|
|
|
|
}
|
|
|
|
$items .= '</ul>';
|
2021-12-10 15:39:09 +01:00
|
|
|
}
|
2021-12-10 15:57:51 +01:00
|
|
|
$items .= '</li>';
|
2021-12-10 15:39:09 +01:00
|
|
|
}
|
2021-12-10 15:57:51 +01:00
|
|
|
// Fin du grand bloc
|
|
|
|
$items .= '</ul>';
|
2021-12-10 15:39:09 +01:00
|
|
|
self::$siteMap = $items;
|
|
|
|
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'title' => 'Plan du site',
|
|
|
|
'view' => 'index'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|