]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Feed.php
Merge pull request #4215 from annando/tag-net
[friendica.git] / src / Protocol / Feed.php
index c33852a7d5c70a263f1f7f1cdc2b605eb0d8b7eb..2dafaaf6e71b0e01ac63b26b8b33d958df22c87c 100644 (file)
@@ -10,10 +10,11 @@ use Friendica\Database\DBM;
 use Friendica\Core\System;
 use dba;
 use DOMDocument;
-use DomXPath;
+use DOMXPath;
 
-require_once("include/html2bbcode.php");
-require_once("include/items.php");
+require_once 'include/dba.php';
+require_once 'include/html2bbcode.php';
+require_once 'include/items.php';
 
 /**
  * @brief This class contain functions to import feeds
@@ -31,7 +32,7 @@ class Feed {
         *
         * @return array In simulation mode it returns the header and the first item
         */
-       function import($xml, $importer, &$contact, &$hub, $simulate = false) {
+       public static function import($xml, $importer, &$contact, &$hub, $simulate = false) {
 
                $a = get_app();
 
@@ -55,7 +56,7 @@ class Feed {
 
                $doc = new DOMDocument();
                @$doc->loadXML(trim($xml));
-               $xpath = new DomXPath($doc);
+               $xpath = new DOMXPath($doc);
                $xpath->registerNamespace('atom', NAMESPACE_ATOM1);
                $xpath->registerNamespace('dc', "http://purl.org/dc/elements/1.1/");
                $xpath->registerNamespace('content', "http://purl.org/rss/1.0/modules/content/");
@@ -126,7 +127,7 @@ class Feed {
                                if ($value != "") {
                                        $author["author-nick"] = $value;
                                }
-                               $value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()', $context)->item(0)->nodeValue;
+                               $value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()')->item(0)->nodeValue;
                                if ($value != "") {
                                        $author["author-location"] = $value;
                                }
@@ -253,7 +254,7 @@ class Feed {
                        if (!$simulate) {
                                $condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
                                        $importer["uid"], $item["uri"], NETWORK_FEED, NETWORK_DFRN];
-                               $previous = dba::select('item', ['id'], $condition, ['limit' => 1]);
+                               $previous = dba::selectFirst('item', ['id'], $condition);
                                if (DBM::is_result($previous)) {
                                        logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG);
                                        continue;
@@ -298,9 +299,6 @@ class Feed {
                        if ($creator != "") {
                                $item["author-name"] = $creator;
                        }
-                       if ($pubDate != "") {
-                               $item["edited"] = $item["created"] = $pubDate;
-                       }
                        $creator = $xpath->query('dc:creator/text()', $entry)->item(0)->nodeValue;
 
                        if ($creator != "") {
@@ -419,7 +417,8 @@ class Feed {
                                        }
                                        $item["body"] .= "\n".$item['tag'];
                                }
-                               if (!strstr($item["body"], '[url') && ($item['plink'] != '')) {
+x                              // Add the link to the original feed entry if not present in feed
+                               if (!strstr($item["body"], $item['plink']) && ($item['plink'] != '')) {
                                        $item["body"] .= "[hr][url]".$item['plink']."[/url]";
                                }
                        }