X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=include%2Ffeed.php;h=12cf06ca5093d6d674a3569bd76e05f1349c0de9;hb=aeb6e53d02fdbc3208851a9a4dc8323db29c62c5;hp=2959933703103d72f2ace8dce104c7995099bc80;hpb=077c4cadf17812296d83efe22b0754cded91aca4;p=friendica.git
diff --git a/include/feed.php b/include/feed.php
index 2959933703..12cf06ca50 100644
--- a/include/feed.php
+++ b/include/feed.php
@@ -55,7 +55,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
if ($xpath->query('/atom:feed')->length > 0) {
$alternate = $xpath->query("atom:link[@rel='alternate']")->item(0)->attributes;
if (is_object($alternate)) {
- foreach($alternate AS $attributes) {
+ foreach ($alternate AS $attributes) {
if ($attributes->name == "href") {
$author["author-link"] = $attributes->textContent;
}
@@ -68,7 +68,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
if ($author["author-link"] == "") {
$self = $xpath->query("atom:link[@rel='self']")->item(0)->attributes;
if (is_object($self)) {
- foreach($self AS $attributes) {
+ foreach ($self AS $attributes) {
if ($attributes->name == "href") {
$author["author-link"] = $attributes->textContent;
}
@@ -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;
@@ -163,7 +171,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
$header["contact-id"] = $contact["id"];
- if(!strlen($contact["notify"])) {
+ if (!strlen($contact["notify"])) {
// one way feed - no remote comment ability
$header["last-child"] = 0;
}
@@ -188,7 +196,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
$alternate = $xpath->query("atom:link", $entry)->item(0)->attributes;
}
if (is_object($alternate)) {
- foreach($alternate AS $attributes) {
+ foreach ($alternate AS $attributes) {
if ($attributes->name == "href") {
$item["plink"] = $attributes->textContent;
}
@@ -200,7 +208,6 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
if ($item["plink"] == "") {
$item["plink"] = $xpath->evaluate('rss:link/text()', $entry)->item(0)->nodeValue;
}
- $item["plink"] = original_url($item["plink"]);
$item["uri"] = $xpath->evaluate('atom:id/text()', $entry)->item(0)->nodeValue;
@@ -210,12 +217,17 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
if ($item["uri"] == "") {
$item["uri"] = $item["plink"];
}
+
+ $orig_plink = $item["plink"];
+
+ $item["plink"] = original_url($item["plink"]);
+
$item["parent-uri"] = $item["uri"];
if (!$simulate) {
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s', '%s')",
intval($importer["uid"]), dbesc($item["uri"]), dbesc(NETWORK_FEED), dbesc(NETWORK_DFRN));
- if ($r) {
+ if (dbm::is_result($r)) {
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$r[0]["id"], LOGGER_DEBUG);
continue;
}
@@ -267,6 +279,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
if ($creator != "") {
$item["author-name"] = $creator;
}
+
/// @TODO ?
// Ausland
//
@@ -280,7 +293,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
$type = "";
$title = "";
- foreach($enclosure->attributes AS $attributes) {
+ foreach ($enclosure->attributes AS $attributes) {
if ($attributes->name == "url") {
$href = $attributes->textContent;
} elseif ($attributes->name == "length") {
@@ -289,8 +302,9 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
$type = $attributes->textContent;
}
}
- if(strlen($item["attach"]))
+ if (strlen($item["attach"])) {
$item["attach"] .= ',';
+ }
$attachments[] = array("link" => $href, "type" => $type, "length" => $length);
@@ -324,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) {
@@ -340,6 +364,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
// Distributed items should have a well formatted URI.
// Additionally we have to avoid conflicts with identical URI between imported feeds and these items.
if ($notify) {
+ $item['guid'] = uri_to_guid($orig_plink, $a->get_hostname());
unset($item['uri']);
unset($item['parent-uri']);
}
@@ -359,4 +384,3 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
return array("header" => $author, "items" => $items);
}
}
-?>