From: x99bachelart Date: Tue, 2 Sep 2003 21:55:49 +0000 (+0000) Subject: format subroutines X-Git-Tag: 1.8~447 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=6ab9c3132bcb1f54be26d867937a8ffd201b2822;p=banana.git format subroutines --- diff --git a/install.d/format.inc.php b/install.d/format.inc.php new file mode 100644 index 0000000..362acc2 --- /dev/null +++ b/install.d/format.inc.php @@ -0,0 +1,192 @@ + + $result = htmlentities($_text); + if (preg_match("/^([^ ]+)@([^ ]+)$/",$_text,$regs)) + $result="".htmlentities($regs[1]. + "@".$regs[2]).""; + if (preg_match("/^([^ ]+)@([^ ]+) \((.*)\)$/",$_text,$regs)) + $result="".htmlentities($regs[3]).""; + if (preg_match("/^\"?([^<>\"]+)\"? +<(.+)@(.+)>$/",$_text,$regs)) + $result="".htmlentities($regs[1]).""; + return preg_replace("/\\\(\(|\))/","\\1",$result); + case "subject": + if ($_isref) { + return ''.htmlentities($_text).''; + } else { + if ($_isread) { + return "" + .htmlentities($_text).""; + }else { + return "" + .htmlentities($_text).""; + } + } + default: + return htmlentities($_text); + } +} + +/** produces HTML ouput for header section in post.php + * @param $_header STRING name of the header + * @param $_text STRING value of the header + * @param $_spool OBJECT spool object for building references + * @return STRING HTML output + */ + +function formatDisplayHeader($_header,$_text,$_spool) { + global $locale; + switch ($_header) { + case "date": + return locale_date($_text); + case "followup": + case "newsgroups": + $res = ""; + $groups = preg_split("/(\t| )*,(\t| )*/",$_text); + foreach ($_groups as $g) { + $res.=''.$g.', '; + } + return substr($res,0, -2); + case "from": +# From: mark@cbosgd.ATT.COM +# From: mark@cbosgd.ATT.COM (Mark Horton) +# From: Mark Horton +# From: Anonymous + $result = htmlentities($_text); + if (preg_match("/^([^ ]+)@([^ ]+)$/",$_text,$regs)) + $result="".htmlentities($regs[1]) + ."@{$regs[2]}"; + if (preg_match("/^([^ ]+)@([^ ]+) \((.*)\)$/",$_text,$regs)) + $result="".htmlentities($regs[3]) + .""; + if (preg_match("/^\"?([^<>\"]+)\"? +<(.+)@(.+)>$/",$_text,$regs)) + $result="".htmlentities($regs[1]) + .""; + return preg_replace("/\\\(\(|\))/","\\1",$result); + case "references": + $rsl = ""; + $ndx = 1; + $text=str_replace("><","> <",$_text); + $text=preg_split("/( |\t)/",strtr($_text,$_spool->ids)); + $parents=preg_grep("/^\d+$/",$_text); + $p=array_pop($parents); + while ($p) { + $rsl .= "group}" + ."&id=$p\">$ndx "; + $_spool->overview[$p]->desc++; + $p = $_spool->overview[$p]->parent; + $ndx++; + } + return $rsl; + case "xface": + return 'x-face'; + default: + return htmlentities($_text); + } +} + +/** produces HTML output for message body + * @param $_text STRING message body + * @return STRING HTML output + */ +function formatbody($_text) { + global $news; + $res ="\n\n"; + $res .= htmlentities(wrap($_text,"",$news['wrap']))."\n"; + $res = preg_replace("/(<|>|")/"," \\1 ",$res); + $res = preg_replace('/(["\[])?((https?|ftp|news):\/\/[a-z@0-9.~%$£µ&i#\-+=_\/\?]*)(["\]])?/i', + "\\1\\2\\4", $res); + $res = preg_replace("/ (<|>|") /","\\1",$res); + return $res."\n"; +} + +/** contextual links + * @return STRING HTML output + */ +function displayshortcuts() { + global $news,$locale,$first,$spool,$group,$post,$id; + $sname = $_SERVER['SCRIPT_NAME']; + $array = explode('/',$sname); + $sname = array_pop($array); + + echo '
'; + echo '['.$locale['format']['disconnection'] + .'] '; + + switch ($sname) { + case 'thread.php' : + echo '['.$locale['format']['grouplist'] + .'] '; + echo "[" + .$locale['format']['newpost']."] "; + if (sizeof($spool->overview)>$news['max']) { + for ($ndx=1; $ndx<=sizeof($spool->overview); $ndx += $news['max']) { + if ($first==$ndx) { + echo "[$ndx-".min($ndx+$news['max']-1,sizeof($spool->overview))."] "; + } else { + echo "[$ndx-".min($ndx+$news['max']-1,sizeof($spool->overview)) + ."] "; + } + } + } + break; + case 'article.php' : + echo '['.$locale['format']['grouplist'] + .'] '; + echo "[" + .$locale['format']['group_b'].$group + .$locale['format']['group_a']."] "; + echo "[" + .$locale['format']['followup']."] "; + if (checkcancel($post->headers)) { + echo "[" + .$locale['format']['cancel']."] "; + } + break; + case 'post.php' : + echo '['.$locale['format']['grouplist'] + .'] '; + echo "[" + .$locale['format']['group_b'].$group + .$locale['format']['group_a']."] "; + break; + } + echo '
'; +} + +?> +