diff options
| -rw-r--r-- | classes/FeedEnclosure.php | 14 | ||||
| -rw-r--r-- | classes/FeedItem_Atom.php | 9 | ||||
| -rw-r--r-- | classes/FeedItem_Common.php | 53 | ||||
| -rw-r--r-- | classes/FeedItem_RSS.php | 15 | ||||
| -rw-r--r-- | classes/PluginHost.php | 3 |
5 files changed, 48 insertions, 46 deletions
diff --git a/classes/FeedEnclosure.php b/classes/FeedEnclosure.php index 6ef9bca5e..1e53de2e8 100644 --- a/classes/FeedEnclosure.php +++ b/classes/FeedEnclosure.php @@ -1,11 +1,9 @@ <?php class FeedEnclosure { - function __construct( - public string $link = '', - public string $type = '', - public string $length = '', - public string $title = '', - public string $height = '', - public string $width = '', - ) {} + public string $link; + public string $type; + public string $length; + public string $title; + public string $height; + public string $width; } diff --git a/classes/FeedItem_Atom.php b/classes/FeedItem_Atom.php index ad1bddc07..6996705da 100644 --- a/classes/FeedItem_Atom.php +++ b/classes/FeedItem_Atom.php @@ -184,11 +184,10 @@ class FeedItem_Atom extends FeedItem_Common { $base = $this->xpath->evaluate("string(ancestor-or-self::*[@xml:base][1]/@xml:base)", $link); if ($link->getAttribute("rel") == "enclosure") { - $enc = new FeedEnclosure( - type: clean($link->getAttribute('type')), - length: clean($link->getAttribute('length')), - link: clean($link->getAttribute('href')), - ); + $enc = new FeedEnclosure(); + $enc->type = clean($link->getAttribute('type')); + $enc->length = clean($link->getAttribute('length')); + $enc->link = clean($link->getAttribute('href')); if (!empty($base)) { $enc->link = UrlHelper::rewrite_relative($base, $enc->link); diff --git a/classes/FeedItem_Common.php b/classes/FeedItem_Common.php index 5b30ab20c..5ec958699 100644 --- a/classes/FeedItem_Common.php +++ b/classes/FeedItem_Common.php @@ -1,10 +1,14 @@ <?php abstract class FeedItem_Common extends FeedItem { - function __construct( - protected readonly DOMElement $elem, - protected readonly DOMDocument $doc, - protected readonly DOMXPath $xpath, - ) { + protected readonly DOMElement $elem; + protected readonly DOMDocument $doc; + protected readonly DOMXPath $xpath; + + function __construct(DOMElement $elem, DOMDocument $doc, DOMXPath $xpath) { + $this->elem = $elem; + $this->doc = $doc; + $this->xpath = $xpath; + try { $source = $elem->getElementsByTagName("source")->item(0); @@ -88,13 +92,12 @@ abstract class FeedItem_Common extends FeedItem { $enclosures = $this->xpath->query("media:content", $this->elem); foreach ($enclosures as $enclosure) { - $enc = new FeedEnclosure( - type: clean($enclosure->getAttribute('type')), - link: clean($enclosure->getAttribute('url')), - length: clean($enclosure->getAttribute('length')), - height: clean($enclosure->getAttribute('height')), - width: clean($enclosure->getAttribute('width')), - ); + $enc = new FeedEnclosure(); + $enc->type = clean($enclosure->getAttribute('type')); + $enc->link = clean($enclosure->getAttribute('url')); + $enc->length = clean($enclosure->getAttribute('length')); + $enc->height = clean($enclosure->getAttribute('height')); + $enc->width = clean($enclosure->getAttribute('width')); $medium = clean($enclosure->getAttribute("medium")); if (!$enc->type && $medium) { @@ -114,13 +117,12 @@ abstract class FeedItem_Common extends FeedItem { $content = $this->xpath->query("media:content", $enclosure)->item(0); if ($content) { - $enc = new FeedEnclosure( - type: clean($content->getAttribute('type')), - link: clean($content->getAttribute('url')), - length: clean($content->getAttribute('length')), - height: clean($content->getAttribute('height')), - width: clean($content->getAttribute('width')), - ); + $enc = new FeedEnclosure(); + $enc->type = clean($content->getAttribute('type')); + $enc->link = clean($content->getAttribute('url')); + $enc->length = clean($content->getAttribute('length')); + $enc->height = clean($content->getAttribute('height')); + $enc->width = clean($content->getAttribute('width')); $medium = clean($content->getAttribute("medium")); if (!$enc->type && $medium) { @@ -142,12 +144,13 @@ abstract class FeedItem_Common extends FeedItem { $enclosures = $this->xpath->query("media:thumbnail", $this->elem); foreach ($enclosures as $enclosure) { - $encs[] = new FeedEnclosure( - type: 'image/generic', - link: clean($enclosure->getAttribute('url')), - height: clean($enclosure->getAttribute('height')), - width: clean($enclosure->getAttribute('width')), - ); + $enc = new FeedEnclosure(); + $enc->type = 'image/generic'; + $enc->link = clean($enclosure->getAttribute('url')); + $enc->height = clean($enclosure->getAttribute('height')); + $enc->width = clean($enclosure->getAttribute('width')); + + array_push($encs, $enc); } return $encs; diff --git a/classes/FeedItem_RSS.php b/classes/FeedItem_RSS.php index 2970e43bd..6e1435310 100644 --- a/classes/FeedItem_RSS.php +++ b/classes/FeedItem_RSS.php @@ -141,13 +141,14 @@ class FeedItem_RSS extends FeedItem_Common { $encs = array(); foreach ($enclosures as $enclosure) { - $encs[] = new FeedEnclosure( - type: clean($enclosure->getAttribute('type')), - link: clean($enclosure->getAttribute('url')), - length: clean($enclosure->getAttribute('length')), - height: clean($enclosure->getAttribute('height')), - width: clean($enclosure->getAttribute('width')), - ); + $enc = new FeedEnclosure(); + $enc->type = clean($enclosure->getAttribute('type')); + $enc->link = clean($enclosure->getAttribute('url')); + $enc->length = clean($enclosure->getAttribute('length')); + $enc->height = clean($enclosure->getAttribute('height')); + $enc->width = clean($enclosure->getAttribute('width')); + + array_push($encs, $enc); } array_push($encs, ...parent::get_enclosures()); diff --git a/classes/PluginHost.php b/classes/PluginHost.php index e40cf86ad..97d0c45c7 100644 --- a/classes/PluginHost.php +++ b/classes/PluginHost.php @@ -784,8 +784,9 @@ class PluginHost { /** * convert feed_id (e.g. -129) to pfeed_id first + * @return (Plugin&IVirtualFeed)|null */ - function get_feed_handler(int $pfeed_id): (Plugin&IVirtualFeed)|null { + function get_feed_handler(int $pfeed_id): ?Plugin { foreach ($this->feeds as $cat) { foreach ($cat as $feed) { if ($feed['id'] == $pfeed_id) { |