X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FFeed.php;h=3981a8860cbf4c3f949885634bf9b703015c01a0;hb=7b91c26c3160e3d13e46efda0f7a77ccb1b99083;hp=71ebe5506b9dadd78587e6123646af464d9c2d5f;hpb=bd972151478f40f73585519110700222a1931d44;p=friendica.git diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index 71ebe5506b..3981a8860c 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -17,9 +17,6 @@ use Friendica\Model\Item; use Friendica\Util\Network; use Friendica\Util\XML; -require_once 'include/dba.php'; -require_once 'include/items.php'; - /** * @brief This class contain functions to import feeds * @@ -28,17 +25,18 @@ class Feed { /** * @brief Read a RSS/RDF/Atom feed and create an item entry for it * - * @param string $xml The feed data - * @param array $importer The user record of the importer - * @param array $contact The contact record of the feed - * @param string $hub Unused dummy value for compatibility reasons - * @param bool $simulate If enabled, no data is imported + * @param string $xml The feed data + * @param array $importer The user record of the importer + * @param array $contact The contact record of the feed + * @param string $hub Unused dummy value for compatibility reasons + * @param bool $simulate If enabled, no data is imported * * @return array In simulation mode it returns the header and the first item + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function import($xml, $importer, &$contact, &$hub, $simulate = false) { - $a = get_app(); + $a = \get_app(); if (!$simulate) { Logger::log("Import Atom/RSS feed '".$contact["name"]."' (Contact ".$contact["id"].") for user ".$importer["uid"], Logger::DEBUG); @@ -123,7 +121,13 @@ class Feed { $author["author-name"] = $value; } if ($simulate) { - $author["author-id"] = XML::getFirstNodeValue($xpath, '/atom:feed/atom:author/atom:uri/text()'); + $author["author-id"] = XML::getFirstNodeValue($xpath, '/atom:feed/atom:author/atom:id/text()'); + + // See https://tools.ietf.org/html/rfc4287#section-3.2.2 + $value = XML::getFirstNodeValue($xpath, 'atom:author/atom:uri/text()'); + if ($value != "") { + $author["author-link"] = $value; + } $value = XML::getFirstNodeValue($xpath, 'atom:author/poco:preferredUsername/text()'); if ($value != "") { @@ -314,7 +318,6 @@ class Feed { $href = ""; $length = ""; $type = ""; - $title = ""; foreach ($enclosure->attributes AS $attribute) { if (in_array($attribute->name, ["url", "href"])) { @@ -344,7 +347,7 @@ class Feed { $tags .= ', '; } - $taglink = "#[url=" . System::baseUrl() . "/search?tag=" . rawurlencode($hashtag) . "]" . $hashtag . "[/url]"; + $taglink = "#[url=" . System::baseUrl() . "/search?tag=" . $hashtag . "]" . $hashtag . "[/url]"; $tags .= $taglink; }