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