--- /dev/null
+<?php
+/********************************************************************************
+* install.d/format.inc.php : HTML output subroutines
+* --------------------------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+/** produces HTML output for overview
+ * @param $_header STRING name of the header
+ * @param $_text STRING value of the header
+ * @param $_id INTEGER MSGNUM of message
+ * @param $_group TEXT name of newsgroup
+ * @param $_isref BOOLEAN emphasizes message in overview tree ?
+ * @param $_isread BOOLEAN displays message as read ?
+ * @return STRING HTML output
+ * @see disp_desc
+ */
+
+function formatSpoolHeader($_header,$_text,$_id,$_group,$_isref,$_isread=true) {
+ global $locale;
+ switch ($_header) {
+ case "date":
+ return date($locale['format']['datefmt'],$_text);
+ case "from":
+# From: mark@cbosgd.ATT.COM
+# From: mark@cbosgd.ATT.COM (Mark Horton)
+# From: Mark Horton <mark@cbosgd.ATT.COM>
+ $result = htmlentities($_text);
+ if (preg_match("/^([^ ]+)@([^ ]+)$/",$_text,$regs))
+ $result="<a href=\"mailto:".
+ "{$regs[1]}@{$regs[2]}\">".htmlentities($regs[1].
+ "@".$regs[2])."</a>";
+ if (preg_match("/^([^ ]+)@([^ ]+) \((.*)\)$/",$_text,$regs))
+ $result="<a href=\"mailto:".
+ "{$regs[1]}@{$regs[2]}\">".htmlentities($regs[3])."</a>";
+ if (preg_match("/^\"?([^<>\"]+)\"? +<(.+)@(.+)>$/",$_text,$regs))
+ $result="<a href=\"mailto:".
+ "{$regs[2]}@{$regs[3]}\">".htmlentities($regs[1])."</a>";
+ return preg_replace("/\\\(\(|\))/","\\1",$result);
+ case "subject":
+ if ($_isref) {
+ return '<span class="isref">'.htmlentities($_text).'</span>';
+ } else {
+ if ($_isread) {
+ return "<a href=\"article.php?group=$_group&id=$_id\">"
+ .htmlentities($_text)."</a>";
+ }else {
+ return "<a href=\"article.php?group=$_group&id=$_id\"><b>"
+ .htmlentities($_text)."</b></a>";
+ }
+ }
+ 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.='<a href="thread.php?group='.$g.'">'.$g.'</a>, ';
+ }
+ return substr($res,0, -2);
+ case "from":
+# From: mark@cbosgd.ATT.COM
+# From: mark@cbosgd.ATT.COM (Mark Horton)
+# From: Mark Horton <mark@cbosgd.ATT.COM>
+# From: Anonymous <anonymous>
+ $result = htmlentities($_text);
+ if (preg_match("/^([^ ]+)@([^ ]+)$/",$_text,$regs))
+ $result="<a href=\"mailto:"
+ ."{$regs[1]}@{$regs[2]}\">".htmlentities($regs[1])
+ ."@{$regs[2]}</a>";
+ if (preg_match("/^([^ ]+)@([^ ]+) \((.*)\)$/",$_text,$regs))
+ $result="<a href=\"mailto:"
+ ."{$regs[1]}@{$regs[2]}\">".htmlentities($regs[3])
+ ."</a>";
+ if (preg_match("/^\"?([^<>\"]+)\"? +<(.+)@(.+)>$/",$_text,$regs))
+ $result="<a href=\"mailto:"
+ ."{$regs[2]}@{$regs[3]}\">".htmlentities($regs[1])
+ ."</a>";
+ 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 .= "<a href=\"article.php?group={$_spool->group}"
+ ."&id=$p\">$ndx</a> ";
+ $_spool->overview[$p]->desc++;
+ $p = $_spool->overview[$p]->parent;
+ $ndx++;
+ }
+ return $rsl;
+ case "xface":
+ return '<img src="xface.php?face='.base64_encode($_text)
+ .'" alt="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<a href=\"\\2\">\\2</a>\\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 '<div class="shortcuts">';
+ echo '[<a href="disconnect.php">'.$locale['format']['disconnection']
+ .'</a>] ';
+
+ switch ($sname) {
+ case 'thread.php' :
+ echo '[<a href="index.php">'.$locale['format']['grouplist']
+ .'</a>] ';
+ echo "[<a href=\"post.php?group=$group\">"
+ .$locale['format']['newpost']."</a>] ";
+ 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 "[<a href=\"".$_SERVER['PHP_SELF']."?group=$group&first="
+ ."$ndx\">$ndx-".min($ndx+$news['max']-1,sizeof($spool->overview))
+ ."</a>] ";
+ }
+ }
+ }
+ break;
+ case 'article.php' :
+ echo '[<a href="index.php">'.$locale['format']['grouplist']
+ .'</a>] ';
+ echo "[<a href=\"thread.php?group=$group\">"
+ .$locale['format']['group_b'].$group
+ .$locale['format']['group_a']."</a>] ";
+ echo "[<a href=\"post.php?group=$group&id=$id&type=followup\">"
+ .$locale['format']['followup']."</a>] ";
+ if (checkcancel($post->headers)) {
+ echo "[<a href=\"article.php?group=$group&id=$id&type=cancel\">"
+ .$locale['format']['cancel']."</a>] ";
+ }
+ break;
+ case 'post.php' :
+ echo '[<a href="index.php">'.$locale['format']['grouplist']
+ .'</a>] ';
+ echo "[<a href=\"thread.php?group=$group\">"
+ .$locale['format']['group_b'].$group
+ .$locale['format']['group_a']."</a>] ";
+ break;
+ }
+ echo '</div>';
+}
+
+?>
+