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