1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-07 09:06:36 +02:00

core: Add FeedItem class (#940)

Add transformation from legacy items to FeedItems, before transforming
items to the desired format. This allows using legacy bridges alongside
bridges that return FeedItems.

As discussed in #940, instead of throwing exceptions on invalid
parameters, add messages to the debug log instead

Add support for strings to setTimestamp(). If the provided timestamp
is a string, automatically try to parse it using strtotime().

This allows bridges to simply use `$item['timestamp'] = $timestamp;`
instead of `$item['timestamp'] = strtotime($timestamp);`

Support simple_html_dom_node as input paramter for setURI

Support simple_html_dom_node as input parameter for setContent
This commit is contained in:
LogMANOriginal
2018-12-26 22:41:32 +01:00
committed by GitHub
parent 4095cad9b4
commit 988635dcf3
9 changed files with 583 additions and 66 deletions

View File

@@ -9,31 +9,31 @@ class HtmlFormat extends FormatAbstract {
$entries = '';
foreach($this->getItems() as $item) {
$entryAuthor = isset($item['author']) ? '<br /><p class="author">by: ' . $item['author'] . '</p>' : '';
$entryTitle = isset($item['title']) ? $this->sanitizeHtml(strip_tags($item['title'])) : '';
$entryUri = isset($item['uri']) ? $item['uri'] : $uri;
$entryAuthor = $item->getAuthor() ? '<br /><p class="author">by: ' . $item->getAuthor() . '</p>' : '';
$entryTitle = $this->sanitizeHtml(strip_tags($item->getTitle()));
$entryUri = $item->getURI() ?: $uri;
$entryTimestamp = '';
if(isset($item['timestamp'])) {
if($item->getTimestamp()) {
$entryTimestamp = '<time datetime="'
. date(DATE_ATOM, $item['timestamp'])
. date(DATE_ATOM, $item->getTimestamp())
. '">'
. date(DATE_ATOM, $item['timestamp'])
. date(DATE_ATOM, $item->getTimestamp())
. '</time>';
}
$entryContent = '';
if(isset($item['content'])) {
if($item->getContent()) {
$entryContent = '<div class="content">'
. $this->sanitizeHtml($item['content'])
. $this->sanitizeHtml($item->getContent())
. '</div>';
}
$entryEnclosures = '';
if(isset($item['enclosures'])) {
if(!empty($item->getEnclosures())) {
$entryEnclosures = '<div class="attachments"><p>Attachments:</p>';
foreach($item['enclosures'] as $enclosure) {
foreach($item->getEnclosures() as $enclosure) {
$url = $this->sanitizeHtml($enclosure);
$entryEnclosures .= '<li class="enclosure"><a href="'
@@ -47,10 +47,10 @@ class HtmlFormat extends FormatAbstract {
}
$entryCategories = '';
if(isset($item['categories']) && count($item['categories']) > 0) {
if(!empty($item->getCategories())) {
$entryCategories = '<div class="categories"><p>Categories:</p>';
foreach($item['categories'] as $category) {
foreach($item->getCategories() as $category) {
$entryCategories .= '<li class="category">'
. $this->sanitizeHtml($category)