mirror of
https://github.com/friendica/friendica
synced 2025-04-28 11:44:23 +02:00
Extract method Fee::getTitleFromItemOrEntry()
This commit is contained in:
parent
befb4796f9
commit
f75b67de2f
1 changed files with 27 additions and 17 deletions
|
@ -9,6 +9,7 @@ namespace Friendica\Protocol;
|
|||
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
use DOMNode;
|
||||
use DOMXPath;
|
||||
use Friendica\App;
|
||||
use Friendica\Contact\LocalRelationship\Entity\LocalRelationship;
|
||||
|
@ -386,23 +387,7 @@ class Feed
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($item['title'])) {
|
||||
$item['title'] = XML::getFirstNodeValue($xpath, $atomns . ':title/text()', $entry);
|
||||
}
|
||||
|
||||
if (empty($item['title'])) {
|
||||
$item['title'] = XML::getFirstNodeValue($xpath, 'title/text()', $entry);
|
||||
}
|
||||
|
||||
if (empty($item['title'])) {
|
||||
$item['title'] = XML::getFirstNodeValue($xpath, 'rss:title/text()', $entry);
|
||||
}
|
||||
|
||||
if (empty($item['title'])) {
|
||||
$item['title'] = XML::getFirstNodeValue($xpath, 'itunes:title/text()', $entry);
|
||||
}
|
||||
|
||||
$item['title'] = trim(html_entity_decode($item['title'], ENT_QUOTES, 'UTF-8'));
|
||||
$item['title'] = static::getTitleFromItemOrEntry($item, $xpath, $atomns, $entry);
|
||||
|
||||
$published = XML::getFirstNodeValue($xpath, $atomns . ':published/text()', $entry);
|
||||
|
||||
|
@ -747,6 +732,31 @@ class Feed
|
|||
return ['header' => $author, 'items' => $items];
|
||||
}
|
||||
|
||||
private static function getTitleFromItemOrEntry(array $item, DOMXPath $xpath, string $atomns, ?DOMNode $entry): string
|
||||
{
|
||||
$title = (string) $item['title'];
|
||||
|
||||
if (empty($title)) {
|
||||
$title = XML::getFirstNodeValue($xpath, $atomns . ':title/text()', $entry);
|
||||
}
|
||||
|
||||
if (empty($title)) {
|
||||
$title = XML::getFirstNodeValue($xpath, 'title/text()', $entry);
|
||||
}
|
||||
|
||||
if (empty($title)) {
|
||||
$title = XML::getFirstNodeValue($xpath, 'rss:title/text()', $entry);
|
||||
}
|
||||
|
||||
if (empty($title)) {
|
||||
$title = XML::getFirstNodeValue($xpath, 'itunes:title/text()', $entry);
|
||||
}
|
||||
|
||||
$title = trim(html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the hostname out of a variety of provided URL
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue