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

160 lines
7.6 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): ?>
2022-03-17 12:55:16 +01:00
<article>
2023-03-23 07:43:23 +01:00
<?php foreach ($module::$articles as $articleId => $article): ?>
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'articlesLenght']) === 0): ?>
2022-03-17 12:55:16 +01:00
<div class="row">
<div class="col12">
<h2 class="blogTitle">
2022-10-07 20:13:55 +02:00
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
<?php echo $article['title']; ?>
</a>
2022-03-17 12:55:16 +01:00
</h2>
</div>
2022-03-15 09:16:42 +01:00
</div>
2022-10-07 20:13:55 +02:00
<div class="row">
<div class="col6 blogEdit">
<!-- bloc signature et date -->
<?php echo template::ico('user'); ?>
2023-03-23 07:43:23 +01:00
<?php echo $module->signature($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'userId'])); ?>
2022-10-07 20:13:55 +02:00
<?php echo template::ico('calendar-empty'); ?>
2023-03-23 07:43:23 +01:00
<?php echo helper::dateUTF8($module::$dateFormat, $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn'])) . ' - ' . helper::dateUTF8($module::$timeFormat, $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn'])); ?>
2022-10-07 20:13:55 +02:00
</div>
</div>
2022-03-17 12:55:16 +01:00
<div class="row">
<div class="col12">
2022-10-07 20:13:55 +02:00
<?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']))
2023-03-23 07:43:23 +01:00
): ?>
<?php $pictureSize = $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'pictureSize']) === null ? '100' : $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'pictureSize']); ?>
2022-10-07 20:13:55 +02:00
<?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']) .
2022-03-17 12:55:16 +01:00
'" alt="' . $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'picture']) . '">';
2022-10-07 20:13:55 +02:00
} ?>
2022-03-17 12:55:16 +01:00
<?php endif; ?>
2022-10-07 20:13:55 +02:00
<?php echo $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'content']); ?>
2022-03-17 12:55:16 +01:00
</div>
2022-03-15 09:16:42 +01:00
</div>
2022-03-17 12:55:16 +01:00
<div class="row verticalAlignMiddle">
2022-10-07 20:13:55 +02:00
<div class="col6 blogEdit">
2022-03-17 12:55:16 +01:00
<!-- Bloc edition -->
<?php if (
2022-03-15 09:16:42 +01:00
2022-03-17 12:55:16 +01:00
$this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
2022-10-07 20:13:55 +02:00
and
2023-03-23 07:43:23 +01:00
( // 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')
2022-10-07 20:13:55 +02:00
or $this->getUser('group') === self::GROUP_ADMIN)
)
or (
2023-03-23 07:43:23 +01:00
// Groupe
($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'editConsent']) === self::GROUP_ADMIN
or $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'editConsent']) === self::GROUP_MODERATOR)
and $this->getUser('group') >= $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'editConsent'])
2022-10-07 20:13:55 +02:00
)
or (
2022-03-17 12:55:16 +01:00
// Tout le monde
2023-03-23 07:43:23 +01:00
$this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'editConsent']) === $module::EDIT_ALL
2022-10-07 20:13:55 +02:00
and $this->getUser('group') >= $module::$actions['config']
2022-03-17 12:55:16 +01:00
)
)
2023-03-23 07:43:23 +01:00
): ?>
<a
href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/edit/' . $articleId . '/' . $_SESSION['csrf']; ?>">
2022-10-07 20:13:55 +02:00
<?php echo template::ico('pencil'); ?> Éditer
</a>
2022-03-17 12:55:16 +01:00
<?php endif; ?>
</div>
<div class="col6 textAlignRight" id="comment">
2023-03-23 07:43:23 +01:00
<?php if ($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'commentClose'])): ?>
2022-03-17 12:55:16 +01:00
<p>Cet article ne reçoit pas de commentaire.</p>
2023-03-23 07:43:23 +01:00
<?php else: ?>
<p>
2022-09-02 18:14:42 +02:00
<?php echo template::ico('comment', ['margin' => 'right']); ?>
2022-03-17 12:55:16 +01:00
<?php
2022-10-07 20:13:55 +02:00
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 {
2023-03-23 07:43:23 +01:00
echo 'Pas encore de commentaire';
2022-10-07 20:13:55 +02:00
}
2022-03-17 12:55:16 +01:00
?>
</p>
<?php endif; ?>
</div>
2018-04-02 08:29:19 +02:00
</div>
2023-03-23 07:43:23 +01:00
<?php else: ?>
2022-03-17 12:55:16 +01:00
<div class="row rowArticle">
2022-10-07 20:13:55 +02:00
<?php if (
$article['picture'] &&
file_exists(self::FILE_DIR . 'source/' . $article['picture'])
2023-03-23 07:43:23 +01:00
): ?>
2022-03-17 12:55:16 +01:00
<div class="col3">
<?php // Déterminer le nom de la miniature
2023-03-23 07:43:23 +01: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
);
}
?>
2022-03-17 12:55:16 +01:00
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>" class="blogPicture">
2023-03-23 07:43:23 +01:00
<img src="<?php echo helper::baseUrl(false) . self::FILE_DIR . 'thumb/' . $thumb; ?>"
alt="<?php echo $article['picture']; ?>">
2022-03-17 12:55:16 +01:00
</a>
</div>
<div class="col9">
2023-03-23 07:43:23 +01:00
<?php else: ?>
2022-10-07 20:13:55 +02:00
<div class="col12">
<?php endif; ?>
<h2 class="blogTitle">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
<?php echo $article['title']; ?>
</a>
</h2>
<div class="blogComment">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>#comment">
2023-03-23 07:43:23 +01:00
<?php if ($article['comment']): ?>
2022-10-07 20:13:55 +02:00
<?php echo count($article['comment']); ?>
<?php endif; ?>
</a>
<?php echo template::ico('comment', ['margin' => 'left']); ?>
</div>
<div class="blogDate">
2023-03-23 07:43:23 +01:00
<!-- bloc signature et date -->
<?php echo template::ico('user'); ?>
<?php echo $module->signature($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'userId'])); ?>
<?php echo template::ico('calendar-empty'); ?>
<?php echo helper::dateUTF8($module::$dateFormat, $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn'])) . ' - ' . helper::dateUTF8($module::$timeFormat, $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn'])); ?>
2022-10-07 20:13:55 +02:00
</div>
<p class="blogContent">
2023-03-23 07:43:23 +01:00
<?php $lenght = $this->getData(['module', $this->getUrl(0), 'config', 'articlesLenght']) !== 0 ? $this->getData(['module', $this->getUrl(0), 'config', 'articlesLenght']) : 500 ?>
2022-10-07 20:13:55 +02:00
<?php echo helper::subword(strip_tags($article['content'], '<br><p>'), 0, $lenght); ?>...
2022-03-17 12:55:16 +01:00
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">Lire la suite</a>
</p>
2022-10-07 20:13:55 +02:00
</div>
2023-03-23 07:43:23 +01:00
</div>
<?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; ?>