This commit is contained in:
Fred Tempez 2020-09-25 08:02:52 +02:00
commit dc65a8e618
17 changed files with 872 additions and 220 deletions

View File

@ -1,6 +1,16 @@
# Changelog
## version 10.3.00
- Modifications :
- Module User
- Pour les articles de blog et de news, choix de la signature, nom+prenom ; nom+prenom ; id ; pseudo
- Module Blog :
- Texte du commentaire enrichi.
- Nombre maximal de caractère par commentaire.
- Gestion des commentaires article par article.
- Suppression des commentaires en masse.
- Limiter l'édition des articles et des commentaires à l'id de l'éditeur
- Approbation des commentaires
- Corrections :
- Bloquage de l'incrémentation de l'id de page lorsque deux pages ont le même nom.
- Login : l'option "Se souvenir de moi" est fonctionnelle.

View File

@ -25,6 +25,10 @@ class common {
const GROUP_MEMBER = 1;
const GROUP_MODERATOR = 2;
const GROUP_ADMIN = 3;
const SIGNATURE_ID = 1;
const SIGNATURE_PSEUDO = 2;
const SIGNATURE_FIRSTLASTNAME = 3;
const SIGNATURE_LASTFIRSTNAME = 4;
// Dossier de travail
const BACKUP_DIR = 'site/backup/';
const DATA_DIR = 'site/data/';
@ -39,7 +43,7 @@ class common {
const ACCESS_TIMER = 1800;
// Numéro de version
const ZWII_VERSION = '10.3.00';
const ZWII_VERSION = '10.4.00';
const ZWII_UPDATE_CHANNEL = "v10";
public static $actions = [];
@ -1403,6 +1407,47 @@ class common {
// Mise à jour du numéro de version
$this->setData(['core', 'dataVersion', 10300]);
}
// Version 10.4.00
if ($this->getData(['core', 'dataVersion']) < 10300) {
// Ajouter le prénom comme pseudo et le pseudo comme signature
foreach($this->getData(['user']) as $userId => $userIds){
$this->setData(['user',$userId,'pseudo',$this->getData(['user',$userId,'firstname'])]);
$this->setData(['user',$userId,'signature',2]);
}
// Ajouter les champs de blog v3
// Liste des pages dans pageList
$pageList = array();
foreach ($this->getHierarchy(null,null,null) as $parentKey=>$parentValue) {
$pageList [] = $parentKey;
foreach ($parentValue as $childKey) {
$pageList [] = $childKey;
}
}
// Parcourir pageList et rechercher les modules de blog
foreach ($pageList as $parentKey => $parent) {
//La page a une galerie
if ($this->getData(['page',$parent,'moduleId']) === 'blog' ) {
$articleIds = array_keys(helper::arrayCollumn($this->getData(['module',$parent]), 'publishedOn', 'SORT_DESC'));
foreach ($articleIds as $key => $article) {
// Droits les deux groupes
$this->setData(['module', $parent, $article,'editRights','22']);
// Limite de taille 500
$this->setData(['module', $parent, $article,'commentMaxlength', '500']);
// Pas d'approbation des commentaires
$this->setData(['module', $parent, $article,'commentApprove', false ]);
}
// Traitement des commentaires
if ( is_array($this->getData(['module', $parent, $article,'comment'])) ) {
foreach($this->getData(['module', $parent, $article,'comment']) as $commentId => $comment) {
// Approbation
$this->setData(['module', $parent, $article,'comment', $commentId, 'approval', true ]);
}
}
}
}
$this->setData(['core', 'dataVersion', 10400]);
}
}
}

View File

@ -27,6 +27,14 @@ class user extends common {
public static $users = [];
//Paramètres pour choix de la signature
public static $signature = [
self::SIGNATURE_ID => 'Identifiant',
self::SIGNATURE_PSEUDO => 'Pseudo',
self::SIGNATURE_FIRSTLASTNAME => 'Prénom Nom',
self::SIGNATURE_LASTFIRSTNAME => 'Nom Prénom'
];
public static $userId = '';
public static $userLongtime = false;
@ -208,15 +216,26 @@ class user extends common {
else {
$newGroup = $this->getData(['user', $this->getUrl(2), 'group']);
}
// Modification de nom Prénom
if($this->getUser('group') === self::GROUP_ADMIN){
$newfirstname = $this->getInput('userEditFirstname', helper::FILTER_STRING_SHORT, true);
$newlastname = $this->getInput('userEditLastname', helper::FILTER_STRING_SHORT, true);
}
else{
$newfirstname = $this->getData(['user', $this->getUrl(2), 'firstname']);
$newlastname = $this->getData(['user', $this->getUrl(2), 'lastname']);
}
// Modifie l'utilisateur
$this->setData([
'user',
$this->getUrl(2),
[
'firstname' => $this->getInput('userEditFirstname', helper::FILTER_STRING_SHORT, true),
'firstname' => $newfirstname,
'forgot' => 0,
'group' => $newGroup,
'lastname' => $this->getInput('userEditLastname', helper::FILTER_STRING_SHORT, true),
'lastname' => $newlastname,
'pseudo' => $this->getInput('userEditPseudo', helper::FILTER_STRING_SHORT, true),
'signature' => $this->getInput('userEditSignature', helper::FILTER_INT, true),
'mail' => $this->getInput('userEditMail', helper::FILTER_MAIL, true),
'password' => $newPassword,
'connectFail' => $this->getData(['user',$this->getUrl(2),'connectFail']),

View File

@ -30,6 +30,14 @@
]); ?>
</div>
</div>
<?php echo template::text('userAddPseudo', [
'autocomplete' => 'off',
'label' => 'Pseudo'
]); ?>
<?php echo template::select('userAddSignature', $module::$signature, [
'label' => 'Signature',
'selected' => 1
]); ?>
<?php echo template::mail('userAddMail', [
'autocomplete' => 'off',
'label' => 'Adresse mail'

View File

@ -1,7 +1,7 @@
<?php echo template::formOpen('userEditForm'); ?>
<div class="row">
<div class="col2">
<?php if($this->getUser('group') === self::GROUP_ADMIN): ?>
<?php if($this->getUser('group') === self::GROUP_ADMIN): ?>
<?php echo template::button('userEditBack', [
'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'user',
@ -29,6 +29,7 @@
<div class="col6">
<?php echo template::text('userEditFirstname', [
'autocomplete' => 'off',
'disabled' => $this->getUser('group') > 2 ? false : true,
'label' => 'Prénom',
'value' => $this->getData(['user', $this->getUrl(2), 'firstname'])
]); ?>
@ -36,11 +37,21 @@
<div class="col6">
<?php echo template::text('userEditLastname', [
'autocomplete' => 'off',
'disabled' => $this->getUser('group') > 2 ? false : true,
'label' => 'Nom',
'value' => $this->getData(['user', $this->getUrl(2), 'lastname'])
]); ?>
</div>
</div>
<?php echo template::text('userEditPseudo', [
'autocomplete' => 'off',
'label' => 'Pseudo',
'value' => $this->getData(['user', $this->getUrl(2), 'pseudo'])
]); ?>
<?php echo template::select('userEditSignature', $module::$signature, [
'label' => 'Signature',
'selected' => $this->getData(['user', $this->getUrl(2), 'signature'])
]); ?>
<?php echo template::mail('userEditMail', [
'autocomplete' => 'off',
'label' => 'Adresse mail',

View File

@ -4,6 +4,13 @@
*/
/**
* Quand tinyMCE est invoqué hors connexion, initialiser privateKey
*/
if ( typeof(privateKey) == 'undefined') {
var privateKey = null;
};
tinymce.init({
// Classe où appliquer l'éditeur
selector: ".editorWysiwyg",
@ -118,12 +125,6 @@ tinymce.init({
external_plugins: {
"filemanager": baseUrl + "core/vendor/filemanager/plugin.min.js"
},
// Thème mobile
// mobile: {
// theme: "mobile",
// plugins: [ 'autosave', 'lists', 'autolink' ],
// toolbar: [ 'undo', 'bold', 'italic', 'styleselect' ]
//},
// Contenu du bouton insérer
insert_button_items: "anchor hr table",
// Contenu du bouton formats
@ -206,6 +207,144 @@ tinymce.init({
]
});
tinymce.init({
// Classe où appliquer l'éditeur
selector: ".editorWysiwygComment",
setup:function(ed) {
// Aperçu dans le pied de page
ed.on('change', function(e) {
if (ed.id === 'themeFooterText') {
$("#footerText").html(tinyMCE.get('themeFooterText').getContent());
}
});
// Limitation du nombre de caractères des commentaires à maxlength
var alarmCaraMin = 200; // alarme sur le nombre de caractères restants à partir de...
var maxlength = parseInt($("#" + (ed.id)).attr("maxlength"));
var id_alarm = "#blogArticleContentAlarm"
var contentLength = 0;
ed.on("keydown", function(e) {
contentLength = ed.getContent({format : 'text'}).length;
if (contentLength > maxlength) {
$(id_alarm).html("Vous avez atteint le maximum de " + maxlength + " caractères ! ");
if(e.keyCode != 8 && e.keyCode != 46){
e.preventDefault();
e.stopPropagation();
return false;
}
}
else{
if(maxlength - contentLength < alarmCaraMin){
$(id_alarm).html((maxlength - contentLength) + " caractères restants");
}
else{
$(id_alarm).html(" ");
}
}
});
// Limitation y compris lors d'un copier/coller
ed.on("paste", function(e){
contentLeng = ed.getContent({format : 'text'}).length - 16;
var data = e.clipboardData.getData('Text');
if (data.length > (maxlength - contentLeng)) {
$(id_alarm).html("Vous alliez dépasser le maximum de " + maxlength + " caractères ! ");
return false;
} else {
if(maxlength - contentLeng < alarmCaraMin){
$(id_alarm).html((maxlength - contentLeng - data.length) + " caractères restants");
}
else{
$(id_alarm).html(" ");
}
return true;
}
});
},
// Langue
language: "fr_FR",
// Plugins
plugins: "advlist anchor autolink autoresize autosave colorpicker contextmenu fullscreen hr lists paste searchreplace stickytoolbar tabfocus template textcolor visualblocks emoticons",
// Contenu de la barre d'outils
toolbar: "restoredraft | undo redo | styleselect | bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist emoticons | visualblocks fullscreen",
// Emoticons
emoticons_append: {
custom_mind_explode: {
keywords: ["brain", "mind", "explode", "blown"],
char: "🤯"
}
},
// Titre des images
image_title: true,
// Pages internes
link_list: baseUrl + "core/vendor/tinymce/links.php",
// Contenu du menu contextuel
contextmenu: "cut copy paste pastetext | selectall searchreplace ",
// Fichiers CSS à intégrer à l'éditeur
content_css: [
baseUrl + "core/layout/common.css",
baseUrl + "core/vendor/tinymce/content.css",
baseUrl + "site/data/theme.css",
baseUrl + "site/data/custom.css"
],
// Classe à ajouter à la balise body dans l'iframe
body_class: "editorWysiwyg",
// Cache les menus
menubar: false,
// URL menu contextuel
link_context_toolbar: true,
// Cache la barre de statut
statusbar: false,
// Autorise le copié collé à partir du web
paste_data_images: true,
// Autorise tous les éléments
//valid_elements :"*[*]",
//valid_children : "*[*]",
// Autorise l'ajout de script
// extended_valid_elements: "script[language|type|src]",
// Bloque le dimensionnement des médias (car automatiquement en fullsize avec fitvids pour le responsive)
media_dimensions: true,
// Désactiver la dimension des images
image_dimensions: true,
// Active l'onglet avancé lors de l'ajout d'une image
image_advtab: true,
// Urls absolues
relative_urls: false,
// Url de base
document_base_url: baseUrl,
// Contenu du bouton formats
style_formats: [
{title: "Headers", items: [
{title: "Header 1", format: "h1"},
{title: "Header 2", format: "h2"},
{title: "Header 3", format: "h3"},
{title: "Header 4", format: "h4"}
]},
{title: "Inline", items: [
{title: "Bold", icon: "bold", format: "bold"},
{title: "Italic", icon: "italic", format: "italic"},
{title: "Underline", icon: "underline", format: "underline"},
{title: "Strikethrough", icon: "strikethrough", format: "strikethrough"},
{title: "Superscript", icon: "superscript", format: "superscript"},
{title: "Subscript", icon: "subscript", format: "subscript"},
{title: "Code", icon: "code", format: "code"}
]},
{title: "Blocks", items: [
{title: "Paragraph", format: "p"},
{title: "Blockquote", format: "blockquote"},
{title: "Div", format: "div"},
{title: "Pre", format: "pre"}
]},
{title: "Alignment", items: [
{title: "Left", icon: "alignleft", format: "alignleft"},
{title: "Center", icon: "aligncenter", format: "aligncenter"},
{title: "Right", icon: "alignright", format: "alignright"},
{title: "Justify", icon: "alignjustify", format: "alignjustify"}
]}
]
});
tinymce.PluginManager.add('stickytoolbar', function(editor, url) {
editor.on('init', function() {
setSticky();

View File

@ -14,10 +14,18 @@
class blog extends common {
// Objets
// Propriétaire - groupe
const EDIT_ALL = '02'; // Groupes Editeurs et admins
const EDIT_OWNER_ADMIN = '23'; // Propriétaire éditeur + groupe admin
const EDIT_ADMIN = '03'; // Groupe des admin
public static $actions = [
'add' => self::GROUP_MODERATOR,
'comment' => self::GROUP_MODERATOR,
'commentApprove' => self::GROUP_MODERATOR,
'commentDelete' => self::GROUP_MODERATOR,
'commentDeleteAll' => self::GROUP_MODERATOR,
'config' => self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR,
@ -26,8 +34,19 @@ class blog extends common {
public static $articles = [];
// Signature de l'article
public static $articleSignature = '';
// Signature du commentaire
public static $editCommentSignature = '';
public static $comments = [];
public static $commentsDelete;
// Signatures des commentaires déjà saisis
public static $commentsSignature = [];
public static $pages;
public static $states = [
@ -48,10 +67,29 @@ class blog extends common {
'right' => 'À droite ',
];
//Paramètre longueur maximale des commentaires en nb de caractères
public static $commentLength = [
'500' => '500',
'1000' => '1000',
'2000' => '2000',
'5000' => '5000',
'10000' => '10000'
];
// Permissions d'un article
public static $articleRightsAdmin = [
self::EDIT_ALL => 'Groupes des éditeurs et des administrateurs',
self::EDIT_OWNER_ADMIN => 'Editeur et groupe des administrateurs',
self::EDIT_ADMIN => 'Groupe des administrateurs'
];
public static $articleRightsModerator = [
self::EDIT_ALL => 'Groupes des éditeurs et des administrateurs',
self::EDIT_OWNER_ADMIN => 'Editeur et groupe des administrateurs'
];
public static $users = [];
const BLOG_VERSION = '2.02';
const BLOG_VERSION = '3.00.dev';
/**
* Édition
@ -59,6 +97,13 @@ class blog extends common {
public function add() {
// Soumission du formulaire
if($this->isPost()) {
// Modification de l'userId
if($this->getUser('group') === self::GROUP_ADMIN){
$newuserid = $this->getInput('blogAddUserId', helper::FILTER_STRING_SHORT, true);
}
else{
$newuserid = $this->getUser('id');
}
// Incrémente l'id de l'article
$articleId = helper::increment($this->getInput('blogAddTitle', helper::FILTER_ID), $this->getData(['page']));
$articleId = helper::increment($articleId, (array) $this->getData(['module', $this->getUrl(0)]));
@ -77,7 +122,8 @@ class blog extends common {
'publishedOn' => $this->getInput('blogAddPublishedOn', helper::FILTER_DATETIME, true),
'state' => $this->getInput('blogAddState', helper::FILTER_BOOLEAN),
'title' => $this->getInput('blogAddTitle', helper::FILTER_STRING_SHORT, true),
'userId' => $this->getInput('blogAddUserId', helper::FILTER_ID, true)
'userId' => $newuserid,
'commentMaxlength' => $this->getInput('blogAddlength', null)
]]);
// Valeurs en sortie
$this->addOutput([
@ -108,14 +154,13 @@ class blog extends common {
* Liste des commentaires
*/
public function comment() {
// Liste les commentaires
$comments = [];
foreach((array) $this->getData(['module', $this->getUrl(0)]) as $articleId => $article) {
foreach($article['comment'] as &$comment) {
$comment['articleId'] = $articleId;
}
$comments += $article['comment'];
}
$comments = $this->getData(['module', $this->getUrl(0), $this->getUrl(2),'comment']);
self::$commentsDelete = template::button('blogCommentDeleteAll', [
'class' => 'blogCommentDeleteAll buttonRed',
'href' => helper::baseUrl() . $this->getUrl(0) . '/commentDeleteAll/' . $this->getUrl(2).'/' . $_SESSION['csrf'] ,
'ico' => 'cancel',
'value' => 'Tout effacer'
]);
// Ids des commentaires par ordre de création
$commentIds = array_keys(helper::arrayCollumn($comments, 'createdOn', 'SORT_DESC'));
// Pagination
@ -126,20 +171,32 @@ class blog extends common {
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
// Met en forme le tableau
$comment = $comments[$commentIds[$i]];
// Bouton d'approbation
$buttonApproval = '';
// Compatibilité avec les commentaires des versions précédentes, les valider
$comment['approval'] = array_key_exists('approval', $comment) === false ? true : $comment['approval'] ;
if ( $this->getData(['module', $this->getUrl(0), $this->getUrl(2),'commentApprove']) === true) {
$buttonApproval = template::button('blogcommentApprove' . $commentIds[$i], [
'class' => $comment['approval'] === true ? 'blogCommentReject' : 'blogCommentApprove buttonRed' ,
'href' => helper::baseUrl() . $this->getUrl(0) . '/commentApprove/' . $this->getUrl(2) . '/' . $commentIds[$i] . '/' . $_SESSION['csrf'] ,
'value' => $comment['approval'] === true ? 'A' : 'R'
]);
}
self::$comments[] = [
utf8_encode(strftime('%d %B %Y - %H:%M', $comment['createdOn'])),
$comment['content'],
$comment['userId'] ? $this->getData(['user', $comment['userId'], 'firstname']) . ' ' . $this->getData(['user', $comment['userId'], 'lastname']) : $comment['author'],
$buttonApproval,
template::button('blogCommentDelete' . $commentIds[$i], [
'class' => 'blogCommentDelete buttonRed',
'href' => helper::baseUrl() . $this->getUrl(0) . '/comment-delete/' . $comment['articleId'] . '/' . $commentIds[$i] . '/' . $_SESSION['csrf'] ,
'href' => helper::baseUrl() . $this->getUrl(0) . '/commentDelete/' . $this->getUrl(2) . '/' . $commentIds[$i] . '/' . $_SESSION['csrf'] ,
'value' => template::ico('cancel')
])
];
}
// Valeurs en sortie
$this->addOutput([
'title' => 'Gestion des commentaires',
'title' => 'Gestion des commentaires : '. $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'title']),
'view' => 'comment'
]);
}
@ -168,33 +225,132 @@ class blog extends common {
$this->deleteData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3)]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/comment',
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/comment/'.$this->getUrl(2),
'notification' => 'Commentaire supprimé',
'state' => true
]);
}
}
/**
* Suppression de tous les commentaires de l'article $this->getUrl(2)
*/
public function commentDeleteAll() {
// Jeton incorrect
if ($this->getUrl(3) !== $_SESSION['csrf']) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
'notification' => 'Action non autorisée'
]);
}
// Suppression
else {
$this->setData(['module', $this->getUrl(0), $this->getUrl(2), 'comment',[] ]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/comment',
'notification' => 'Commentaires supprimés',
'state' => true
]);
}
}
/**
* Approbation oou désapprobation de commentaire
*/
public function commentApprove() {
// Le commentaire n'existe pas
if($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3)]) === null) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
}
// Jeton incorrect
elseif ($this->getUrl(4) !== $_SESSION['csrf']) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
'notification' => 'Action non autorisée'
]);
}
// Inversion du statut
else {
$this->setData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), [
'author' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'author']),
'content' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'content']),
'createdOn' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'createdOn']),
'userId' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'userId']),
'approval' => !$this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'approval'])
]]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/comment/'.$this->getUrl(2),
'notification' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'approval']) === true ? 'Commentaire approuvé' : 'Commentaire rejeté',
'state' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'approval'])
]);
}
}
/**
* Configuration
*/
public function config() {
// Ids des articles par ordre de publication
$articleIds = array_keys(helper::arrayCollumn($this->getData(['module', $this->getUrl(0)]), 'publishedOn', 'SORT_DESC'));
// Gestion des droits d'accès
$filterData=[];
foreach ($articleIds as $key => $value) {
$rights = $this->getData(['module', $this->getUrl(0), $value,'editRights']);
// Compatibilité pas de droit stocké placer droit par défaut
$rights = empty($rights) ? '02' : $rights;
// Check les droits du propriétaire
// Check les droits du groupe
if (
( substr($rights,0,1) === '2'
AND $this->getData(['module', $this->getUrl(0), $value,'userId']) === $this->getUser('id')
)
OR ( $this->getUser('group') >= substr($rights,1,1) )
) {
$filterData[] = $value;
}
}
$articleIds = $filterData;
// Pagination
$pagination = helper::pagination($articleIds, $this->getUrl(),$this->getData(['config','itemsperPage']));
// Liste des pages
self::$pages = $pagination['pages'];
// Articles en fonction de la pagination
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
// Nombre de commentaires à approuver et approuvés
$approvals = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), $articleIds[$i], 'comment' ]),'approval', 'SORT_DESC');
if ( is_array($approvals) ) {
$a = array_values($approvals);
$toApprove = count(array_keys($a,false));
$approved = count(array_keys($a,true));
} else {
$toApprove = 0;
$approved = count($this->getData(['module', $this->getUrl(0), $articleIds[$i],'comment']));
}
// Met en forme le tableau
self::$articles[] = [
$this->getData(['module', $this->getUrl(0), $articleIds[$i], 'title']),
'<a href="' . helper::baseurl() . $this->getUrl(0) . '/' . $articleIds[$i] . '" target="_blank" >' .
$this->getData(['module', $this->getUrl(0), $articleIds[$i], 'title']) .
'</a>',
// date('d/m/Y H:i', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])),
utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])))
.' à '.
utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn']))),
self::$states[$this->getData(['module', $this->getUrl(0), $articleIds[$i], 'state'])],
// Bouton pour afficher les commentaires de l'article
template::button('blogConfigComment' . $articleIds[$i], [
'class' => ($toApprove || $approved ) > 0 ? 'buttonBlue' : 'buttonGrey' ,
'href' => ($toApprove || $approved ) > 0 ? helper::baseUrl() . $this->getUrl(0) . '/comment/' . $articleIds[$i] : '',
'value' => $toApprove > 0 ? $toApprove . '/' . $approved : $approved
//'value' => count($this->getData(['module', $this->getUrl(0), $articleIds[$i],'comment']))
]),
template::button('blogConfigEdit' . $articleIds[$i], [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $articleIds[$i] . '/' . $_SESSION['csrf'],
'value' => template::ico('pencil')
@ -266,6 +422,12 @@ class blog extends common {
else {
// Soumission du formulaire
if($this->isPost()) {
if($this->getUser('group') === self::GROUP_ADMIN){
$newuserid = $this->getInput('blogEditUserId', helper::FILTER_STRING_SHORT, true);
}
else{
$newuserid = $this->getUser('id');
}
$articleId = $this->getInput('blogEditTitle', helper::FILTER_ID, true);
// Incrémente le nouvel id de l'article
if($articleId !== $this->getUrl(2)) {
@ -274,7 +436,7 @@ class blog extends common {
$articleId = helper::increment($articleId, array_keys(self::$actions));
}
$this->setData(['module', $this->getUrl(0), $articleId, [
'closeComment' => $this->getInput('blogEditCloseComment'),
'closeComment' => $this->getInput('blogEditCloseComment', helper::FILTER_BOOLEAN),
'mailNotification' => $this->getInput('blogEditMailNotification', helper::FILTER_BOOLEAN),
'groupNotification' => $this->getInput('blogEditGroupNotification', helper::FILTER_INT),
'comment' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment']),
@ -286,7 +448,10 @@ class blog extends common {
'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' => $this->getInput('blogEditUserId', helper::FILTER_ID, true)
'userId' => $newuserid,
'commentMaxlength' => $this->getInput('blogEditCommentMaxlength'),
'commentApprove' => $this->getInput('blogEditCommentApprove', helper::FILTER_BOOLEAN),
'editRights' => $this->getInput('blogEditRights')
]]);
// Supprime l'ancien article
if($articleId !== $this->getUrl(2)) {
@ -303,7 +468,7 @@ class blog extends common {
self::$users = helper::arrayCollumn($this->getData(['user']), 'firstname');
ksort(self::$users);
foreach(self::$users as $userId => &$userFirstname) {
$userFirstname = $userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']);
$userFirstname = $userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']) . ' (' . self::$groupEdits[$this->getData(['user', $userId, 'group'])] . ')';
}
unset($userFirstname);
// Valeurs en sortie
@ -350,11 +515,11 @@ class blog extends common {
$commentId = helper::increment(uniqid(), $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment']));
$this->setData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentId, [
'author' => $this->getInput('blogArticleAuthor', helper::FILTER_STRING_SHORT, empty($this->getInput('blogArticleUserId')) ? TRUE : FALSE),
'content' => $this->getInput('blogArticleContent', helper::FILTER_STRING_SHORT, true),
'content' => $this->getInput('blogArticleContent', false),
'createdOn' => time(),
'userId' => $this->getInput('blogArticleUserId'),
'approval' => !$this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'commentApprove']) // true commentaire publié false en attente de publication
]]);
// Envoi d'une notification aux administrateurs
// Init tableau
$to = [];
@ -365,20 +530,21 @@ class blog extends common {
}
}
// Envoi du mail $sent code d'erreur ou de réussite
$notification = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentId, 'approval']) === false ? 'Commentaire déposé en attente d\'approbation.': 'Commentaire déposé.';
if ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'mailNotification']) === true) {
$sent = $this->sendMail(
$to,
'Nouveau commentaire',
'Bonjour' . ' <strong>' . $user['firstname'] . ' ' . $user['lastname'] . '</strong>,<br><br>' .
'Nouveau commentaire déposé sur la page "' . $this->getData(['page', $this->getUrl(0), 'title']) . '" :<br><br>',
'Nouveau commentaire ' . $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentId, 'approval']) === false ? 'à approuver' : '' .
'déposé sur la page "' . $this->getData(['page', $this->getUrl(0), 'title']) . '" :<br><br>'.
$this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentId, 'content']),
''
);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl() . '#comment',
//'notification' => 'Commentaire ajouté',
//'state' => true
'notification' => ($sent === true ? 'Commentaire ajouté et une notification envoyée' : 'Commentaire ajouté, erreur de notification : <br/>' . $sent),
'notification' => ($sent === true ? $notification . '<br/>Une notification a été envoyée.' : $notification . '<br/> Erreur de notification : ' . $sent),
'state' => ($sent === true ? true : null)
]);
@ -386,7 +552,7 @@ class blog extends common {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl() . '#comment',
'notification' => 'Commentaire ajouté',
'notification' => $notification,
'state' => true
]);
}
@ -398,14 +564,78 @@ class blog extends common {
$pagination = helper::pagination($commentIds, $this->getUrl(),$this->getData(['config','itemsperPage']),'#comment');
// Liste des pages
self::$pages = $pagination['pages'];
// Signature de l'article
$userIdArticle = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'userId']);
switch ($this->getData(['user', $userIdArticle, 'signature'])){
case 1:
self::$articleSignature = $userIdArticle;
break;
case 2:
self::$articleSignature = $this->getData(['user', $userIdArticle, 'pseudo']);
break;
case 3:
self::$articleSignature = $this->getData(['user', $userIdArticle, 'firstname']) . ' ' . $this->getData(['user', $userIdArticle, 'lastname']);
break;
case 4:
self::$articleSignature = $this->getData(['user', $userIdArticle, 'lastname']) . ' ' . $this->getData(['user', $userIdArticle, 'firstname']);
break;
default:
self::$articleSignature = $this->getData(['user', $userIdArticle, 'firstname']);
}
// Signature du commentaire édité
if($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')) {
$useridcomment = $this->getUser('id');
switch ($this->getData(['user', $useridcomment, 'signature'])){
case 1:
self::$editCommentSignature = $useridcomment;
break;
case 2:
self::$editCommentSignature = $this->getData(['user', $useridcomment, 'pseudo']);
break;
case 3:
self::$editCommentSignature = $this->getData(['user', $useridcomment, 'firstname']) . ' ' . $this->getData(['user', $useridcomment, 'lastname']);
break;
case 4:
self::$editCommentSignature = $this->getData(['user', $useridcomment, 'lastname']) . ' ' . $this->getData(['user', $useridcomment, 'firstname']);
break;
default:
self::$editCommentSignature = $this->getData(['user', $useridcomment, 'firstname']);
}
}
// Commentaires en fonction de la pagination
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
self::$comments[$commentIds[$i]] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentIds[$i]]);
// Signatures des commentaires
$e = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentIds[$i],'userId']);
if ($e) {
switch ($this->getData(['user', $e, 'signature'])){
case 1:
self::$commentsSignature[$commentIds[$i]] = $e;
break;
case 2:
self::$commentsSignature[$commentIds[$i]] = $this->getData(['user', $e, 'pseudo']);
break;
case 3:
self::$commentsSignature[$commentIds[$i]] = $this->getData(['user', $e, 'firstname']) . ' ' . $this->getData(['user', $e, 'lastname']);
break;
case 4:
self::$commentsSignature[$commentIds[$i]] = $this->getData(['user', $e, 'lastname']) . ' ' . $this->getData(['user', $e, 'firstname']);
break;
}
} else {
self::$commentsSignature[$commentIds[$i]] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentIds[$i],'author']);
}
// Données du commentaire si approuvé
if ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentIds[$i],'approval']) === true ) {
self::$comments[$commentIds[$i]] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentIds[$i]]);
}
}
// Valeurs en sortie
$this->addOutput([
'showBarEditButton' => true,
'title' => $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'title']),
'vendor' => [
'tinymce'
],
'view' => 'article'
]);
}

View File

@ -17,3 +17,39 @@ $("#blogAddDraft").on("click", function() {
$("#blogAddState").val(0);
$("#blogAddForm").trigger("submit");
});
/**
* Options de commentaires
*/
$("#blogAddCloseComment").on("change", function() {
if ($(this).is(':checked') ) {
$("#commentOptionsWrapper").slideUp();
} else {
$("#commentOptionsWrapper").slideDown();
}
});
$("#blogAddMailNotification").on("change", function() {
if ($(this).is(':checked') ) {
$("#blogAddGroupNotification").slideDown();
} else {
$("#blogAddGroupNotification").slideUp();
}
});
$( document).ready(function() {
if ($("#blogAddCloseComment").is(':checked') ) {
$("#commentOptionsWrapper").slideUp();
} else {
$("#commentOptionsWrapper").slideDown();
}
if ($("#blogAddMailNotification").is(':checked') ) {
$("#blogAddGroupNotification").slideDown();
} else {
$("#blogAddGroupNotification").slideUp();
}
});

View File

@ -67,31 +67,75 @@
<?php echo template::textarea('blogAddContent', [
'class' => 'editorWysiwyg'
]); ?>
<div class="row">
<div class="col12">
<div class="block">
<h4>Options de publication</h4>
<div class="row">
<div class="col4">
<?php echo template::select('blogAddCommentMaxlength', $module::$commentLength,[
'help' => 'Choix du nombre maximum de caractères pour chaque commentaire de l\'article, mise en forme html comprise.',
'label' => 'Caractères par commentaire',
'selected' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'commentMaxlength'])
]); ?>
</div>
<div class="col4">
<?php echo template::select('blogAddUserId', $module::$users, [
'label' => 'Auteur',
'selected' => $this->getUser('id'),
'disabled' => $this->getUser('group') !== self::GROUP_ADMIN ? true : false
]); ?>
</div>
<div class="col4">
<?php echo template::date('blogAddPublishedOn', [
'help' => 'L\'article n\'est visible qu\'après la date de publication prévue.',
'label' => 'Date de publication',
'value' => time()
]); ?>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col6">
<div class="block">
<h4>Options de publication</h4>
<?php echo template::select('blogAddUserId', $module::$users, [
'label' => 'Auteur',
'selected' => $this->getUser('id')
]); ?>
<?php echo template::date('blogAddPublishedOn', [
'help' => 'L\'article n\'est visible qu\'après la date de publication prévue.',
'label' => 'Date de publication',
'value' => time()
<h4>Permissions</h4>
<?php echo template::select('blogAddRights', $this->getUser('group') === self::GROUP_ADMIN ? $module::$articleRightsAdmin : $module::$articleRightsModerator , [
'label' => 'Droits d\'édition et de modification',
'selected' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'editRights'])
]); ?>
</div>
</div>
<div class="col6">
<div class="block">
<h4>Options avancées</h4>
<?php echo template::checkbox('blogAddCloseComment', true, 'Fermer les commentaires' ); ?>
<?php echo template::checkbox('blogAddMailNotification', true, 'Notifier le commentaire aux groupes à partir de :', [
'help' => 'Editeurs = éditeurs + administrateurs<br/> Membres = membres + éditeurs + administrateurs'
]); ?>
<?php echo template::select('blogAddGroupNotification', $module::$groupNews, [
'label' => ''
<h4>Commentaires</h4>
<?php echo template::checkbox('blogAddCloseComment', true, 'Fermer les commentaires', [
'checked' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'closeComment'])
]); ?>
<div id="commentOptionsWrapper">
<div class="row">
<div class="col12">
<?php echo template::checkbox('blogAddCommentApprove', true, 'Approbation des commentaires', [
'checked' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'commentApprove']),
''
]); ?>
</div>
</div>
<div class="row">
<div class="col7">
<?php echo template::checkbox('blogAddMailNotification', true, 'Notification des nouveaux commentaires par mail aux groupes', [
'checked' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'mailNotification']),
]); ?>
</div>
<div class="col5">
<?php echo template::select('blogAddGroupNotification', $module::$groupNews, [
'selected' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'groupNotification']),
'help' => 'Editeurs = éditeurs + administrateurs<br/> Membres = membres + éditeurs + administrateurs'
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -50,6 +50,4 @@
.blogArticlePicture {
height:auto;
max-width: 100%;}
}
}

View File

@ -1,120 +1,113 @@
<div class="row">
<div class="col10">
<div class="blogDate">
<i class="far fa-calendar-alt"></i>
<?php echo utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'publishedOn']))); ?>
à <?php echo utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'publishedOn']))); ?>
<article>
<div class="row">
<div class="col10">
<div class="blogDate">
<i class="far fa-calendar-alt"></i>
<?php echo utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'publishedOn']))); ?>
à <?php echo utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'publishedOn']))); ?>
</div>
</div>
<?php if($this->getUser('group') >= self::GROUP_ADMIN): ?>
<div class="col2">
<?php echo template::button('blogEdit', [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $this->getUrl(1) . '/' . $_SESSION['csrf'],
'value' => 'Editer'
]); ?>
</div>
<?php endif; ?>
</div>
<?php if(
$this->getUser('group') >= self::GROUP_ADMIN
AND $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
): ?>
<div class="col2">
<?php echo template::button('blogEdit', [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $this->getUrl(1) . '/' . $_SESSION['csrf'],
'value' => 'Editer'
<?php $pictureSize = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'pictureSize']) === null ? '100' : $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'pictureSize']); ?>
<?php if ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'hidePicture']) == false) {
echo '<img class="blogArticlePicture blogArticlePicture' . $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'picturePosition']) .
' pict' . $pictureSize . '" src="' . helper::baseUrl(false) . self::FILE_DIR.'source/' . $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'picture']) .
'" alt="' . $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'picture']) . '">';
} ?>
<?php echo $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'content']); ?>
<p class="clearBoth signature"><?php echo $module::$articleSignature;?></p>
<?php if($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'closeComment'])): ?>
<p>Cet article ne reçoit pas de commentaire.</p>
<?php else: ?>
<h3 id="comment">
<?php $commentsNb = count($module::$comments); ?>
<?php $s = $commentsNb === 1 ? '': 's' ?>
<?php echo $commentsNb > 0 ? $commentsNb . ' ' . 'commentaire' . $s : 'Pas encore de commentaire'; ?>
</h3>
<?php echo template::formOpen('blogArticleForm'); ?>
<?php echo template::text('blogArticleCommentShow', [
'placeholder' => 'Rédiger un commentaire...',
'readonly' => true
]); ?>
</div>
<?php endif; ?>
</div>
<?php $pictureSize = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'pictureSize']) === null ? '100' : $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'pictureSize']); ?>
<?php if ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'hidePicture']) == false) {
echo '<img class="blogArticlePicture blogArticlePicture' . $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'picturePosition']) .
' pict' . $pictureSize . '" src="' . helper::baseUrl(false) . self::FILE_DIR.'source/' . $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'picture']) .
'" alt="' . $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'picture']) . '">';
} ?>
<?php echo $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'content']); ?>
<p class="clearBoth signature">
<?php echo $this->getData(['user', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'userId']), 'firstname']); ?>
<?php echo $this->getData(['user', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'userId']), 'lastname']); ?>
</p>
<?php if($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'closeComment'])): ?>
<p>Cet article ne reçoit pas de commentaire.</p>
<?php else: ?>
<h3 id="comment">
<?php $commentsNb = count($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment'])); ?>
<?php $s = $commentsNb === 1 ? '': 's' ?>
<?php echo $commentsNb > 0 ? $commentsNb . ' ' . 'commentaire' . $s : 'Pas encore de commentaire'; ?>
</h3>
<?php echo template::formOpen('blogArticleForm'); ?>
<?php echo template::text('blogArticleCommentShow', [
'placeholder' => 'Rédiger un commentaire...',
'readonly' => true
]); ?>
<div id="blogArticleCommentWrapper" class="displayNone">
<?php if($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')): ?>
<?php echo template::text('blogArticleUserName', [
'label' => 'Nom',
'readonly' => true,
'value' => $this->getUser('firstname') . ' ' . $this->getUser('lastname')
<div id="blogArticleCommentWrapper" class="displayNone">
<?php if($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')): ?>
<?php echo template::text('blogArticleUserName', [
'label' => 'Nom',
'readonly' => true,
'value' => $module::$editCommentSignature
]); ?>
<?php echo template::hidden('blogArticleUserId', [
'value' => $this->getUser('id')
]); ?>
<?php else: ?>
<div class="row">
<div class="col9">
<?php echo template::text('blogArticleAuthor', [
'label' => 'Nom'
]); ?>
</div>
<div class="col1 textAlignCenter verticalAlignBottom">
<div id="blogArticleOr">Ou</div>
</div>
<div class="col2 verticalAlignBottom">
<?php echo template::button('blogArticleLogin', [
'href' => helper::baseUrl() . 'user/login/' . str_replace('/', '_', $this->getUrl()) . '__comment',
'value' => 'Connexion'
]); ?>
</div>
</div>
<?php endif; ?>
<?php echo template::textarea('blogArticleContent', [
'label' => 'Commentaire avec maximum '.$this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'commentMaxlength']).' caractères',
'class' => 'editorWysiwygComment',
'noDirty' => true,
'maxlength' => $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'commentMaxlength'])
]); ?>
<?php echo template::hidden('blogArticleUserId', [
'value' => $this->getUser('id')
]); ?>
<?php else: ?>
<div id="blogArticleContentAlarm"> </div>
<?php if($this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')): ?>
<div class="row">
<div class="col4">
<?php echo template::capcha('blogArticleCapcha'); ?>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col9">
<?php echo template::text('blogArticleAuthor', [
'label' => 'Nom'
<div class="col2 offset8">
<?php echo template::button('blogArticleCommentHide', [
'class' => 'buttonGrey',
'value' => 'Annuler'
]); ?>
</div>
<div class="col1 textAlignCenter verticalAlignBottom">
<div id="blogArticleOr">Ou</div>
</div>
<div class="col2 verticalAlignBottom">
<?php echo template::button('blogArticleLogin', [
'href' => helper::baseUrl() . 'user/login/' . str_replace('/', '_', $this->getUrl()) . '__comment',
'value' => 'Connexion'
<div class="col2">
<?php echo template::submit('blogArticleSubmit', [
'value' => 'Envoyer',
'ico' => ''
]); ?>
</div>
</div>
<?php endif; ?>
<?php echo template::textarea('blogArticleContent', [
'label' => 'Commentaire',
'maxlength' => '500'
]); ?>
<?php if($this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')): ?>
<div class="row">
<div class="col5">
<?php echo template::captcha('blogArticlecaptcha'); ?>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col2 offset8">
<?php echo template::button('blogArticleCommentHide', [
'class' => 'buttonGrey',
'value' => 'Annuler'
]); ?>
</div>
<div class="col2">
<?php echo template::submit('blogArticleSubmit', [
'value' => 'Envoyer',
'ico' => ''
]); ?>
</div>
</div>
</div>
<?php echo template::formClose(); ?>
<?php endif;?>
<?php echo template::formClose(); ?>
<?php endif;?>
<div class="row">
<div class="col12">
<?php foreach($module::$comments as $commentId => $comment): ?>
<div class="block">
<h4>
<?php if($comment['userId']): ?>
<?php echo $this->getData(['user', $comment['userId'], 'firstname']) . ' ' . $this->getData(['user', $comment['userId'], 'lastname']); ?>
<?php else: ?>
<?php echo $comment['author']; ?>
<?php endif; ?>
le <?php echo utf8_encode(strftime('%d %B %Y - %H:%M', $comment['createdOn'])); ?>
</h4>
<?php echo $comment['content']; ?>
</div>
<?php endforeach; ?>
<div class="row">
<div class="col12">
<?php foreach($module::$comments as $commentId => $comment): ?>
<div class="block">
<h4><?php echo $module::$commentsSignature[$commentId]; ?>
le <?php echo utf8_encode(strftime('%d %B %Y - %H:%M', $comment['createdOn'])); ?>
</h4>
<?php echo $comment['content']; ?>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php echo $module::$pages; ?>
<?php echo $module::$pages; ?>
</article>

View File

@ -10,12 +10,53 @@
* @link http://zwiicms.fr/
*/
/**
* Confirmation de suppression
*/
$(".blogCommentDelete").on("click", function() {
var _this = $(this);
return core.confirm("Êtes-vous sûr de vouloir supprimer ce commentaire ?", function() {
var nom = "<?php echo $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'title' ]); ?>";
return core.confirm("Supprimer le commentaire de l'article " + nom + " ?", function() {
$(location).attr("href", _this.attr("href"));
});
});
/**
* Confirmation d'approbation
*/
$(".blogCommentApprove").on("click", function() {
var _this = $(this);
var nom = "<?php echo $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'title' ]); ?>";
return core.confirm("Approuver le commentaire de l'article " + nom + " ?", function() {
$(location).attr("href", _this.attr("href"));
});
});
/**
* Confirmation de rejet
*/
$(".blogCommentReject").on("click", function() {
var _this = $(this);
var nom = "<?php echo $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'title' ]); ?>";
return core.confirm("Rejeter le commentaire de l'article " + nom + " ?", function() {
$(location).attr("href", _this.attr("href"));
});
});
/**
* Confirmation de suppression en masse
*/
$(".blogCommentDeleteAll").on("click", function() {
var _this = $(this);
var nombre = "<?php echo count($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment' ])); ?>";
var nom = "<?php echo $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'title' ]); ?>";
if( nombre === "1"){
var message = "Supprimer le commentaire de l'article " + nom + " ?";
} else{
var message = "Supprimer les " + nombre + " commentaires de l'article " + nom + " ?";
}
return core.confirm(message, function() {
$(location).attr("href", _this.attr("href"));
});
});

View File

@ -7,10 +7,16 @@
'value' => 'Retour'
]); ?>
</div>
</div>
<?php if($module::$comments): ?>
<?php echo template::table([3, 6, 2, 1], $module::$comments, ['Date', 'Contenu', 'Auteur', '']); ?>
<?php echo $module::$pages; ?>
<div class="col2 offset8">
<?php echo $module::$commentsDelete; ?>
</div>
</div>
<?php echo template::table([3, 5, 2, 1, 1], $module::$comments, ['Date', 'Contenu', 'Auteur', '', '']); ?>
<?php echo $module::$pages.'<br/>'; ?>
<?php else: ?>
</div>
<?php echo template::speech('Aucun commentaire.'); ?>
<?php endif; ?>

View File

@ -7,13 +7,7 @@
'value' => 'Retour'
]); ?>
</div>
<div class="col3 offset5">
<?php echo template::button('blogConfigComment', [
'href' => helper::baseUrl() . $this->getUrl(0) . '/comment',
'value' => 'Gérer les commentaires'
]); ?>
</div>
<div class="col2">
<div class="col2 offset8">
<?php echo template::button('blogConfigAdd', [
'href' => helper::baseUrl() . $this->getUrl(0) . '/add',
'ico' => 'plus',
@ -22,7 +16,7 @@
</div>
</div>
<?php if($module::$articles): ?>
<?php echo template::table([4, 4, 2, 1, 1], $module::$articles, ['Titre', 'Date de publication', 'État', '', '']); ?>
<?php echo template::table([4, 4, 1, 1, 1, 1], $module::$articles, ['Titre', 'Date de publication', 'État', 'Commentaires', '','']); ?>
<?php echo $module::$pages; ?>
<?php else: ?>
<?php echo template::speech('Aucun article.'); ?>

View File

@ -29,3 +29,39 @@ $("#blogEditDraft").on("click", function() {
$("#blogEditState").val(0);
$("#blogEditForm").trigger("submit");
});
/**
* Options de commentaires
*/
$("#blogEditCloseComment").on("change", function() {
if ($(this).is(':checked') ) {
$("#commentOptionsWrapper").slideUp();
} else {
$("#commentOptionsWrapper").slideDown();
}
});
$("#blogEditMailNotification").on("change", function() {
if ($(this).is(':checked') ) {
$("#blogEditGroupNotification").slideDown();
} else {
$("#blogEditGroupNotification").slideUp();
}
});
$( document).ready(function() {
if ($("#blogEditCloseComment").is(':checked') ) {
$("#commentOptionsWrapper").slideUp();
} else {
$("#commentOptionsWrapper").slideDown();
}
if ($("#blogEditMailNotification").is(':checked') ) {
$("#blogEditGroupNotification").slideDown();
} else {
$("#blogEditGroupNotification").slideUp();
}
});

View File

@ -21,6 +21,7 @@
<?php echo template::submit('blogEditSubmit', [
'value' => 'Publier'
]); ?>
</div>
</div>
<div class="row">
@ -73,35 +74,74 @@
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'content'])
]); ?>
<div class="row">
<div class="col6">
<div class="col12">
<div class="block">
<h4>Options de publication</h4>
<?php echo template::select('blogEditUserId', $module::$users, [
'label' => 'Auteur',
'selected' => $this->getUser('id')
]); ?>
<?php echo template::date('blogEditPublishedOn', [
'help' => 'L\'article n\'est visible qu\'après la date de publication prévue.',
'label' => 'Date de publication',
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'publishedOn'])
<div class="row">
<div class="col4">
<?php echo template::select('blogEditCommentMaxlength', $module::$commentLength,[
'help' => 'Choix du nombre maximum de caractères pour chaque commentaire de l\'article, mise en forme html comprise.',
'label' => 'Caractères par commentaire',
'selected' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'commentMaxlength'])
]); ?>
</div>
<div class="col4">
<?php echo template::select('blogEditUserId', $module::$users, [
'label' => 'Auteur',
'selected' => $this->getUser('id'),
'disabled' => $this->getUser('group') !== self::GROUP_ADMIN ? true : false
]); ?>
</div>
<div class="col4">
<?php echo template::date('blogEditPublishedOn', [
'help' => 'L\'article n\'est visible qu\'après la date de publication prévue.',
'label' => 'Date de publication',
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'publishedOn'])
]); ?>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col6">
<div class="block">
<h4>Permissions</h4>
<?php echo template::select('blogEditRights', $this->getUser('group') === self::GROUP_ADMIN ? $module::$articleRightsAdmin : $module::$articleRightsModerator , [
'label' => 'Droits d\'édition et de modification',
'selected' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'editRights'])
]); ?>
</div>
</div>
<div class="col6">
<div class="block">
<h4>Options avancées</h4>
<h4>Commentaires</h4>
<?php echo template::checkbox('blogEditCloseComment', true, 'Fermer les commentaires', [
'checked' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'closeComment'])
]); ?>
<?php echo template::checkbox('blogEditMailNotification', true, 'Notifier le commentaire aux groupes à partir de :', [
'checked' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'mailNotification']),
'help' => 'Editeurs = éditeurs + administrateurs<br/> Membres = membres + éditeurs + administrateurs'
]); ?>
<?php echo template::select('blogEditGroupNotification', $module::$groupNews, [
'label' => '',
'selected' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'groupNotification'])
]); ?>
<div id="commentOptionsWrapper">
<div class="row">
<div class="col12">
<?php echo template::checkbox('blogEditCommentApprove', true, 'Approbation des commentaires', [
'checked' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'commentApprove']),
''
]); ?>
</div>
</div>
<div class="row">
<div class="col7">
<?php echo template::checkbox('blogEditMailNotification', true, 'Notification des nouveaux commentaires par mail aux groupes', [
'checked' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'mailNotification']),
]); ?>
</div>
<div class="col5">
<?php echo template::select('blogEditGroupNotification', $module::$groupNews, [
'selected' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'groupNotification']),
'help' => 'Editeurs = éditeurs + administrateurs<br/> Membres = membres + éditeurs + administrateurs'
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -21,6 +21,7 @@
</a>
</div>
<div class="col9">
<article>
<h1 class="blogTitle">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
<?php echo $article['title']; ?>
@ -40,6 +41,7 @@
<?php echo helper::subword(strip_tags($article['content']), 0, 400); ?>...
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">Lire la suite</a>
</p>
</article>
</div>
</div>
<?php endforeach; ?>