r91: Fixed issues with background class in Admin::row_text()
[bugdar.git] / includes / adminfunctions.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 class Admin_Print_Class
14 {
15 function redirect($location, $timeout = 10)
16 {
17 $timeout = $timeout * 200;
18
19 $js =
20 <<<EOD
21 <script type="text/javascript">
22 <!--
23 var timeout = $timeout;
24
25 if (timeout > 0)
26 {
27 setTimeout("redirect()", $timeout);
28 }
29 else
30 {
31 redirect();
32 }
33
34 function redirect()
35 {
36 window.location = "$location";
37 }
38 -->
39 </script>
40 EOD;
41
42 $this->page_start(phrase('redirect'), ':default:', 15, $js);
43
44 $this->page_message(phrase('redirect'), phrase('wait_to_be_redirected', $location));
45
46 $this->page_end();
47 }
48
49 function error($message)
50 {
51 $this->page_start(phrase('error'));
52 $this->page_message(phrase('Error'), $message);
53 $this->page_end();
54
55 exit;
56 }
57
58 // ###################################################################
59 // ########################### PAGE CONTROL ##########################
60 // ###################################################################
61 function page_start($actiontitle, $pageclass = ':default:', $pagemargin = 15, $extra = '', $onload = false, $margin = 0, $dotpath = '.')
62 {
63 $title = 'BugStrike - ' . phrase('administration_x', $actiontitle);
64
65 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r";
66 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\r<head>";
67 echo "\r\t<title>$title</title>";
68 echo "\r\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />";
69 echo "\r\t<link rel=\"stylesheet\" href=\"$dotpath/admin.css\" />" . (($extra) ? "\r$extra" : '');
70 if (!defined('HIDE_SETUP'))
71 {
72 echo "\r\t<script type=\"text/javascript\"> parent.document.title = \"$title\"; </script>";
73 }
74 echo "\r</head>\r<body style=\"margin: {$margin}px;\"" . (($pageclass !== ':default:') ? " class=\"$pageclass\"" : '') . (($onload) ? " onload=\"$onload\"" : '') . ">\r";
75
76 echo "<div style=\"margin: {$pagemargin}px;\">\r<!-- / page head -->\r\r";
77 }
78
79 function page_code($code)
80 {
81 echo "\r\r$code\r\r";
82 }
83
84 function page_message($title, $message)
85 {
86 $this->table_start(true, '75%');
87 $this->table_head($title, 1);
88 $this->row_span("<blockquote>$message</blockquote>", ':swap:', 'left', 1);
89 $this->table_end();
90 }
91
92 function page_confirm($message, $location)
93 {
94 $this->page_start(phrase('confirm'));
95
96 $this->page_message(phrase('confirm'), $message . '<p><input type="button" name="confirm" value=" ' . phrase('yes') . ' " onclick="window.location = \'' . $location . '\';" />');
97
98 $this->page_end();
99 }
100
101 function page_end()
102 {
103 global $bugsys;
104
105 $copyright = "\r<br />\r<p align=\"center\" class=\"copyright\">\r\t<a href=\"http://www.iris-studios.com\" target=\"_blank\">BugStrike " . $bugsys->options['trackerversion'] . ", &copy; 2002 - " . date('Y') . " Iris Studios, Inc.</a>\r</p>";
106
107 if (!defined('HIDE_SETUP'))
108 {
109 echo "\r<!-- page end -->\r</div>\r$copyright";
110 }
111 else
112 {
113 echo "\r<!-- page end -->\r</div>";
114 }
115
116 echo "\r\r</body>\r</html>";
117
118 exit;
119 }
120
121 // ###################################################################
122 // ##################### TABLE SKELETON RENDERING ####################
123 // ###################################################################
124 function table_start($break = true, $width = '90%')
125 {
126 if ($break)
127 {
128 echo '<br />';
129 }
130
131 echo "\r<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\" align=\"center\" width=\"$width\" class=\"tborder\">\r";
132 }
133
134 function table_head($title, $colspan = 2, $strong = true)
135 {
136 echo "<tr>\r\t<td class=\"tcat\" align=\"center\" colspan=\"$colspan\">" . (($strong) ? "<strong>$title</strong>" : $title) . "</td>\r</tr>\r";
137 }
138
139 function table_column_head($columnarray)
140 {
141 if (is_array($columnarray))
142 {
143 $render = "<tr valign=\"top\" align=\"center\">\r";
144
145 foreach ($columnarray AS $header)
146 {
147 $render .= "\t<td class=\"thead\" align=\"center\">$header</td>\r";
148 }
149
150 $render .= "</tr>\r";
151
152 echo $render;
153 }
154 }
155
156 function table_end()
157 {
158 echo "\r</table>\r";
159 }
160
161 // ###################################################################
162 // ########################## FORM CREATION ##########################
163 // ###################################################################
164 function form_start($action, $do, $enctype = false, $name = 'inputform', $submitmethod = 'post')
165 {
166 echo "\r<!-- input form -->\r<form name=\"$name\" action=\"$action\"" . (($enctype) ? " enctype=\"$enctype\"" : '') . " method=\"$submitmethod\">\r";
167 $this->form_hidden_field('do', $do);
168 }
169
170 function form_hidden_field($name, $value)
171 {
172 echo "<input type=\"hidden\" name=\"$name\" value=\"$value\" />\r";
173 }
174
175 function form_end()
176 {
177 echo "</form>\r<!-- / input form -->\r";
178 }
179
180 // ###################################################################
181 // ####################### TABLE ROW RENDERING #######################
182 // ###################################################################
183 function row_span($text, $class = ':swap:', $align = 'left', $colspan = 2)
184 {
185 global $bugsys;
186 if ($class === ':swap:')
187 {
188 $bugsys->funct->exec_swap_bg();
189 $row_class = $bugsys->funct->bgcolour;
190 $is_style_element = false;
191 }
192 else
193 {
194 if (preg_match('#:style:(.*?)#i', $class))
195 {
196 $is_style_element = true;
197 $style = str_replace(':style:', '', $class);
198 }
199 else
200 {
201 $row_class = $class;
202 $is_style_element = false;
203 }
204 }
205
206 echo "<tr>\r\t<td ". (($is_style_element) ? "style=\"$style\"" : "class=\"$row_class\"") . " colspan=\"$colspan\" align=\"$align\">$text</td>\r</tr>";
207 }
208
209 function row_multi_item($row_array)
210 {
211 global $bugsys;
212 $bugsys->funct->exec_swap_bg();
213
214 foreach ($row_array AS $item => $align)
215 {
216 $row_data["$align"][] = $item;
217 }
218
219 echo "<tr valign=\"top\">";
220
221 foreach ($row_data AS $align_key => $item_array)
222 {
223 if ($align_key == 'c')
224 {
225 $align = 'center';
226 }
227 else if ($align_key == 'l')
228 {
229 $align = 'left';
230 }
231 else if ($align_key == 'r')
232 {
233 $align = 'right';
234 }
235
236 foreach ($item_array AS $value)
237 {
238 echo "\r\t<td class=\"{$bugsys->funct->bgcolour}\" align=\"$align\">$value</td>";
239 }
240 }
241
242 echo "\r</tr>\r";
243 }
244
245 function row_text($label, $value = '&nbsp;', $valign = 'top', $colspan = 2, $class = -1)
246 {
247 global $bugsys, $IS_SETTINGS;
248
249 if ($class == -1)
250 {
251 if (!$IS_SETTINGS)
252 {
253 $bugsys->funct->exec_swap_bg();
254 $rowclass = $bugsys->funct->bgcolour;
255 }
256 else
257 {
258 $row_class = 'alt2';
259 }
260 }
261 else
262 {
263 $row_class = $class;
264 }
265
266 echo "<tr valign=\"$valign\">";
267 echo "\r\t<td class=\"$row_class\">$label</td>";
268 echo "\r\t<td class=\"$row_class\">$value</td>";
269
270 if ($colspan > 2)
271 {
272 echo "\r\t<td class=\"$row_class\" colspan=\"" . $colspan - 2 . "\">&nbsp;</td>";
273 }
274
275 echo "\r</tr>\r";
276 }
277
278 function row_input($label, $name, $value = '', $colspan = 2, $size = 35, $length = false, $password = false, $lalign = 'top')
279 {
280 $this->row_text($label, "<input type=\"" . (($password) ? 'password' : 'text') . "\" class=\"input\" name=\"$name\" value=\"$value\" size=\"$size\" " . (($length) ? "maxlength=\"$length\" " : '') . "/>", $lalign, $colspan);
281 }
282
283 function row_textarea($label, $name, $value = '', $colspan = 2, $rows = 7, $cols = 50, $code = false, $style = '')
284 {
285 $this->row_text($label, "<textarea name=\"$name\" class=\"" . (($code) ? 'code' : 'input') . "\" rows=\"$rows\" cols=\"$cols\"" . (($style) ? ' style="' . $style . '"' : '') . ">$value</textarea>", 'top', $colspan);
286 }
287
288 function row_tfoot($data, $colspan = 2)
289 {
290 echo $this->row_span($data, 'tfoot', 'center');
291 }
292
293 function row_submit($extra = false, $submit = ':save:', $reset = ':reset:', $colspan = 2)
294 {
295 if ($submit === ':save:')
296 {
297 $submit = " " . phrase('submit') . " ";
298 }
299 else
300 {
301 $submit = " $submit ";
302 }
303
304 if ($reset === ':reset:')
305 {
306 $reset = " " . phrase('reset') . " ";
307 }
308 else
309 {
310 $reset = (($reset) ? " $reset " : '');
311 }
312
313 $output = "\r\t\t<input type=\"submit\" class=\"button\" value=\"$submit\" accesskey=\"s\" />";
314 $output .= (($reset) ? "\r\t\t<input type=\"reset\" class=\"button\" value=\"$reset\" accesskey=\"r\" /> $extra\r\t" : '');
315 $this->row_tfoot($output);
316 }
317
318 function row_upload($label, $name, $colspan = 2)
319 {
320 $this->row_text($label, "<input type=\"file\" class=\"button\" name=\"$name\" size=\"35\" />", 'top', $colspan);
321 }
322
323 function list_item($name, $value, $selected = false)
324 {
325 global $listitem;
326
327 $listitem[] = "\r\t<option value=\"$value\"" . (($selected == true) ? ' selected="selected"' : '') . ">$name</option>";
328 }
329
330 function row_list($label, $name, $is_jump = true, $colspan = 2)
331 {
332 global $listitem;
333
334 foreach ($listitem AS $option)
335 {
336 $optionlist .= $option;
337 }
338
339 $listitem = '';
340
341 $this->row_text($label, "\r<select class=\"button\" name=\"$name\"" . (($is_jump) ? " onchange=\"this.form.submit();\"" : '') . ">$optionlist\r</select>" . (($is_jump) ? "\r<input type=\"submit\" class=\"button\" value=\" " . phrase('go') . " \" accesskey=\"g\" />" : '') . "\r", $colspan);
342 }
343
344 function row_yesno($label, $name, $value, $colspan = 2)
345 {
346 $this->row_text($label, "<input type=\"radio\" name=\"$name\" value=\"1\"" . (($value) ? ' checked="checked"' : '') . " /> " . phrase('yes') . " <input type=\"radio\" name=\"$name\" value=\"0\"" . ((!$value) ? ' checked="checked"' : '') . " /> " . phrase('no'), $colspan);
347 }
348 }
349
350 /*=====================================================================*\
351 || ###################################################################
352 || # $HeadURL$
353 || # $Id$
354 || ###################################################################
355 \*=====================================================================*/
356 ?>