Blog lien permanent + imga ede couvertire non obligatoire

This commit is contained in:
fredtempez 2022-03-16 11:53:26 +01:00
parent 038d85219f
commit b66a9562f1
4 changed files with 49 additions and 42 deletions

View File

@ -210,7 +210,7 @@ class blog extends common {
$newuserid = $this->getUser('id'); $newuserid = $this->getUser('id');
} }
// Incrémente l'id de l'article // Incrémente l'id de l'article
$articleId = helper::increment($this->getInput('blogAddTitle', helper::FILTER_ID), $this->getData(['page'])); $articleId = helper::increment($this->getInput('blogAddPermalink'), $this->getData(['page']));
$articleId = helper::increment($articleId, (array) $this->getData(['module', $this->getUrl(0)])); $articleId = helper::increment($articleId, (array) $this->getData(['module', $this->getUrl(0)]));
$articleId = helper::increment($articleId, array_keys(self::$actions)); $articleId = helper::increment($articleId, array_keys(self::$actions));
// Crée l'article // Crée l'article
@ -218,9 +218,8 @@ class blog extends common {
$this->getUrl(0), $this->getUrl(0),
'posts', 'posts',
$articleId, [ $articleId, [
'comment' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment']),
'content' => $this->getInput('blogAddContent', null), 'content' => $this->getInput('blogAddContent', null),
'picture' => $this->getInput('blogAddPicture', helper::FILTER_STRING_SHORT, true), 'picture' => $this->getInput('blogAddPicture', helper::FILTER_STRING_SHORT),
'hidePicture' => $this->getInput('blogAddHidePicture', helper::FILTER_BOOLEAN), 'hidePicture' => $this->getInput('blogAddHidePicture', helper::FILTER_BOOLEAN),
'pictureSize' => $this->getInput('blogAddPictureSize', helper::FILTER_STRING_SHORT), 'pictureSize' => $this->getInput('blogAddPictureSize', helper::FILTER_STRING_SHORT),
'picturePosition' => $this->getInput('blogAddPicturePosition', helper::FILTER_STRING_SHORT), 'picturePosition' => $this->getInput('blogAddPicturePosition', helper::FILTER_STRING_SHORT),
@ -234,6 +233,7 @@ class blog extends common {
'commentClose' => $this->getInput('blogAddCommentClose', helper::FILTER_BOOLEAN), 'commentClose' => $this->getInput('blogAddCommentClose', helper::FILTER_BOOLEAN),
'commentNotification' => $this->getInput('blogAddCommentNotification', helper::FILTER_BOOLEAN), 'commentNotification' => $this->getInput('blogAddCommentNotification', helper::FILTER_BOOLEAN),
'commentGroupNotification' => $this->getInput('blogAddCommentGroupNotification', helper::FILTER_INT), 'commentGroupNotification' => $this->getInput('blogAddCommentGroupNotification', helper::FILTER_INT),
'comment' => []
] ]
]); ]);
// Valeurs en sortie // Valeurs en sortie
@ -655,7 +655,7 @@ class blog extends common {
else{ else{
$newuserid = $this->getUser('id'); $newuserid = $this->getUser('id');
} }
$articleId = $this->getInput('blogEditTitle', helper::FILTER_ID, true); $articleId = $this->getInput('blogEditPermalink', null, true);
// Incrémente le nouvel id de l'article // Incrémente le nouvel id de l'article
if($articleId !== $this->getUrl(2)) { if($articleId !== $this->getUrl(2)) {
$articleId = helper::increment($articleId, $this->getData(['page'])); $articleId = helper::increment($articleId, $this->getData(['page']));
@ -667,10 +667,9 @@ class blog extends common {
'posts', 'posts',
$articleId, [ $articleId, [
'title' => $this->getInput('blogEditTitle', helper::FILTER_STRING_SHORT, true), 'title' => $this->getInput('blogEditTitle', helper::FILTER_STRING_SHORT, true),
'permalink' => $this->getInput('blogEditPermalink', helper::FILTER_STRING_SHORT, true),
'comment' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment']), 'comment' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment']),
'content' => $this->getInput('blogEditContent', null), 'content' => $this->getInput('blogEditContent', null),
'picture' => $this->getInput('blogEditPicture', helper::FILTER_STRING_SHORT, true), 'picture' => $this->getInput('blogEditPicture', helper::FILTER_STRING_SHORT),
'hidePicture' => $this->getInput('blogEditHidePicture', helper::FILTER_BOOLEAN), 'hidePicture' => $this->getInput('blogEditHidePicture', helper::FILTER_BOOLEAN),
'pictureSize' => $this->getInput('blogEditPictureSize', helper::FILTER_STRING_SHORT), 'pictureSize' => $this->getInput('blogEditPictureSize', helper::FILTER_STRING_SHORT),
'picturePosition' => $this->getInput('blogEditPicturePosition', helper::FILTER_STRING_SHORT), 'picturePosition' => $this->getInput('blogEditPicturePosition', helper::FILTER_STRING_SHORT),
@ -859,7 +858,7 @@ class blog extends common {
if($articlePublishedOn <= time() AND $articleIdsStates[$articleId]) { if($articlePublishedOn <= time() AND $articleIdsStates[$articleId]) {
$articleIds[] = $articleId; $articleIds[] = $articleId;
// Nombre de commentaires approuvés par article // Nombre de commentaires approuvés par article
self::$comments [$articleId] = count ( $this->getData(['module', $this->getUrl(0), 'posts',$articleId, 'comment'])); self::$comments [$articleId] = count ( $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'comment']));
} }
} }
// Pagination // Pagination

View File

@ -1,4 +1,6 @@
# version 6 # version 6
- mise à la norme avec le module news : le formulaire est sorti de l'écran principal - mise à la norme avec le module news : le formulaire est sorti de l'écran principal
- Présentation moderner de la liste des articles - Présentation moderner de la liste des articles
- Respect des balises headings - Respect des balises headings
- permalink des articles
- Image de couverture non obligatoire, présentation adaptive de la liste classique des articles.

View File

@ -37,7 +37,7 @@
<div class="col6"> <div class="col6">
<?php echo template::text('blogEditPermalink', [ <?php echo template::text('blogEditPermalink', [
'label' => 'Permalink', 'label' => 'Permalink',
'value' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'permalink']) 'value' => $this->getUrl(2)
]); ?> ]); ?>
</div> </div>
</div> </div>

View File

@ -12,13 +12,16 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?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, 'picture']) &&
<?php if ($this->getData(['module', $this->getUrl(0), 'posts',$articleId, 'hidePicture']) == false) { file_exists( self::FILE_DIR.'source/' . $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'picture'])) ): ?>
echo '<img class="blogArticlePicture blogArticlePicture' . $this->getData(['module', $this->getUrl(0), 'posts',$articleId, 'picturePosition']) . <?php $pictureSize = $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'pictureSize']) === null ? '100' : $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'pictureSize']); ?>
' pict' . $pictureSize . '" src="' . helper::baseUrl(false) . self::FILE_DIR.'source/' . $this->getData(['module', $this->getUrl(0), 'posts',$articleId, 'picture']) . <?php if ($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'hidePicture']) == false) {
'" alt="' . $this->getData(['module', $this->getUrl(0), 'posts',$articleId, 'picture']) . '">'; 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']) .
<?php echo $this->getData(['module', $this->getUrl(0),'posts',$articleId, 'content']); ?> '" alt="' . $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'picture']) . '">';
} ?>
<?php endif; ?>
<?php echo $this->getData(['module', $this->getUrl(0),'posts', $articleId, 'content']); ?>
</div> </div>
</div> </div>
<div class="row verticalAlignMiddle"> <div class="row verticalAlignMiddle">
@ -27,12 +30,12 @@
<?php echo $module->signature($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'userId']));?> <?php echo $module->signature($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'userId']));?>
<?php echo ' - ';?> <?php echo ' - ';?>
<?php echo template::ico('calendar-empty'); ?> <?php echo template::ico('calendar-empty'); ?>
<?php $date = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts',$articleId, 'publishedOn'])), 'UTF-8', true) <?php $date = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn'])), 'UTF-8', true)
? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts',$articleId, 'publishedOn'])) ? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn']))
: utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts',$articleId, 'publishedOn']))); : utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn'])));
$heure = mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts',$articleId, 'publishedOn'])), 'UTF-8', true) $heure = mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn'])), 'UTF-8', true)
? strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts',$articleId, 'publishedOn'])) ? strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn']))
: utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts',$articleId, 'publishedOn']))); : utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn'])));
echo $date . ' à ' . $heure; echo $date . ' à ' . $heure;
?> ?>
<!-- Bloc edition --> <!-- Bloc edition -->
@ -42,15 +45,15 @@
AND AND
( // Propriétaire ( // Propriétaire
( (
$this->getData(['module', $this->getUrl(0), 'posts',$articleId,'editConsent']) === $module::EDIT_OWNER $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') AND ( $this->getData(['module', $this->getUrl(0), 'posts', $articleId,'userId']) === $this->getUser('id')
OR $this->getUser('group') === self::GROUP_ADMIN ) OR $this->getUser('group') === self::GROUP_ADMIN )
) )
OR ( OR (
// Groupe // Groupe
( $this->getData(['module', $this->getUrl(0), 'posts', $articleId,'editConsent']) === self::GROUP_ADMIN ( $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) 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']) AND $this->getUser('group') >= $this->getData(['module',$this->getUrl(0), 'posts', $articleId,'editConsent'])
) )
OR ( OR (
// Tout le monde // Tout le monde
@ -85,24 +88,27 @@
</div> </div>
<?php else: ?> <?php else: ?>
<div class="row rowArticle"> <div class="row rowArticle">
<div class="col3"> <?php if ( $article['picture'] &&
<?php if ( file_exists(self::FILE_DIR . 'source/' . $article['picture']) ): ?> file_exists( self::FILE_DIR . 'source/' . $article['picture']) ):?>
<?php // Déterminer le nom de la miniature <div class="col3">
$parts = explode('/',$article['picture']); <?php // Déterminer le nom de la miniature
$thumb = str_replace ($parts[(count($parts)-1)],'mini_' . $parts[(count($parts)-1)], $article['picture']); $parts = explode('/',$article['picture']);
// Créer la miniature si manquante $thumb = str_replace ($parts[(count($parts)-1)],'mini_' . $parts[(count($parts)-1)], $article['picture']);
if (!file_exists( self::FILE_DIR . 'thumb/' . $thumb) ) { // Créer la miniature si manquante
$this->makeThumb( self::FILE_DIR . 'source/' . $article['picture'], if (!file_exists( self::FILE_DIR . 'thumb/' . $thumb) ) {
self::FILE_DIR . 'thumb/' . $thumb, $this->makeThumb( self::FILE_DIR . 'source/' . $article['picture'],
self::THUMBS_WIDTH); self::FILE_DIR . 'thumb/' . $thumb,
} self::THUMBS_WIDTH);
?> }
<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 href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>" class="blogPicture">
</a> <img src="<?php echo helper::baseUrl(false) . self::FILE_DIR . 'thumb/' . $thumb; ?>" alt="<?php echo $article['picture']; ?>">
</a>
</div>
<div class="col9">
<?php else:?>
<div class="col12">
<?php endif;?> <?php endif;?>
</div>
<div class="col9">
<h2 class="blogTitle"> <h2 class="blogTitle">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>"> <a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
<?php echo $article['title']; ?> <?php echo $article['title']; ?>