forked from ZwiiCMS-Team/ZwiiCMS
Compatibilité anciens blogs et correction de bugs (décompte)
This commit is contained in:
parent
ad73150bc4
commit
6dd3f034cb
@ -1367,6 +1367,38 @@ class common {
|
||||
$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', 10300]);
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +173,8 @@ class blog extends common {
|
||||
$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' ,
|
||||
@ -323,18 +325,14 @@ class blog extends common {
|
||||
// Articles en fonction de la pagination
|
||||
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
|
||||
// Nombre de commentaires à approuver et approuvés
|
||||
$approvals = [];
|
||||
// Compatibilité : vérifier si les données sont disponibles
|
||||
if ( $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'comment' ,'approval' ]) !== NULL ) {
|
||||
$approvals = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), $articleIds[$i], 'comment' ]),'approval', 'SORT_DESC');
|
||||
}
|
||||
if ( empty($approvals) ) {
|
||||
$toApprove = 0;
|
||||
$approved = count($this->getData(['module', $this->getUrl(0), $articleIds[$i],'comment']));
|
||||
} else {
|
||||
$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[] = [
|
||||
|
@ -27,7 +27,7 @@
|
||||
<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 $commentsNb = count($module::$comments); ?>
|
||||
<?php $s = $commentsNb === 1 ? '': 's' ?>
|
||||
<?php echo $commentsNb > 0 ? $commentsNb . ' ' . 'commentaire' . $s : 'Pas encore de commentaire'; ?>
|
||||
</h3>
|
||||
|
Loading…
Reference in New Issue
Block a user