From 9f98f6bbd518558a71a92148252db7877ee1dffe Mon Sep 17 00:00:00 2001 From: Saiwal K Date: Sun, 4 Jan 2026 19:36:06 +0000 Subject: [PATCH] move shared post formatting to its own tpl --- include/bbcode.php | 35 ++++++++++++++++------------------- view/tpl/bb_share.tpl | 1 + 2 files changed, 17 insertions(+), 19 deletions(-) create mode 100644 view/tpl/bb_share.tpl diff --git a/include/bbcode.php b/include/bbcode.php index 11d06ad06..43c1189e0 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -552,13 +552,6 @@ function bb_ShareAttributes($match) { $rnd = mt_rand(); - $reldate = '' . datetime_convert('UTC', date_default_timezone_get(), $posted, 'r') . ''; - - $headline = '
'; - - if ($avatar != "") - $headline .= '' . $author . ''; - if(strpos($link,'/cards/')) $type = t('card'); elseif(strpos($link,'/articles/')) @@ -566,19 +559,23 @@ function bb_ShareAttributes($match) { else $type = t('post'); - // Bob Smith wrote the following post 2 hours ago + $author_url = (($auth) ? zid($profile) : $profile); + $post_url = (($auth) ? zid($link) : $link); + $reldate = datetime_convert('UTC', date_default_timezone_get(), $posted, 'r'); + $reldate_iso = datetime_convert('UTC', date_default_timezone_get(), $posted, 'c'); - $fmt = sprintf( t('%1$s wrote the following %2$s %3$s'), - '' . $author . '', - '' . $type . '', - $reldate - ); - - $headline .= '' . $fmt . '
'; - - $text = $headline . '
' . trim($match[2]) . '
'; - - return $text; + return replace_macros(get_markup_template('bb_share.tpl'), [ + '$rnd' => $rnd, + '$avatar' => $avatar, + '$text' => t(' wrote the following '), + '$author' => $author, + '$author_url' => $author_url, + '$post_url' => $post_url, + '$type' => $type, + '$reldate' => $reldate, + '$reldate_iso' => $reldate_iso, + '$content' => trim($match[2]), + ]); } function bb_location($match) { diff --git a/view/tpl/bb_share.tpl b/view/tpl/bb_share.tpl new file mode 100644 index 000000000..048647496 --- /dev/null +++ b/view/tpl/bb_share.tpl @@ -0,0 +1 @@ +
{{if $avatar}}{{$author}}{{/if}}{{$author}} {{$text}} {{$type}} {{$reldate}}
{{$content}}