ZwiiCMS, le gestionnaire de site Web sans base de données à installer. Conçu en 2008 par Rémi Jean, le développement a été repris par Frédéric Tempez en 2018. zwii cms nosql json flat file https://www.zwiicms.fr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
5.3 KiB

4 years ago
<?php
/**
2 years ago
* This file is part of Zwii.
4 years ago
* 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
2 years ago
* @author Frédéric Tempez <frederic.tempez@outlook.com>
* @copyright Copyright (C) 2018-2021, Frédéric Tempez
4 years ago
* @license GNU General Public License, version 3
* @link http://zwiicms.fr/
4 years ago
*/
8 months ago
class sitemap extends common
{
public static $actions = [
'index' => self::GROUP_VISITOR
];
4 years ago
8 months ago
public static $siteMap = '';
4 years ago
8 months ago
/**
* Plan du site
*/
public function index()
{
$items = '<ul>';
foreach ($this->getHierarchy(null, true, null) as $parentId => $childIds) {
8 months ago
$items .= ' <li>';
if ($this->getData(['page', $parentId, 'disable']) === false && $this->getUser('group') >= $this->getData(['page', $parentId, 'group'])) {
$items .= '<a href="' .helper::baseUrl() . $parentId .'">' .$this->getData(['page', $parentId, 'title']) . '</a>';
8 months ago
} else {
// page désactivée
8 months ago
$items .= $this->getData(['page', $parentId, 'title']);
8 months ago
}
8 months ago
// ou articles d'un blog
if ($this->getData(['page', $parentId, 'moduleId']) === 'blog' &&
!empty($this->getData(['module',$parentId, 'posts' ]))) {
$items .= '<ul>';
8 months ago
// Ids des articles par ordre de publication
8 months ago
$articleIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $parentId,'posts']), 'publishedOn', 'SORT_DESC');
$articleIdsStates = helper::arrayCollumn($this->getData(['module', $parentId, 'posts']), 'state', 'SORT_DESC');
8 months ago
$articleIds = [];
foreach ($articleIdsPublishedOns as $articleId => $articlePublishedOn) {
if ($articlePublishedOn <= time() and $articleIdsStates[$articleId]) {
$articleIds[] = $articleId;
}
}
foreach ($articleIds as $articleId => $article) {
8 months ago
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>';
8 months ago
$items .= '</li>';
}
}
$items .= '</ul>';
8 months ago
}
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'])) {
$items .= '<a href="' . helper::baseUrl() . $childId . '">' . $this->getData(['page', $childId, 'title']) . '</a>';
} 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>';
8 months ago
}
8 months ago
$items .= '</li>';
8 months ago
}
8 months ago
// Fin du grand bloc
$items .= '</ul>';
8 months ago
self::$siteMap = $items;
// Valeurs en sortie
$this->addOutput([
'title' => 'Plan du site',
'view' => 'index'
]);
}
}