notices--
[isso.git] / printer.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 /**
23 * Printer
24 * printer.php
25 *
26 * @package ISSO
27 */
28
29 /**
30 * Printer
31 *
32 * This framework generates standard HTML through various functions. The purpose
33 * is generally so that things like the admin system can be created without templates.
34 *
35 * @author Iris Studios, Inc.
36 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
37 * @version $Revision$
38 * @package ISSO
39 *
40 */
41 class Printer
42 {
43 /**
44 * Framework registry object
45 * @var object
46 */
47 var $registry = null;
48
49 /**
50 * Realm that we are operating in (displayed in the <title>)
51 * @var string
52 */
53 var $realm = '[UNDEFINED REALM]';
54
55 /**
56 * CSS to place in the page
57 * @var string
58 */
59 var $css = '';
60
61 /**
62 * Constructor
63 */
64 function __construct(&$registry)
65 {
66 $this->registry =& $registry;
67 }
68
69 /**
70 * (PHP 4) Constructor
71 */
72 function Printer(&$registry)
73 {
74 $this->__construct($registry);
75 }
76
77 /**
78 * Creates a redirect to another page; constructs the header and footer (therefore execution stops)
79 *
80 * @param string Location to redirect to
81 * @param integer Time to wait before the redirect
82 */
83 function redirect($location, $timeout = 10)
84 {
85 $timeout = $timeout * 200;
86
87 $js =
88 <<<EOD
89 <script type="text/javascript">
90 <!--
91 var timeout = $timeout;
92
93 if (timeout > 0)
94 {
95 setTimeout("redirect()", $timeout);
96 }
97 else
98 {
99 redirect();
100 }
101
102 function redirect()
103 {
104 window.location = "$location";
105 }
106 -->
107 </script>
108 EOD;
109
110 $this->page_start($this->registry->modules['localize']->string('Redirect'), ':default:', 15, $js);
111
112 $this->page_message($this->registry->modules['localize']->string('Redirect'), sprintf($this->registry->modules['localize']->string('Please wait to be redirected. If you are not redirected in a few seconds, click <a href="%1$s">here</a>.'), $location));
113
114 $this->page_end();
115 }
116
117 /**
118 * Throws a fatal error; constructs the header and footer
119 *
120 * @param string Error messsage text
121 */
122 function error($message)
123 {
124 $this->page_start($this->registry->modules['localize']->string('Error'));
125 $this->page_message($this->registry->modules['localize']->string('Error'), $message);
126 $this->page_end();
127
128 exit;
129 }
130
131 // ###################################################################
132 /**
133 * Outputs the header of the page: doctype, <html>, <head>, <title>, <body>
134 * and imbeds the style information
135 *
136 * @param string Title of the page
137 * @param string Class of the page to be applied to the body
138 * @param integer Margin of the <div> that all content is placed in
139 * @param string Extra HTML to imbed in the <head> tag
140 * @param string <body> onLoad action to imbed
141 * @param integer Margin of the actual <body > tag
142 * @param string Relative path where the CSS data is stored
143 * @param bool Will force re-print the header if it has already been printed
144 */
145 function page_start($actiontitle, $pageclass = ':default:', $pagemargin = 15, $extra = '', $onload = false, $margin = 0, $dotpath = '.', $override = false)
146 {
147 if ($this->registry->debug AND isset($_GET['query']))
148 {
149 ob_start();
150 }
151
152 if (defined('DONE_HEADER') AND !$override)
153 {
154 if (constant('DONE_HEADER') AND !$override)
155 {
156 return;
157 }
158 }
159
160 $title = sprintf($this->registry->modules['localize']->string('%1$s - %2$s - %3$s'), $this->registry->application, $this->realm, $actiontitle);
161
162 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
163 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>";
164 echo "\n\t<title>$title</title>";
165 echo "\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />";
166 echo $this->css;
167 echo ($extra ? "\n$extra" : '');
168 echo "\n</head>\n<body style=\"margin: {$margin}px;\"" . (($pageclass !== ':default:') ? " class=\"$pageclass\"" : '') . (($onload) ? " onload=\"$onload\"" : '') . ">\n";
169
170 if (!defined('HIDE_SETUP') AND function_exists('_printer_page_start'))
171 {
172 _printer_page_start();
173 }
174
175 echo "<div style=\"margin: {$pagemargin}px;\">\n<!-- / page head -->\n\n";
176
177 if (!defined('DONE_HEADER'))
178 {
179 define('DONE_HEADER', 1);
180 }
181 }
182
183 /**
184 * Links CSS to the page from a given relative path
185 *
186 * @param string Relative path to the CSS file
187 */
188 function css_link($path)
189 {
190 $this->css .= "\n\t<link rel=\"stylesheet\" href=\"$path\" />";
191 }
192
193 /**
194 * Imbeds actual CSS information into the page in <style> tags
195 *
196 * @param string Path of the CSS file to be imbeded
197 */
198 function css_imbed($path)
199 {
200 $data = require_once($path);
201 $css = preg_replace('#/\*(.*?)\*/(\r|\n)*#s', '', $css);
202 $css = trim($css);
203 $this->css .= "\n\t<style type=\"text/css\">\n\t<!--\n" . $css . "\n\t//-->\n\t</style>";
204 }
205
206 /**
207 * Places raw HTML code directly into the documet at the current position
208 *
209 * @param string HTML code
210 */
211 function page_code($code)
212 {
213 echo "\n\n$code\n\n";
214 }
215
216 /**
217 * A block function that produces a table with a message in it. This does not print the header and footer
218 *
219 * @param string The title of the message (appears at the top of the block)
220 * @param string Content of the message
221 */
222 function page_message($title, $message)
223 {
224 $this->table_start(true, '75%');
225 $this->table_head($title, 1);
226 $this->row_span("<blockquote>$message</blockquote>", ':swap:', 'left', 1);
227 $this->table_end();
228 }
229
230 /**
231 * Produces an entire page layout that asks the user whether or not they want to perform X action and provides
232 * a link to the YES and NO action
233 *
234 * @param string Message that asks if they want to do X
235 * @param string Location to go for YES
236 * @param string DO action to pass
237 * @param array Hidden parameters to pass to the next page
238 */
239 function page_confirm($message, $location, $action, $params)
240 {
241 $this->page_start($this->registry->modules['localize']->string('Confirm'));
242
243 $this->form_start($location, $action);
244 foreach ($params AS $key => $value)
245 {
246 $this->form_hidden_field($key, $value);
247 }
248
249 $this->table_start(true, '75%');
250 $this->table_head($this->registry->modules['localize']->string('Confirm'), 1);
251 $this->row_span("<blockquote>$message</blockquote>", ':swap:', 'left', 1);
252 $this->row_submit('<input type="button" class="button" name="no" value=" ' . $this->registry->modules['localize']->string('No') . ' " onclick="history.back(1); return false;" />', $this->registry->modules['localize']->string('Yes'), '');
253 $this->table_end();
254
255 $this->form_end();
256
257 $this->page_end();
258 }
259
260 /**
261 * Closes the HTML document structure an adds the copyright; this also stops execution of the page
262 */
263 function page_end()
264 {
265 if ($this->registry->debug AND isset($_GET['query']))
266 {
267 ob_clean();
268 ob_end_clean();
269
270 if (is_array($this->registry->modules['db_mysql']->history))
271 {
272 echo '<pre>';
273 foreach ($this->registry->modules['db_mysql']->history AS $query)
274 {
275 echo $query . "\n\n<hr />\n\n";
276 }
277 echo '</pre>';
278 }
279 exit;
280 }
281
282 $copyright = "\n<br />\n<p align=\"center\" class=\"copyright\">\n\t<a href=\"http://www.iris-studios.com\" target=\"_blank\">" . $this->registry->application . ' ' . $this->registry->appversion . ", &copy; 2002 - " . date('Y') . " Iris Studios, Inc.</a>\n</p>";
283
284 if (!defined('HIDE_SETUP'))
285 {
286 echo "\n<!-- page end -->\n</div>\n$copyright";
287 }
288 else
289 {
290 echo "\n<!-- page end -->\n</div>";
291 }
292
293 if ($this->registry->debug)
294 {
295 // source control
296 $scinfo = 'Not Under Source Control';
297 $possiblescms = array('cvs', 'svn', 'cvs_information', 'svn_information', 'scm', 'sc_information', 'scm_information');
298 foreach ($possiblescms AS $scm)
299 {
300 if (defined(strtoupper($scm)))
301 {
302 $scinfo = constant(strtoupper($scm));
303
304 $type = '';
305 // CVS
306 if (strpos($scinfo, 'RCSfile:') !== false)
307 {
308 $type = 'cvs';
309 }
310 else if (strpos($scinfo, ',v ') !== false)
311 {
312 $type = 'cvs';
313 }
314 // SVN
315 else if (strpos($scinfo, 'URL:') !== false)
316 {
317 $type = 'svn';
318 }
319 else if (strpos($scinfo, 'https://') !== false OR strpos($scinfo, 'http://') !== false)
320 {
321 $type= 'svn';
322 }
323 // not found so just return it
324 // try a SVN ID tag as we can't really tell if we're using it
325 else
326 {
327 $test = preg_replace('#\$' . 'Id: (.+?) (.+?) [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.+?) (.+?) \$#', '\\1 - SVN \\2', $scinfo);
328 if ($test == '$' . 'Id: $')
329 {
330 $scinfo = 'Not Under Source Control';
331 }
332 else
333 {
334 $scinfo = $test;
335 }
336 break;
337 }
338
339 if ($type == 'cvs')
340 {
341 $scinfo = preg_replace('#\$' . 'RCSfile: (.+?) \$#', '\\1', $scinfo);
342 $scinfo = preg_replace('#\$' . 'Revision: (.+?) \$#', 'CVS \\1', $scinfo);
343 $scinfo = preg_replace('#\$' . 'Id: (.+?) (.+?) [0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} (.+?) (.+?) \$#', '\\1 - CVS \\2', $scinfo);
344 }
345 else if ($type == 'svn')
346 {
347 $scinfo = preg_replace('#\$' . '(Head)?URL: (.+?) \$#e', "end(explode('/', '\\2'))", $scinfo);
348 $scinfo = preg_replace('#\$' . '(LastModified)?Revision: (.+?) \$#', 'SVN \\2', $scinfo);
349 $scinfo = preg_replace('#\$' . 'Id: (.+?) ([0-9].+?) [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.+?) (.+?) \$#', '\\1 - SVN \\2', $scinfo);
350 }
351 else
352 {
353 $scinfo = 'Not Under Source Control';
354 }
355 break;
356 }
357 }
358 $scinfo = trim($scinfo);
359 $debug = "\n\t<li><strong>Source Control:</strong> $scinfo</li>";
360
361 // query information
362 if (is_object($this->registry->modules['db_mysql']))
363 {
364 $debug .= "\n\t<li><strong>Total Queries:</strong> " . sizeof($this->registry->modules['db_mysql']->history) . " (<a href=\"" . $this->registry->sanitize($_SERVER['REQUEST_URI']) . ((strpos($_SERVER['REQUEST_URI'], '?') !== false) ? '&amp;query=1' : '?query=1') . "\">?</a>)</li>";
365 }
366
367 // total execution time
368 if (defined('ISSO_MT_START'))
369 {
370 $this->registry->load('functions', 'functions');
371 $debug .= "\n\t<li><strong>Total Execution Time:</strong> " . round($this->registry->modules['functions']->fetch_microtime_diff(ISSO_MT_START), 10) . "</li>";
372 }
373
374 // debug notices
375 $debug .= "\n\t<li>\n\t\t<select>\n\t\t\t<option>Debug Notices (" . sizeof($this->registry->debuginfo) . ")</option>";
376 foreach ((array)$this->registry->debuginfo AS $msg)
377 {
378 $debug .= "\n\t\t\t<option>--- $msg</option>";
379 }
380 $debug .= "\n\t\t</select>\n\t</li>";
381
382 // loaded modules
383 $modules = $this->registry->show_modules(true);
384 $debug .= "\n\t<li>\n\t\t<select>\n\t\t\t<option>Loaded Modules (" . sizeof($modules) . ")</option>";
385 foreach ($modules AS $mod)
386 {
387 $debug .= "\n\t\t\t<option>--- $mod</option>";
388 }
389 $debug .= "\n\t\t</select>\n\t</li>";
390
391 // --- END
392 $debug .= "\n</ul>";
393
394 $debug = "\n<hr />\n" . $this->registry->message('Debug Information', $debug, 1, true, false);
395 echo "\n\n<!-- dev debug -->\n<div align=\"center\">\n$debug\n</div>\n<!-- / dev debug -->\n\n";
396 }
397
398 echo "\n\n</body>\n</html>";
399
400 exit;
401 }
402
403 // ###################################################################
404 /**
405 * Opens a <table> tag with styling
406 *
407 * @param bool Whether to add a <br /> before the table
408 * @param string Value of the width attribute
409 */
410 function table_start($break = true, $width = '90%')
411 {
412 if ($break)
413 {
414 echo '<br />';
415 }
416
417 echo "\n<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\" align=\"center\" width=\"$width\" class=\"tborder\">\n";
418 }
419
420 /**
421 * Adds a table row that is sued to head the entire table
422 *
423 * @param string Title string
424 * @param integer Colspan attribute value
425 * @param bool Whether to bold the title
426 */
427 function table_head($title, $colspan = 2, $strong = true)
428 {
429 echo "<tr>\n\t<td class=\"tcat\" align=\"center\" colspan=\"$colspan\">" . (($strong) ? "<strong>$title</strong>" : $title) . "</td>\n</tr>\n";
430 }
431
432 /**
433 * Creates column headings; useful for a grid-style page. This uses a different styling than table_head()
434 * and is usually used directly after a table header
435 *
436 * @param array Array of titles to print
437 */
438 function table_column_head($columnarray)
439 {
440 if (is_array($columnarray))
441 {
442 $render = "<tr valign=\"top\" align=\"center\">\n";
443
444 foreach ($columnarray AS $header)
445 {
446 $render .= "\t<td class=\"thead\" align=\"center\">$header</td>\n";
447 }
448
449 $render .= "</tr>\n";
450
451 echo $render;
452 }
453 }
454
455 /**
456 * Closes a <table> tag
457 */
458 function table_end()
459 {
460 echo "\n</table>\n";
461 }
462
463 // ###################################################################
464 /**
465 * Starts a <form> tag and adds the DO hidden input field
466 *
467 * @param string Action/name of the file to action to
468 * @param string Value of the DO parameter; used to do-branch
469 * @param bool Enctype attribute; used for mime/multi-part
470 * @param string Name of the form; this only matters for DOM access
471 * @param string Method to action as; POST or GET (default is POST)
472 */
473 function form_start($action, $do, $enctype = false, $name = 'inputform', $submitmethod = 'post')
474 {
475 echo "\n<!-- input form -->\n<form name=\"$name\" action=\"$action\"" . (($enctype) ? " enctype=\"$enctype\"" : '') . " method=\"$submitmethod\">\n";
476 $this->form_hidden_field('do', $do);
477 }
478
479 /**
480 * Adds a hidden field at the current location
481 *
482 * @param string Name of the field
483 * @param string Value of the field
484 */
485 function form_hidden_field($name, $value)
486 {
487 echo "<input type=\"hidden\" name=\"$name\" value=\"$value\" />\n";
488 }
489
490 /**
491 * Closes a <form> tag
492 */
493 function form_end()
494 {
495 echo "</form>\n<!-- / input form -->\n";
496 }
497
498 // ###################################################################
499 /**
500 * Creates a table row that spans an entire row; this is used to divide sections, usually
501 *
502 * @param string Text to place in the row
503 * @param string Class name to style with; by default it alternates between alt1 and alt2 (use :swap: to do that)
504 * @param string Alignment of the text in the row
505 * @param integer Colspan attribute
506 */
507 function row_span($text, $class = ':swap:', $align = 'left', $colspan = 2)
508 {
509 if ($class === ':swap:')
510 {
511 $this->registry->modules['functions']->exec_swap_bg();
512 $row_class = $this->registry->modules['functions']->bgcolour;
513 $is_style_element = false;
514 }
515 else
516 {
517 if (preg_match('#:style:(.*?)#i', $class))
518 {
519 $is_style_element = true;
520 $style = str_replace(':style:', '', $class);
521 }
522 else
523 {
524 $row_class = $class;
525 $is_style_element = false;
526 }
527 }
528
529 echo "\n<tr>\n\t<td ". (($is_style_element) ? "style=\"$style\"" : "class=\"$row_class\"") . " colspan=\"$colspan\" align=\"$align\">$text</td>\n</tr>";
530 }
531
532 /**
533 * Creates a table row that has more than two columns; this is used in conjunction with table_column_head()
534 * usually; it takes an array of values
535 *
536 * @param array Array of values in form value => alignment key (c for center, l for left, and r for right)
537 */
538 function row_multi_item($row_array)
539 {
540 $this->registry->modules['functions']->exec_swap_bg();
541
542 foreach ($row_array AS $item => $align)
543 {
544 $row_data["$align"][] = $item;
545 }
546
547 echo "<tr valign=\"top\">";
548
549 foreach ($row_data AS $align_key => $item_array)
550 {
551 if ($align_key == 'c')
552 {
553 $align = 'center';
554 }
555 else if ($align_key == 'l')
556 {
557 $align = 'left';
558 }
559 else if ($align_key == 'r')
560 {
561 $align = 'right';
562 }
563
564 foreach ($item_array AS $value)
565 {
566 echo "\n\t<td class=\"{$this->registry->modules['functions']->bgcolour}\" align=\"$align\">$value</td>";
567 }
568 }
569
570 echo "\n</tr>\n";
571 }
572
573 /**
574 * Generic row creation function that has two columns: label and value; this is used for many
575 * other form functions, but can also be used for non-editable fields
576 *
577 * @param string Label text
578 * @param string HTML or text to place in the value column
579 * @param string Vertical align (valign attribute) for the row
580 * @param integer Colspan attribute
581 * @param string Class to style the row with; default is to alternate
582 */
583 function row_text($label, $value = '&nbsp;', $valign = 'top', $colspan = 2, $class = -1)
584 {
585 global $IS_SETTINGS;
586
587 if ($class == -1)
588 {
589 if (!$IS_SETTINGS)
590 {
591 $this->registry->modules['functions']->exec_swap_bg();
592 $row_class = $this->registry->modules['functions']->bgcolour;
593 }
594 else
595 {
596 $row_class = 'alt2';
597 }
598 }
599 else
600 {
601 $row_class = $class;
602 }
603
604 echo "<tr valign=\"$valign\">";
605 echo "\n\t<td class=\"$row_class\">$label</td>";
606 echo "\n\t<td class=\"$row_class\">$value</td>";
607
608 if ($colspan > 2)
609 {
610 echo "\n\t<td class=\"$row_class\" colspan=\"" . $colspan - 2 . "\">&nbsp;</td>";
611 }
612
613 echo "\n</tr>\n";
614 }
615
616 /**
617 * Creates a table row with an <input> text field as the value column
618 *
619 * @param string Label text
620 * @param string Name of the <input> field
621 * @param string Value of the field
622 * @param integer Colspan attribute
623 * @param integer Size of the <input> field
624 * @param integer Length attribute; use FALSE for no length to be specified
625 * @param bool Whether to make this a password field
626 * @param string Vertical align (valign attribute)
627 */
628 function row_input($label, $name, $value = '', $colspan = 2, $size = 35, $length = false, $password = false, $lalign = 'top')
629 {
630 $this->row_text($label, "<input type=\"" . (($password) ? 'password' : 'text') . "\" class=\"input\" name=\"$name\" value=\"$value\" size=\"$size\" " . (($length) ? "maxlength=\"$length\" " : '') . "/>", $lalign, $colspan);
631 }
632
633 /**
634 * Creates a table row with a <textarea> as the value column
635 *
636 * @param string Label text
637 * @param string Name of the <textarea>
638 * @param string Value of the <textarea>
639 * @param integer Colspan attribute
640 * @param integer Number of rows in the <textarea>
641 * @param integer Number of colums in the <textarea>
642 * @param bool Whether or not to use monospacing font
643 * @param string Extra style attributes to apply to the <textarea>
644 */
645 function row_textarea($label, $name, $value = '', $colspan = 2, $rows = 7, $cols = 50, $code = false, $style = '')
646 {
647 $this->row_text($label, "<textarea name=\"$name\" class=\"" . (($code) ? 'code' : 'input') . "\" rows=\"$rows\" cols=\"$cols\"" . (($style) ? ' style="' . $style . '"' : '') . ">$value</textarea>", 'top', $colspan);
648 }
649
650 /**
651 * Creates a table row with the tfoot class
652 *
653 * @param string Extra text or HTML to insert into the row
654 * @param integer Colspan attribute
655 */
656 function row_tfoot($data, $colspan = 2)
657 {
658 echo $this->row_span($data, 'tfoot', 'center', $colspan);
659 }
660
661 /**
662 * Creates a tfoot table row with submit buttons
663 *
664 * @param string Extra HTML to imbed in the row after the buttons
665 * @param string Submit button text (by default it uses pre-translated "Submit" from :save:)
666 * @param string Reset button text (default it uses pre-translated "Reset" from :reset:)
667 * @param integer Colspan attribute
668 */
669 function row_submit($extra = false, $submit = ':save:', $reset = ':reset:', $colspan = 2)
670 {
671 if ($submit === ':save:')
672 {
673 $submit = " " . $this->registry->modules['localize']->string('Submit') . " ";
674 }
675 else
676 {
677 $submit = " $submit ";
678 }
679
680 if ($reset === ':reset:')
681 {
682 $reset = " " . $this->registry->modules['localize']->string('Reset') . " ";
683 }
684 else
685 {
686 $reset = (($reset) ? " $reset " : '');
687 }
688
689 $output = "\n\t\t<input type=\"submit\" class=\"button\" value=\"$submit\" accesskey=\"s\" />";
690 $output .= ($reset ? "\n\t\t<input type=\"reset\" class=\"button\" value=\"$reset\" accesskey=\"r\" />" : '');
691 $output .= ($extra ? "\n\t\t$extra" : '');
692 $output .= "\n\t";
693 $this->row_tfoot($output, $colspan);
694 }
695
696 /**
697 * Creates an upload row; you need to specify some other paramaters in form_start() for this to work
698 *
699 * @param string Label text
700 * @param string Upload name
701 * @param integer Colspan attribute
702 */
703 function row_upload($label, $name, $colspan = 2)
704 {
705 $this->row_text($label, "<input type=\"file\" class=\"button\" name=\"$name\" size=\"35\" />", 'top', $colspan);
706 }
707
708 /**
709 * Adds a name-value pair to an array that is constructed into a <select> list
710 *
711 * @param string Text displayed for the option
712 * @param string Value of the option
713 * @param bool Whether or not to select this particluar option
714 */
715 function list_item($name, $value, $selected = false)
716 {
717 global $listitem;
718
719 $listitem[] = "\n\t<option value=\"$value\"" . (($selected == true) ? ' selected="selected"' : '') . ">$name</option>";
720 }
721
722 /**
723 * Assembles a <select> table row from list_item() items
724 *
725 * @param string Label text
726 * @param string Name of the <select>
727 * @param bool Automatically submit the form on a change?
728 * @param integer Colspan attribute
729 */
730 function row_list($label, $name, $is_jump = false, $colspan = 2)
731 {
732 global $listitem;
733
734 foreach ($listitem AS $option)
735 {
736 $optionlist .= $option;
737 }
738
739 $listitem = '';
740
741 $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=\" " . $this->registry->modules['localize']->string('Go') . " \" accesskey=\"g\" />" : '') . "\n", $colspan);
742 }
743
744 /**
745 * Creates a row with two radio buttons: yes and now
746 *
747 * @param string Label text
748 * @param string Name of the BOOL flag
749 * @param bool TRUE to select the YES by default; FALSE for NO
750 * @param integer Colspan attribute
751 */
752 function row_yesno($label, $name, $value, $colspan = 2)
753 {
754 $this->row_text($label, "<input type=\"radio\" name=\"$name\" value=\"1\"" . (($value) ? ' checked="checked"' : '') . " /> " . $this->registry->modules['localize']->string('Yes') . " <input type=\"radio\" name=\"$name\" value=\"0\"" . ((!$value) ? ' checked="checked"' : '') . " /> " . $this->registry->modules['localize']->string('No'), $colspan);
755 }
756 }
757
758 /*=====================================================================*\
759 || ###################################################################
760 || # $HeadURL$
761 || # $Id$
762 || ###################################################################
763 \*=====================================================================*/
764 ?>