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