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