Some little improvements in description display

This commit is contained in:
pezcurrel 2024-08-24 13:56:24 +02:00
parent 7593f1b65c
commit 49a0da0982

View file

@ -718,8 +718,8 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
if ($row['Noxious'])
$out.='<div><div class="noxlab">'._('Why we consider this instance noxious').'</div><div class="noxreas">'.text2html($row['NoxReason'],'<span class="null">'._('Not available{singular}').'</span>').'</div></div>'.N;
$out.='<div><div class="idlab">'._('Short description').'</div><div class="idesc">'.nully(strip($row['ShortDesc'],$row['URI'])).'</div></div>'.N;
$out.='<div><div class="idlab">'._('Long description').'</div><div class="idesc">'.nully(strip($row['LongDesc'],$row['URI'])).'</div></div>'.N;
$out.='<div><div class="idlab">'._('Short description').'</div><div class="idesc">'.nully(text2html($row['ShortDesc'],null)).'</div></div>'.N;
$out.='<div><div class="idlab">'._('Long description').'</div><div class="idesc">'.nully(strip($row['LongDesc'],"{$row['URI']}/about/")).'</div></div>'.N;
$out.='<div><div class="idlab">'._('Instance rules').'</div><div class="idesc">';
$rres=tquery('SELECT Text FROM InstRules WHERE InstID='.$row['ID'],__LINE__);
@ -781,7 +781,7 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
$admacc='<span class="null">'._('Opted out of search engines indexing').'</span>';
}
(is_null($row['AdmCreatedAt'])) ? $fdate='<span class="null">'._('Not available{singular}').'</span>' : $fdate=datefmt_format($dfmt,$row['AdmCreatedAt']).' UTC';
$out.='<div class="abox"><img class="aimg" src="'.$thumb.'"><div><span class="ilab">'._('Admin account').'</span> '.$admacc.'</div><div><span class="ilab">'._('Date of creation').'</span> '.$fdate.'</div><div><span class="ilab">'._('Display name').'</span> '.nully(hspech($row['AdmDisplayName'])).'</div><div><div class="idlab">'._('Bio').'</div><div class="inote">'.nully(strip($row['AdmNote'],$row['URI'])).'</div>'.N;
$out.='<div class="abox"><img class="aimg" src="'.$thumb.'"><div><span class="ilab">'._('Admin account').'</span> '.$admacc.'</div><div><span class="ilab">'._('Date of creation').'</span> '.$fdate.'</div><div><span class="ilab">'._('Display name').'</span> '.nully(hspech($row['AdmDisplayName'])).'</div><div><div class="idlab">'._('Bio').'</div><div class="inote">'.nully(strip($row['AdmNote'],"{$row['URI']}/@{$row['AdmAccount']}/")).'</div>'.N;
$out.='</div></div>';
$out.='<div class="ghost"><div class="idlab">'._('Statistics').'</div><div class="istat">';
@ -953,8 +953,9 @@ function nullyp($str) {
function strip($str,$uri) {
if (nullemp($str)) return(null);
$str=preg_replace('#<style( [^>]*)?>.*</style>#is','',$str);
$str=preg_replace('#<a href="(?![a-zA-Z]+://)([^"]+)#i','<a href="https://'.$uri.'$1>',$str);
$str=preg_replace('#<style( [^>]*)?>.*</style>#is','',$str);// strip all inline css styles definitions
$str=preg_replace('#<a href="(?![a-zA-Z]+://)([^"]+)#i','<a href="https://'.$uri.'$1',$str);// if an href is not preceded by a protocol scheme, it's relative ...
$str=str_ireplace('</a><a','</a> <a',$str);// always put at least one space between links
$str=preg_replace(['#<h[1-9][^>]*>#i','#</h[1-9]>#i'],['<p class="exh">','</p>'],$str);
$str=preg_replace(['#</p><br>#i','#</li><br>#i','#</ul><br>#i','#<ul><br>#i'],['</p>','</li>','</ul>','<ul>'],$str);
$str=preg_replace(['#<b>#i','#</b>#i','#<i>#i','#</i>#i'],['<strong>','</strong>','<em>','</em>'],$str);