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