move shared post formatting to its own tpl

This commit is contained in:
Saiwal K
2026-01-04 19:36:06 +00:00
committed by Mario
parent 87f79381d9
commit 9f98f6bbd5
2 changed files with 17 additions and 19 deletions

View File

@@ -552,13 +552,6 @@ function bb_ShareAttributes($match) {
$rnd = mt_rand();
$reldate = '<span class="autotime" title="' . datetime_convert('UTC', date_default_timezone_get(), $posted, 'c') . '" >' . datetime_convert('UTC', date_default_timezone_get(), $posted, 'r') . '</span>';
$headline = '<div id="shared_container_' . $rnd . '" class="shared_container"> <div id="shared_header_' . $rnd . '" class="shared_header">';
if ($avatar != "")
$headline .= '<a href="' . (($auth) ? zid($profile) : $profile) . '" ><img src="' . $avatar . '" alt="' . $author . '" height="32" width="32" loading="lazy" /></a>';
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'),
'<a href="' . (($auth) ? zid($profile) : $profile) . '" ><bdi>' . $author . '</bdi></a>',
'<a href="' . (($auth) ? zid($link) : $link) . '" >' . $type . '</a>',
$reldate
);
$headline .= '<span>' . $fmt . '</span></div>';
$text = $headline . '<div id="reshared-content-' . $rnd . '" class="reshared-content">' . trim($match[2]) . '</div></div>';
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) {

1
view/tpl/bb_share.tpl Normal file
View File

@@ -0,0 +1 @@
<div id="shared_container_{{$rnd}}" class="shared_container"><div id="shared_header_{{$rnd}}" class="shared_header">{{if $avatar}}<a href="{{$author_url}}"><img src="{{$avatar}}" alt="{{$author}}" height="32" width="32" loading="lazy" /></a>{{/if}}<span><a href="{{$author_url}}">{{$author}}</a> {{$text}} <a href="{{$post_url}}">{{$type}} </a><span class="autotime" title="{{$reldate_iso}}">{{$reldate}}</span></span></div><div id="reshared-content-{{$rnd}}" class="reshared-content">{{$content}}</div></div>