]> git.mxchange.org Git - friendica.git/commitdiff
Update getShareOpeningTag::getShareOpeningTag method signature
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 21 Jun 2020 13:42:37 +0000 (09:42 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 21 Jun 2020 13:42:37 +0000 (09:42 -0400)
- Optional parameter $guid is now at the end
- Always provided parameter $posted is now mandatory

include/api.php
mod/share.php
src/Content/Text/BBCode.php
src/Protocol/ActivityPub/Transmitter.php
src/Protocol/Diaspora.php

index d314988ed867eb861d90143c4df2443d52473427..d55183fbf7d757024636d6cc579bc8bf2eba0f19 100644 (file)
@@ -2043,7 +2043,7 @@ function api_statuses_repeat($type)
                        $pos = strpos($item['body'], "[share");
                        $post = substr($item['body'], $pos);
                } else {
-                       $post = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['guid'], $item['created'], $item['plink']);
+                       $post = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['plink'], $item['created'], $item['guid']);
 
                        if (!empty($item['title'])) {
                                $post .= '[h3]' . $item['title'] . "[/h3]\n";
index fe4b7bfe7fc9ce342fc41ad768d3f592a7eeae6d..a8ac3bd8b57a796b88a6044458849c04d70f2648 100644 (file)
@@ -43,7 +43,7 @@ function share_init(App $a) {
                $pos = strpos($item['body'], "[share");
                $o = substr($item['body'], $pos);
        } else {
-               $o = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['guid'], $item['created'], $item['plink']);
+               $o = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['plink'], $item['created'], $item['guid']);
 
                if ($item['title']) {
                        $o .= '[h3]'.$item['title'].'[/h3]'."\n";
index 1cd8e438cd310a1f3656c17fb5f4ef14c6d55628..266182b3b8672e9e32590b16d561b637447d8c48 100644 (file)
@@ -2225,30 +2225,28 @@ class BBCode
        }
 
        /**
-        * @param $author
-        * @param $profile
-        * @param $avatar
-        * @param $guid
-        * @param $posted
-        * @param $link
+        * @param string      $author  Author display name
+        * @param string      $profile Author profile URL
+        * @param string      $avatar  Author profile picture URL
+        * @param string      $link    Post source URL
+        * @param string      $posted  Post created date
+        * @param string|null $guid    Post guid (if any)
         * @return string
         * @TODO Rewrite to handle over whole record array
         */
-       public static function getShareOpeningTag($author, $profile, $avatar, $guid, $posted, $link)
+       public static function getShareOpeningTag(string $author, string $profile, string $avatar, string $link, string $posted, string $guid = null)
        {
-               $header = "[share author='" . str_replace(["'", "[", "]"], ["&#x27;", "&#x5B;", "&#x5D;"], $author).
-                       "' profile='" . str_replace(["'", "[", "]"], ["&#x27;", "&#x5B;", "&#x5D;"], $profile).
-                       "' avatar='" . str_replace(["'", "[", "]"], ["&#x27;", "&#x5B;", "&#x5D;"], $avatar);
+               $header = "[share author='" . str_replace(["'", "[", "]"], ["&#x27;", "&#x5B;", "&#x5D;"], $author) .
+                       "' profile='" . str_replace(["'", "[", "]"], ["&#x27;", "&#x5B;", "&#x5D;"], $profile) .
+                       "' avatar='" . str_replace(["'", "[", "]"], ["&#x27;", "&#x5B;", "&#x5D;"], $avatar) .
+                       "' link='" . str_replace(["'", "[", "]"], ["&#x27;", "&#x5B;", "&#x5D;"], $link) .
+                       "' posted='" . str_replace(["'", "[", "]"], ["&#x27;", "&#x5B;", "&#x5D;"], $posted);
 
                if ($guid) {
                        $header .= "' guid='" . str_replace(["'", "[", "]"], ["&#x27;", "&#x5B;", "&#x5D;"], $guid);
                }
 
-               if ($posted) {
-                       $header .= "' posted='" . str_replace(["'", "[", "]"], ["&#x27;", "&#x5B;", "&#x5D;"], $posted);
-               }
-
-               $header .= "' link='" . str_replace(["'", "[", "]"], ["&#x27;", "&#x5B;", "&#x5D;"], $link)."']";
+               $header  .= "']";
 
                return $header;
        }
index dfe7c77df7c6270acd4c43b90cbc9b98de7afc81..e7a16f0527d2bdf27d7f70625bdca61bab0b5ddd 100644 (file)
@@ -864,7 +864,7 @@ class Transmitter
 
                                // Disguise forum posts as reshares. Will later be converted to a real announce
                                $item['body'] = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'],
-                                       $item['guid'], $item['created'], $item['plink']) . $item['body'] . '[/share]';
+                                       $item['plink'], $item['created'], $item['guid']) . $item['body'] . '[/share]';
                        }
                }
 
index 3833aae23cb97ada8be206f0a4b2c29a8e3f3f59..7f46908799e0461e99efadbb4442f37f371b4968 100644 (file)
@@ -2799,9 +2799,9 @@ class Diaspora
                        $original_item["author-name"],
                        $original_item["author-link"],
                        $original_item["author-avatar"],
-                       $original_item["guid"],
+                       $orig_url,
                        $original_item["created"],
-                       $orig_url
+                       $original_item["guid"]
                );
 
                if (!empty($original_item['title'])) {
@@ -3677,7 +3677,7 @@ class Diaspora
                        if ($item['author-link'] != $item['owner-link']) {
                                require_once 'mod/share.php';
                                $body = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'],
-                                       "", $item['created'], $item['plink']) . $body . '[/share]';
+                                       $item['plink'], $item['created']) . $body . '[/share]';
                        }
 
                        // convert to markdown