]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/OStatus.php
Merge pull request #5109 from rabuzarus/20180522_-_frio_nav_about_instance
[friendica.git] / src / Protocol / OStatus.php
index bf0cca90c21e91adcf233adcf1d668eeedb632c0..8b6939214496aa61ff92b5598cc120ed397f4e0c 100644 (file)
@@ -5,6 +5,7 @@
 namespace Friendica\Protocol;
 
 use Friendica\Content\Text\BBCode;
+use Friendica\Content\Text\HTML;
 use Friendica\Core\Cache;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
@@ -25,7 +26,6 @@ use DOMDocument;
 use DOMXPath;
 
 require_once 'include/dba.php';
-require_once 'include/html2bbcode.php';
 require_once 'include/items.php';
 require_once 'mod/share.php';
 require_once 'include/enotify.php';
@@ -171,7 +171,7 @@ class OStatus
 
                        $value = $xpath->evaluate('atom:author/poco:note/text()', $context)->item(0)->nodeValue;
                        if ($value != "") {
-                               $contact["about"] = html2bbcode($value);
+                               $contact["about"] = HTML::toBBCode($value);
                        }
 
                        $value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()', $context)->item(0)->nodeValue;
@@ -559,7 +559,7 @@ class OStatus
         */
        private static function processPost($xpath, $entry, &$item, $importer)
        {
-               $item["body"] = html2bbcode($xpath->query('atom:content/text()', $entry)->item(0)->nodeValue);
+               $item["body"] = HTML::toBBCode($xpath->query('atom:content/text()', $entry)->item(0)->nodeValue);
                $item["object-type"] = $xpath->query('activity:object-type/text()', $entry)->item(0)->nodeValue;
                if (($item["object-type"] == ACTIVITY_OBJ_BOOKMARK) || ($item["object-type"] == ACTIVITY_OBJ_EVENT)) {
                        $item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
@@ -661,7 +661,7 @@ class OStatus
                if (($item["verb"] == ACTIVITY_POST) && $xpath->evaluate('boolean(atom:summary)', $entry)) {
                        $clear_text = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
                        if (!empty($clear_text)) {
-                               $item['content-warning'] = html2bbcode($clear_text);
+                               $item['content-warning'] = HTML::toBBCode($clear_text);
                        }
                }
 
@@ -1019,7 +1019,7 @@ class OStatus
                $item["author-link"] = $orig_author["author-link"];
                $item["author-avatar"] = $orig_author["author-avatar"];
 
-               $item["body"] = html2bbcode($orig_body);
+               $item["body"] = HTML::toBBCode($orig_body);
                $item["created"] = $orig_created;
                $item["edited"] = $orig_edited;
 
@@ -1313,7 +1313,7 @@ class OStatus
        }
 
        /**
-        * @brief Adds attachement data to the XML document
+        * @brief Adds attachment data to the XML document
         *
         * @param object $doc  XML document
         * @param object $root XML root element where the hub links are added
@@ -1328,11 +1328,13 @@ class OStatus
                switch ($siteinfo["type"]) {
                        case 'photo':
                                $imgdata = Image::getInfoFromURL($siteinfo["image"]);
-                               $attributes = ["rel" => "enclosure",
-                                               "href" => $siteinfo["image"],
-                                               "type" => $imgdata["mime"],
-                                               "length" => intval($imgdata["size"])];
-                               XML::addElement($doc, $root, "link", "", $attributes);
+                               if ($imgdata) {
+                                       $attributes = ["rel" => "enclosure",
+                                                       "href" => $siteinfo["image"],
+                                                       "type" => $imgdata["mime"],
+                                                       "length" => intval($imgdata["size"])];
+                                       XML::addElement($doc, $root, "link", "", $attributes);
+                               }
                                break;
                        case 'video':
                                $attributes = ["rel" => "enclosure",
@@ -1348,12 +1350,14 @@ class OStatus
 
                if (!Config::get('system', 'ostatus_not_attach_preview') && ($siteinfo["type"] != "photo") && isset($siteinfo["image"])) {
                        $imgdata = Image::getInfoFromURL($siteinfo["image"]);
-                       $attributes = ["rel" => "enclosure",
-                                       "href" => $siteinfo["image"],
-                                       "type" => $imgdata["mime"],
-                                       "length" => intval($imgdata["size"])];
+                       if ($imgdata) {
+                               $attributes = ["rel" => "enclosure",
+                                               "href" => $siteinfo["image"],
+                                               "type" => $imgdata["mime"],
+                                               "length" => intval($imgdata["size"])];
 
-                       XML::addElement($doc, $root, "link", "", $attributes);
+                               XML::addElement($doc, $root, "link", "", $attributes);
+                       }
                }
 
                $arr = explode('[/attach],', $item['attach']);