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