forked from ZwiiCMS-Team/ZwiiCMS
Amélioration flux RSS
This commit is contained in:
parent
b8366f34cb
commit
b02326f0cc
@ -44,7 +44,7 @@ class common {
|
|||||||
const ACCESS_TIMER = 1800;
|
const ACCESS_TIMER = 1800;
|
||||||
|
|
||||||
// Numéro de version
|
// Numéro de version
|
||||||
const ZWII_VERSION = '10.4.00';
|
const ZWII_VERSION = '10.4.00.001';
|
||||||
const ZWII_UPDATE_CHANNEL = "v10";
|
const ZWII_UPDATE_CHANNEL = "v10";
|
||||||
|
|
||||||
public static $actions = [];
|
public static $actions = [];
|
||||||
|
@ -28,7 +28,8 @@ class blog extends common {
|
|||||||
'delete' => self::GROUP_MODERATOR,
|
'delete' => self::GROUP_MODERATOR,
|
||||||
'edit' => self::GROUP_MODERATOR,
|
'edit' => self::GROUP_MODERATOR,
|
||||||
'index' => self::GROUP_VISITOR,
|
'index' => self::GROUP_VISITOR,
|
||||||
'rss' => self::GROUP_VISITOR
|
'rss' => self::GROUP_VISITOR,
|
||||||
|
'signature' => self::GROUP_VISITOR
|
||||||
];
|
];
|
||||||
|
|
||||||
public static $articles = [];
|
public static $articles = [];
|
||||||
@ -103,11 +104,11 @@ class blog extends common {
|
|||||||
$feeds = new \FeedWriter\RSS2();
|
$feeds = new \FeedWriter\RSS2();
|
||||||
|
|
||||||
// En-tête
|
// En-tête
|
||||||
$feeds->setTitle($this->getData (['page', $this->getUrl(0), 'posts','title']));
|
$feeds->setTitle($this->getData (['page', $this->getUrl(0), 'title']));
|
||||||
$feeds->setLink(helper::baseUrl() . $this->getUrl(0));
|
$feeds->setLink(helper::baseUrl() . $this->getUrl(0));
|
||||||
$feeds->setDescription(html_entity_decode(strip_tags($this->getData (['page', $this->getUrl(0), 'metaDescription']))));
|
$feeds->setDescription($this->getData (['page', $this->getUrl(0), 'metaDescription']));
|
||||||
$feeds->setChannelElement('language', 'fr-FR');
|
$feeds->setChannelElement('language', 'fr-FR');
|
||||||
$feeds->setDate(time());
|
$feeds->setDate(date('r',time()));
|
||||||
$feeds->addGenerator();
|
$feeds->addGenerator();
|
||||||
// Corps des articles
|
// Corps des articles
|
||||||
$articleIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC');
|
$articleIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC');
|
||||||
@ -119,11 +120,19 @@ class blog extends common {
|
|||||||
$thumb = str_replace ($parts[(count($parts)-1)],'mini_' . $parts[(count($parts)-1)], $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'picture']));
|
$thumb = str_replace ($parts[(count($parts)-1)],'mini_' . $parts[(count($parts)-1)], $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'picture']));
|
||||||
// Créer les articles du flux
|
// Créer les articles du flux
|
||||||
$newsArticle = $feeds->createNewItem();
|
$newsArticle = $feeds->createNewItem();
|
||||||
|
// Signature de l'article
|
||||||
|
$author = $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'userId']));
|
||||||
$newsArticle->addElementArray([
|
$newsArticle->addElementArray([
|
||||||
'title' => strip_tags($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'title']) ),
|
'title' => $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'title']),
|
||||||
'link' => helper::baseUrl() .$this->getUrl(0) . '/' . $articleId,
|
'link' => helper::baseUrl() .$this->getUrl(0) . '/' . $articleId,
|
||||||
'description' => html_entity_decode(strip_tags($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'content']))),
|
'description' => '<img src="' . helper::baseUrl() . self::FILE_DIR . $thumb
|
||||||
'addEnclosure' => helper::baseUrl() . self::FILE_DIR . $thumb
|
. '" alt="' . $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'title'])
|
||||||
|
. '" title="' . $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'title'])
|
||||||
|
. '" />' .
|
||||||
|
$this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'content']),
|
||||||
|
'setAuthor' => $author,
|
||||||
|
'setId' => helper::baseUrl() .$this->getUrl(0) . '/' . $articleId,
|
||||||
|
'setDate' => date('r', $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn']))
|
||||||
]);
|
]);
|
||||||
$feeds->addItem($newsArticle);
|
$feeds->addItem($newsArticle);
|
||||||
}
|
}
|
||||||
@ -659,62 +668,17 @@ class blog extends common {
|
|||||||
// Liste des pages
|
// Liste des pages
|
||||||
self::$pages = $pagination['pages'];
|
self::$pages = $pagination['pages'];
|
||||||
// Signature de l'article
|
// Signature de l'article
|
||||||
$userIdArticle = $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'userId']);
|
self::$articleSignature = $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $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é
|
// Signature du commentaire édité
|
||||||
if($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')) {
|
if($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')) {
|
||||||
$useridcomment = $this->getUser('id');
|
self::$editCommentSignature = $this->signature($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
|
// Commentaires en fonction de la pagination
|
||||||
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
|
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
|
||||||
// Signatures des commentaires
|
// Signatures des commentaires
|
||||||
$e = $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'comment', $commentIds[$i],'userId']);
|
$e = $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'comment', $commentIds[$i],'userId']);
|
||||||
if ($e) {
|
if ($e) {
|
||||||
switch ($this->getData(['user', $e, 'signature'])){
|
self::$commentsSignature[$commentIds[$i]] = $this->signature($e);
|
||||||
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 {
|
} else {
|
||||||
self::$commentsSignature[$commentIds[$i]] = $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'comment', $commentIds[$i],'author']);
|
self::$commentsSignature[$commentIds[$i]] = $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'comment', $commentIds[$i],'author']);
|
||||||
}
|
}
|
||||||
@ -762,5 +726,27 @@ class blog extends common {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la signature d'un utilisateur
|
||||||
|
*/
|
||||||
|
private function signature($userId) {
|
||||||
|
switch ($this->getData(['user', $userId, 'signature'])){
|
||||||
|
case 1:
|
||||||
|
return $userId;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return $this->getData(['user', $userId, 'pseudo']);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
return $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
return $this->getData(['user', $userId, 'lastname']) . ' ' . $this->getData(['user', $userId, 'firstname']);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return $this->getData(['user', $userId, 'firstname']);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,8 @@ class news extends common {
|
|||||||
'delete' => self::GROUP_MODERATOR,
|
'delete' => self::GROUP_MODERATOR,
|
||||||
'edit' => self::GROUP_MODERATOR,
|
'edit' => self::GROUP_MODERATOR,
|
||||||
'index' => self::GROUP_VISITOR,
|
'index' => self::GROUP_VISITOR,
|
||||||
'rss' => self::GROUP_VISITOR
|
'rss' => self::GROUP_VISITOR,
|
||||||
|
'signature' => self::GROUP_VISITOR
|
||||||
];
|
];
|
||||||
|
|
||||||
public static $news = [];
|
public static $news = [];
|
||||||
@ -53,11 +54,11 @@ class news extends common {
|
|||||||
$feeds = new \FeedWriter\RSS2();
|
$feeds = new \FeedWriter\RSS2();
|
||||||
|
|
||||||
// En-tête
|
// En-tête
|
||||||
$feeds->setTitle($this->getData (['page', $this->getUrl(0),'posts','title']));
|
$feeds->setTitle($this->getData (['page', $this->getUrl(0),'title']));
|
||||||
$feeds->setLink(helper::baseUrl() . $this->getUrl(0));
|
$feeds->setLink(helper::baseUrl() . $this->getUrl(0));
|
||||||
$feeds->setDescription(html_entity_decode(strip_tags($this->getData (['page', $this->getUrl(0), 'metaDescription']))));
|
$feeds->setDescription($this->getData (['page', $this->getUrl(0), 'metaDescription']));
|
||||||
$feeds->setChannelElement('language', 'fr-FR');
|
$feeds->setChannelElement('language', 'fr-FR');
|
||||||
$feeds->setDate(time());
|
$feeds->setDate(date('r',time()));
|
||||||
$feeds->addGenerator();
|
$feeds->addGenerator();
|
||||||
// Corps des articles
|
// Corps des articles
|
||||||
$newsIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC');
|
$newsIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC');
|
||||||
@ -67,10 +68,14 @@ class news extends common {
|
|||||||
foreach($newsIdsPublishedOns as $newsId => $newsPublishedOn) {
|
foreach($newsIdsPublishedOns as $newsId => $newsPublishedOn) {
|
||||||
if($newsPublishedOn <= time() AND $newsIdsStates[$newsId]) {
|
if($newsPublishedOn <= time() AND $newsIdsStates[$newsId]) {
|
||||||
$newsArticle = $feeds->createNewItem();
|
$newsArticle = $feeds->createNewItem();
|
||||||
|
$author = $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $newsId, 'userId']));
|
||||||
$newsArticle->addElementArray([
|
$newsArticle->addElementArray([
|
||||||
'title' => strip_tags($this->getData(['module', $this->getUrl(0),'posts', $newsId, 'title']) ),
|
'title' => $this->getData(['module', $this->getUrl(0),'posts', $newsId, 'title']),
|
||||||
'link' => helper::baseUrl() . $this->getUrl(0),
|
'link' => helper::baseUrl() . $this->getUrl(0),
|
||||||
'description' => html_entity_decode(strip_tags($this->getData(['module', $this->getUrl(0),'posts', $newsId, 'content'])))
|
'description' => $this->getData(['module', $this->getUrl(0),'posts', $newsId, 'content']),
|
||||||
|
'setId' => helper::baseUrl() .$this->getUrl(0) . '/' . $newsId,
|
||||||
|
'setAuthor' => $author,
|
||||||
|
'setDate' => date('r', $this->getData(['module', $this->getUrl(0), 'posts', $newsId, 'publishedOn']))
|
||||||
]);
|
]);
|
||||||
$feeds->addItem($newsArticle);
|
$feeds->addItem($newsArticle);
|
||||||
}
|
}
|
||||||
@ -302,4 +307,26 @@ class news extends common {
|
|||||||
'view' => 'index'
|
'view' => 'index'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la signature d'un utilisateur
|
||||||
|
*/
|
||||||
|
private function signature($userId) {
|
||||||
|
switch ($this->getData(['user', $userId, 'signature'])){
|
||||||
|
case 1:
|
||||||
|
return $userId;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return $this->getData(['user', $userId, 'pseudo']);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
return $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
return $this->getData(['user', $userId, 'lastname']) . ' ' . $this->getData(['user', $userId, 'firstname']);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return $this->getData(['user', $userId, 'firstname']);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user