diff --git a/core/core.php b/core/core.php
index c9f96495..c5d29407 100644
--- a/core/core.php
+++ b/core/core.php
@@ -17,9 +17,10 @@ class common {
const DISPLAY_RAW = 0;
const DISPLAY_JSON = 1;
- const DISPLAY_LAYOUT_BLANK = 2;
- const DISPLAY_LAYOUT_MAIN = 3;
- const DISPLAY_LAYOUT_LIGHT = 4;
+ const DISPLAY_RSS = 2;
+ const DISPLAY_LAYOUT_BLANK = 3;
+ const DISPLAY_LAYOUT_MAIN = 4;
+ const DISPLAY_LAYOUT_LIGHT = 5;
const GROUP_BANNED = -1;
const GROUP_VISITOR = 0;
const GROUP_MEMBER = 1;
@@ -2096,7 +2097,12 @@ class core extends common {
header('Content-Type: application/json');
echo json_encode($this->output['content']);
break;
- // Layout alléger
+ // RSS feed
+ case self::DISPLAY_RSS:
+ header('Content-type: application/rss+xml; charset=UTF-8');
+ echo $this->output['content'];
+ break;
+ // Layout allégé
case self::DISPLAY_LAYOUT_LIGHT:
require 'core/layout/light.php';
break;
diff --git a/module/blog/blog.php b/module/blog/blog.php
index a13c011c..f736f29c 100644
--- a/module/blog/blog.php
+++ b/module/blog/blog.php
@@ -21,7 +21,8 @@ class blog extends common {
'config' => self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR,
- 'index' => self::GROUP_VISITOR
+ 'index' => self::GROUP_VISITOR,
+ 'rss' => self::GROUP_VISITOR
];
public static $articles = [];
@@ -30,6 +31,8 @@ class blog extends common {
public static $pages;
+ public static $rssUrl;
+
public static $states = [
false => 'Brouillon',
true => 'Publié'
@@ -51,7 +54,45 @@ class blog extends common {
public static $users = [];
- const BLOG_VERSION = '2.02';
+ const BLOG_VERSION = '3.00';
+
+ /**
+ * Flux RSS
+ */
+ public function rss() {
+ // En-tête
+ $feeds = '';
+ $feeds .= '';
+ $feeds .= '';
+ $feeds .= '' . $this->getData (['page', $this->getUrl(0),'title']) . '';
+ $feeds .= '' . helper::baseUrl() .'';
+ $feeds .= '' . html_entity_decode(strip_tags($this->getData (['page', $this->getUrl(0), 'metaDescription']))) . '';
+ $feeds .= 'fr-FR';
+ // Articles
+ $articleIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0)]), 'publishedOn', 'SORT_DESC');
+ $articleIdsStates = helper::arrayCollumn($this->getData(['module', $this->getUrl(0)]), 'state', 'SORT_DESC');
+ foreach($articleIdsPublishedOns as $articleId => $articlePublishedOn) {
+ if($articlePublishedOn <= time() AND $articleIdsStates[$articleId]) {
+ $feeds .= '- ';
+ $feeds .= '' . strip_tags($this->getData(['module', $this->getUrl(0), $articleId, 'title']) ) . '';
+ $feeds .= '' . helper::baseUrl() .$this->getUrl(0) . '';
+ $feeds .= '' . html_entity_decode(strip_tags($this->getData(['module', $this->getUrl(0), $articleId, 'content']))) . '';
+ //$feeds .= '' . $this->getData(['module', $this->getUrl(0), $newsId, 'publishedOn']) . '';
+ $date = new DateTime($this->getData(['module', $this->getUrl(0), $articleId, 'publishedOn']));
+ $feeds .= '' . $date->format(DateTime::RFC822). '';
+ $feeds .= '
';
+ }
+ }
+ // Pied
+ $feeds .= '';
+ $feeds .= '';
+ // Valeurs en sortie
+ $this->addOutput([
+ 'display' => self::DISPLAY_RSS,
+ 'content' => $feeds,
+ 'view' => 'rss'
+ ]);
+ }
/**
* Édition
@@ -436,6 +477,7 @@ class blog extends common {
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
self::$articles[$articleIds[$i]] = $this->getData(['module', $this->getUrl(0), $articleIds[$i]]);
}
+ self::$rssUrl = helper::baseUrl() . $this->getUrl(0) . '/rss';
// Valeurs en sortie
$this->addOutput([
'showBarEditButton' => true,
diff --git a/module/blog/ressource/feed-icon-16.gif b/module/blog/ressource/feed-icon-16.gif
new file mode 100644
index 00000000..b0e4adf1
Binary files /dev/null and b/module/blog/ressource/feed-icon-16.gif differ
diff --git a/module/blog/view/index/index.css b/module/blog/view/index/index.css
index 8213aa1c..e0a4e738 100755
--- a/module/blog/view/index/index.css
+++ b/module/blog/view/index/index.css
@@ -46,4 +46,8 @@
.blogContent {
display: none;
}
+}
+
+#rssIcon {
+ text-align: right;
}
\ No newline at end of file
diff --git a/module/blog/view/index/index.php b/module/blog/view/index/index.php
index 271e2dba..ff470d5e 100644
--- a/module/blog/view/index/index.php
+++ b/module/blog/view/index/index.php
@@ -1,4 +1,11 @@
+
$article): ?>
diff --git a/module/blog/view/rss/rss.php b/module/blog/view/rss/rss.php
new file mode 100644
index 00000000..4b8f6d3c
--- /dev/null
+++ b/module/blog/view/rss/rss.php
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/module/news/news.php b/module/news/news.php
index 10486ec8..ec1661a2 100644
--- a/module/news/news.php
+++ b/module/news/news.php
@@ -19,7 +19,8 @@ class news extends common {
'config' => self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR,
- 'index' => self::GROUP_VISITOR
+ 'index' => self::GROUP_VISITOR,
+ 'rss' => self::GROUP_VISITOR
];
public static $news = [];
@@ -28,14 +29,54 @@ class news extends common {
public static $pages;
+ public static $rssUrl;
+
public static $states = [
false => 'Brouillon',
true => 'Publié'
];
- const NEWS_VERSION = '1.2';
+ const NEWS_VERSION = '2.0';
public static $users = [];
+ /**
+ * Flux RSS
+ */
+ public function rss() {
+ // En-tête
+ $feeds = '';
+ $feeds .= '
';
+ $feeds .= '';
+ $feeds .= '' . $this->getData (['page', $this->getUrl(0),'title']) . '';
+ $feeds .= '' . helper::baseUrl() .'';
+ $feeds .= '' . html_entity_decode(strip_tags($this->getData (['page', $this->getUrl(0), 'metaDescription']))) . '';
+ $feeds .= 'fr-FR';
+ // Articles
+ $newsIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0)]), 'publishedOn', 'SORT_DESC');
+ $newsIdsStates = helper::arrayCollumn($this->getData(['module', $this->getUrl(0)]), 'state', 'SORT_DESC');
+ foreach($newsIdsPublishedOns as $newsId => $newsPublishedOn) {
+ if($newsPublishedOn <= time() AND $newsIdsStates[$newsId]) {
+ $feeds .= '- ';
+ $feeds .= '' . strip_tags($this->getData(['module', $this->getUrl(0), $newsId, 'title']) ) . '';
+ $feeds .= '' . helper::baseUrl() .$this->getUrl(0) . '';
+ $feeds .= '' . html_entity_decode(strip_tags($this->getData(['module', $this->getUrl(0), $newsId, 'content']))) . '';
+ //$feeds .= '' . $this->getData(['module', $this->getUrl(0), $newsId, 'publishedOn']) . '';
+ $date = new DateTime($this->getData(['module', $this->getUrl(0), $newsId, 'publishedOn']));
+ $feeds .= '' . $date->format(DateTime::RFC822). '';
+ $feeds .= '
';
+ }
+ }
+ // Pied
+ $feeds .= '';
+ $feeds .= '';
+ // Valeurs en sortie
+ $this->addOutput([
+ 'display' => self::DISPLAY_RSS,
+ 'content' => $feeds,
+ 'view' => 'rss'
+ ]);
+ }
+
/**
* Édition
*/
@@ -233,6 +274,7 @@ class news extends common {
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
self::$news[$newsIds[$i]] = $this->getData(['module', $this->getUrl(0), $newsIds[$i]]);
}
+ self::$rssUrl = helper::baseUrl() . $this->getUrl(0) . '/rss';
// Valeurs en sortie
$this->addOutput([
'showBarEditButton' => true,
diff --git a/module/news/ressource/feed-icon-16.gif b/module/news/ressource/feed-icon-16.gif
new file mode 100644
index 00000000..b0e4adf1
Binary files /dev/null and b/module/news/ressource/feed-icon-16.gif differ
diff --git a/module/news/view/index/index.css b/module/news/view/index/index.css
index 92caffc5..c9fec874 100755
--- a/module/news/view/index/index.css
+++ b/module/news/view/index/index.css
@@ -1 +1,17 @@
-/* Volontairement vide */
\ No newline at end of file
+/**
+ * This file is part of Zwii.
+ *
+ * For full copyright and license information, please see the LICENSE
+ * file that was distributed with this source code.
+ *
+ * @author Rémi Jean
+ * @copyright Copyright (C) 2008-2018, Rémi Jean
+ * @author Frédéric Tempez
+ * @copyright Copyright (C) 2018-2020, Frédéric Tempez
+ * @license GNU General Public License, version 3
+ * @link http://zwiicms.fr/
+ */
+
+#rssIcon {
+ text-align: right;
+}
\ No newline at end of file
diff --git a/module/news/view/index/index.php b/module/news/view/index/index.php
index 60bbe60b..b296d9ea 100644
--- a/module/news/view/index/index.php
+++ b/module/news/view/index/index.php
@@ -1,4 +1,11 @@
+
$news): ?>
@@ -23,4 +30,4 @@
-
\ No newline at end of file
+
diff --git a/module/news/view/rss/rss.php b/module/news/view/rss/rss.php
new file mode 100644
index 00000000..74056a56
--- /dev/null
+++ b/module/news/view/rss/rss.php
@@ -0,0 +1 @@
+