r105: Added some kind of navigation.. no idea if it works or not, though.
[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\">\n";
66 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>";
67 echo "\n\t<title>$title</title>";
68 echo "\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />";
69 echo "\n\t<link rel=\"stylesheet\" href=\"$dotpath/admin.css\" />" . (($extra) ? "\n$extra" : '');
70 echo "\n</head>\n<body style=\"margin: {$margin}px;\"" . (($pageclass !== ':default:') ? " class=\"$pageclass\"" : '') . (($onload) ? " onload=\"$onload\"" : '') . ">\n";
71
72 if (!defined('HIDE_SETUP'))
73 {
74 global $globalnav;
75
76 echo "<div class=\"thead\">\n";
77 echo "\n\t<form action=\"jump.php\" method=\"post\" title=\"navigation\" style=\"display: inline\">";
78
79 foreach ($globalnav AS $grouptitle => $links)
80 {
81 echo "\n\t\t<select name=\"jump[$grouptitle]\">";
82 foreach ($links AS $title => $url)
83 {
84 echo "\n\t\t\t<option value=\"$url\">$title</option>";
85 }
86 echo "\n\t\t</select>";
87 }
88 echo "\n\t</form>";
89 echo "\n</div>";
90 }
91
92 echo "<div style=\"margin: {$pagemargin}px;\">\n<!-- / page head -->\n\n";
93 }
94
95 function page_code($code)
96 {
97 echo "\n\n$code\n\n";
98 }
99
100 function page_message($title, $message)
101 {
102 $this->table_start(true, '75%');
103 $this->table_head($title, 1);
104 $this->row_span("<blockquote>$message</blockquote>", ':swap:', 'left', 1);
105 $this->table_end();
106 }
107
108 function page_confirm($message, $location)
109 {
110 $this->page_start(phrase('confirm'));
111
112 $this->page_message(phrase('confirm'), $message . '<p><input type="button" name="confirm" value=" ' . phrase('yes') . ' " onclick="window.location = \'' . $location . '\';" />');
113
114 $this->page_end();
115 }
116
117 function page_end()
118 {
119 global $bugsys;
120
121 $copyright = "\n<br />\n<p align=\"center\" class=\"copyright\">\n\t<a href=\"http://www.iris-studios.com\" target=\"_blank\">BugStrike " . $bugsys->options['trackerversion'] . ", &copy; 2002 - " . date('Y') . " Iris Studios, Inc.</a>\n</p>";
122
123 if (!defined('HIDE_SETUP'))
124 {
125 echo "\n<!-- page end -->\n</div>\n$copyright";
126 }
127 else
128 {
129 echo "\n<!-- page end -->\n</div>";
130 }
131
132 echo "\n\n</body>\n</html>";
133
134 exit;
135 }
136
137 // ###################################################################
138 // ##################### TABLE SKELETON RENDERING ####################
139 // ###################################################################
140 function table_start($break = true, $width = '90%')
141 {
142 if ($break)
143 {
144 echo '<br />';
145 }
146
147 echo "\n<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\" align=\"center\" width=\"$width\" class=\"tborder\">\n";
148 }
149
150 function table_head($title, $colspan = 2, $strong = true)
151 {
152 echo "<tr>\n\t<td class=\"tcat\" align=\"center\" colspan=\"$colspan\">" . (($strong) ? "<strong>$title</strong>" : $title) . "</td>\n</tr>\n";
153 }
154
155 function table_column_head($columnarray)
156 {
157 if (is_array($columnarray))
158 {
159 $render = "<tr valign=\"top\" align=\"center\">\n";
160
161 foreach ($columnarray AS $header)
162 {
163 $render .= "\t<td class=\"thead\" align=\"center\">$header</td>\n";
164 }
165
166 $render .= "</tr>\n";
167
168 echo $render;
169 }
170 }
171
172 function table_end()
173 {
174 echo "\n</table>\n";
175 }
176
177 // ###################################################################
178 // ########################## FORM CREATION ##########################
179 // ###################################################################
180 function form_start($action, $do, $enctype = false, $name = 'inputform', $submitmethod = 'post')
181 {
182 echo "\n<!-- input form -->\n<form name=\"$name\" action=\"$action\"" . (($enctype) ? " enctype=\"$enctype\"" : '') . " method=\"$submitmethod\">\n";
183 $this->form_hidden_field('do', $do);
184 }
185
186 function form_hidden_field($name, $value)
187 {
188 echo "<input type=\"hidden\" name=\"$name\" value=\"$value\" />\n";
189 }
190
191 function form_end()
192 {
193 echo "</form>\n<!-- / input form -->\n";
194 }
195
196 // ###################################################################
197 // ####################### TABLE ROW RENDERING #######################
198 // ###################################################################
199 function row_span($text, $class = ':swap:', $align = 'left', $colspan = 2)
200 {
201 global $bugsys;
202 if ($class === ':swap:')
203 {
204 $bugsys->funct->exec_swap_bg();
205 $row_class = $bugsys->funct->bgcolour;
206 $is_style_element = false;
207 }
208 else
209 {
210 if (preg_match('#:style:(.*?)#i', $class))
211 {
212 $is_style_element = true;
213 $style = str_replace(':style:', '', $class);
214 }
215 else
216 {
217 $row_class = $class;
218 $is_style_element = false;
219 }
220 }
221
222 echo "<tr>\n\t<td ". (($is_style_element) ? "style=\"$style\"" : "class=\"$row_class\"") . " colspan=\"$colspan\" align=\"$align\">$text</td>\n</tr>";
223 }
224
225 function row_multi_item($row_array)
226 {
227 global $bugsys;
228 $bugsys->funct->exec_swap_bg();
229
230 foreach ($row_array AS $item => $align)
231 {
232 $row_data["$align"][] = $item;
233 }
234
235 echo "<tr valign=\"top\">";
236
237 foreach ($row_data AS $align_key => $item_array)
238 {
239 if ($align_key == 'c')
240 {
241 $align = 'center';
242 }
243 else if ($align_key == 'l')
244 {
245 $align = 'left';
246 }
247 else if ($align_key == 'r')
248 {
249 $align = 'right';
250 }
251
252 foreach ($item_array AS $value)
253 {
254 echo "\n\t<td class=\"{$bugsys->funct->bgcolour}\" align=\"$align\">$value</td>";
255 }
256 }
257
258 echo "\n</tr>\n";
259 }
260
261 function row_text($label, $value = '&nbsp;', $valign = 'top', $colspan = 2, $class = -1)
262 {
263 global $bugsys, $IS_SETTINGS;
264
265 if ($class == -1)
266 {
267 if (!$IS_SETTINGS)
268 {
269 $bugsys->funct->exec_swap_bg();
270 $row_class = $bugsys->funct->bgcolour;
271 }
272 else
273 {
274 $row_class = 'alt2';
275 }
276 }
277 else
278 {
279 $row_class = $class;
280 }
281
282 echo "<tr valign=\"$valign\">";
283 echo "\n\t<td class=\"$row_class\">$label</td>";
284 echo "\n\t<td class=\"$row_class\">$value</td>";
285
286 if ($colspan > 2)
287 {
288 echo "\n\t<td class=\"$row_class\" colspan=\"" . $colspan - 2 . "\">&nbsp;</td>";
289 }
290
291 echo "\n</tr>\n";
292 }
293
294 function row_input($label, $name, $value = '', $colspan = 2, $size = 35, $length = false, $password = false, $lalign = 'top')
295 {
296 $this->row_text($label, "<input type=\"" . (($password) ? 'password' : 'text') . "\" class=\"input\" name=\"$name\" value=\"$value\" size=\"$size\" " . (($length) ? "maxlength=\"$length\" " : '') . "/>", $lalign, $colspan);
297 }
298
299 function row_textarea($label, $name, $value = '', $colspan = 2, $rows = 7, $cols = 50, $code = false, $style = '')
300 {
301 $this->row_text($label, "<textarea name=\"$name\" class=\"" . (($code) ? 'code' : 'input') . "\" rows=\"$rows\" cols=\"$cols\"" . (($style) ? ' style="' . $style . '"' : '') . ">$value</textarea>", 'top', $colspan);
302 }
303
304 function row_tfoot($data, $colspan = 2)
305 {
306 echo $this->row_span($data, 'tfoot', 'center');
307 }
308
309 function row_submit($extra = false, $submit = ':save:', $reset = ':reset:', $colspan = 2)
310 {
311 if ($submit === ':save:')
312 {
313 $submit = " " . phrase('submit') . " ";
314 }
315 else
316 {
317 $submit = " $submit ";
318 }
319
320 if ($reset === ':reset:')
321 {
322 $reset = " " . phrase('reset') . " ";
323 }
324 else
325 {
326 $reset = (($reset) ? " $reset " : '');
327 }
328
329 $output = "\n\t\t<input type=\"submit\" class=\"button\" value=\"$submit\" accesskey=\"s\" />";
330 $output .= (($reset) ? "\n\t\t<input type=\"reset\" class=\"button\" value=\"$reset\" accesskey=\"r\" /> $extra\n\t" : '');
331 $this->row_tfoot($output);
332 }
333
334 function row_upload($label, $name, $colspan = 2)
335 {
336 $this->row_text($label, "<input type=\"file\" class=\"button\" name=\"$name\" size=\"35\" />", 'top', $colspan);
337 }
338
339 function list_item($name, $value, $selected = false)
340 {
341 global $listitem;
342
343 $listitem[] = "\n\t<option value=\"$value\"" . (($selected == true) ? ' selected="selected"' : '') . ">$name</option>";
344 }
345
346 function row_list($label, $name, $is_jump = true, $colspan = 2)
347 {
348 global $listitem;
349
350 foreach ($listitem AS $option)
351 {
352 $optionlist .= $option;
353 }
354
355 $listitem = '';
356
357 $this->row_text($label, "\n<select class=\"button\" name=\"$name\"" . (($is_jump) ? " onchange=\"this.form.submit();\"" : '') . ">$optionlist\n</select>" . (($is_jump) ? "\n<input type=\"submit\" class=\"button\" value=\" " . phrase('go') . " \" accesskey=\"g\" />" : '') . "\n", $colspan);
358 }
359
360 function row_yesno($label, $name, $value, $colspan = 2)
361 {
362 $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);
363 }
364 }
365
366 /*=====================================================================*\
367 || ###################################################################
368 || # $HeadURL$
369 || # $Id$
370 || ###################################################################
371 \*=====================================================================*/
372 ?>