]> git.mxchange.org Git - friendica.git/commitdiff
Added missing function
authorMichael <heluecht@pirati.ca>
Sun, 10 Sep 2017 07:58:14 +0000 (07:58 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 10 Sep 2017 07:58:14 +0000 (07:58 +0000)
include/items.php
include/ostatus.php

index ec4c986a18303c6715f218e96025c14db62fc60d..f2ee2311b74cf885e4c9ceb904a34f85ee580e74 100644 (file)
@@ -534,6 +534,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
        }
 
        // Converting the plink
+       /// @todo Check if this is really still needed
        if ($arr['network'] == NETWORK_OSTATUS) {
                if (isset($arr['plink'])) {
                        $arr['plink'] = ostatus::convert_href($arr['plink']);
index c13a466ed4e91b8c1320997cc6abdf73d54a4bc9..02bd2f44750593acb230ee52c33b20d4ee1aeedd 100644 (file)
@@ -796,6 +796,36 @@ class ostatus {
                return $link_data;
        }
 
+/**
+        * @brief Create an url out of an uri
+        *
+        * @param string $href URI in the format "parameter1:parameter1:..."
+        *
+        * @return string URL in the format http(s)://....
+        */
+       public static function convert_href($href) {
+               $elements = explode(":",$href);
+
+               if ((count($elements) <= 2) || ($elements[0] != "tag"))
+                       return $href;
+
+               $server = explode(",", $elements[1]);
+               $conversation = explode("=", $elements[2]);
+
+               if ((count($elements) == 4) && ($elements[2] == "post"))
+                       return "http://".$server[0]."/notice/".$elements[3];
+
+               if ((count($conversation) != 2) || ($conversation[1] =="")) {
+                       return $href;
+               }
+               if ($elements[3] == "objectType=thread") {
+                       return "http://".$server[0]."/conversation/".$conversation[1];
+               } else {
+                       return "http://".$server[0]."/notice/".$conversation[1];
+               }
+               return $href;
+       }
+
        /**
         * @brief Checks if the current post is a reshare
         *