From d8974c9a2ae28b5dbf6281cee250b733f1363851 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 9 Jul 2021 06:29:24 +0000 Subject: [PATCH] Function renamed to better reflect the functionality --- src/Content/Text/BBCode.php | 4 ++-- src/Model/Event.php | 26 ++++++++++++------------ src/Model/Item.php | 2 +- src/Module/Contact.php | 6 +++--- src/Object/Api/Mastodon/Account.php | 2 +- src/Object/Api/Mastodon/Status.php | 2 +- src/Protocol/ActivityPub/Transmitter.php | 6 +++--- src/Protocol/DFRN.php | 2 +- src/Protocol/Feed.php | 4 ++-- src/Protocol/OStatus.php | 4 ++-- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index a86a0d155c..37f650bbe9 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1264,7 +1264,7 @@ class BBCode } /** - * Converts a BBCode message for a given ID to a HTML message + * Converts a BBCode message for a given URI-ID to a HTML message * * BBcode 2 HTML was written by WAY2WEB.net * extended to work with Mistpark/Friendica - Mike Macgirvin @@ -1287,7 +1287,7 @@ class BBCode * @return string * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function convertForItem(int $uriid = 0, string $text = null, int $simple_html = self::INTERNAL) + public static function convertForUriId(int $uriid = 0, string $text = null, int $simple_html = self::INTERNAL) { $try_oembed = ($simple_html == self::INTERNAL); diff --git a/src/Model/Event.php b/src/Model/Event.php index 0cc2aeaa45..f0a552303a 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -69,11 +69,11 @@ class Event $o = ''; if (!empty($event['summary'])) { - $o .= "

" . BBCode::convertForItem($uriid, Strings::escapeHtml($event['summary']), $simple) . "

"; + $o .= "

" . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['summary']), $simple) . "

"; } if (!empty($event['desc'])) { - $o .= "
" . BBCode::convertForItem($uriid, Strings::escapeHtml($event['desc']), $simple) . "
"; + $o .= "
" . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['desc']), $simple) . "
"; } $o .= "

" . DI::l10n()->t('Starts:') . "

" . $event_start . "

"; @@ -83,7 +83,7 @@ class Event } if (!empty($event['location'])) { - $o .= "

" . DI::l10n()->t('Location:') . "

" . BBCode::convertForItem($uriid, Strings::escapeHtml($event['location']), $simple) . "

"; + $o .= "

" . DI::l10n()->t('Location:') . "

" . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['location']), $simple) . "

"; } return $o; @@ -91,7 +91,7 @@ class Event $o = '
' . "\r\n"; - $o .= '
' . BBCode::convertForItem($uriid, Strings::escapeHtml($event['summary']), $simple) . '
' . "\r\n"; + $o .= '
' . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['summary']), $simple) . '
' . "\r\n"; $o .= '
' . DI::l10n()->t('Starts:') . ' ' . BBCode::convertForItem($uriid, Strings::escapeHtml($event['desc']), $simple) . '
' . "\r\n"; + $o .= '
' . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['desc']), $simple) . '
' . "\r\n"; } if (!empty($event['location'])) { $o .= '
' . DI::l10n()->t('Location:') . ' ' - . BBCode::convertForItem($uriid, Strings::escapeHtml($event['location']), $simple) + . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['location']), $simple) . '
' . "\r\n"; // Include a map of the location if the [map] BBCode is used. @@ -623,9 +623,9 @@ class Event $drop = [DI::baseUrl() . '/events/drop/' . $event['id'] , DI::l10n()->t('Delete event') , '', '']; } - $title = BBCode::convertForItem($event['uri-id'], Strings::escapeHtml($event['summary'])); + $title = BBCode::convertForUriId($event['uri-id'], Strings::escapeHtml($event['summary'])); if (!$title) { - list($title, $_trash) = explode(" $event['id'], 'start' => $start, @@ -940,7 +940,7 @@ class Event $tpl = Renderer::getMarkupTemplate('event_stream_item.tpl'); $return = Renderer::replaceMacros($tpl, [ '$id' => $item['event-id'], - '$title' => BBCode::convertForItem($item['uri-id'], $item['event-summary']), + '$title' => BBCode::convertForUriId($item['uri-id'], $item['event-summary']), '$dtstart_label' => DI::l10n()->t('Starts:'), '$dtstart_title' => $dtstart_title, '$dtstart_dt' => $dtstart_dt, @@ -958,7 +958,7 @@ class Event '$author_name' => $item['author-name'], '$author_link' => $profile_link, '$author_avatar' => $item['author-avatar'], - '$description' => BBCode::convertForItem($item['uri-id'], $item['event-desc']), + '$description' => BBCode::convertForUriId($item['uri-id'], $item['event-desc']), '$location_label' => DI::l10n()->t('Location:'), '$show_map_label' => DI::l10n()->t('Show map'), '$hide_map_label' => DI::l10n()->t('Hide map'), diff --git a/src/Model/Item.php b/src/Model/Item.php index 0a4af82bc9..86b9270fe9 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -2640,7 +2640,7 @@ class Item ) { self::addRedirToImageTags($item); - $item['rendered-html'] = BBCode::convertForItem($item['uri-id'], $item['body']); + $item['rendered-html'] = BBCode::convertForUriId($item['uri-id'], $item['body']); $item['rendered-hash'] = hash('md5', BBCode::VERSION . '::' . $body); $hook_data = ['item' => $item, 'rendered-html' => $item['rendered-html'], 'rendered-hash' => $item['rendered-hash']]; diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 4610020179..2609a5b8bf 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -650,11 +650,11 @@ class Contact extends BaseModule '$profileurllabel'=> DI::l10n()->t('Profile URL'), '$profileurl' => $contact['url'], '$account_type' => Model\Contact::getAccountType($contact), - '$location' => BBCode::convertForItem($contact['uri-id'] ?? 0, $contact['location']), + '$location' => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['location']), '$location_label' => DI::l10n()->t('Location:'), - '$xmpp' => BBCode::convertForItem($contact['uri-id'] ?? 0, $contact['xmpp']), + '$xmpp' => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['xmpp']), '$xmpp_label' => DI::l10n()->t('XMPP:'), - '$about' => BBCode::convertForItem($contact['uri-id'] ?? 0, $contact['about'], BBCode::EXTERNAL), + '$about' => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['about'], BBCode::EXTERNAL), '$about_label' => DI::l10n()->t('About:'), '$keywords' => $contact['keywords'], '$keywords_label' => DI::l10n()->t('Tags:'), diff --git a/src/Object/Api/Mastodon/Account.php b/src/Object/Api/Mastodon/Account.php index 39c58e099e..2b95e06877 100644 --- a/src/Object/Api/Mastodon/Account.php +++ b/src/Object/Api/Mastodon/Account.php @@ -111,7 +111,7 @@ class Account extends BaseDataTransferObject $created = $userContactCreated < $publicContactCreated && ($userContactCreated != DBA::NULL_DATETIME) ? $userContactCreated : $publicContactCreated; $this->created_at = DateTimeFormat::utc($created, DateTimeFormat::JSON); - $this->note = BBCode::convertForItem($publicContact['uri-id'] ?? 0, $publicContact['about'], BBCode::EXTERNAL); + $this->note = BBCode::convertForUriId($publicContact['uri-id'] ?? 0, $publicContact['about'], BBCode::EXTERNAL); $this->url = $publicContact['url']; $this->avatar = Contact::getAvatarUrlForId($userContact['id'] ?? 0 ?: $publicContact['id'], Proxy::SIZE_SMALL, $userContact['updated'] ?? '' ?: $publicContact['updated']); $this->avatar_static = $this->avatar; diff --git a/src/Object/Api/Mastodon/Status.php b/src/Object/Api/Mastodon/Status.php index 62b44e3370..90e8732ce2 100644 --- a/src/Object/Api/Mastodon/Status.php +++ b/src/Object/Api/Mastodon/Status.php @@ -131,7 +131,7 @@ class Status extends BaseDataTransferObject $this->muted = $userAttributes->muted; $this->bookmarked = $userAttributes->bookmarked; $this->pinned = $userAttributes->pinned; - $this->content = BBCode::convertForItem($item['uri-id'], ($item['raw-body'] ?? $item['body']), BBCode::EXTERNAL); + $this->content = BBCode::convertForUriId($item['uri-id'], ($item['raw-body'] ?? $item['body']), BBCode::EXTERNAL); $this->reblog = $reblog; $this->application = $application->toArray(); $this->account = $account->toArray(); diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index a60b7c7645..cdf1538308 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -1464,7 +1464,7 @@ class Transmitter { $event = []; $event['name'] = $item['event-summary']; - $event['content'] = BBCode::convertForItem($item['uri-id'], $item['event-desc'], BBCode::ACTIVITYPUB); + $event['content'] = BBCode::convertForUriId($item['uri-id'], $item['event-desc'], BBCode::ACTIVITYPUB); $event['startTime'] = DateTimeFormat::utc($item['event-start'] . '+00:00', DateTimeFormat::ATOM); if (!$item['event-nofinish']) { @@ -1571,7 +1571,7 @@ class Transmitter $regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism"; $body = preg_replace_callback($regexp, ['self', 'mentionCallback'], $body); - $data['content'] = BBCode::convertForItem($item['uri-id'], $body, BBCode::ACTIVITYPUB); + $data['content'] = BBCode::convertForUriId($item['uri-id'], $body, BBCode::ACTIVITYPUB); } // The regular "content" field does contain a minimized HTML. This is done since systems like @@ -1583,7 +1583,7 @@ class Transmitter $richbody = preg_replace_callback($regexp, ['self', 'mentionCallback'], $item['body']); $richbody = BBCode::removeAttachment($richbody); - $data['contentMap'][$language] = BBCode::convertForItem($item['uri-id'], $richbody, BBCode::EXTERNAL); + $data['contentMap'][$language] = BBCode::convertForUriId($item['uri-id'], $richbody, BBCode::EXTERNAL); } $data['source'] = ['content' => $item['body'], 'mediaType' => "text/bbcode"]; diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index b2fe7ef956..4d27444987 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -918,7 +918,7 @@ class DFRN $htmlbody = "[b]" . $item['title'] . "[/b]\n\n" . $htmlbody; } - $htmlbody = BBCode::convertForItem($item['uri-id'], $htmlbody, BBCode::OSTATUS); + $htmlbody = BBCode::convertForUriId($item['uri-id'], $htmlbody, BBCode::OSTATUS); } $author = self::addEntryAuthor($doc, "author", $item["author-link"], $item); diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index 47248bde1b..c088876d93 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -1109,7 +1109,7 @@ class Feed $body = OStatus::formatPicturePost($item['body'], $item['uri-id']); - $body = BBCode::convertForItem($item['uri-id'], $body, BBCode::OSTATUS, false); + $body = BBCode::convertForUriId($item['uri-id'], $body, BBCode::OSTATUS, false); XML::addElement($doc, $entry, "content", $body, ["type" => "html"]); @@ -1186,7 +1186,7 @@ class Feed private static function getTitle(array $item) { if ($item['title'] != '') { - return BBCode::convertForItem($item['uri-id'], $item['title'], BBCode::OSTATUS); + return BBCode::convertForUriId($item['uri-id'], $item['title'], BBCode::OSTATUS); } // Fetch information about the post diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 8b02eb00e9..03ff68d963 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -1803,7 +1803,7 @@ class OStatus if (!$toplevel) { if (!empty($item['title'])) { - $title = BBCode::convertForItem($item['uri-id'], $item['title'], BBCode::OSTATUS); + $title = BBCode::convertForUriId($item['uri-id'], $item['title'], BBCode::OSTATUS); } else { $title = sprintf("New note by %s", $owner["nick"]); } @@ -1892,7 +1892,7 @@ class OStatus $body = "[b]".$item['title']."[/b]\n\n".$body; } - $body = BBCode::convertForItem($item['uri-id'], $body, BBCode::OSTATUS); + $body = BBCode::convertForUriId($item['uri-id'], $body, BBCode::OSTATUS); XML::addElement($doc, $entry, "content", $body, ["type" => "html"]);