From dc6075aa3f91ad8e96f440f0569cfe5bd862b201 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Mar 2023 19:33:39 +0000 Subject: do not use zrl tag for non zot profiles and remove redundant foreach which was a leftover from zot to zot6 transition days --- include/text.php | 64 +++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index d7ffa5550..5dc894d11 100644 --- a/include/text.php +++ b/include/text.php @@ -3033,46 +3033,44 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) if($r) { - $xchan[0] = Libzot::zot_record_preferred($r, 'xchan_network'); - - foreach($xchan as $xc) { - $profile = $xc['xchan_url']; - $newname = $xc['xchan_name']; - // add the channel's xchan_hash to $access_tag if exclusive - if($exclusive) { - $access_tag = 'cid:' . $xc['xchan_hash']; - } + $xc = Libzot::zot_record_preferred($r, 'xchan_network'); - // if there is a url for this channel + $profile = $xc['xchan_url']; + $newname = $xc['xchan_name']; + // add the channel's xchan_hash to $access_tag if exclusive + if($exclusive) { + $access_tag = 'cid:' . $xc['xchan_hash']; + } - if(isset($profile)) { - $replaced = true; - //create profile link - $profile = str_replace(',','%2c',$profile); - $url = $profile; + // if there is a url for this channel - $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; - $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + if(isset($profile)) { + $replaced = true; + //create profile link + $profile = str_replace(',','%2c',$profile); + $url = $profile; + $bb_tag = (($xc['xchan_network'] === 'zot6') ? 'zrl' : 'url'); - // append tag to str_tags - if(! stristr($str_tags,$newtag)) { - if(strlen($str_tags)) - $str_tags .= ','; - $str_tags .= $newtag; - } - } + $newtag = '@' . (($exclusive) ? '!' : '') . '[' . $bb_tag . '=' . $profile . ']' . $newname . '[/' . $bb_tag . ']'; + $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + // append tag to str_tags + if(! stristr($str_tags,$newtag)) { + if(strlen($str_tags)) + $str_tags .= ','; + $str_tags .= $newtag; + } + } - $fn_results[] = [ - 'replaced' => $replaced, - 'termtype' => $termtype, - 'term' => $newname, - 'url' => $url, - 'access_tag' => $access_tag, - 'contact' => (($r) ? $xc : []), - ]; - } + $fn_results[] = [ + 'replaced' => $replaced, + 'termtype' => $termtype, + 'term' => $newname, + 'url' => $url, + 'access_tag' => $access_tag, + 'contact' => (($r) ? $xc : []), + ]; } else { -- cgit v1.2.3