simplifications
[banana.git] / install.d / format.inc.php
CommitLineData
6ab9c313 1<?php
2/********************************************************************************
3* install.d/format.inc.php : HTML output subroutines
4* --------------------------
5*
6* This file is part of the banana distribution
7* Copyright: See COPYING files that comes with this distribution
8********************************************************************************/
9
6ab9c313 10/** produces HTML ouput for header section in post.php
11 * @param $_header STRING name of the header
12 * @param $_text STRING value of the header
13 * @param $_spool OBJECT spool object for building references
14 * @return STRING HTML output
15 */
16
17function formatDisplayHeader($_header,$_text,$_spool) {
dd7d1c59 18 global $locale;
19 switch ($_header) {
20 case "date":
21 return locale_date($_text);
22
23 case "followup":
24 case "newsgroups":
25 $res = "";
26 $groups = preg_split("/(\t| )*,(\t| )*/",$_text);
27 foreach ($groups as $g) {
28 $res.='<a href="thread.php?group='.$g.'">'.$g.'</a>, ';
29 }
30 return substr($res,0, -2);
6ab9c313 31
dd7d1c59 32 case "from":
33 return formatFrom($_text);
34
35 case "references":
36 $rsl = "";
37 $ndx = 1;
38 $text=str_replace("><","> <",$_text);
39 $text=preg_split("/( |\t)/",strtr($text,$_spool->ids));
40 $parents=preg_grep("/^\d+$/",$text);
41 $p=array_pop($parents);
42 while ($p) {
43 $rsl .= "<a href=\"article.php?group={$_spool->group}"
44 ."&amp;id=$p\">$ndx</a> ";
45 $_spool->overview[$p]->desc++;
46 $p = $_spool->overview[$p]->parent;
47 $ndx++;
48 }
49 return $rsl;
50
51 case "xface":
52 return '<img src="xface.php?face='.base64_encode($_text)
53 .'" alt="x-face" />';
54
55 default:
56 return htmlentities($_text);
57 }
6ab9c313 58}
59
60/** contextual links
61 * @return STRING HTML output
62 */
63function displayshortcuts() {
dd7d1c59 64 global $news,$locale,$first,$spool,$group,$post,$id;
65 $sname = basename($_SERVER['SCRIPT_NAME']);
6ab9c313 66
dd7d1c59 67 echo '<div class="shortcuts">';
68 echo '[<a href="disconnect.php">'.$locale['format']['disconnection']
6ab9c313 69 .'</a>] ';
dd7d1c59 70
71 switch ($sname) {
72 case 'thread.php' :
73 echo '[<a href="index.php">'.$locale['format']['grouplist'].'</a>] ';
74 echo "[<a href=\"post.php?group=$group\">".$locale['format']['newpost']."</a>] ";
75 if (sizeof($spool->overview)>$news['max']) {
76 for ($ndx=1; $ndx<=sizeof($spool->overview); $ndx += $news['max']) {
77 if ($first==$ndx) {
78 echo "[$ndx-".min($ndx+$news['max']-1,sizeof($spool->overview))."] ";
79 } else {
80 echo "[<a href=\"".$_SERVER['PHP_SELF']."?group=$group&amp;first="
81 ."$ndx\">$ndx-".min($ndx+$news['max']-1,sizeof($spool->overview))
82 ."</a>] ";
83 }
84 }
85 }
86 break;
87 case 'article.php' :
88 echo '[<a href="index.php">'.$locale['format']['grouplist'].'</a>] ';
89 echo "[<a href=\"thread.php?group=$group\">"
90 .$locale['format']['group_b'].$group
91 .$locale['format']['group_a']."</a>] ";
92 echo "[<a href=\"post.php?group=$group&amp;id=$id&amp;type=followup\">"
93 .$locale['format']['followup']."</a>] ";
94 if (checkcancel($post->headers)) {
95 echo "[<a href=\"article.php?group=$group&amp;id=$id&amp;type=cancel\">"
96 .$locale['format']['cancel']."</a>] ";
97 }
98 break;
99 case 'post.php' :
100 echo '[<a href="index.php">'.$locale['format']['grouplist'].'</a>] ';
101 echo "[<a href=\"thread.php?group=$group\">"
102 .$locale['format']['group_b'].$group
103 .$locale['format']['group_a']."</a>] ";
104 break;
105 }
106 echo '</div>';
6ab9c313 107}
108
109?>
110