r665: Renaming product from "BugStrike" to "Bugdar"
[bugdar.git] / includes / adminfunctions.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]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 global $bugsys;
18
19 $timeout = $timeout * 200;
20
21 $js =
22 <<<EOD
23 <script type="text/javascript">
24 <!--
25 var timeout = $timeout;
26
27 if (timeout > 0)
28 {
29 setTimeout("redirect()", $timeout);
30 }
31 else
32 {
33 redirect();
34 }
35
36 function redirect()
37 {
38 window.location = "$location";
39 }
40 -->
41 </script>
42 EOD;
43
44 $this->page_start($bugsys->lang->string('Redirect'), ':default:', 15, $js);
45
46 $this->page_message($bugsys->lang->string('Redirect'), sprintf($bugsys->lang->string('Please wait to be redirected. If you are not redirected in a few seconds, click <a href="%1$s">here</a>.'), $location));
47
48 $this->page_end();
49 }
50
51 function error($message)
52 {
53 global $bugsys;
54
55 $this->page_start($bugsys->lang->string('Error'));
56 $this->page_message($bugsys->lang->string('Error'), $message);
57 $this->page_end();
58
59 exit;
60 }
61
62 // ###################################################################
63 // ########################### PAGE CONTROL ##########################
64 // ###################################################################
65 function page_start($actiontitle, $pageclass = ':default:', $pagemargin = 15, $extra = '', $onload = false, $margin = 0, $dotpath = '.', $override = false)
66 {
67 global $bugsys;
68
69 if (constant('DONE_HEADER') AND !$override)
70 {
71 return;
72 }
73
74 $title = sprintf($bugsys->lang->string('Bugdar - Administration - %1$s'), $actiontitle);
75
76 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
77 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>";
78 echo "\n\t<title>$title</title>";
79 echo "\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
80 echo "\n\t<link rel=\"stylesheet\" href=\"$dotpath/admin.css\" />" . (($extra) ? "\n$extra" : '');
81 echo "\n</head>\n<body style=\"margin: {$margin}px;\"" . (($pageclass !== ':default:') ? " class=\"$pageclass\"" : '') . (($onload) ? " onload=\"$onload\"" : '') . ">\n";
82
83 if (!defined('HIDE_SETUP') AND $bugsys->userinfo['adminsession'])
84 {
85 global $globalnav;
86
87 $location = parse_url($_SERVER['SCRIPT_URL']);
88 $location['path'] = preg_quote(end(explode('/', $location['path'])));
89 $location['path'] = ((!$location['path']) ? 'index.php' : $location['path']);
90
91 echo "<div class=\"tcat\" style=\"padding: 5px; border-bottom: 4px outset\">\n";
92 echo "\n\t<form action=\"jump.php\" method=\"post\" title=\"navigation\" style=\"display: inline\">";
93 echo "\n\t<span style=\"float: right\"><a href=\"../\">" . $bugsys->lang->string('Tracker Home') . "</a></span>";
94 echo "\n\t\t" . $bugsys->lang->string('Navigation') . ": <select name=\"jumplocation\" onchange=\"this.form.submit()\" class=\"input\">";
95 foreach ($globalnav AS $grouptitle => $links)
96 {
97 echo "\n\t\t<optgroup label=\"$grouptitle\">";
98 foreach ($links AS $title => $url)
99 {
100 $selected = ((preg_match("#$location[path]$#i", $url)) ? ' selected="selected"' : '');
101 echo "\n\t\t\t<option value=\"$url\"$selected>$title</option>";
102 }
103 echo "\n\t\t</optgroup>";
104 }
105 echo "\n\t\t</select>";
106 echo "\n\t\t<input type=\"submit\" name=\"go\" value=\"&nbsp;" . $bugsys->lang->string('Go') . "&nbsp;\" class=\"button\" />";
107 echo "\n\t</form>";
108 echo "\n</div>";
109 }
110
111 echo "<div style=\"margin: {$pagemargin}px;\">\n<!-- / page head -->\n\n";
112
113 if (!defined('DONE_HEADER'))
114 {
115 define('DONE_HEADER', 1);
116 }
117 }
118
119 function page_code($code)
120 {
121 echo "\n\n$code\n\n";
122 }
123
124 function page_message($title, $message)
125 {
126 $this->table_start(true, '75%');
127 $this->table_head($title, 1);
128 $this->row_span("<blockquote>$message</blockquote>", ':swap:', 'left', 1);
129 $this->table_end();
130 }
131
132 function page_confirm($message, $location)
133 {
134 global $bugsys;
135
136 $this->page_start($bugsys->lang->string('Confirm'));
137
138 $this->page_message($bugsys->lang->string('Confirm'), $message . '<p><input type="button" name="confirm" value=" ' . $bugsys->lang->string('Yes') . ' " onclick="window.location = \'' . $location . '\';" />');
139
140 $this->page_end();
141 }
142
143 function page_end()
144 {
145 global $bugsys;
146
147 $copyright = "\n<br />\n<p align=\"center\" class=\"copyright\">\n\t<a href=\"http://www.iris-studios.com\" target=\"_blank\">Bugdar " . $bugsys->options['trackerversion'] . ", &copy; 2002 - " . date('Y') . " Iris Studios, Inc.</a>\n</p>";
148
149 if (!defined('HIDE_SETUP'))
150 {
151 echo "\n<!-- page end -->\n</div>\n$copyright";
152 }
153 else
154 {
155 echo "\n<!-- page end -->\n</div>";
156 }
157
158 echo "\n\n</body>\n</html>";
159
160 exit;
161 }
162
163 // ###################################################################
164 // ##################### TABLE SKELETON RENDERING ####################
165 // ###################################################################
166 function table_start($break = true, $width = '90%')
167 {
168 if ($break)
169 {
170 echo '<br />';
171 }
172
173 echo "\n<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\" align=\"center\" width=\"$width\" class=\"tborder\">\n";
174 }
175
176 function table_head($title, $colspan = 2, $help = null)
177 {
178 global $edoc;
179 $title = ($help ? "<a href=\"http://www.iris-studios.com/support/bugdar/$help.html\" target=\"_blank\" style=\"cursor: help; text-decoration: none\">$title</a>" : $title);
180 $help = ($help ? "<span style=\"float: right\"><a href=\"http://www.iris-studios.com/support/bugdar/$help.html\" target=\"_blank\" style=\"cursor: help; text-decoration: none; font-size: 9px; color: #FFFFFF\">Help</a></span>" : '');
181 echo "<tr>\n\t<td class=\"tcat\" align=\"center\" colspan=\"$colspan\">$help<strong>$title</strong></td>\n</tr>\n";
182 }
183
184 function table_column_head($columnarray)
185 {
186 if (is_array($columnarray))
187 {
188 $render = "<tr valign=\"top\" align=\"center\">\n";
189
190 foreach ($columnarray AS $header)
191 {
192 $render .= "\t<td class=\"thead\" align=\"center\">$header</td>\n";
193 }
194
195 $render .= "</tr>\n";
196
197 echo $render;
198 }
199 }
200
201 function table_end()
202 {
203 echo "\n</table>\n";
204 }
205
206 // ###################################################################
207 // ########################## FORM CREATION ##########################
208 // ###################################################################
209 function form_start($action, $do, $enctype = false, $name = 'inputform', $submitmethod = 'post')
210 {
211 echo "\n<!-- input form -->\n<form name=\"$name\" action=\"$action\"" . (($enctype) ? " enctype=\"$enctype\"" : '') . " method=\"$submitmethod\">\n";
212 $this->form_hidden_field('do', $do);
213 }
214
215 function form_hidden_field($name, $value)
216 {
217 echo "<input type=\"hidden\" name=\"$name\" value=\"$value\" />\n";
218 }
219
220 function form_end()
221 {
222 echo "</form>\n<!-- / input form -->\n";
223 }
224
225 // ###################################################################
226 // ####################### TABLE ROW RENDERING #######################
227 // ###################################################################
228 function row_span($text, $class = ':swap:', $align = 'left', $colspan = 2)
229 {
230 global $bugsys;
231 if ($class === ':swap:')
232 {
233 $bugsys->funct->exec_swap_bg();
234 $row_class = $bugsys->funct->bgcolour;
235 $is_style_element = false;
236 }
237 else
238 {
239 if (preg_match('#:style:(.*?)#i', $class))
240 {
241 $is_style_element = true;
242 $style = str_replace(':style:', '', $class);
243 }
244 else
245 {
246 $row_class = $class;
247 $is_style_element = false;
248 }
249 }
250
251 echo "<tr>\n\t<td ". (($is_style_element) ? "style=\"$style\"" : "class=\"$row_class\"") . " colspan=\"$colspan\" align=\"$align\">$text</td>\n</tr>";
252 }
253
254 function row_multi_item($row_array)
255 {
256 global $bugsys;
257 $bugsys->funct->exec_swap_bg();
258
259 foreach ($row_array AS $item => $align)
260 {
261 $row_data["$align"][] = $item;
262 }
263
264 echo "<tr valign=\"top\">";
265
266 foreach ($row_data AS $align_key => $item_array)
267 {
268 if ($align_key == 'c')
269 {
270 $align = 'center';
271 }
272 else if ($align_key == 'l')
273 {
274 $align = 'left';
275 }
276 else if ($align_key == 'r')
277 {
278 $align = 'right';
279 }
280
281 foreach ($item_array AS $value)
282 {
283 echo "\n\t<td class=\"{$bugsys->funct->bgcolour}\" align=\"$align\">$value</td>";
284 }
285 }
286
287 echo "\n</tr>\n";
288 }
289
290 function row_text($label, $value = '&nbsp;', $valign = 'top', $colspan = 2, $class = -1)
291 {
292 global $bugsys, $IS_SETTINGS;
293
294 if ($class == -1)
295 {
296 if (!$IS_SETTINGS)
297 {
298 $bugsys->funct->exec_swap_bg();
299 $row_class = $bugsys->funct->bgcolour;
300 }
301 else
302 {
303 $row_class = 'alt2';
304 }
305 }
306 else
307 {
308 $row_class = $class;
309 }
310
311 echo "<tr valign=\"$valign\">";
312 echo "\n\t<td class=\"$row_class\">$label</td>";
313 echo "\n\t<td class=\"$row_class\">$value</td>";
314
315 if ($colspan > 2)
316 {
317 echo "\n\t<td class=\"$row_class\" colspan=\"" . $colspan - 2 . "\">&nbsp;</td>";
318 }
319
320 echo "\n</tr>\n";
321 }
322
323 function row_input($label, $name, $value = '', $colspan = 2, $size = 35, $length = false, $password = false, $lalign = 'top')
324 {
325 $this->row_text($label, "<input type=\"" . (($password) ? 'password' : 'text') . "\" class=\"input\" name=\"$name\" value=\"$value\" size=\"$size\" " . (($length) ? "maxlength=\"$length\" " : '') . "/>", $lalign, $colspan);
326 }
327
328 function row_textarea($label, $name, $value = '', $colspan = 2, $rows = 7, $cols = 50, $code = false, $style = '')
329 {
330 $this->row_text($label, "<textarea name=\"$name\" class=\"" . (($code) ? 'code' : 'input') . "\" rows=\"$rows\" cols=\"$cols\"" . (($style) ? ' style="' . $style . '"' : '') . ">$value</textarea>", 'top', $colspan);
331 }
332
333 function row_tfoot($data, $colspan = 2)
334 {
335 echo $this->row_span($data, 'tfoot', 'center');
336 }
337
338 function row_submit($extra = false, $submit = ':save:', $reset = ':reset:', $colspan = 2)
339 {
340 global $bugsys;
341
342 if ($submit === ':save:')
343 {
344 $submit = " " . $bugsys->lang->string('Submit') . " ";
345 }
346 else
347 {
348 $submit = " $submit ";
349 }
350
351 if ($reset === ':reset:')
352 {
353 $reset = " " . $bugsys->lang->string('Reset') . " ";
354 }
355 else
356 {
357 $reset = (($reset) ? " $reset " : '');
358 }
359
360 $output = "\n\t\t<input type=\"submit\" class=\"button\" value=\"$submit\" accesskey=\"s\" />";
361 $output .= (($reset) ? "\n\t\t<input type=\"reset\" class=\"button\" value=\"$reset\" accesskey=\"r\" /> $extra\n\t" : $extra);
362 $this->row_tfoot($output);
363 }
364
365 function row_upload($label, $name, $colspan = 2)
366 {
367 $this->row_text($label, "<input type=\"file\" class=\"button\" name=\"$name\" size=\"35\" />", 'top', $colspan);
368 }
369
370 function list_item($name, $value, $selected = false)
371 {
372 global $listitem;
373
374 $listitem[] = "\n\t<option value=\"$value\"" . (($selected == true) ? ' selected="selected"' : '') . ">$name</option>";
375 }
376
377 function row_list($label, $name, $is_jump = false, $colspan = 2)
378 {
379 global $listitem;
380
381 foreach ($listitem AS $option)
382 {
383 $optionlist .= $option;
384 }
385
386 $listitem = '';
387
388 $this->row_text($label, "\n<select class=\"input\" name=\"$name\"" . (($is_jump) ? " onchange=\"this.form.submit();\"" : '') . ">$optionlist\n</select>" . (($is_jump) ? "\n<input type=\"submit\" class=\"button\" value=\" " . $bugsys->lang->string('Go') . " \" accesskey=\"g\" />" : '') . "\n", $colspan);
389 }
390
391 function row_yesno($label, $name, $value, $colspan = 2)
392 {
393 global $bugsys;
394
395 $this->row_text($label, "<input type=\"radio\" name=\"$name\" value=\"1\"" . (($value) ? ' checked="checked"' : '') . " /> " . $bugsys->lang->string('Yes') . " <input type=\"radio\" name=\"$name\" value=\"0\"" . ((!$value) ? ' checked="checked"' : '') . " /> " . $bugsys->lang->string('No'), $colspan);
396 }
397 }
398
399 /*=====================================================================*\
400 || ###################################################################
401 || # $HeadURL$
402 || # $Id$
403 || ###################################################################
404 \*=====================================================================*/
405 ?>