Premier commit
This commit is contained in:
parent
cafb3cd1ee
commit
f3d1c930d7
@ -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;
|
||||
|
@ -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 = '<?xml version="1.0" encoding="UTF-8"?>';
|
||||
$feeds .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
|
||||
$feeds .= '<channel>';
|
||||
$feeds .= '<title>' . $this->getData (['page', $this->getUrl(0),'title']) . '</title>';
|
||||
$feeds .= '<link>' . helper::baseUrl() .'</link>';
|
||||
$feeds .= '<description>' . html_entity_decode(strip_tags($this->getData (['page', $this->getUrl(0), 'metaDescription']))) . '</description>';
|
||||
$feeds .= '<language>fr-FR</language>';
|
||||
// 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 .= '<item>';
|
||||
$feeds .= '<title>' . strip_tags($this->getData(['module', $this->getUrl(0), $articleId, 'title']) ) . '</title>';
|
||||
$feeds .= '<link>' . helper::baseUrl() .$this->getUrl(0) . '</link>';
|
||||
$feeds .= '<description>' . html_entity_decode(strip_tags($this->getData(['module', $this->getUrl(0), $articleId, 'content']))) . '</description>';
|
||||
//$feeds .= '<guid>' . $this->getData(['module', $this->getUrl(0), $newsId, 'publishedOn']) . '</guid>';
|
||||
$date = new DateTime($this->getData(['module', $this->getUrl(0), $articleId, 'publishedOn']));
|
||||
$feeds .= '<pubDate>' . $date->format(DateTime::RFC822). '</pubDate>';
|
||||
$feeds .= '</item>';
|
||||
}
|
||||
}
|
||||
// Pied
|
||||
$feeds .= '</channel>';
|
||||
$feeds .= '</rss>';
|
||||
// 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,
|
||||
|
BIN
module/blog/ressource/feed-icon-16.gif
Normal file
BIN
module/blog/ressource/feed-icon-16.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 652 B |
@ -46,4 +46,8 @@
|
||||
.blogContent {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
#rssIcon {
|
||||
text-align: right;
|
||||
}
|
@ -1,4 +1,11 @@
|
||||
<?php if($module::$articles): ?>
|
||||
<div class="row">
|
||||
<div class="col3 offset9 textAlignRight">
|
||||
<a type="application/rss+xml" href="<?php echo $module::$rssUrl ?> ">
|
||||
<img id="rssIcon" src='module/news/ressource/feed-icon-16.gif'>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<?php foreach($module::$articles as $articleId => $article): ?>
|
||||
|
1
module/blog/view/rss/rss.php
Normal file
1
module/blog/view/rss/rss.php
Normal file
@ -0,0 +1 @@
|
||||
<!-- rien -->
|
@ -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 = '<?xml version="1.0" encoding="UTF-8"?>';
|
||||
$feeds .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
|
||||
$feeds .= '<channel>';
|
||||
$feeds .= '<title>' . $this->getData (['page', $this->getUrl(0),'title']) . '</title>';
|
||||
$feeds .= '<link>' . helper::baseUrl() .'</link>';
|
||||
$feeds .= '<description>' . html_entity_decode(strip_tags($this->getData (['page', $this->getUrl(0), 'metaDescription']))) . '</description>';
|
||||
$feeds .= '<language>fr-FR</language>';
|
||||
// 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 .= '<item>';
|
||||
$feeds .= '<title>' . strip_tags($this->getData(['module', $this->getUrl(0), $newsId, 'title']) ) . '</title>';
|
||||
$feeds .= '<link>' . helper::baseUrl() .$this->getUrl(0) . '</link>';
|
||||
$feeds .= '<description>' . html_entity_decode(strip_tags($this->getData(['module', $this->getUrl(0), $newsId, 'content']))) . '</description>';
|
||||
//$feeds .= '<guid>' . $this->getData(['module', $this->getUrl(0), $newsId, 'publishedOn']) . '</guid>';
|
||||
$date = new DateTime($this->getData(['module', $this->getUrl(0), $newsId, 'publishedOn']));
|
||||
$feeds .= '<pubDate>' . $date->format(DateTime::RFC822). '</pubDate>';
|
||||
$feeds .= '</item>';
|
||||
}
|
||||
}
|
||||
// Pied
|
||||
$feeds .= '</channel>';
|
||||
$feeds .= '</rss>';
|
||||
// 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,
|
||||
|
BIN
module/news/ressource/feed-icon-16.gif
Normal file
BIN
module/news/ressource/feed-icon-16.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 652 B |
@ -1 +1,17 @@
|
||||
/* Volontairement vide */
|
||||
/**
|
||||
* 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 <remi.jean@outlook.com>
|
||||
* @copyright Copyright (C) 2008-2018, Rémi Jean
|
||||
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
||||
* @copyright Copyright (C) 2018-2020, Frédéric Tempez
|
||||
* @license GNU General Public License, version 3
|
||||
* @link http://zwiicms.fr/
|
||||
*/
|
||||
|
||||
#rssIcon {
|
||||
text-align: right;
|
||||
}
|
@ -1,4 +1,11 @@
|
||||
<?php if($module::$news): ?>
|
||||
<div class="row">
|
||||
<div class="col3 offset9 textAlignRight">
|
||||
<a type="application/rss+xml" href="<?php echo $module::$rssUrl ?> ">
|
||||
<img id="rssIcon" src='module/news/ressource/feed-icon-16.gif'>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<?php foreach($module::$news as $newsId => $news): ?>
|
||||
@ -23,4 +30,4 @@
|
||||
<?php echo $module::$pages; ?>
|
||||
<?php else: ?>
|
||||
<?php echo template::speech('Aucune news.'); ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
1
module/news/view/rss/rss.php
Normal file
1
module/news/view/rss/rss.php
Normal file
@ -0,0 +1 @@
|
||||
<!-- rien -->
|
Loading…
Reference in New Issue
Block a user