mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-04 01:55:21 +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:
parent
4095cad9b4
commit
988635dcf3
9 changed files with 583 additions and 66 deletions
|
@ -25,24 +25,24 @@ class MrssFormat extends FormatAbstract {
|
|||
|
||||
$items = '';
|
||||
foreach($this->getItems() as $item) {
|
||||
$itemAuthor = isset($item['author']) ? $this->xml_encode($item['author']) : '';
|
||||
$itemTitle = strip_tags(isset($item['title']) ? $this->xml_encode($item['title']) : '');
|
||||
$itemUri = isset($item['uri']) ? $this->xml_encode($item['uri']) : '';
|
||||
$itemTimestamp = isset($item['timestamp']) ? $this->xml_encode(date(DATE_RFC2822, $item['timestamp'])) : '';
|
||||
$itemContent = isset($item['content']) ? $this->xml_encode($this->sanitizeHtml($item['content'])) : '';
|
||||
$itemAuthor = $this->xml_encode($item->getAuthor());
|
||||
$itemTitle = $this->xml_encode($item->getTitle());
|
||||
$itemUri = $this->xml_encode($item->getURI());
|
||||
$itemTimestamp = $this->xml_encode(date(DATE_RFC2822, $item->getTimestamp()));
|
||||
$itemContent = $this->xml_encode($this->sanitizeHtml($item->getContent()));
|
||||
|
||||
$entryEnclosuresWarning = '';
|
||||
$entryEnclosures = '';
|
||||
if(isset($item['enclosures'])) {
|
||||
if(!empty($item->getEnclosures())) {
|
||||
$entryEnclosures .= '<enclosure url="'
|
||||
. $this->xml_encode($item['enclosures'][0])
|
||||
. '" type="' . getMimeType($item['enclosures'][0]) . '" />';
|
||||
. $this->xml_encode($item->getEnclosures()[0])
|
||||
. '" type="' . getMimeType($item->getEnclosures()[0]) . '" />';
|
||||
|
||||
if(count($item['enclosures']) > 1) {
|
||||
if(count($item->getEnclosures()) > 1) {
|
||||
$entryEnclosures .= PHP_EOL;
|
||||
$entryEnclosuresWarning = '<br>Warning:
|
||||
Some media files might not be shown to you. Consider using the ATOM format instead!';
|
||||
foreach($item['enclosures'] as $enclosure) {
|
||||
foreach($item->getEnclosures() as $enclosure) {
|
||||
$entryEnclosures .= '<atom:link rel="enclosure" href="'
|
||||
. $enclosure . '" type="' . getMimeType($enclosure) . '" />'
|
||||
. PHP_EOL;
|
||||
|
@ -51,13 +51,10 @@ Some media files might not be shown to you. Consider using the ATOM format inste
|
|||
}
|
||||
|
||||
$entryCategories = '';
|
||||
if(isset($item['categories'])) {
|
||||
|
||||
foreach($item['categories'] as $category) {
|
||||
$entryCategories .= '<category>'
|
||||
. $category . '</category>'
|
||||
. PHP_EOL;
|
||||
}
|
||||
foreach($item->getCategories() as $category) {
|
||||
$entryCategories .= '<category>'
|
||||
. $category . '</category>'
|
||||
. PHP_EOL;
|
||||
}
|
||||
|
||||
$items .= <<<EOD
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue