Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
+36
-12
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Class for managing RSS documents
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -75,7 +75,7 @@ class _Rss extends SimpleXML
|
||||
$item->addChild( 'title', $title );
|
||||
}
|
||||
|
||||
$item->addChild( 'link', $link->rfc3986() );
|
||||
$item->addChild( 'link', (string) $link );
|
||||
|
||||
if ( $description !== NULL )
|
||||
{
|
||||
@@ -127,15 +127,16 @@ class _Rss extends SimpleXML
|
||||
*/
|
||||
public function articles( $guidKey=NULL )
|
||||
{
|
||||
$articles = array();
|
||||
foreach ( $this->channel->item as $item )
|
||||
$articles = array();
|
||||
$items = $this->getItems();
|
||||
foreach ( $items as $item )
|
||||
{
|
||||
$link = NULL;
|
||||
if ( isset( $item->link ) AND $item->link )
|
||||
{
|
||||
try
|
||||
{
|
||||
$link = \IPS\Http\Url::external( $item->link );
|
||||
$link = \IPS\Http\Url::external( (string) $item->link );
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
@@ -158,7 +159,7 @@ class _Rss extends SimpleXML
|
||||
}
|
||||
$guid = md5( $guidKey . $guid );
|
||||
|
||||
$text = (string) $item->description;
|
||||
$text = isset( $item->description ) ? (string) $item->description : (string) $item->title;
|
||||
|
||||
/* If there is a <content:encoded> tag, get the contents of that instead of description */
|
||||
if( count( $item->children( 'content', true ) ) AND count( $item->children( 'content', true )->encoded ) )
|
||||
@@ -167,11 +168,7 @@ class _Rss extends SimpleXML
|
||||
}
|
||||
|
||||
/* Some feeds may not provide a pubDate for the Item or Channel in the feed. Work out which one exists and if neither do, use the current time */
|
||||
$pubDate = NULL;
|
||||
if ( $item->pubDate )
|
||||
{
|
||||
$pubDate = \IPS\DateTime::ts( strtotime( $item->pubDate ), TRUE );
|
||||
}
|
||||
$pubDate = $this->getDate( $item );
|
||||
|
||||
if ( $pubDate === NULL AND $this->channel->pubDate )
|
||||
{
|
||||
@@ -187,4 +184,31 @@ class _Rss extends SimpleXML
|
||||
}
|
||||
return $articles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the date
|
||||
*
|
||||
* @param object $item RSS item
|
||||
* @return NULL|\IPS\DateTime
|
||||
*/
|
||||
protected function getDate( $item )
|
||||
{
|
||||
$pubDate = NULL;
|
||||
if ( $item->pubDate )
|
||||
{
|
||||
$pubDate = \IPS\DateTime::ts( strtotime( $item->pubDate ), TRUE );
|
||||
}
|
||||
|
||||
return $pubDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the items
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getItems()
|
||||
{
|
||||
return $this->channel->item;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user