1
0
Fork 0

Update getShareOpeningTag::getShareOpeningTag method signature

- Optional parameter $guid is now at the end
- Always provided parameter $posted is now mandatory
This commit is contained in:
Hypolite Petovan 2020-06-21 09:42:37 -04:00
parent 5ec8025f69
commit 912ff069c0
5 changed files with 19 additions and 21 deletions

View 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";

View 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";

View 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(["'", "[", "]"], ["'", "[", "]"], $author).
"' profile='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $profile).
"' avatar='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $avatar);
$header = "[share author='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $author) .
"' profile='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $profile) .
"' avatar='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $avatar) .
"' link='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $link) .
"' posted='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $posted);
if ($guid) {
$header .= "' guid='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $guid);
}
if ($posted) {
$header .= "' posted='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $posted);
}
$header .= "' link='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $link)."']";
$header .= "']";
return $header;
}

View 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]';
}
}

View 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