X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Ffeed.php;h=5676566c422d5538bcde68cc4279f5aff4e9ca39;hb=9f2196aa1aa0dc112e3fc238832828d4e22fe137;hp=cfef6d4ad03deb12b562840dfec395a827601eb9;hpb=fa3fa42d966e00534aa6cbf33d60ef438a8e3b97;p=friendica.git diff --git a/include/feed.php b/include/feed.php index cfef6d4ad0..5676566c42 100644 --- a/include/feed.php +++ b/include/feed.php @@ -28,7 +28,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) { } $doc = new DOMDocument(); - @$doc->loadXML($xml); + @$doc->loadXML(trim($xml)); $xpath = new DomXPath($doc); $xpath->registerNamespace('atom', NAMESPACE_ATOM1); $xpath->registerNamespace('dc', "http://purl.org/dc/elements/1.1/"); @@ -108,6 +108,14 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) { if ($value != "") { $author["author-about"] = $value; } + $avatar = $xpath->evaluate("atom:author/atom:link[@rel='avatar']")->item(0)->attributes; + if (is_object($avatar)) { + foreach ($avatar AS $attributes) { + if ($attributes->name == "href") { + $author["author-avatar"] = $attributes->textContent; + } + } + } } $author["edited"] = $author["created"] = $xpath->query('/atom:feed/atom:updated/text()')->item(0)->nodeValue; @@ -330,12 +338,22 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) { if ($body == "") { $body = trim($xpath->evaluate('atom:summary/text()', $entry)->item(0)->nodeValue); } + // remove the content of the title if it is identically to the body // This helps with auto generated titles e.g. from tumblr if (title_is_body($item["title"], $body)) { $item["title"] = ""; } $item["body"] = html2bbcode($body); + + if (($item["body"] == '') && ($item["title"] != '')) { + $item["body"] = $item["title"]; + $item["title"] = ''; + } + + if (!strstr($item["body"], '[url') && ($item['plink'] != '')) { + $item["body"] .= "[hr][url]".$item['plink']."[/url]"; + } } if (!$simulate) {