2 /********************************************************************************
3 * install.d/format.inc.php : HTML output subroutines
4 * --------------------------
6 * This file is part of the banana distribution
7 * Copyright: See COPYING files that comes with this distribution
8 ********************************************************************************/
10 /** produces HTML output for overview
11 * @param $_header STRING name of the header
12 * @param $_text STRING value of the header
13 * @param $_id INTEGER MSGNUM of message
14 * @param $_group TEXT name of newsgroup
15 * @param $_isref BOOLEAN emphasizes message in overview tree ?
16 * @param $_isread BOOLEAN displays message as read ?
17 * @return STRING HTML output
21 function formatSpoolHeader($_header,$_text,$_id,$_group,$_isref,$_isread=true
) {
25 return locale_header_date($_text);
27 # From: mark@cbosgd.ATT.COM
28 # From: mark@cbosgd.ATT.COM (Mark Horton)
29 # From: Mark Horton <mark@cbosgd.ATT.COM>
30 $result = htmlentities($_text);
31 if (preg_match("/^([^ ]+)@([^ ]+)$/",$_text,$regs))
32 $result="<a href=\"mailto:".
33 "{$regs[1]}@{$regs[2]}\">".htmlentities($regs[1].
34 "@".$regs[2])."</a>";
35 if (preg_match("/^([^ ]+)@([^ ]+) \((.*)\)$/",$_text,$regs))
36 $result="<a href=\"mailto:".
37 "{$regs[1]}@{$regs[2]}\">".htmlentities($regs[3])."</a>";
38 if (preg_match("/^\"?([^<>\"]+)\"? +<(.+)@(.+)>$/",$_text,$regs))
39 $result="<a href=\"mailto:".
40 "{$regs[2]}@{$regs[3]}\">".htmlentities($regs[1])."</a>";
41 return preg_replace("/\\\(\(|\))/","\\1",$result);
44 return '<span class="isref">'.htmlentities($_text).'</span>';
47 return "<a href=\"article.php?group=$_group&id=$_id\">"
48 .htmlentities($_text)."</a>";
50 return "<a href=\"article.php?group=$_group&id=$_id\"><b>"
51 .htmlentities($_text)."</b></a>";
55 return htmlentities($_text);
59 /** produces HTML ouput for header section in post.php
60 * @param $_header STRING name of the header
61 * @param $_text STRING value of the header
62 * @param $_spool OBJECT spool object for building references
63 * @return STRING HTML output
66 function formatDisplayHeader($_header,$_text,$_spool) {
70 return locale_date($_text);
74 $groups = preg_split("/(\t| )*,(\t| )*/",$_text);
75 foreach ($groups as $g) {
76 $res.='<a href="thread.php?group='.$g.'">'.$g.'</a>, ';
78 return substr($res,0, -2);
80 # From: mark@cbosgd.ATT.COM
81 # From: mark@cbosgd.ATT.COM (Mark Horton)
82 # From: Mark Horton <mark@cbosgd.ATT.COM>
83 # From: Anonymous <anonymous>
84 $result = htmlentities($_text);
85 if (preg_match("/^([^ ]+)@([^ ]+)$/",$_text,$regs))
86 $result="<a href=\"mailto:"
87 ."{$regs[1]}@{$regs[2]}\">".htmlentities($regs[1])
88 ."@{$regs[2]}</a>";
89 if (preg_match("/^([^ ]+)@([^ ]+) \((.*)\)$/",$_text,$regs))
90 $result="<a href=\"mailto:"
91 ."{$regs[1]}@{$regs[2]}\">".htmlentities($regs[3])
93 if (preg_match("/^\"?([^<>\"]+)\"? +<(.+)@(.+)>$/",$_text,$regs))
94 $result="<a href=\"mailto:"
95 ."{$regs[2]}@{$regs[3]}\">".htmlentities($regs[1])
97 return preg_replace("/\\\(\(|\))/","\\1",$result);
101 $text=str_replace("><","> <",$_text);
102 $text=preg_split("/( |\t)/",strtr($text,$_spool->ids
));
103 $parents=preg_grep("/^\d+$/",$text);
104 $p=array_pop($parents);
106 $rsl .= "<a href=\"article.php?group={$_spool->group}"
107 ."&id=$p\">$ndx</a> ";
108 $_spool->overview
[$p]->desc++
;
109 $p = $_spool->overview
[$p]->parent
;
114 return '<img src="xface.php?face='.base64_encode($_text)
115 .'" alt="x-face" />';
117 return htmlentities($_text);
121 /** produces HTML output for message body
122 * @param $_text STRING message body
123 * @return STRING HTML output
125 function formatbody($_text) {
128 $res .= htmlentities(wrap($_text,"",$news['wrap']))."\n";
129 $res = preg_replace("/(<|>|")/"," \\1 ",$res);
130 $res = preg_replace('/(["\[])?((https?|ftp|news):\/\/[a-z@0-9.~%$£µ&i#\-+=_\/\?]*)(["\]])?/i',
131 "\\1<a href=\"\\2\">\\2</a>\\4", $res);
132 $res = preg_replace("/ (<|>|") /","\\1",$res);
137 * @return STRING HTML output
139 function displayshortcuts() {
140 global $news,$locale,$first,$spool,$group,$post,$id;
141 $sname = $_SERVER['SCRIPT_NAME'];
142 $array = explode('/',$sname);
143 $sname = array_pop($array);
145 echo '<div class="shortcuts">';
146 echo '[<a href="disconnect.php">'.$locale['format']['disconnection']
151 echo '[<a href="index.php">'.$locale['format']['grouplist']
153 echo "[<a href=\"post.php?group=$group\">"
154 .$locale['format']['newpost']."</a>] ";
155 if (sizeof($spool->overview
)>$news['max']) {
156 for ($ndx=1; $ndx<=sizeof($spool->overview
); $ndx +
= $news['max']) {
158 echo "[$ndx-".min($ndx+
$news['max']-1,sizeof($spool->overview
))."] ";
160 echo "[<a href=\"".$_SERVER['PHP_SELF']."?group=$group&first="
161 ."$ndx\">$ndx-".min($ndx+
$news['max']-1,sizeof($spool->overview
))
168 echo '[<a href="index.php">'.$locale['format']['grouplist']
170 echo "[<a href=\"thread.php?group=$group\">"
171 .$locale['format']['group_b'].$group
172 .$locale['format']['group_a']."</a>] ";
173 echo "[<a href=\"post.php?group=$group&id=$id&type=followup\">"
174 .$locale['format']['followup']."</a>] ";
175 if (checkcancel($post->headers
)) {
176 echo "[<a href=\"article.php?group=$group&id=$id&type=cancel\">"
177 .$locale['format']['cancel']."</a>] ";
181 echo '[<a href="index.php">'.$locale['format']['grouplist']
183 echo "[<a href=\"thread.php?group=$group\">"
184 .$locale['format']['group_b'].$group
185 .$locale['format']['group_a']."</a>] ";