Adding visiblity indicators to functions, too
[isso.git] / printer.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
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 * Constants:
36 * ISSO_PRINTER_DONE_HEADER - An internal constant that is used to check to see
37 * if the page header has already been printed
38 * ISSO_PRINTER_HIDE_SETUP - Will stop the page footer data (copyright and debug
39 * box) from being printed
40 * ISSO_PRINTER_NO_NAVIGATION - Do not show the navigation frame from ISSO.Printer.Navigation
41 *
42 * Hooks:
43 * $this->page_start_hook - Define function to echo() data after the page header
44 * has been outputted
45 *
46 * @author Blue Static
47 * @copyright Copyright ©2002 - [#]year[#], Blue Static
48 * @version $Revision$
49 * @package ISSO
50 *
51 */
52 class Printer
53 {
54 /**
55 * Framework registry object
56 * @var object
57 */
58 private $registry = null;
59
60 /**
61 * Realm that we are operating in (displayed in the <title>)
62 * @var string
63 */
64 private $realm = '[UNDEFINED REALM]';
65
66 /**
67 * CSS to place in the page
68 * @var string
69 */
70 private $css = '';
71
72 /**
73 * Extra code to place
74 * @var sring
75 */
76 private $code = '';
77
78 /**
79 * Page-start hooko
80 * @var string
81 */
82 private $page_start_hook = ':=NO METHOD=:';
83
84 /**
85 * Fields array that is used in this module
86 * @var array
87 */
88 private $fields = array(
89 'realm' => array(REQ_YES, null, false),
90 'page_start_hook' => array(REQ_NO, null, false)
91 );
92
93 // ###################################################################
94 /**
95 * Constructor
96 */
97 public function __construct(&$registry)
98 {
99 $this->registry =& $registry;
100 }
101
102 // ###################################################################
103 /**
104 * Sets an ISSO field
105 *
106 * @param string Field name
107 * @param mixed Value of the field
108 */
109 public function set($name, $value)
110 {
111 $this->registry->do_set($name, $value, 'printer');
112 }
113
114 // ###################################################################
115 /**
116 * Gets an ISSO field
117 *
118 * @param string Field name
119 *
120 * @return mixed Value of the field
121 */
122 public function get($fieldname)
123 {
124 return $this->registry->do_get($fieldname, 'printer');
125 }
126
127 // ###################################################################
128 /**
129 * Creates a redirect to another page; constructs the header and footer
130 * (therefore execution stops)
131 *
132 * @param string Location to redirect to
133 * @param string Redirect message to be shown
134 * @param array An aray of POST variables to send through on the redirect
135 */
136 public function redirect($location, $message = null, $postvars = array())
137 {
138 $timeout = 10 * 200;
139
140 if ($postvars)
141 {
142 $js = <<<JS
143 <script type="text/javascript">
144 <!--
145 var timeout = $timeout;
146
147 if (timeout > 0)
148 {
149 setTimeout("redirect()", $timeout);
150 }
151 else
152 {
153 redirect();
154 }
155
156 function redirect()
157 {
158 document.forms.postvars.submit();
159 }
160
161 //-->
162 </script>
163 JS;
164 }
165 else
166 {
167 $js = <<<JS
168 <script type="text/javascript">
169 <!--
170 var timeout = $timeout;
171
172 if (timeout > 0)
173 {
174 setTimeout("redirect()", $timeout);
175 }
176 else
177 {
178 redirect();
179 }
180
181 function redirect()
182 {
183 window.location = "$location";
184 }
185 //-->
186 </script>
187 JS;
188 }
189
190 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
191 {
192 define('ISSO_PRINTER_NO_NAVIGATION', 1);
193 }
194
195 $this->page_start($this->registry->modules['localize']->string('Redirect'));
196
197 if ($postvars)
198 {
199 $this->form_start($location, null, false, 'postvars');
200
201 foreach ($postvars AS $key => $value)
202 {
203 $this->form_hidden_field($key, $value);
204 }
205
206 $this->form_end();
207 }
208
209 $redir = 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);
210 $override = false;
211 if ($message == null)
212 {
213 $showmessage = $redir;
214 }
215 else
216 {
217 $showmessage = '<blockquote>' . $message . '</blockquote>';
218 $showmessage .= "\n<p>" . $redir . "</p>";
219 $override = true;
220 }
221
222 $this->page_message($this->registry->modules['localize']->string('Redirect'), $showmessage, $override);
223
224 $this->page_code($js);
225
226 $this->page_end();
227 }
228
229 // ###################################################################
230 /**
231 * Throws a fatal error; constructs the header and footer
232 *
233 * @param string Error messsage text
234 */
235 public function error($message)
236 {
237 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
238 {
239 define('ISSO_PRINTER_NO_NAVIGATION', 1);
240 }
241
242 $this->page_start($this->registry->modules['localize']->string('Error'));
243 $this->page_message($this->registry->modules['localize']->string('Error'), $message);
244 $this->page_end();
245
246 exit;
247 }
248
249 // ###################################################################
250 /**
251 * Outputs the header of the page: doctype, <html>, <head>, <title>,
252 * <body> and imbeds the style information
253 *
254 * @param string Title of the page
255 * @param string Class of the page to be applied to the body
256 * @param integer Margin of the <div> that all content is placed in
257 * @param string Extra HTML to imbed in the <head> tag
258 * @param string <body> onLoad action to imbed
259 * @param integer Margin of the actual <body > tag
260 * @param string Relative path where the CSS data is stored
261 * @param bool Will force re-print the header if it has already been printed
262 */
263 public function page_start($actiontitle, $pageclass = ':default:', $pagemargin = 15, $extra = '', $onload = false, $margin = 0, $dotpath = '.', $override = false)
264 {
265 $this->registry->check_isso_fields(get_class($this));
266
267 if ($this->registry->debug AND isset($_GET['query']))
268 {
269 ob_start();
270 }
271
272 if (defined('ISSO_PRINTER_DONE_HEADER') AND !$override)
273 {
274 if (constant('ISSO_PRINTER_DONE_HEADER') AND !$override)
275 {
276 return;
277 }
278 }
279
280 $title = sprintf($this->registry->modules['localize']->string('%1$s - %2$s - %3$s'), $this->registry->application, $this->realm, $actiontitle);
281
282 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
283 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>";
284 echo "\n\t<title>$title</title>";
285 echo "\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
286 echo $this->css;
287 echo $this->code;
288 echo ($extra ? "\n$extra" : '');
289 echo "\n</head>\n<body style=\"margin: {$margin}px;\"" . (($pageclass !== ':default:') ? " class=\"$pageclass\"" : '') . (($onload) ? " onload=\"$onload\"" : '') . ">\n";
290
291 if (is_callable($this->page_start_hook))
292 {
293 call_user_func($this->page_start_hook);
294 }
295
296 echo "<div style=\"margin: {$pagemargin}px;\">\n<!-- / page head -->\n\n";
297
298 if ($this->registry->is_loaded('printer_navigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR (defined('ISSO_PRINTER_NO_NAVIGATION') AND constant('ISSO_PRINTER_NO_NAVIGATION') != true)))
299 {
300 echo $this->registry->modules['printer_navigation']->generate_header_html();
301 }
302
303 if (!defined('ISSO_PRINTER_DONE_HEADER'))
304 {
305 define('ISSO_PRINTER_DONE_HEADER', 1);
306 }
307 }
308
309 // ###################################################################
310 /**
311 * Links CSS to the page from a given relative path
312 *
313 * @param string Relative path to the CSS file
314 */
315 public function css_link($path)
316 {
317 $this->css .= "\n\t<link rel=\"stylesheet\" href=\"$path\" />";
318 }
319
320 // ###################################################################
321 /**
322 * Imbeds actual CSS information into the page in <style> tags
323 *
324 * @param string Path of the CSS file to be imbeded
325 */
326 public function css_imbed($path)
327 {
328 $data = require_once($path);
329 $css = preg_replace('#/\*(.*?)\*/(\r|\n)*#s', '', $css);
330 $css = trim($css);
331 $this->css .= "\n\t<style type=\"text/css\">\n\t<!--\n" . $css . "\n\t//-->\n\t</style>";
332 }
333
334 // ###################################################################
335 /**
336 * Places raw HTML code directly into the documet at the current
337 * position
338 *
339 * @param string HTML code
340 */
341 public function page_code($code)
342 {
343 if (defined('ISSO_PRINTER_DONE_HEADER'))
344 {
345 echo "\n\n$code\n\n";
346 }
347 else
348 {
349 $this->code .= "\n\n$code\n\n";
350 }
351 }
352
353 // ###################################################################
354 /**
355 * A block function that produces a table with a message in it. This
356 * does not print the header and footer.
357 *
358 * @param string The title of the message (appears at the top of the block)
359 * @param string Content of the message
360 * @param bool Override the message: control the entire output (no <blockquote>)?
361 */
362 public function page_message($title, $message, $overridemessage = false)
363 {
364 $this->table_start(true, '75%');
365 $this->table_head($title, 1);
366 $this->row_span(($overridemessage ? $message : "<blockquote>$message</blockquote>"), ':swap:', 'left', 1);
367 $this->table_end();
368 }
369
370 // ###################################################################
371 /**
372 * Produces an entire page layout that asks the user whether or not
373 * they want to perform X action and provides a link to the YES and NO
374 * action
375 *
376 * @param string Message that asks if they want to do X
377 * @param string Location to go for YES
378 * @param string DO action to pass
379 * @param array Hidden parameters to pass to the next page
380 */
381 public function page_confirm($message, $location, $action, $params)
382 {
383 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
384 {
385 define('ISSO_PRINTER_NO_NAVIGATION', 1);
386 }
387
388 $this->page_start($this->registry->modules['localize']->string('Confirm'));
389
390 $this->form_start($location, $action);
391 foreach ($params AS $key => $value)
392 {
393 $this->form_hidden_field($key, $value);
394 }
395
396 $this->table_start(true, '75%');
397 $this->table_head($this->registry->modules['localize']->string('Confirm'), 1);
398 $this->row_span("<blockquote>$message</blockquote>", ':swap:', 'left', 1);
399 $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'), '');
400 $this->table_end();
401
402 $this->form_end();
403
404 $this->page_end();
405 }
406
407 // ###################################################################
408 /**
409 * Closes the HTML document structure an adds the copyright; this also
410 * stops execution of the page
411 */
412 public function page_end()
413 {
414 if ($this->registry->debug AND isset($_GET['query']))
415 {
416 ob_clean();
417 ob_end_clean();
418
419 if (is_array($this->registry->modules[ISSO_DB_LAYER]->history))
420 {
421 foreach ($this->registry->modules[ISSO_DB_LAYER]->history AS $query)
422 {
423 echo $this->registry->modules[ISSO_DB_LAYER]->construct_query_debug($query);
424 }
425 }
426 exit;
427 }
428
429 if ($this->registry->is_loaded('printer_navigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR (defined('ISSO_PRINTER_NO_NAVIGATION') AND constant('ISSO_PRINTER_NO_NAVIGATION') != true)))
430 {
431 echo $this->registry->modules['printer_navigation']->generate_footer_html();
432 }
433
434 $copyright = "\n<br />\n<p align=\"center\" class=\"copyright\">\n\t<a href=\"http://www.bluestatic.org\" target=\"_blank\">" . $this->registry->get('application') . ' ' . $this->registry->get('appversion') . ", &copy;2002 - " . date('Y') . " Blue Static</a>\n</p>";
435
436 if (!defined('ISSO_PRINTER_HIDE_SETUP'))
437 {
438 echo "\n<!-- page end -->\n</div>\n$copyright";
439 echo $this->registry->construct_debug_block(false);
440 }
441 else
442 {
443 echo "\n<!-- page end -->\n</div>";
444 }
445
446 echo "\n\n</body>\n</html>";
447
448 exit;
449 }
450
451 // -------------------------------------------------------------------
452
453 // ###################################################################
454 /**
455 * Opens a <table> tag with styling
456 *
457 * @param bool Whether to add a <br /> before the table
458 * @param string Value of the width attribute
459 */
460 public function table_start($break = true, $width = '90%')
461 {
462 if ($break)
463 {
464 echo '<br />';
465 }
466
467 echo "\n<table cellpadding=\"4\" cellspacing=\"1\" border=\"0\" align=\"center\" width=\"$width\" class=\"tborder\">\n";
468 }
469
470 // ###################################################################
471 /**
472 * Adds a table row that is sued to head the entire table
473 *
474 * @param string Title string
475 * @param integer Colspan attribute value
476 * @param bool Whether to bold the title
477 */
478 public function table_head($title, $colspan = 2, $strong = true)
479 {
480 echo "<tr>\n\t<td class=\"tcat\" align=\"center\" colspan=\"$colspan\">" . (($strong) ? "<strong>$title</strong>" : $title) . "</td>\n</tr>\n";
481 }
482
483 // ###################################################################
484 /**
485 * Creates column headings; useful for a grid-style page. This uses a
486 * different styling than table_head() and is usually used directly
487 * after a table header.
488 *
489 * @param array Array of titles to print
490 */
491 public function table_column_head($columnarray)
492 {
493 if (is_array($columnarray))
494 {
495 $render = "<tr valign=\"top\" align=\"center\">\n";
496
497 foreach ($columnarray AS $header)
498 {
499 $render .= "\t<td class=\"thead\" align=\"center\">$header</td>\n";
500 }
501
502 $render .= "</tr>\n";
503
504 echo $render;
505 }
506 }
507
508 // ###################################################################
509 /**
510 * Closes a <table> tag
511 */
512 public function table_end()
513 {
514 echo "\n</table>\n";
515 }
516
517 // -------------------------------------------------------------------
518
519 // ###################################################################
520 /**
521 * Starts a <form> tag and adds the DO hidden input field
522 *
523 * @param string Action/name of the file to action to
524 * @param string Value of the DO parameter; used to do-branch
525 * @param bool Enctype attribute; used for mime/multi-part
526 * @param string Name of the form; this only matters for DOM access
527 * @param string Method to action as; POST or GET (default is POST)
528 */
529 public function form_start($action, $do, $enctype = false, $name = 'inputform', $submitmethod = 'post')
530 {
531 echo "\n<!-- input form -->\n<form name=\"$name\" action=\"$action\"" . (($enctype) ? " enctype=\"$enctype\"" : '') . " method=\"$submitmethod\">\n";
532
533 if ($do !== null)
534 {
535 $this->form_hidden_field('do', $do);
536 }
537 }
538
539 // ###################################################################
540 /**
541 * Adds a hidden field at the current location
542 *
543 * @param string Name of the field
544 * @param string Value of the field
545 */
546 public function form_hidden_field($name, $value)
547 {
548 echo "<input type=\"hidden\" name=\"$name\" value=\"$value\" />\n";
549 }
550
551 // ###################################################################
552 /**
553 * Closes a <form> tag
554 */
555 public function form_end()
556 {
557 echo "</form>\n<!-- / input form -->\n";
558 }
559
560 // -------------------------------------------------------------------
561
562 // ###################################################################
563 /**
564 * Creates a table row that spans an entire row; this is used to divide
565 * sections, usually
566 *
567 * @param string Text to place in the row
568 * @param string Class name to style with; by default it alternates between alt1 and alt2 (use :swap: to do that)
569 * @param string Alignment of the text in the row
570 * @param integer Colspan attribute
571 */
572 public function row_span($text, $class = ':swap:', $align = 'left', $colspan = 2)
573 {
574 if ($class === ':swap:')
575 {
576 $this->registry->modules['functions']->exec_swap_bg();
577 $row_class = $this->registry->modules['functions']->bgcolour;
578 $is_style_element = false;
579 }
580 else
581 {
582 if (preg_match('#:style:(.*?)#i', $class))
583 {
584 $is_style_element = true;
585 $style = str_replace(':style:', '', $class);
586 }
587 else
588 {
589 $row_class = $class;
590 $is_style_element = false;
591 }
592 }
593
594 echo "\n<tr>\n\t<td ". (($is_style_element) ? "style=\"$style\"" : "class=\"$row_class\"") . " colspan=\"$colspan\" align=\"$align\">$text</td>\n</tr>";
595 }
596
597 // ###################################################################
598 /**
599 * Creates a table row that has more than two columns; this is used in
600 * conjunction with table_column_head() usually; it takes an array of
601 * values
602 *
603 * @param array Array of values in form value => alignment key (c for center, l for left, and r for right)
604 */
605 public function row_multi_item($row_array)
606 {
607 $this->registry->modules['functions']->exec_swap_bg();
608
609 foreach ($row_array AS $item => $align)
610 {
611 $row_data["$align"][] = $item;
612 }
613
614 echo "<tr valign=\"top\">";
615
616 foreach ($row_data AS $align_key => $item_array)
617 {
618 if ($align_key == 'c')
619 {
620 $align = 'center';
621 }
622 else if ($align_key == 'l')
623 {
624 $align = 'left';
625 }
626 else if ($align_key == 'r')
627 {
628 $align = 'right';
629 }
630
631 foreach ($item_array AS $value)
632 {
633 echo "\n\t<td class=\"{$this->registry->modules['functions']->bgcolour}\" align=\"$align\">$value</td>";
634 }
635 }
636
637 echo "\n</tr>\n";
638 }
639
640 // ###################################################################
641 /**
642 * Generic row creation function that has two columns: label and value;
643 * this is used for many other form functions, but can also be used for
644 * non-editable fields
645 *
646 * @param string Label text
647 * @param string HTML or text to place in the value column
648 * @param string Vertical align (valign attribute) for the row
649 * @param integer Colspan attribute
650 * @param string Class to style the row with; default is to alternate
651 */
652 public function row_text($label, $value = '&nbsp;', $valign = 'top', $colspan = 2, $class = -1)
653 {
654 global $IS_SETTINGS;
655
656 if ($class == -1)
657 {
658 if (!$IS_SETTINGS)
659 {
660 $this->registry->modules['functions']->exec_swap_bg();
661 $row_class = $this->registry->modules['functions']->bgcolour;
662 }
663 else
664 {
665 $row_class = 'alt2';
666 }
667 }
668 else
669 {
670 $row_class = $class;
671 }
672
673 echo "<tr valign=\"$valign\">";
674 echo "\n\t<td class=\"$row_class\">$label</td>";
675 echo "\n\t<td class=\"$row_class\" colspan=\"" . ($colspan - 1) . "\">$value</td>";
676
677 echo "\n</tr>\n";
678 }
679
680 // ###################################################################
681 /**
682 * Creates a table row with an <input> text field as the value column
683 *
684 * @param string Label text
685 * @param string Name of the <input> field
686 * @param string Value of the field
687 * @param integer Colspan attribute
688 * @param integer Size of the <input> field
689 * @param integer Length attribute; use FALSE for no length to be specified
690 * @param bool Whether to make this a password field
691 * @param string Vertical align (valign attribute)
692 */
693 public function row_input($label, $name, $value = '', $colspan = 2, $size = 35, $length = false, $password = false, $lalign = 'top')
694 {
695 $this->row_text($label, "<input type=\"" . (($password) ? 'password' : 'text') . "\" class=\"input\" name=\"$name\" value=\"$value\" size=\"$size\" " . (($length) ? "maxlength=\"$length\" " : '') . "/>", $lalign, $colspan);
696 }
697
698 // ###################################################################
699 /**
700 * Creates a table row with a <textarea> as the value column
701 *
702 * @param string Label text
703 * @param string Name of the <textarea>
704 * @param string Value of the <textarea>
705 * @param integer Colspan attribute
706 * @param integer Number of rows in the <textarea>
707 * @param integer Number of colums in the <textarea>
708 * @param bool Whether or not to use monospacing font
709 * @param string Extra style attributes to apply to the <textarea>
710 */
711 public function row_textarea($label, $name, $value = '', $colspan = 2, $rows = 7, $cols = 50, $code = false, $style = '')
712 {
713 $this->row_text($label, "<textarea name=\"$name\" class=\"" . (($code) ? 'code' : 'input') . "\" rows=\"$rows\" cols=\"$cols\"" . (($style) ? ' style="' . $style . '"' : '') . ">$value</textarea>", 'top', $colspan);
714 }
715
716 // ###################################################################
717 /**
718 * Creates a table row with the tfoot class
719 *
720 * @param string Extra text or HTML to insert into the row
721 * @param integer Colspan attribute
722 */
723 public function row_tfoot($data, $colspan = 2)
724 {
725 echo $this->row_span($data, 'tfoot', 'center', $colspan);
726 }
727
728 // ###################################################################
729 /**
730 * Creates a tfoot table row with submit buttons
731 *
732 * @param string Extra HTML to imbed in the row after the buttons
733 * @param string Submit button text (by default it uses pre-translated "Submit" from :save:)
734 * @param string Reset button text (default it uses pre-translated "Reset" from :reset:)
735 * @param integer Colspan attribute
736 */
737 public function row_submit($extra = false, $submit = ':save:', $reset = ':reset:', $colspan = 2)
738 {
739 if ($submit === ':save:')
740 {
741 $submit = " " . $this->registry->modules['localize']->string('Submit') . " ";
742 }
743 else
744 {
745 $submit = " $submit ";
746 }
747
748 if ($reset === ':reset:')
749 {
750 $reset = " " . $this->registry->modules['localize']->string('Reset') . " ";
751 }
752 else
753 {
754 $reset = (($reset) ? " $reset " : '');
755 }
756
757 $output = "\n\t\t<input type=\"submit\" class=\"button\" name=\"__submit__\" value=\"$submit\" accesskey=\"s\" />";
758 $output .= ($reset ? "\n\t\t<input type=\"reset\" class=\"button\" name=\"__reset__\" value=\"$reset\" accesskey=\"r\" />" : '');
759 $output .= ($extra ? "\n\t\t$extra" : '');
760 $output .= "\n\t";
761 $this->row_tfoot($output, $colspan);
762 }
763
764 // ###################################################################
765 /**
766 * Creates an upload row; you need to specify some other paramaters in
767 * form_start() for this to work
768 *
769 * @param string Label text
770 * @param string Upload name
771 * @param integer Colspan attribute
772 */
773 public function row_upload($label, $name, $colspan = 2)
774 {
775 $this->row_text($label, "<input type=\"file\" class=\"button\" name=\"$name\" size=\"35\" />", 'top', $colspan);
776 }
777
778 // ###################################################################
779 /**
780 * Adds a name-value pair to an array that is constructed into a
781 * <select> list
782 *
783 * @param string Text displayed for the option
784 * @param string Value of the option
785 * @param bool Whether or not to select this particluar option
786 */
787 public function list_item($name, $value, $selected = false)
788 {
789 global $listitem;
790
791 $listitem["$value"] = array('name' => $name, 'selected' => $selected);
792 }
793
794 // ###################################################################
795 /**
796 * Assembles a <select> table row from list_item() items
797 *
798 * @param string Label text
799 * @param string Name of the <select>
800 * @param bool Automatically submit the form on a change?
801 * @param integer Colspan attribute
802 */
803 public function row_list($label, $name, $is_jump = false, $colspan = 2)
804 {
805 global $listitem;
806
807 foreach ($listitem AS $value => $option)
808 {
809 $optionlist .= "\n\t<option value=\"$value\"" . ($option['selected'] == true ? ' selected="selected"' : '') . ">$option[name]</option>";
810 }
811
812 $listitem = array();
813
814 $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);
815 }
816
817 // ###################################################################
818 /**
819 * Assembles a list of checkboxes from list_item() items
820 *
821 * @param string Label text
822 * @param string Name of the <input>s
823 * @param integer Colspan attribute
824 */
825 public function row_checkbox($label, $name, $colspan = 2)
826 {
827 global $listitem;
828
829 foreach ($listitem AS $value => $box)
830 {
831 $optionlist[] = "\n\t<input type=\"checkbox\" class=\"button\" name=\"{$name}[]\" value=\"$value\"" . ($box['selected'] == true ? ' checked="checked"' : '') . " /> $box[name]";
832 }
833
834 $listitem = array();
835
836 $this->row_text($label, "\n" . implode('<br />', $optionlist) . "\n", $colspan);
837 }
838
839 // ###################################################################
840 /**
841 * Creates a row with two radio buttons: yes and now
842 *
843 * @param string Label text
844 * @param string Name of the BOOL flag
845 * @param bool TRUE to select the YES by default; FALSE for NO
846 * @param integer Colspan attribute
847 */
848 public function row_yesno($label, $name, $value, $colspan = 2)
849 {
850 $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);
851 }
852 }
853
854 /*=====================================================================*\
855 || ###################################################################
856 || # $HeadURL$
857 || # $Id$
858 || ###################################################################
859 \*=====================================================================*/
860 ?>