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