From 283341e75e6ef4fbb3c522635b8a7805d3ab3a20 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 8 Apr 2024 11:10:10 +0200 Subject: Allow multiple authors on enclosures (#6272) fix https://github.com/FreshRSS/FreshRSS/issues/5066 --- app/Models/Entry.php | 13 +++++++++---- app/Models/Feed.php | 9 ++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'app/Models') diff --git a/app/Models/Entry.php b/app/Models/Entry.php index e5e859a1d..c5a9ddc7e 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -201,7 +201,7 @@ HTML; if (!$allowDuplicateEnclosures && self::containsLink($content, $elink)) { continue; } - $credit = $enclosure['credit'] ?? ''; + $credits = $enclosure['credit'] ?? ''; $description = nl2br($enclosure['description'] ?? '', true); $length = $enclosure['length'] ?? 0; $medium = $enclosure['medium'] ?? ''; @@ -238,8 +238,13 @@ HTML; . '" title="' . $etitle . '">💾

'; } - if ($credit != '') { - $content .= '

© ' . $credit . '

'; + if ($credits != '') { + if (!is_array($credits)) { + $credits = [$credits]; + } + foreach ($credits as $credit) { + $content .= '

© ' . $credit . '

'; + } } if ($description != '') { $content .= '
' . $description . '
'; @@ -250,7 +255,7 @@ HTML; return $content; } - /** @return Traversable}> */ + /** @return Traversable,'height'?:int,'width'?:int,'thumbnails'?:array}> */ public function enclosures(bool $searchBodyImages = false): Traversable { $attributeEnclosures = $this->attributeArray('enclosures'); if (is_iterable($attributeEnclosures)) { diff --git a/app/Models/Feed.php b/app/Models/Feed.php index a957c8d10..cde0a91b8 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -520,7 +520,7 @@ class FreshRSS_Feed extends Minz_Model { $elink = $enclosure->get_link(); if ($elink != '') { $etitle = $enclosure->get_title() ?? ''; - $credit = $enclosure->get_credit() ?? null; + $credits = $enclosure->get_credits() ?? null; $description = $enclosure->get_description() ?? ''; $mime = strtolower($enclosure->get_type() ?? ''); $medium = strtolower($enclosure->get_medium() ?? ''); @@ -534,8 +534,11 @@ class FreshRSS_Feed extends Minz_Model { if ($etitle != '') { $attributeEnclosure['title'] = $etitle; } - if ($credit != null) { - $attributeEnclosure['credit'] = $credit->get_name(); + if (is_array($credits)) { + $attributeEnclosure['credit'] = []; + foreach ($credits as $credit) { + $attributeEnclosure['credit'][] = $credit->get_name(); + } } if ($description != '') { $attributeEnclosure['description'] = $description; -- cgit v1.2.3