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