]> git.mxchange.org Git - friendica.git/blobdiff - include/feed.php
Add defuse/php-encryption 2.0 to Composer dependencies
[friendica.git] / include / feed.php
index db6f631d45af6accbbef5c97c6c98b334c7ecbae..22deff535a2383dd47822296ccb7ee680f3c7d90 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+use Friendica\Database\DBM;
 require_once("include/html2bbcode.php");
 require_once("include/items.php");
 
@@ -235,7 +236,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
                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 (dbm::is_result($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;
                        }
@@ -353,11 +354,28 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
                                }
                        }
 
-                       if (strlen($item["title"]) > strlen($item["body"])) {
-//echo "*".strlen($item["title"]).">".strlen($item["body"])."\n";
+                       // Remove a possible link to the item itself
+                       $item["body"] = str_replace($item["plink"], '', $item["body"]);
+                       $item["body"] = preg_replace('/\[url\=\](\w+.*?)\[\/url\]/i', '', $item["body"]);
+
+                       // Replace the content when the title is longer than the body
+                       $replace = (strlen($item["title"]) > strlen($item["body"]));
+
+                       // Replace it, when there is an image in the body
+                       if (strstr($item["body"], '[/img]')) {
+                               $replace = true;
+                       }
+
+                       // Replace it, when there is a link in the body
+                       if (strstr($item["body"], '[/url]')) {
+                               $replace = true;
+                       }
+
+                       if ($replace) {
                                $item["body"] = $item["title"];
-                               $item["title"] = "";
                        }
+                       // We always strip the title since it will be added in the page information
+                       $item["title"] = "";
                        $item["body"] = $item["body"].add_page_info($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
                        $item["tag"] = add_page_keywords($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
                        $item["object-type"] = ACTIVITY_OBJ_BOOKMARK;