r63: Updated initial copyright year from 2003 to 2002
[bugdar.git] / includes / adminfunctions.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Renapsus [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # All parts of this file are ©2002-[#]year[#] Iris Studios, Inc. No # ||
7 || # part of this file may be reproduced in any way: part or whole. # ||
8 || # --------------------------------------------------------------- # ||
9 || # ©2002 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
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 = 'Renapsus - ' . 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\" />" . iff($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;\"" . iff($pageclass !== ':default:', " class=\"$pageclass\"") . iff($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\">Renapsus " . $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\">" . iff($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\"" . iff($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 if ($class === ':swap:')
186 {
187 global $row_class;
188 exec_swap_bg();
189 $is_style_element = false;
190 }
191 else
192 {
193 if (preg_match('#:style:(.*?)#i', $class))
194 {
195 $is_style_element = true;
196 $style = str_replace(':style:', '', $class);
197 }
198 else
199 {
200 $row_class = $class;
201 $is_style_element = false;
202 }
203 }
204
205 echo "<tr>\r\t<td ". iff($is_style_element, "style=\"$style\"", "class=\"$row_class\"") . " colspan=\"$colspan\" align=\"$align\">$text</td>\r</tr>";
206 }
207
208 function row_multi_item($row_array)
209 {
210 global $row_class;
211 exec_swap_bg();
212
213 foreach ($row_array AS $item => $align)
214 {
215 $row_data["$align"][] = $item;
216 }
217
218 echo "<tr valign=\"top\">";
219
220 foreach ($row_data AS $align_key => $item_array)
221 {
222 if ($align_key == 'c')
223 {
224 $align = 'center';
225 }
226 else if ($align_key == 'l')
227 {
228 $align = 'left';
229 }
230 else if ($align_key == 'r')
231 {
232 $align = 'right';
233 }
234
235 foreach ($item_array AS $value)
236 {
237 echo "\r\t<td class=\"$row_class\" align=\"$align\">$value</td>";
238 }
239 }
240
241 echo "\r</tr>\r";
242 }
243
244 function row_text($label, $value = '&nbsp;', $valign = 'top', $colspan = 2, $class = -1)
245 {
246 global $IS_SETTINGS;
247
248 if ($class == -1)
249 {
250 if (!$IS_SETTINGS)
251 {
252 global $row_class;
253 exec_swap_bg();
254 }
255 else
256 {
257 $row_class = 'alt2';
258 }
259 }
260 else
261 {
262 $row_class = $class;
263 }
264
265 echo "<tr valign=\"$valign\">";
266 echo "\r\t<td class=\"$row_class\">$label</td>";
267 echo "\r\t<td class=\"$row_class\">$value</td>";
268
269 if ($colspan > 2)
270 {
271 echo "\r\t<td class=\"$row_class\" colspan=\"" . $colspan - 2 . "\">&nbsp;</td>";
272 }
273
274 echo "\r</tr>\r";
275 }
276
277 function row_input($label, $name, $value = '', $colspan = 2, $size = 35, $length = false, $password = false, $lalign = 'top')
278 {
279 $this->row_text($label, "<input type=\"" . iff($password, 'password', 'text') . "\" class=\"input\" name=\"$name\" value=\"$value\" size=\"$size\" " . iff($length, "maxlength=\"$length\" ") . "/>", $lalign, $colspan);
280 }
281
282 function row_textarea($label, $name, $value = '', $colspan = 2, $rows = 7, $cols = 50, $code = false, $style = '')
283 {
284 $this->row_text($label, "<textarea name=\"$name\" class=\"" . iff($code, 'code', 'input') . "\" rows=\"$rows\" cols=\"$cols\"" . iff($style, ' style="' . $style . '"') . ">$value</textarea>", 'top', $colspan);
285 }
286
287 function row_tfoot($data, $colspan = 2)
288 {
289 echo $this->row_span($data, 'tfoot', 'center');
290 }
291
292 function row_submit($extra = false, $submit = ':save:', $reset = ':reset:', $colspan = 2)
293 {
294 if ($submit === ':save:')
295 {
296 $submit = " " . phrase('submit') . " ";
297 }
298 else
299 {
300 $submit = " $submit ";
301 }
302
303 if ($reset === ':reset:')
304 {
305 $reset = " " . phrase('reset') . " ";
306 }
307 else
308 {
309 $reset = iff($reset, " $reset ");
310 }
311
312 $output = "\r\t\t<input type=\"submit\" class=\"button\" value=\"$submit\" accesskey=\"s\" />";
313 $output .= iff($reset, "\r\t\t<input type=\"reset\" class=\"button\" value=\"$reset\" accesskey=\"r\" /> $extra\r\t");
314 $this->row_tfoot($output);
315 }
316
317 function row_upload($label, $name, $colspan = 2)
318 {
319 $this->row_text($label, "<input type=\"file\" class=\"button\" name=\"$name\" size=\"35\" />", 'top', $colspan);
320 }
321
322 function list_item($name, $value, $selected = false)
323 {
324 global $listitem;
325
326 $listitem[] = "\r\t<option value=\"$value\"" . iff($selected == true, ' selected="selected"') . ">$name</option>";
327 }
328
329 function row_list($label, $name, $is_jump = true, $colspan = 2)
330 {
331 global $listitem;
332
333 foreach ($listitem AS $option)
334 {
335 $optionlist .= $option;
336 }
337
338 $listitem = '';
339
340 $this->row_text($label, "\r<select class=\"button\" name=\"$name\"" . iff($is_jump, " onchange=\"this.form.submit();\"") . ">$optionlist\r</select>" . iff($is_jump, "\r<input type=\"submit\" class=\"button\" value=\" " . phrase('go') . " \" accesskey=\"g\" />") . "\r", $colspan);
341 }
342
343 function row_yesno($label, $name, $value, $colspan = 2)
344 {
345 $this->row_text($label, "<input type=\"radio\" name=\"$name\" value=\"1\"" . iff($value, ' checked="checked"') . " /> " . phrase('yes') . " <input type=\"radio\" name=\"$name\" value=\"0\"" . iff(!$value, ' checked="checked"') . " /> " . phrase('no'), $colspan);
346 }
347 }
348
349 /*=====================================================================*\
350 || ###################################################################
351 || # $HeadURL$
352 || # $Id$
353 || ###################################################################
354 \*=====================================================================*/
355 ?>