blog WIP reste pleine page

This commit is contained in:
fredtempez 2022-03-15 09:16:42 +01:00
parent ba58f2052f
commit 10218d0a63
15 changed files with 344 additions and 71 deletions

View File

@ -1959,6 +1959,7 @@ class common {
if(common::$inputNotices) {
$notification = 'Impossible de soumettre le formulaire, car il contient des erreurs';
$notificationClass = 'notificationError';
var_dump(common::$inputNotices) ;
}
if (common::$coreNotices) {
$notification = 'Données absentes, restauration de <p> | ';

View File

@ -77,7 +77,7 @@ class blog extends common {
];
// Nombre d'objets par page
public static $ItemsList = [
public static $ArticlesListed = [
4 => '4 articles',
8 => '8 articles',
12 => '12 articles',
@ -87,11 +87,18 @@ class blog extends common {
//Paramètre longueur maximale des commentaires en nb de caractères
public static $commentLength = [
'500' => '500',
'1000' => '1000',
'2000' => '2000',
'5000' => '5000',
'10000' => '10000'
100 => '100 signes',
250 => '250 signes',
500 => '500 signes',
750 => '750 signes'
];
public static $articlesLenght = [
0 => 'Article complet',
500 => '500 signes',
1000 => '1000 signes',
1500 => '1500 signes',
2000 => '2000 signes'
];
// Permissions d'un article
@ -101,6 +108,7 @@ class blog extends common {
self::EDIT_OWNER => 'Propriétaire'
];
// Nombre d'articles dans la page de config:
public static $itemsperPage = 8;
@ -245,7 +253,8 @@ class blog extends common {
'title' => 'Nouvel article',
'vendor' => [
'flatpickr',
'tinymce'
'tinymce',
'furl'
],
'view' => 'add'
]);
@ -494,7 +503,9 @@ class blog extends common {
'feeds' => $this->getInput('blogOptionShowFeeds',helper::FILTER_BOOLEAN),
'feedsLabel' => $this->getInput('blogOptionFeedslabel',helper::FILTER_STRING_SHORT),
'itemsperPage' => $this->getInput('blogOptionItemsperPage', helper::FILTER_INT,true),
'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData'])
'layout' => $this->getInput('blogOptionLayout',helper::FILTER_BOOLEAN),
'articlesLenght'=> $this->getInput('blogOptionArticlesLenght', helper::FILTER_INT),
'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData']),
]]);
// Valeurs en sortie
$this->addOutput([
@ -654,6 +665,8 @@ class blog extends common {
$this->getUrl(0),
'posts',
$articleId, [
'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']),
'content' => $this->getInput('blogEditContent', null),
'picture' => $this->getInput('blogEditPicture', helper::FILTER_STRING_SHORT, true),
@ -662,7 +675,6 @@ class blog extends common {
'picturePosition' => $this->getInput('blogEditPicturePosition', helper::FILTER_STRING_SHORT),
'publishedOn' => $this->getInput('blogEditPublishedOn', helper::FILTER_DATETIME, true),
'state' => $this->getInput('blogEditState', helper::FILTER_BOOLEAN),
'title' => $this->getInput('blogEditTitle', helper::FILTER_STRING_SHORT, true),
'userId' => $newuserid,
'editConsent' => $this->getInput('blogEditConsent') === self::EDIT_GROUP ? $this->getUser('group') : $this->getInput('blogEditConsent'),
'commentMaxlength' => $this->getInput('blogEditCommentMaxlength'),
@ -699,7 +711,8 @@ class blog extends common {
'title' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'title']),
'vendor' => [
'flatpickr',
'tinymce'
'tinymce',
'furl'
],
'view' => 'edit'
]);
@ -844,6 +857,8 @@ class blog extends common {
foreach($articleIdsPublishedOns as $articleId => $articlePublishedOn) {
if($articlePublishedOn <= time() AND $articleIdsStates[$articleId]) {
$articleIds[] = $articleId;
// Nombre de commentaires approuvés par article
self::$comments [$articleId] = count ( $this->getData(['module', $this->getUrl(0), 'posts',$articleId, 'comment']));
}
}
// Pagination

View File

@ -1,2 +1,3 @@
# 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
- Les images ne sont plus obligatoire et la liste des articles peut être sans tableau.

21
module/blog/vendor/furl/LICENSE vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Vedat Taylan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

4
module/blog/vendor/furl/README.md vendored Normal file
View File

@ -0,0 +1,4 @@
# furl
jQuery Furl (Friendly URL) Plugin 1.0.0
Usage : $('#InputID').furl({id:'ReplaceInputID', seperate (optional) : '_' });

3
module/blog/vendor/furl/inc.json vendored Normal file
View File

@ -0,0 +1,3 @@
[
"jquery.furl.js"
]

76
module/blog/vendor/furl/jquery.furl.js vendored Normal file
View File

@ -0,0 +1,76 @@
/*
* jQuery Furl (Friendly URL) Plugin 1.0.0
*
* Author : Vedat Taylan
*
* Year : 2018
* Usage : $('#InputID').furl({id:'ReplaceInputID', seperate (optional) : '_' });
*/
(function ($, undefined) {
function Furl() {
this.defaults = {
seperate: '-'
};
}
Furl.prototype = {
init: function (target, options) {
var $this = this;
options = $.extend({}, $this.defaults, options);
$(target).keyup(function () {
var url = urlReplace($(this).val(), options);
var $element = $('#' + options.id);
if ($element.length > 0) {
var tagName = $element.get(0).tagName;
switch (tagName) {
case 'INPUT':
$element.val(url);
break;
default:
$element.text(url);
}
}
});
}
};
function urlReplace(url, options) {
return url.toLowerCase()
.replace(/ä/g, 'ae')
.replace(/Ä/g, 'ae')
.replace(/ğ/g, 'g')
.replace(/ü/g, 'u')
.replace(/ş/g, 's')
.replace(/ı/g, 'i')
.replace(/ö/g, 'o')
.replace(/ç/g, 'c')
.replace(/Ğ/g, 'g')
.replace(/Ü/g, 'u')
.replace(/Ş/g, 's')
.replace(/I/g, 'i')
.replace(/İ/g, 'i')
.replace(/Ö/g, 'o')
.replace(/Ç/g, 'c')
.replace(/[^a-z0-9\s-]/g, "")
.replace(/[\s-]+/g, " ")
.replace(/^\s+|\s+$/g, "")
.replace(/\s/g, "-")
.replace(/^\s+|\s+$/g, "")
.replace(/[_|\s]+/g, "-")
.replace(/[^a-z\u0400-\u04FF0-9-]+/g, "")
.replace(/[-]+/g, "-")
.replace(/^-+|-+$/g, "")
.replace(/[-]+/g, options.seperate);
}
$.furl = new Furl();
$.furl.version = "1.0.0";
$.fn.furl = function (options) {
return this.each(function () {
$.furl.init(this, options);
});
};
})(jQuery);

View File

@ -52,4 +52,7 @@ $( document).ready(function() {
} else {
$("#blogAddCommentGroupNotification").slideUp();
}
// Permalink
$('#blogAddTitle').furl({id:'blogAddPermalink', seperate: '_' });
});

View File

@ -28,11 +28,16 @@
<div class="block">
<h4>Informations générales</h4>
<div class="row">
<div class="col12">
<div class="col6">
<?php echo template::text('blogAddTitle', [
'label' => 'Titre'
]); ?>
</div>
<div class="col6">
<?php echo template::text('blogAddPermalink', [
'label' => 'Permalink'
]); ?>
</div>
</div>
<div class="row">
<div class="col4">
@ -55,10 +60,10 @@
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::checkbox('blogAddHidePicture', true, 'Masquer l\'image dans l\'article', [
'checked' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'hidePicture'])
]); ?>
<div class="col6">
<?php echo template::checkbox('blogAddHidePicture', true, 'Masquer l\'image dans l\'article', [
'checked' => true
]); ?>
</div>
</div>
</div>

View File

@ -66,12 +66,12 @@
<?php if($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'commentClose'])): ?>
<p>Cet article ne reçoit pas de commentaire.</p>
<?php else: ?>
<h3 id="comment">
<h5 id="comment">
<?php //$commentsNb = count($module::$comments); ?>
<?php $commentsNb = $module::$nbCommentsApproved; ?>
<?php $s = $commentsNb === 1 ? '': 's' ?>
<?php echo $commentsNb > 0 ? $commentsNb . ' ' . 'commentaire' . $s : 'Pas encore de commentaire'; ?>
</h3>
</h5>
<?php echo template::formOpen('blogArticleForm'); ?>
<?php echo template::text('blogArticleCommentShow', [
'placeholder' => 'Rédiger un commentaire...',

View File

@ -64,4 +64,8 @@ $( document).ready(function() {
} else {
$("#blogEditCommentGroupNotification").slideUp();
}
// Permalink
$('#blogEditTitle').furl({id:'blogEditPermalink', seperate: '_' });
});

View File

@ -28,12 +28,18 @@
<div class="block">
<h4>Informations générales</h4>
<div class="row">
<div class="col12">
<div class="col6">
<?php echo template::text('blogEditTitle', [
'label' => 'Titre',
'value' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'title'])
]); ?>
</div>
<div class="col6">
<?php echo template::text('blogEditPermalink', [
'label' => 'Permalink',
'value' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'permalink'])
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
@ -60,7 +66,7 @@
</div>
<div class="row">
<div class="col6">
<?php echo template::checkbox('blogEditHidePicture', true, 'Masquer l\'image dans l\'article', [
<?php echo template::checkbox('blogEditHidePicture', true, 'Masquer l\'image de couverture dans l\'article', [
'checked' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'hidePicture'])
]); ?>
</div>

View File

@ -14,6 +14,24 @@
*/
}
#sectionTitle {
margin-top: 0;
margin-bottom: 5px;
}
.blogArticlePicture {
height: auto;
border:1px solid lightgray;
box-shadow: 1px 1px 5px;
}
.blogArticlePictureleft {
float: left;
margin: 15px 10px 5px 0 ;
}
.blogArticlePictureright {
float: right;
margin: 15px 0 5px 10px ;
}
.blogPicture:hover {
opacity: .7;
}
@ -55,6 +73,24 @@
}
}
.pict20{
width: 20%;
}
.pict30{
width: 30%;
}
.pict40{
width: 40%;
}
.pict50{
width: 50%;
}
.pict100{
width: 100%;
margin: 15px 0 20px 0 ;
}
/*
* Flux RSS
*/

View File

@ -1,54 +1,132 @@
<?php if($module::$articles): ?>
<div class="row">
<div class="col12">
<?php foreach($module::$articles as $articleId => $article): ?>
<div class="row rowArticle">
<div class="col3">
<?php if ( file_exists(self::FILE_DIR . 'source/' . $article['picture']) ): ?>
<?php // Déterminer le nom de la miniature
$parts = explode('/',$article['picture']);
$thumb = str_replace ($parts[(count($parts)-1)],'mini_' . $parts[(count($parts)-1)], $article['picture']);
// 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);
}
?>
<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']; ?>">
<?php foreach($module::$articles as $articleId => $article): ?>
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'layout']) !== true): ?>
<div class="row rowArticle">
<div class="col3">
<?php if ( file_exists(self::FILE_DIR . 'source/' . $article['picture']) ): ?>
<?php // Déterminer le nom de la miniature
$parts = explode('/',$article['picture']);
$thumb = str_replace ($parts[(count($parts)-1)],'mini_' . $parts[(count($parts)-1)], $article['picture']);
// 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);
}
?>
<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>
<?php endif;?>
</div>
<div class="col9">
<h1 class="blogTitle">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
<?php echo $article['title']; ?>
</a>
<?php endif;?>
</h1>
<div class="blogComment">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>#comment">
<?php if ($article['comment']): ?>
<?php echo count($article['comment']); ?>
<?php endif; ?>
</a>
<?php echo template::ico('comment', 'left'); ?>
</div>
<div class="col9">
<h1 class="blogTitle">
<div class="blogDate">
<?php echo template::ico('calendar-empty'); ?>
<?php echo mb_detect_encoding(strftime('%d %B %Y - %H:%M', $article['publishedOn']), 'UTF-8', true)
? strftime('%d %B %Y', $article['publishedOn'])
: utf8_encode(strftime('%d %B %Y', $article['publishedOn'])); ?>
</div>
<p class="blogContent">
<?php $lenght = $this->getData(['module',$this->getUrl(0), 'config', 'articlesLenght']) !== 0 ? $this->getData(['module',$this->getUrl(0), 'config', 'articlesLenght']) : 500 ?>
<?php echo helper::subword(strip_tags($article['content'],'<br><p>'), 0, $lenght); ?>...
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">Lire la suite</a>
</p>
</div>
</div>
<?php else: ?>
<div class="row">
<div class="col12">
<h1 class="blogTitle">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
<?php echo $article['title']; ?>
</a>
</h1>
<div class="blogComment">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>#comment">
<?php if ($article['comment']): ?>
<?php echo count($article['comment']); ?>
<?php endif; ?>
</a>
<?php echo template::ico('comment', 'left'); ?>
</div>
<div class="blogDate">
<?php echo template::ico('calendar-empty'); ?>
<?php echo mb_detect_encoding(strftime('%d %B %Y - %H:%M', $article['publishedOn']), 'UTF-8', true)
? strftime('%d %B %Y', $article['publishedOn'])
: utf8_encode(strftime('%d %B %Y', $article['publishedOn'])); ?>
</div>
<p class="blogContent">
<?php echo helper::subword(strip_tags($article['content'],'<br><p>'), 0, 400); ?>...
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">Lire la suite</a>
</p>
</div>
</h1>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<div class="row">
<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, '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 echo $this->getData(['module', $this->getUrl(0),'posts',$articleId, 'content']); ?>
</div>
</div>
<div class="row verticalAlignMiddle">
<div class="col12 blogDate">
<!-- bloc signature et date -->
<?php echo $module::$articleSignature . ' - ';?>
<?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)
? 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)
? 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;
?>
<!-- Bloc edition -->
<?php if (
$this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
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
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'])
)
OR (
// Tout le monde
$this->getData(['module', $this->getUrl(0), 'posts', $articleId,'editConsent']) === $module::EDIT_ALL
AND $this->getUser('group') >= $module::$actions['config']
)
)
): ?>
<a href ="<?php echo helper::baseUrl() . $this->getUrl(0) . '/edit/' .$articleId . '/' . $_SESSION['csrf'];?>">
<?php echo template::ico('pencil');?> Editer
</a>
<?php endif; ?>
</div>
</div>
<?php if($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'commentClose'])): ?>
<p>Cet article ne reçoit pas de commentaire.</p>
<?php else: ?>
<h5 id="comment">
<?php //$commentsNb = count($module::$comments); ?>
<?php $commentsNb = $module::$comments[$articleId];?>
<?php $s = $commentsNb === 1 ? '': 's' ?>
<?php
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
<?php echo $article['title']; ?>
</a>
echo $commentsNb > 0 ? $commentsNb . ' ' . 'commentaire' . $s : 'Pas encore de commentaire';
?>
</h5>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php echo $module::$pages; ?>
<?php if ($this->getData(['module',$this->getUrl(0), 'config', 'feeds'])): ?>
<div id="rssFeed">

View File

@ -14,27 +14,47 @@
<div class="row">
<div class="col12">
<div class="block">
<h4>Paramètres du module</h4>
<h4>Flux RSS</h4>
<div class="row">
<div class="col6">
<div class="col4">
<?php echo template::checkbox('blogOptionShowFeeds', true, 'Lien du flux RSS', [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'feeds']),
]); ?>
</div>
<div class="col6">
<div class="col4">
<?php echo template::text('blogOptionFeedslabel', [
'label' => 'Texte de l\'étiquette',
'value' => $this->getData(['module', $this->getUrl(0), 'config', 'feedsLabel'])
]); ?>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>Disposition de la liste des articles</h4>
<div class="row">
<div class="col6 offset6">
<?php echo template::select('blogOptionItemsperPage', $module::$ItemsList, [
'label' => 'Articles par page',
'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage'])
<div class="col4">
<?php echo template::checkbox('blogOptionLayout', true, 'Disposition moderne', [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'layout']),
'help' => 'La disposition moderne affiche les articles les uns à la suite des autres'
]); ?>
</div>
<div class="col4">
<?php echo template::select('blogOptionArticlesLenght', $module::$articlesLenght, [
'label' => 'Longueur des articles',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'articlesLenght'])
]); ?>
</div>
<div class="col4">
<?php echo template::select('blogOptionItemsperPage', $module::$ArticlesListed, [
'label' => 'Articles par page',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'itemsperPage'])
]); ?>
</div>
</div>
</div>
</div>