use Friendica\Model\Photo;
use Friendica\Model\Post;
use Friendica\Model\Tag;
+use Friendica\Network\HTTPClientOptions;
use Friendica\Object\Image;
use Friendica\Protocol\Activity;
use Friendica\Util\Images;
use Friendica\Util\Map;
use Friendica\Util\ParseUrl;
-use Friendica\Util\Proxy as ProxyUtils;
+use Friendica\Util\Proxy;
use Friendica\Util\Strings;
use Friendica\Util\XML;
class BBCode
{
// Update this value to the current date whenever changes are made to BBCode::convert
- const VERSION = '2021-07-13';
+ const VERSION = '2021-07-28';
const INTERNAL = 0;
const EXTERNAL = 1;
*/
public static function getAttachmentData($body)
{
+ DI::profiler()->startRecording('rendering');
$data = [
'type' => '',
'text' => '',
];
if (!preg_match("/(.*)\[attachment(.*?)\](.*?)\[\/attachment\](.*)/ism", $body, $match)) {
+ DI::profiler()->stopRecording();
return self::getOldAttachmentData($body);
}
}
if (!in_array($data['type'], ['link', 'audio', 'photo', 'video'])) {
+ DI::profiler()->stopRecording();
return [];
}
}
}
+ DI::profiler()->stopRecording();
return $data;
}
- (thumbnail)
*/
+ DI::profiler()->startRecording('rendering');
$has_title = !empty($item['title']);
$plink = $item['plink'] ?? '';
$post = self::getAttachmentData($body);
}
}
} elseif (count($pictures) > 0) {
- $post['type'] = 'link';
- $post['url'] = $plink;
+ if (count($pictures) > 4) {
+ $post['type'] = 'link';
+ $post['url'] = $plink;
+ } else {
+ $post['type'] = 'photo';
+ }
+
$post['image'] = $pictures[0][2];
$post['text'] = $body;
}
}
+ DI::profiler()->stopRecording();
return $post;
}
public static function removeAttachment($body, $no_link_desc = false)
{
return preg_replace_callback("/\s*\[attachment (.*?)\](.*?)\[\/attachment\]\s*/ism",
- function ($match) use ($no_link_desc) {
+ function ($match) use ($body, $no_link_desc) {
$attach_data = self::getAttachmentData($match[0]);
if (empty($attach_data['url'])) {
return $match[0];
+ } elseif (strpos(str_replace($match[0], '', $body), $attach_data['url']) !== false) {
+ return '';
} elseif (empty($attach_data['title']) || $no_link_desc) {
return " \n[url]" . $attach_data['url'] . "[/url]\n";
} else {
*/
public static function toPlaintext($text, $keep_urls = true)
{
+ DI::profiler()->startRecording('rendering');
// Remove pictures in advance to avoid unneeded proxy calls
$text = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", ' $2 ', $text);
$text = preg_replace("/\[img.*?\[\/img\]/ism", ' ', $text);
$naked_text = HTML::toPlaintext(self::convert($text, false, 0, true), 0, !$keep_urls);
+ DI::profiler()->stopRecording();
return $naked_text;
}
} elseif ($uriid > 0) {
return Post\Link::getByLink($uriid, $image, $size);
} else {
- return ProxyUtils::proxifyUrl($image, $size);
+ return Proxy::proxifyUrl($image, $size);
}
}
*/
public static function scaleExternalImages(string $srctext)
{
+ DI::profiler()->startRecording('rendering');
$s = $srctext;
// Simplify image links
continue;
}
- $curlResult = DI::httpRequest()->get($mtch[1]);
+ $curlResult = DI::httpClient()->get($mtch[1]);
if (!$curlResult->isSuccess()) {
continue;
}
}
}
+ DI::profiler()->stopRecording();
return $s;
}
*/
public static function limitBodySize($body)
{
+ DI::profiler()->startRecording('rendering');
$maxlen = DI::config()->get('config', 'max_import_size', 0);
// If the length of the body, including the embedded images, is smaller
$new_body = $new_body . $orig_body;
}
+ DI::profiler()->stopRecording();
return $new_body;
} else {
+ DI::profiler()->stopRecording();
return $body;
}
}
*/
public static function convertAttachment($text, $simplehtml = self::INTERNAL, $tryoembed = true, array $data = [], $uriid = 0)
{
+ DI::profiler()->startRecording('rendering');
$data = $data ?: self::getAttachmentData($text);
if (empty($data) || empty($data['url'])) {
+ DI::profiler()->stopRecording();
return $text;
}
- $stamp1 = microtime(true);
-
if (isset($data['title'])) {
$data['title'] = strip_tags($data['title']);
$data['title'] = str_replace(['http://', 'https://'], '', $data['title']);
} elseif (!empty($data['preview'])) {
$return .= sprintf('<a href="%s" target="_blank" rel="noopener noreferrer"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br>', $data['url'], self::proxyUrl($data['preview'], $simplehtml, $uriid), $data['title']);
}
- $return .= sprintf('<h4><a href="%s">%s</a></h4>', $data['url'], $data['title']);
+ $return .= sprintf('<h4><a href="%s" target="_blank" rel="noopener noreferrer">%s</a></h4>', $data['url'], $data['title']);
}
}
if (!empty($data['provider_url']) && !empty($data['provider_name'])) {
if (!empty($data['author_name'])) {
- $return .= sprintf('<sup><a href="%s">%s (%s)</a></sup>', $data['provider_url'], $data['author_name'], $data['provider_name']);
+ $return .= sprintf('<sup><a href="%s" target="_blank" rel="noopener noreferrer">%s (%s)</a></sup>', $data['provider_url'], $data['author_name'], $data['provider_name']);
} else {
- $return .= sprintf('<sup><a href="%s">%s</a></sup>', $data['provider_url'], $data['provider_name']);
+ $return .= sprintf('<sup><a href="%s" target="_blank" rel="noopener noreferrer">%s</a></sup>', $data['provider_url'], $data['provider_name']);
}
}
}
}
- DI::profiler()->saveTimestamp($stamp1, 'rendering');
+ DI::profiler()->stopRecording();
return trim(($data['text'] ?? '') . ' ' . $return . ' ' . ($data['after'] ?? ''));
}
public static function removeShareInformation($Text, $plaintext = false, $nolink = false)
{
+ DI::profiler()->startRecording('rendering');
$data = self::getAttachmentData($Text);
if (!$data) {
+ DI::profiler()->stopRecording();
return $Text;
} elseif ($nolink) {
+ DI::profiler()->stopRecording();
return $data['text'] . ($data['after'] ?? '');
}
}
if (empty($data['text']) && !empty($data['title']) && empty($data['url'])) {
+ DI::profiler()->stopRecording();
return $data['title'] . $data['after'];
}
// If the link already is included in the post, don't add it again
if (!empty($data['url']) && strpos($data['text'], $data['url'])) {
+ DI::profiler()->stopRecording();
return $data['text'] . $data['after'];
}
$text .= "\n[url]" . $data['url'] . '[/url]';
}
+ DI::profiler()->stopRecording();
return $text . "\n" . $data['after'];
}
*/
public static function getTagPosition($text, $name, $occurrences = 0)
{
+ DI::profiler()->startRecording('rendering');
if ($occurrences < 0) {
$occurrences = 0;
}
}
if ($start_open === false) {
+ DI::profiler()->stopRecording();
return false;
}
$start_close = strpos($text, ']', $start_open);
if ($start_close === false) {
+ DI::profiler()->stopRecording();
return false;
}
$end_open = strpos($text, '[/' . $name . ']', $start_close);
if ($end_open === false) {
+ DI::profiler()->stopRecording();
return false;
}
$res['start']['equal'] = $start_equal + 1;
}
+ DI::profiler()->stopRecording();
return $res;
}
*/
public static function pregReplaceInTag($pattern, $replace, $name, $text)
{
+ DI::profiler()->startRecording('rendering');
$occurrences = 0;
$pos = self::getTagPosition($text, $name, $occurrences);
while ($pos !== false && $occurrences++ < 1000) {
$pos = self::getTagPosition($text, $name, $occurrences);
}
+ DI::profiler()->stopRecording();
return $text;
}
*/
public static function fetchShareAttributes($text)
{
+ DI::profiler()->startRecording('rendering');
// See Issue https://github.com/friendica/friendica/issues/10454
// Hashtags in usernames are expanded to links. This here is a quick fix.
$text = preg_replace('/([@!#])\[url\=.*?\](.*?)\[\/url\]/ism', '$1$2', $text);
$attributes = [];
if (!preg_match("/(.*?)\[share(.*?)\](.*)\[\/share\]/ism", $text, $matches)) {
+ DI::profiler()->stopRecording();
return $attributes;
}
preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches);
$attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8');
}
+ DI::profiler()->stopRecording();
return $attributes;
}
*/
public static function convertShare($text, callable $callback, int $uriid = 0)
{
+ DI::profiler()->startRecording('rendering');
$return = preg_replace_callback(
"/(.*?)\[share(.*?)\](.*)\[\/share\]/ism",
function ($match) use ($callback, $uriid) {
$attributes['profile'] = ($author_contact['url'] ?? '') ?: $attributes['profile'];
if (!empty($author_contact['id'])) {
- $attributes['avatar'] = Contact::getAvatarUrlForId($author_contact['id'], ProxyUtils::SIZE_THUMB);
+ $attributes['avatar'] = Contact::getAvatarUrlForId($author_contact['id'], Proxy::SIZE_THUMB);
} elseif ($attributes['avatar']) {
- $attributes['avatar'] = self::proxyUrl($attributes['avatar'], self::INTERNAL, $uriid, ProxyUtils::SIZE_THUMB);
+ $attributes['avatar'] = self::proxyUrl($attributes['avatar'], self::INTERNAL, $uriid, Proxy::SIZE_THUMB);
}
$content = preg_replace(Strings::autoLinkRegEx(), '<a href="$1">$1</a>', $match[3]);
$text
);
+ DI::profiler()->stopRecording();
+ return $return;
+ }
+
+ /**
+ * Convert complex IMG and ZMG elements
+ *
+ * @param [type] $text
+ * @param integer $simplehtml
+ * @param integer $uriid
+ * @return string
+ */
+ private static function convertImages(string $text, int $simplehtml, int $uriid = 0):string
+ {
+ DI::profiler()->startRecording('rendering');
+ $return = preg_replace_callback(
+ "/\[[zi]mg(.*?)\]([^\[\]]*)\[\/[zi]mg\]/ism",
+ function ($match) use ($simplehtml, $uriid) {
+ $attribute_string = $match[1];
+ $attributes = [];
+ foreach (['alt', 'width', 'height'] as $field) {
+ preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches);
+ $attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8');
+ }
+
+ $img_str = '<img src="' .
+ self::proxyUrl($match[2], $simplehtml, $uriid) . '"';
+ foreach ($attributes as $key => $value) {
+ if (!empty($value)) {
+ $img_str .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT) . '"';
+ }
+ }
+ return $img_str . '>';
+ },
+ $text
+ );
+
+ DI::profiler()->stopRecording();
return $return;
}
*/
private static function convertShareCallback(array $attributes, array $author_contact, $content, $is_quote_share, $simplehtml)
{
+ DI::profiler()->startRecording('rendering');
$mention = Protocol::formatMention($attributes['profile'], $attributes['author']);
switch ($simplehtml) {
$text = DI::cache()->get($cache_key);
if (is_null($text)) {
- $curlResult = DI::httpRequest()->head($match[1], ['timeout' => DI::config()->get('system', 'xrd_timeout')]);
+ $curlResult = DI::httpClient()->head($match[1], [HTTPClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout')]);
if ($curlResult->isSuccess()) {
- $mimetype = $curlResult->getHeader('Content-Type');
+ $mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
} else {
$mimetype = '';
}
$text = "[url=" . $match[2] . ']' . $match[2] . "[/url]";
// if its not a picture then look if its a page that contains a picture link
- $body = DI::httpRequest()->fetch($match[1]);
+ $body = DI::httpClient()->fetch($match[1]);
if (empty($body)) {
DI::cache()->set($cache_key, $text);
return $text;
return $text;
}
- $curlResult = DI::httpRequest()->head($match[1], ['timeout' => DI::config()->get('system', 'xrd_timeout')]);
+ $curlResult = DI::httpClient()->head($match[1], [HTTPClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout')]);
if ($curlResult->isSuccess()) {
- $mimetype = $curlResult->getHeader('Content-Type');
+ $mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
} else {
$mimetype = '';
}
}
// if its not a picture then look if its a page that contains a picture link
- $body = DI::httpRequest()->fetch($match[1]);
+ $body = DI::httpClient()->fetch($match[1]);
if (empty($body)) {
DI::cache()->set($cache_key, $text);
return $text;
public static function cleanPictureLinks($text)
{
+ DI::profiler()->startRecording('rendering');
$return = preg_replace_callback("&\[url=([^\[\]]*)\]\[img=(.*)\](.*)\[\/img\]\[\/url\]&Usi", 'self::cleanPictureLinksCallback', $text);
$return = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'self::cleanPictureLinksCallback', $return);
+ DI::profiler()->stopRecording();
return $return;
}
public static function removeLinks(string $bbcode)
{
+ DI::profiler()->startRecording('rendering');
$bbcode = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", ' $1 ', $bbcode);
$bbcode = preg_replace("/\[img.*?\[\/img\]/ism", ' ', $bbcode);
$bbcode = preg_replace('/[@!#]\[url\=.*?\].*?\[\/url\]/ism', '', $bbcode);
$bbcode = preg_replace("/\[url=[^\[\]]*\](.*)\[\/url\]/Usi", ' $1 ', $bbcode);
$bbcode = preg_replace('/[@!#]?\[url.*?\[\/url\]/ism', '', $bbcode);
+ DI::profiler()->stopRecording();
return $bbcode;
}
+ /**
+ * Replace names in mentions with nicknames
+ *
+ * @param string $body
+ * @return string Body with replaced mentions
+ */
+ public static function setMentionsToNicknames(string $body):string
+ {
+ DI::profiler()->startRecording('rendering');
+ $regexp = "/([@!])\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
+ $body = preg_replace_callback($regexp, ['self', 'mentionCallback'], $body);
+ DI::profiler()->stopRecording();
+ return $body;
+ }
+
+ /**
+ * Callback function to replace a Friendica style mention in a mention with the nickname
+ *
+ * @param array $match Matching values for the callback
+ * @return string Replaced mention
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
+ private static function mentionCallback($match)
+ {
+ if (empty($match[2])) {
+ return '';
+ }
+
+ $data = Contact::getByURL($match[2], false, ['url', 'nick']);
+ if (empty($data['nick'])) {
+ return $match[0];
+ }
+
+ return $match[1] . '[url=' . $data['url'] . ']' . $data['nick'] . '[/url]';
+ }
+
/**
* Converts a BBCode message for a given URI-ID to a HTML message
*
return '';
}
+ DI::profiler()->startRecording('rendering');
+
Hook::callAll('bbcode', $text);
$a = DI::app();
$text = self::convertAttachment($text, $simple_html, $try_oembed, [], $uriid);
}
- // Add HTML new lines
- $text = str_replace("\n", '<br>', $text);
-
$nosmile = strpos($text, '[nosmile]') !== false;
$text = str_replace('[nosmile]', '', $text);
// Check for list text
$text = str_replace("[*]", "<li>", $text);
- // Check for style sheet commands
+ // Check for block-level custom CSS
+ $text = preg_replace('#(?<=^|\n)\[style=(.*?)](.*?)\[/style](?:\n|$)#ism', '<div style="$1">$2</div>', $text);
+
+ // Check for inline custom CSS
$text = preg_replace("(\[style=(.*?)\](.*?)\[\/style\])ism", '<span style="$1">$2</span>', $text);
+ // Mastodon Emoji (internal tag, do not document for users)
+ $text = preg_replace("(\[emoji=(.*?)](.*?)\[/emoji])ism", '<span class="mastodon emoji"><img src="$1" alt="$2" title="$2"/></span>', $text);
+
// Check for CSS classes
+ // @deprecated since 2021.12, left for backward-compatibility reasons
$text = preg_replace("(\[class=(.*?)\](.*?)\[\/class\])ism", '<span class="$1">$2</span>', $text);
+ // Add HTML new lines
+ $text = str_replace("\n", '<br>', $text);
// handle nested lists
$endlessloop = 0;
$text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . DI::l10n()->t('Image/photo') . '" />', $text);
$text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img src="$1" alt="' . DI::l10n()->t('Image/photo') . '" />', $text);
+
+ $text = self::convertImages($text, $simple_html, $uriid);
$text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism", '<br><img src="' .DI::baseUrl() . '/images/lock_icon.gif" alt="' . DI::l10n()->t('Encrypted content') . '" title="' . DI::l10n()->t('Encrypted content') . '" /><br>', $text);
$text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism", '<br><img src="' .DI::baseUrl() . '/images/lock_icon.gif" alt="' . DI::l10n()->t('Encrypted content') . '" title="' . '$1' . ' ' . DI::l10n()->t('Encrypted content') . '" /><br>', $text);
$text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism", '[youtube]$1[/youtube]', $text);
if ($try_oembed) {
- $text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $text);
+ $text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->getThemeInfoValue('videowidth') . '" height="' . $a->getThemeInfoValue('videoheight') . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $text);
} else {
$text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism",
'<a href="https://www.youtube.com/watch?v=$1" target="_blank" rel="noopener noreferrer">https://www.youtube.com/watch?v=$1</a>', $text);
$text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism", '[vimeo]$1[/vimeo]', $text);
if ($try_oembed) {
- $text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="https://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $text);
+ $text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . $a->getThemeInfoValue('videowidth') . '" height="' . $a->getThemeInfoValue('videoheight') . '" src="https://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $text);
} else {
$text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
'<a href="https://vimeo.com/$1" target="_blank" rel="noopener noreferrer">https://vimeo.com/$1</a>', $text);
$text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/ism", $sub, $text);
$text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/ism", '', $text);
$text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/ism", '', $text);
- $text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism", '', $text);
$text = preg_replace("/\[event\-id\](.*?)\[\/event\-id\]/ism", '', $text);
}
);
$text = HTML::purify($text, $allowedIframeDomains);
+ DI::profiler()->stopRecording();
return trim($text);
}
*/
public static function stripAbstract($text)
{
+ DI::profiler()->startRecording('rendering');
$text = preg_replace("/[\s|\n]*\[abstract\].*?\[\/abstract\][\s|\n]*/ism", '', $text);
$text = preg_replace("/[\s|\n]*\[abstract=.*?\].*?\[\/abstract][\s|\n]*/ism", '', $text);
+ DI::profiler()->stopRecording();
return $text;
}
*/
public static function getAbstract($text, $addon = '')
{
+ DI::profiler()->startRecording('rendering');
$abstract = '';
$abstracts = [];
$addon = strtolower($addon);
if (preg_match_all("/\[abstract=(.*?)\](.*?)\[\/abstract\]/ism", $text, $results, PREG_SET_ORDER)) {
- foreach ($results AS $result) {
+ foreach ($results as $result) {
$abstracts[strtolower($result[1])] = $result[2];
}
}
$abstract = $result[1];
}
+ DI::profiler()->stopRecording();
return $abstract;
}
*/
public static function toMarkdown($text, $for_diaspora = true)
{
+ DI::profiler()->startRecording('rendering');
$original_text = $text;
// Since Diaspora is creating a summary for links, this function removes them before posting
// Maybe we should make this newline at every time before a quote.
$text = str_replace(['</a><blockquote>'], ['</a><br><blockquote>'], $text);
- $stamp1 = microtime(true);
-
// Now convert HTML to Markdown
$text = HTML::toMarkdown($text);
- DI::profiler()->saveTimestamp($stamp1, "parser");
-
// Libertree has a problem with escaped hashtags.
$text = str_replace(['\#'], ['#'], $text);
Hook::callAll('bb2diaspora', $text);
+ DI::profiler()->stopRecording();
return $text;
}
*/
public static function getTags($string)
{
+ DI::profiler()->startRecording('rendering');
$ret = [];
self::performWithEscapedTags($string, ['noparse', 'pre', 'code', 'img'], function ($string) use (&$ret) {
}
});
+ DI::profiler()->stopRecording();
return array_unique($ret);
}
/**
- * Expand tags to URLs
+ * Expand tags to URLs, checks the tag is at the start of a line or preceded by a non-word character
*
* @param string $body
* @return string body with expanded tags
*/
public static function expandTags(string $body)
{
- return preg_replace_callback("/([!#@])([^\^ \x0D\x0A,;:?\']*[^\^ \x0D\x0A,;:?!\'.])/",
+ return preg_replace_callback("/(?<=\W|^)([!#@])([^\^ \x0D\x0A,;:?'\"]*[^\^ \x0D\x0A,;:?!'\".])/",
function ($match) {
switch ($match[1]) {
case '!':
}
break;
case '#':
+ default:
return $match[1] . '[url=' . 'https://' . DI::baseUrl() . '/search?tag=' . $match[2] . ']' . $match[2] . '[/url]';
}
}, $body);
*/
public static function setMentions($body, $profile_uid = 0, $network = '')
{
+ DI::profiler()->startRecording('rendering');
self::performWithEscapedTags($body, ['noparse', 'pre', 'code', 'img'], function ($body) use ($profile_uid, $network) {
$tags = self::getTags($body);
return $body;
});
+ DI::profiler()->stopRecording();
return $body;
}
*/
public static function getShareOpeningTag(string $author, string $profile, string $avatar, string $link, string $posted, string $guid = null)
{
+ DI::profiler()->startRecording('rendering');
$header = "[share author='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $author) .
"' profile='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $profile) .
"' avatar='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $avatar) .
$header .= "']";
+ DI::profiler()->stopRecording();
return $header;
}
*/
public static function embedURL(string $url, bool $tryAttachment = true, string $title = null, string $description = null, string $tags = null): string
{
+ DI::profiler()->startRecording('rendering');
DI::logger()->info($url);
// If there is already some content information submitted we don't
DI::logger()->info('(unparsed): returns: ' . $result);
+ DI::profiler()->stopRecording();
return $result;
}
break;
}
+ DI::profiler()->stopRecording();
return $bbcode;
}
// Bypass attachment if parse url for a comment
if (!$tryAttachment) {
+ DI::profiler()->stopRecording();
return "\n" . '[url=' . $url . ']' . $siteinfo['title'] . '[/url]';
}
// Format it as BBCode attachment
- return "\n" . PageInfo::getFooterFromData($siteinfo);
+ $bbcode = "\n" . PageInfo::getFooterFromData($siteinfo);
+ DI::profiler()->stopRecording();
+ return $bbcode;
}
}