From f3d1c930d71c5cc026249e420302dd8f9a3221c0 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Sun, 15 Nov 2020 18:39:03 +0100 Subject: [PATCH] Premier commit --- core/core.php | 14 +++++--- module/blog/blog.php | 46 +++++++++++++++++++++++-- module/blog/ressource/feed-icon-16.gif | Bin 0 -> 652 bytes module/blog/view/index/index.css | 4 +++ module/blog/view/index/index.php | 7 ++++ module/blog/view/rss/rss.php | 1 + module/news/news.php | 46 +++++++++++++++++++++++-- module/news/ressource/feed-icon-16.gif | Bin 0 -> 652 bytes module/news/view/index/index.css | 18 +++++++++- module/news/view/index/index.php | 9 ++++- module/news/view/rss/rss.php | 1 + 11 files changed, 136 insertions(+), 10 deletions(-) create mode 100644 module/blog/ressource/feed-icon-16.gif create mode 100644 module/blog/view/rss/rss.php create mode 100644 module/news/ressource/feed-icon-16.gif create mode 100644 module/news/view/rss/rss.php 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 0000000000000000000000000000000000000000..b0e4adf1d517547adb01c44d4b91dc78c170b6a5 GIT binary patch literal 652 zcmZ?wbhEHb6krfwc*el+Wun>ZdZS-+EPv0n`Z3e;&({zCe|~<~YVxAe@L9d_w<+eI zdQG2|=)Y_={m^OhuGRS8k57;D^!|N%b}LTnd4>L)F0+RfhHn~;9%Sjhsx^FEY4o_# z@aJ5|7tJR3Qg!}*e0DEi|9+vtokZ=wx3)ekF?ii+`l8kJ-}g^XOY|O<89r|`zE@!I zw8rQ~lgXb$Ew9>5@8;=0sWy6AYxJ_i?AMyOU+0$pSfBZBqR*FQ>F;Kx{5&!HWu4`h zy)%Byb9vwE_-=LQzc;sjE)9COY3j%A(|_+Qe^BcBc}e>FxhY@P6#u!o_50e)zxNOR z`}pkB;X?tj(k`Srkzulr~IeR}rieAnO4Zv4Ey|51V2uYJwG*T+4nasRbB>(}MY z-=|yroMriSlKIDO(^nhX|NsBbKr~SN$pTiZ10q3j!odErfwe$P+R%toOO{t(Rn)kk z$y!51Qk{%#a$H*ZiJ2Ns}=!r?* zzC;clP2T0XA-8-MDRdS$IkE`po9V86lyt^MlhN +
+
+ + + +
+
$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 0000000000000000000000000000000000000000..b0e4adf1d517547adb01c44d4b91dc78c170b6a5 GIT binary patch literal 652 zcmZ?wbhEHb6krfwc*el+Wun>ZdZS-+EPv0n`Z3e;&({zCe|~<~YVxAe@L9d_w<+eI zdQG2|=)Y_={m^OhuGRS8k57;D^!|N%b}LTnd4>L)F0+RfhHn~;9%Sjhsx^FEY4o_# z@aJ5|7tJR3Qg!}*e0DEi|9+vtokZ=wx3)ekF?ii+`l8kJ-}g^XOY|O<89r|`zE@!I zw8rQ~lgXb$Ew9>5@8;=0sWy6AYxJ_i?AMyOU+0$pSfBZBqR*FQ>F;Kx{5&!HWu4`h zy)%Byb9vwE_-=LQzc;sjE)9COY3j%A(|_+Qe^BcBc}e>FxhY@P6#u!o_50e)zxNOR z`}pkB;X?tj(k`Srkzulr~IeR}rieAnO4Zv4Ey|51V2uYJwG*T+4nasRbB>(}MY z-=|yroMriSlKIDO(^nhX|NsBbKr~SN$pTiZ10q3j!odErfwe$P+R%toOO{t(Rn)kk z$y!51Qk{%#a$H*ZiJ2Ns}=!r?* zzC;clP2T0XA-8-MDRdS$IkE`po9V86lyt^MlhN + * @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 @@ +