Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+24 -3
View File
@@ -11,7 +11,7 @@
namespace IPS\Xml;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -56,10 +56,11 @@ class _Rss extends SimpleXML
* @param string|NULL $description Item description/content
* @param \IPS\DateTime|NULL $date Item date
* @param string $guid Item ID
* @param \IPS\File $enclosure Enclosure file object
* @return void
* @todo [Future] The feed will validate now, but unrecognized attribute values cause warnings when validating. Also, the validator recommends using an Atom feed with the atom:link attribute.
*/
public function addItem( $title = NULL, \IPS\Http\Url $link = NULL, $description = NULL, \IPS\DateTime $date = NULL, $guid = NULL )
public function addItem( $title = NULL, \IPS\Http\Url $link = NULL, $description = NULL, \IPS\DateTime $date = NULL, $guid = NULL, $enclosure=NULL )
{
if ( $title === NULL and $description === NULL )
{
@@ -95,6 +96,14 @@ class _Rss extends SimpleXML
$item->addChild( 'description', $description );
}
if ( $enclosure !== NULL and $enclosure instanceof \IPS\File and $enclosure->mediaType() == 'image' )
{
$child = $item->addChild( 'enclosure' );
$child->addAttribute( 'url', (string) $enclosure->url );
$child->addAttribute( 'length', (string) $enclosure->filesize() );
$child->addAttribute( 'type', \IPS\File::getMimeType( (string) $enclosure->url ) );
}
if ( $guid !== NULL )
{
@@ -105,6 +114,7 @@ class _Rss extends SimpleXML
{
$item->addChild( 'pubDate', $date->format('r') );
}
}
/**
@@ -160,7 +170,7 @@ class _Rss extends SimpleXML
$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 ) )
if( \count( $item->children( 'content', true ) ) AND \count( $item->children( 'content', true )->encoded ) )
{
$text = (string) $item->children( 'content', true )->encoded[0];
}
@@ -179,6 +189,17 @@ class _Rss extends SimpleXML
'date' => $pubDate ?: \IPS\DateTime::create(),
'link' => $link
);
if ( isset( $item->enclosure ) )
{
$attr = array();
foreach( $item->enclosure->attributes() as $k => $v )
{
$attr[ $k ] = (string) $v;
}
$articles[ $guid ]['enclosure'] = $attr;
}
}
return $articles;
}