page_code() now should work a wee bit better
[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 integer Time to wait before the redirect
146 * @param array An aray of POST variables to send through on the redirect
147 */
148 function redirect($location, $timeout = 10, $postvars = array())
149 {
150 $timeout = $timeout * 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 $this->page_message($this->registry->modules['localize']->string('Redirect'), sprintf($this->registry->modules['localize']->string('Please wait to be redirected. If you are not redirected in a few seconds, click <a href="%1$s">here</a>.'), $location));
217
218 $this->page_code($js);
219
220 $this->page_end();
221 }
222
223 // ###################################################################
224 /**
225 * Throws a fatal error; constructs the header and footer
226 *
227 * @access public
228 *
229 * @param string Error messsage text
230 */
231 function error($message)
232 {
233 $this->page_start($this->registry->modules['localize']->string('Error'));
234 $this->page_message($this->registry->modules['localize']->string('Error'), $message);
235 $this->page_end();
236
237 exit;
238 }
239
240 // ###################################################################
241 /**
242 * Outputs the header of the page: doctype, <html>, <head>, <title>,
243 * <body> and imbeds the style information
244 *
245 * @access public
246 *
247 * @param string Title of the page
248 * @param string Class of the page to be applied to the body
249 * @param integer Margin of the <div> that all content is placed in
250 * @param string Extra HTML to imbed in the <head> tag
251 * @param string <body> onLoad action to imbed
252 * @param integer Margin of the actual <body > tag
253 * @param string Relative path where the CSS data is stored
254 * @param bool Will force re-print the header if it has already been printed
255 */
256 function page_start($actiontitle, $pageclass = ':default:', $pagemargin = 15, $extra = '', $onload = false, $margin = 0, $dotpath = '.', $override = false)
257 {
258 $this->registry->check_isso_fields(get_class($this));
259
260 if ($this->registry->debug AND isset($_GET['query']))
261 {
262 ob_start();
263 }
264
265 if (defined('ISSO_PRINTER_DONE_HEADER') AND !$override)
266 {
267 if (constant('ISSO_PRINTER_DONE_HEADER') AND !$override)
268 {
269 return;
270 }
271 }
272
273 $title = sprintf($this->registry->modules['localize']->string('%1$s - %2$s - %3$s'), $this->registry->application, $this->realm, $actiontitle);
274
275 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
276 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>";
277 echo "\n\t<title>$title</title>";
278 echo "\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
279 echo $this->css;
280 echo $this->code;
281 echo ($extra ? "\n$extra" : '');
282 echo "\n</head>\n<body style=\"margin: {$margin}px;\"" . (($pageclass !== ':default:') ? " class=\"$pageclass\"" : '') . (($onload) ? " onload=\"$onload\"" : '') . ">\n";
283
284 if (!defined('ISSO_PRINTER_HIDE_SETUP') AND function_exists('_printer_page_start'))
285 {
286 _printer_page_start();
287 }
288
289 echo "<div style=\"margin: {$pagemargin}px;\">\n<!-- / page head -->\n\n";
290
291 if (!defined('ISSO_PRINTER_DONE_HEADER'))
292 {
293 define('ISSO_PRINTER_DONE_HEADER', 1);
294 }
295 }
296
297 // ###################################################################
298 /**
299 * Links CSS to the page from a given relative path
300 *
301 * @access public
302 *
303 * @param string Relative path to the CSS file
304 */
305 function css_link($path)
306 {
307 $this->css .= "\n\t<link rel=\"stylesheet\" href=\"$path\" />";
308 }
309
310 // ###################################################################
311 /**
312 * Imbeds actual CSS information into the page in <style> tags
313 *
314 * @access public
315 *
316 * @param string Path of the CSS file to be imbeded
317 */
318 function css_imbed($path)
319 {
320 $data = require_once($path);
321 $css = preg_replace('#/\*(.*?)\*/(\r|\n)*#s', '', $css);
322 $css = trim($css);
323 $this->css .= "\n\t<style type=\"text/css\">\n\t<!--\n" . $css . "\n\t//-->\n\t</style>";
324 }
325
326 // ###################################################################
327 /**
328 * Places raw HTML code directly into the documet at the current
329 * position
330 *
331 * @access public
332 *
333 * @param string HTML code
334 */
335 function page_code($code)
336 {
337 if (defined('ISSO_PRINTER_DONE_HEADER'))
338 {
339 echo "\n\n$code\n\n";
340 }
341 else
342 {
343 $this->code .= "\n\n$code\n\n";
344 }
345 }
346
347 // ###################################################################
348 /**
349 * A block function that produces a table with a message in it. This
350 * does not print the header and footer.
351 *
352 * @access public
353 *
354 * @param string The title of the message (appears at the top of the block)
355 * @param string Content of the message
356 */
357 function page_message($title, $message)
358 {
359 $this->table_start(true, '75%');
360 $this->table_head($title, 1);
361 $this->row_span("<blockquote>$message</blockquote>", ':swap:', 'left', 1);
362 $this->table_end();
363 }
364
365 // ###################################################################
366 /**
367 * Produces an entire page layout that asks the user whether or not
368 * they want to perform X action and provides a link to the YES and NO
369 * action
370 *
371 * @access public
372 *
373 * @param string Message that asks if they want to do X
374 * @param string Location to go for YES
375 * @param string DO action to pass
376 * @param array Hidden parameters to pass to the next page
377 */
378 function page_confirm($message, $location, $action, $params)
379 {
380 $this->page_start($this->registry->modules['localize']->string('Confirm'));
381
382 $this->form_start($location, $action);
383 foreach ($params AS $key => $value)
384 {
385 $this->form_hidden_field($key, $value);
386 }
387
388 $this->table_start(true, '75%');
389 $this->table_head($this->registry->modules['localize']->string('Confirm'), 1);
390 $this->row_span("<blockquote>$message</blockquote>", ':swap:', 'left', 1);
391 $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'), '');
392 $this->table_end();
393
394 $this->form_end();
395
396 $this->page_end();
397 }
398
399 // ###################################################################
400 /**
401 * Closes the HTML document structure an adds the copyright; this also
402 * stops execution of the page
403 *
404 * @access public
405 */
406 function page_end()
407 {
408 if ($this->registry->debug AND isset($_GET['query']))
409 {
410 ob_clean();
411 ob_end_clean();
412
413 if (is_array($this->registry->modules[ISSO_DB_LAYER]->history))
414 {
415 foreach ($this->registry->modules[ISSO_DB_LAYER]->history AS $query)
416 {
417 echo $this->registry->modules[ISSO_DB_LAYER]->construct_query_debug($query);
418 }
419 }
420 exit;
421 }
422
423 $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>";
424
425 if (!defined('ISSO_PRINTER_HIDE_SETUP'))
426 {
427 echo "\n<!-- page end -->\n</div>\n$copyright";
428 echo $this->registry->construct_debug_block(false);
429 }
430 else
431 {
432 echo "\n<!-- page end -->\n</div>";
433 }
434
435 echo "\n\n</body>\n</html>";
436
437 exit;
438 }
439
440 // -------------------------------------------------------------------
441
442 // ###################################################################
443 /**
444 * Opens a <table> tag with styling
445 *
446 * @access public
447 *
448 * @param bool Whether to add a <br /> before the table
449 * @param string Value of the width attribute
450 */
451 function table_start($break = true, $width = '90%')
452 {
453 if ($break)
454 {
455 echo '<br />';
456 }
457
458 echo "\n<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\" align=\"center\" width=\"$width\" class=\"tborder\">\n";
459 }
460
461 // ###################################################################
462 /**
463 * Adds a table row that is sued to head the entire table
464 *
465 * @access public
466 *
467 * @param string Title string
468 * @param integer Colspan attribute value
469 * @param bool Whether to bold the title
470 */
471 function table_head($title, $colspan = 2, $strong = true)
472 {
473 echo "<tr>\n\t<td class=\"tcat\" align=\"center\" colspan=\"$colspan\">" . (($strong) ? "<strong>$title</strong>" : $title) . "</td>\n</tr>\n";
474 }
475
476 // ###################################################################
477 /**
478 * Creates column headings; useful for a grid-style page. This uses a
479 * different styling than table_head() and is usually used directly
480 * after a table header.
481 *
482 * @access public
483 *
484 * @param array Array of titles to print
485 */
486 function table_column_head($columnarray)
487 {
488 if (is_array($columnarray))
489 {
490 $render = "<tr valign=\"top\" align=\"center\">\n";
491
492 foreach ($columnarray AS $header)
493 {
494 $render .= "\t<td class=\"thead\" align=\"center\">$header</td>\n";
495 }
496
497 $render .= "</tr>\n";
498
499 echo $render;
500 }
501 }
502
503 // ###################################################################
504 /**
505 * Closes a <table> tag
506 *
507 * @access public
508 */
509 function table_end()
510 {
511 echo "\n</table>\n";
512 }
513
514 // -------------------------------------------------------------------
515
516 // ###################################################################
517 /**
518 * Starts a <form> tag and adds the DO hidden input field
519 *
520 * @access public
521 *
522 * @param string Action/name of the file to action to
523 * @param string Value of the DO parameter; used to do-branch
524 * @param bool Enctype attribute; used for mime/multi-part
525 * @param string Name of the form; this only matters for DOM access
526 * @param string Method to action as; POST or GET (default is POST)
527 */
528 function form_start($action, $do, $enctype = false, $name = 'inputform', $submitmethod = 'post')
529 {
530 echo "\n<!-- input form -->\n<form name=\"$name\" action=\"$action\"" . (($enctype) ? " enctype=\"$enctype\"" : '') . " method=\"$submitmethod\">\n";
531
532 if ($do !== null)
533 {
534 $this->form_hidden_field('do', $do);
535 }
536 }
537
538 // ###################################################################
539 /**
540 * Adds a hidden field at the current location
541 *
542 * @access public
543 *
544 * @param string Name of the field
545 * @param string Value of the field
546 */
547 function form_hidden_field($name, $value)
548 {
549 echo "<input type=\"hidden\" name=\"$name\" value=\"$value\" />\n";
550 }
551
552 // ###################################################################
553 /**
554 * Closes a <form> tag
555 *
556 * @access public
557 */
558 function form_end()
559 {
560 echo "</form>\n<!-- / input form -->\n";
561 }
562
563 // -------------------------------------------------------------------
564
565 // ###################################################################
566 /**
567 * Creates a table row that spans an entire row; this is used to divide
568 * sections, usually
569 *
570 * @access public
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 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 * @access public
609 *
610 * @param array Array of values in form value => alignment key (c for center, l for left, and r for right)
611 */
612 function row_multi_item($row_array)
613 {
614 $this->registry->modules['functions']->exec_swap_bg();
615
616 foreach ($row_array AS $item => $align)
617 {
618 $row_data["$align"][] = $item;
619 }
620
621 echo "<tr valign=\"top\">";
622
623 foreach ($row_data AS $align_key => $item_array)
624 {
625 if ($align_key == 'c')
626 {
627 $align = 'center';
628 }
629 else if ($align_key == 'l')
630 {
631 $align = 'left';
632 }
633 else if ($align_key == 'r')
634 {
635 $align = 'right';
636 }
637
638 foreach ($item_array AS $value)
639 {
640 echo "\n\t<td class=\"{$this->registry->modules['functions']->bgcolour}\" align=\"$align\">$value</td>";
641 }
642 }
643
644 echo "\n</tr>\n";
645 }
646
647 // ###################################################################
648 /**
649 * Generic row creation function that has two columns: label and value;
650 * this is used for many other form functions, but can also be used for
651 * non-editable fields
652 *
653 * @access public
654 *
655 * @param string Label text
656 * @param string HTML or text to place in the value column
657 * @param string Vertical align (valign attribute) for the row
658 * @param integer Colspan attribute
659 * @param string Class to style the row with; default is to alternate
660 */
661 function row_text($label, $value = '&nbsp;', $valign = 'top', $colspan = 2, $class = -1)
662 {
663 global $IS_SETTINGS;
664
665 if ($class == -1)
666 {
667 if (!$IS_SETTINGS)
668 {
669 $this->registry->modules['functions']->exec_swap_bg();
670 $row_class = $this->registry->modules['functions']->bgcolour;
671 }
672 else
673 {
674 $row_class = 'alt2';
675 }
676 }
677 else
678 {
679 $row_class = $class;
680 }
681
682 echo "<tr valign=\"$valign\">";
683 echo "\n\t<td class=\"$row_class\">$label</td>";
684 echo "\n\t<td class=\"$row_class\">$value</td>";
685
686 if ($colspan > 2)
687 {
688 echo "\n\t<td class=\"$row_class\" colspan=\"" . $colspan - 2 . "\">&nbsp;</td>";
689 }
690
691 echo "\n</tr>\n";
692 }
693
694 // ###################################################################
695 /**
696 * Creates a table row with an <input> text field as the value column
697 *
698 * @access public
699 *
700 * @param string Label text
701 * @param string Name of the <input> field
702 * @param string Value of the field
703 * @param integer Colspan attribute
704 * @param integer Size of the <input> field
705 * @param integer Length attribute; use FALSE for no length to be specified
706 * @param bool Whether to make this a password field
707 * @param string Vertical align (valign attribute)
708 */
709 function row_input($label, $name, $value = '', $colspan = 2, $size = 35, $length = false, $password = false, $lalign = 'top')
710 {
711 $this->row_text($label, "<input type=\"" . (($password) ? 'password' : 'text') . "\" class=\"input\" name=\"$name\" value=\"$value\" size=\"$size\" " . (($length) ? "maxlength=\"$length\" " : '') . "/>", $lalign, $colspan);
712 }
713
714 // ###################################################################
715 /**
716 * Creates a table row with a <textarea> as the value column
717 *
718 * @access public
719 *
720 * @param string Label text
721 * @param string Name of the <textarea>
722 * @param string Value of the <textarea>
723 * @param integer Colspan attribute
724 * @param integer Number of rows in the <textarea>
725 * @param integer Number of colums in the <textarea>
726 * @param bool Whether or not to use monospacing font
727 * @param string Extra style attributes to apply to the <textarea>
728 */
729 function row_textarea($label, $name, $value = '', $colspan = 2, $rows = 7, $cols = 50, $code = false, $style = '')
730 {
731 $this->row_text($label, "<textarea name=\"$name\" class=\"" . (($code) ? 'code' : 'input') . "\" rows=\"$rows\" cols=\"$cols\"" . (($style) ? ' style="' . $style . '"' : '') . ">$value</textarea>", 'top', $colspan);
732 }
733
734 // ###################################################################
735 /**
736 * Creates a table row with the tfoot class
737 *
738 * @access public
739 *
740 * @param string Extra text or HTML to insert into the row
741 * @param integer Colspan attribute
742 */
743 function row_tfoot($data, $colspan = 2)
744 {
745 echo $this->row_span($data, 'tfoot', 'center', $colspan);
746 }
747
748 // ###################################################################
749 /**
750 * Creates a tfoot table row with submit buttons
751 *
752 * @access public
753 *
754 * @param string Extra HTML to imbed in the row after the buttons
755 * @param string Submit button text (by default it uses pre-translated "Submit" from :save:)
756 * @param string Reset button text (default it uses pre-translated "Reset" from :reset:)
757 * @param integer Colspan attribute
758 */
759 function row_submit($extra = false, $submit = ':save:', $reset = ':reset:', $colspan = 2)
760 {
761 if ($submit === ':save:')
762 {
763 $submit = " " . $this->registry->modules['localize']->string('Submit') . " ";
764 }
765 else
766 {
767 $submit = " $submit ";
768 }
769
770 if ($reset === ':reset:')
771 {
772 $reset = " " . $this->registry->modules['localize']->string('Reset') . " ";
773 }
774 else
775 {
776 $reset = (($reset) ? " $reset " : '');
777 }
778
779 $output = "\n\t\t<input type=\"submit\" class=\"button\" name=\"__submit__\" value=\"$submit\" accesskey=\"s\" />";
780 $output .= ($reset ? "\n\t\t<input type=\"reset\" class=\"button\" name=\"__reset__\" value=\"$reset\" accesskey=\"r\" />" : '');
781 $output .= ($extra ? "\n\t\t$extra" : '');
782 $output .= "\n\t";
783 $this->row_tfoot($output, $colspan);
784 }
785
786 // ###################################################################
787 /**
788 * Creates an upload row; you need to specify some other paramaters in
789 * form_start() for this to work
790 *
791 * @access public
792 *
793 * @param string Label text
794 * @param string Upload name
795 * @param integer Colspan attribute
796 */
797 function row_upload($label, $name, $colspan = 2)
798 {
799 $this->row_text($label, "<input type=\"file\" class=\"button\" name=\"$name\" size=\"35\" />", 'top', $colspan);
800 }
801
802 // ###################################################################
803 /**
804 * Adds a name-value pair to an array that is constructed into a
805 * <select> list
806 *
807 * @access public
808 *
809 * @param string Text displayed for the option
810 * @param string Value of the option
811 * @param bool Whether or not to select this particluar option
812 */
813 function list_item($name, $value, $selected = false)
814 {
815 global $listitem;
816
817 $listitem["$value"] = array('name' => $name, 'selected' => $selected);
818 }
819
820 // ###################################################################
821 /**
822 * Assembles a <select> table row from list_item() items
823 *
824 * @access public
825 *
826 * @param string Label text
827 * @param string Name of the <select>
828 * @param bool Automatically submit the form on a change?
829 * @param integer Colspan attribute
830 */
831 function row_list($label, $name, $is_jump = false, $colspan = 2)
832 {
833 global $listitem;
834
835 foreach ($listitem AS $value => $option)
836 {
837 $optionlist .= "\n\t<option value=\"$value\"" . ($option['selected'] == true ? ' selected="selected"' : '') . ">$option[name]</option>";
838 }
839
840 $listitem = array();
841
842 $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);
843 }
844
845 // ###################################################################
846 /**
847 * Assembles a list of checkboxes from list_item() items
848 *
849 * @access public
850 *
851 * @param string Label text
852 * @param string Name of the <input>s
853 * @param integer Colspan attribute
854 */
855 function row_checkbox($label, $name, $colspan = 2)
856 {
857 global $listitem;
858
859 foreach ($listitem AS $value => $box)
860 {
861 $optionlist[] = "\n\t<input type=\"checkbox\" class=\"button\" name=\"{$name}[]\" value=\"$value\"" . ($box['selected'] == true ? ' checked="checked"' : '') . " /> $box[name]";
862 }
863
864 $listitem = array();
865
866 $this->row_text($label, "\n" . implode('<br />', $optionlist) . "\n", $colspan);
867 }
868
869 // ###################################################################
870 /**
871 * Creates a row with two radio buttons: yes and now
872 *
873 * @access public
874 *
875 * @param string Label text
876 * @param string Name of the BOOL flag
877 * @param bool TRUE to select the YES by default; FALSE for NO
878 * @param integer Colspan attribute
879 */
880 function row_yesno($label, $name, $value, $colspan = 2)
881 {
882 $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);
883 }
884 }
885
886 /*=====================================================================*\
887 || ###################################################################
888 || # $HeadURL$
889 || # $Id$
890 || ###################################################################
891 \*=====================================================================*/
892 ?>