mirror of
https://github.com/friendica/friendica
synced 2025-04-28 15:44:24 +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 DOMDocument;
|
||||||
use DOMElement;
|
use DOMElement;
|
||||||
|
use DOMNode;
|
||||||
use DOMXPath;
|
use DOMXPath;
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Contact\LocalRelationship\Entity\LocalRelationship;
|
use Friendica\Contact\LocalRelationship\Entity\LocalRelationship;
|
||||||
|
@ -386,23 +387,7 @@ class Feed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($item['title'])) {
|
$item['title'] = static::getTitleFromItemOrEntry($item, $xpath, $atomns, $entry);
|
||||||
$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'));
|
|
||||||
|
|
||||||
$published = XML::getFirstNodeValue($xpath, $atomns . ':published/text()', $entry);
|
$published = XML::getFirstNodeValue($xpath, $atomns . ':published/text()', $entry);
|
||||||
|
|
||||||
|
@ -747,6 +732,31 @@ class Feed
|
||||||
return ['header' => $author, 'items' => $items];
|
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
|
* Return the hostname out of a variety of provided URL
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue