ZwiiCMS/module/blog/view/index/index.php

213 lines
9.7 KiB
PHP
Raw Normal View History

2023-03-23 07:43:23 +01:00
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'feeds'])): ?>
<div id="rssFeed">
<a type="application/rss+xml" href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/rss'; ?>" target="_blank">
<img src='module/blog/ressource/feed-icon-16.gif' />
<?php
echo $this->getData(['module', $this->getUrl(0), 'config', 'feedsLabel']) ? '<p>' . $this->getData(['module', $this->getUrl(0), 'config', 'feedsLabel']) . '</p>' : '';
?>
</a>
</div>
<?php endif; ?>
<?php if ($module::$articles): ?>
2023-05-30 21:06:26 +02:00
<article id="article">
2023-03-23 07:43:23 +01:00
<?php foreach ($module::$articles as $articleId => $article): ?>
2023-03-24 16:56:04 +01:00
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'layout']) === true): ?>
<div class="readMoreModernContainer">
<div class="row">
<div class="col12">
<h2 class="blogTitle">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
<?php echo $article['title']; ?>
</a>
</h2>
</div>
2022-03-17 12:55:16 +01:00
</div>
2023-03-24 16:56:04 +01:00
<div class="row">
<div class="col6 blogEdit">
<!-- bloc signature -->
2024-10-15 14:40:13 +02:00
<?php if (
$this->getData(['module', $this->getUrl(0), 'config', 'showPseudo']) === true
): ?>
<?php echo template::ico('user'); ?>
<?php echo $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'userId'])); ?>
<?php endif; ?>
<!-- bloc Date -->
<?php if (
$this->getData(['module', $this->getUrl(0), 'config', 'showDate']) === true
|| $this->getData(['module', $this->getUrl(0), 'config', 'showTime']) === true
): ?>
<?php echo template::ico('calendar-empty', ['margin' => 'left']); ?>
<?php endif; ?>
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'showDate']) === true): ?>
<?php echo helper::dateUTF8($module::$dateFormat, $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn']), self::$i18nUI); ?>
<?php endif; ?>
<?php if (
$this->getData(['module', $this->getUrl(0), 'config', 'showDate']) === true
&& $this->getData(['module', $this->getUrl(0), 'config', 'showTime']) === true
): ?>
<?php echo '&nbsp;-&nbsp;'; ?>
<?php endif; ?>
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'showTime']) === true): ?>
<?php echo helper::dateUTF8($module::$timeFormat, $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn']), self::$i18nUI); ?>
<?php endif; ?>
2023-03-24 16:56:04 +01:00
</div>
2022-10-07 20:13:55 +02:00
</div>
2023-03-24 16:56:04 +01:00
<div class="row">
<div class="col12">
<?php if (
$this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'picture']) &&
file_exists(self::FILE_DIR . 'source/' . $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'picture']))
): ?>
<?php $pictureSize = $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'pictureSize']) === null ? '100' : $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'pictureSize']); ?>
<?php if ($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'hidePicture']) == false) {
echo '<img class="blogArticlePicture blogArticlePicture' . $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'picturePosition']) .
' pict' . $pictureSize . '" src="' . helper::baseUrl(false) . self::FILE_DIR . 'source/' . $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'picture']) .
'" alt="' . $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'picture']) . '">';
} ?>
<?php endif; ?>
<?php echo $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'content']); ?>
</div>
2022-03-17 12:55:16 +01:00
</div>
2023-03-24 16:56:04 +01:00
<div class="row">
<div class="col6 blogEdit">
<!-- Bloc edition -->
<?php if (
2024-09-06 17:32:29 +02:00
$this->isConnected() === true
2023-03-24 16:56:04 +01:00
and
( // Propriétaire
($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'editConsent']) === $module::EDIT_OWNER
and ($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'userId']) === $this->getUser('id')
or $this->getUser('group') === self::GROUP_ADMIN)
)
or (
// Groupe
($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'editConsent']) === self::GROUP_ADMIN
2023-07-05 18:04:42 +02:00
or $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'editConsent']) === self::GROUP_EDITOR)
2023-03-24 16:56:04 +01:00
and $this->getUser('group') >= $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'editConsent'])
)
or (
// Tout le monde
$this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'editConsent']) === $module::EDIT_ALL
and $this->getUser('group') >= $module::$actions['config']
)
2022-03-17 12:55:16 +01:00
)
2023-03-24 16:56:04 +01:00
): ?>
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/edit/' . $articleId; ?>">
2023-03-24 16:56:04 +01:00
<?php echo template::ico('pencil'); ?> Éditer
</a>
<?php endif; ?>
</div>
<div class="col6 textAlignRight" id="comment">
<?php if ($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'commentClose'])): ?>
<p>Cet article ne reçoit pas de commentaire.</p>
<?php else: ?>
<p>
<?php echo template::ico('comment', ['margin' => 'right']); ?>
<?php
if ($module::$comments[$articleId] > 0) {
echo '<a href="' . helper::baseUrl() . $this->getUrl(0) . '/' . $articleId . '">';
echo $module::$comments[$articleId] . ' commentaire' . ($module::$comments[$articleId] > 1 ? 's' : '');
echo '</a>';
} else {
echo 'Pas encore de commentaire';
}
?>
</p>
<?php endif; ?>
</div>
2022-03-17 12:55:16 +01:00
</div>
2024-10-09 20:49:27 +02:00
</div>
<?php else: ?>
<div class="row">
<?php if (
$article['picture'] &&
file_exists(self::FILE_DIR . 'source/' . $article['picture'])
): ?>
<div class="col3">
2024-10-10 19:57:27 +02:00
<?php
2024-10-09 20:49:27 +02:00
// Déterminer le nom de la miniature
2024-10-10 19:57:27 +02:00
$parts = pathinfo($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'picture']));
$thumb = 'mini_' . $parts['basename'];
// Créer la miniature si manquante
if (!file_exists(self::FILE_DIR . 'thumb/' . $thumb)) {
$this->makeThumb(
self::FILE_DIR . 'source/' . $article['picture'],
self::FILE_DIR . 'thumb/' . $thumb,
self::THUMBS_WIDTH
);
}
2024-10-09 20:49:27 +02:00
?>
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>" class="blogPicture">
<img src="<?php echo helper::baseUrl(false) . self::FILE_DIR . 'thumb/' . $thumb; ?>"
alt="<?php echo $article['picture']; ?>">
</a>
</div>
<div class="col9">
2024-10-10 19:57:27 +02:00
<?php else: ?>
<div class="col12">
<?php endif; ?>
<h2 class="blogTitle">
2024-10-09 20:49:27 +02:00
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
2024-10-10 19:57:27 +02:00
<?php echo $article['title']; ?>
</a>
</h2>
<div class="blogComment">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>#comment">
<?php if ($module::$comments[$articleId]): ?>
<?php echo $module::$comments[$articleId]; ?>
<?php echo template::ico('comment', ['margin' => 'left']); ?>
<?php endif; ?>
2024-10-09 20:49:27 +02:00
</a>
2023-03-24 08:48:30 +01:00
</div>
2024-10-10 19:57:27 +02:00
<div class="blogDate">
<!-- bloc signature -->
2024-10-15 14:40:13 +02:00
<?php if (
$this->getData(['module', $this->getUrl(0), 'config', 'showPseudo']) === true
): ?>
<?php echo template::ico('user'); ?>
<?php echo $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'userId'])); ?>
<?php endif; ?> <!-- bloc date -->
<?php if (
$this->getData(['module', $this->getUrl(0), 'config', 'showDate']) === true
|| $this->getData(['module', $this->getUrl(0), 'config', 'showTime']) === true
): ?>
<?php echo template::ico('calendar-empty', ['margin' => 'left']); ?>
<?php endif; ?>
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'showDate']) === true): ?>
<?php echo helper::dateUTF8($module::$dateFormat, $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn']), self::$i18nUI); ?>
2024-10-10 19:57:27 +02:00
<?php endif; ?>
<?php if (
$this->getData(['module', $this->getUrl(0), 'config', 'showDate']) === true
&& $this->getData(['module', $this->getUrl(0), 'config', 'showTime']) === true
): ?>
<?php echo '&nbsp;-&nbsp;'; ?>
<?php endif; ?>
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'showTime']) === true): ?>
<?php echo helper::dateUTF8($module::$timeFormat, $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn']), self::$i18nUI); ?>
<?php endif; ?>
<div class="blogContent">
<?php $lenght = $this->getData(['module', $this->getUrl(0), 'config', 'articlesLenght']); ?>
<?php if ($lenght > 0): ?>
<?php ?>
<?php echo helper::subword($article['content'], 0, $lenght); ?>...
<div class="readMoreContainer">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
<button class="readMoreButton">
<?php echo helper::translate('Lire la suite'); ?>
</button>
</a>
</div>
<?php else: ?>
<?php echo $article['content']; ?>
<?php endif; ?>
</div>
2024-10-10 19:57:27 +02:00
</div>
2024-10-09 20:49:27 +02:00
</div>
2023-03-23 07:43:23 +01:00
</div>
2024-10-10 19:57:27 +02:00
<?php endif; ?>
<?php endforeach; ?>
2022-03-17 12:55:16 +01:00
</article>
2018-04-02 08:29:19 +02:00
<?php echo $module::$pages; ?>
2023-03-23 07:43:23 +01:00
<?php else: ?>
2023-01-13 17:16:39 +01:00
<?php echo template::speech('Aucun article'); ?>
2022-10-07 20:13:55 +02:00
<?php endif; ?>