Increment year in copyright notice.
[squirrelmail.git] / functions / options.php
CommitLineData
44ef0f47 1<?php
2ba13803 2
35586184 3/**
4 * options.php
5 *
6c84ba1e 6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Functions needed to display the options pages.
10 *
31841a9e 11 * @version $Id$
d6c32258 12 * @package squirrelmail
35586184 13 */
a3ec3c91 14
15/**********************************************/
16/* Define constants used in the options code. */
17/**********************************************/
18
19/* Define constants for the various option types. */
20define('SMOPT_TYPE_STRING', 0);
21define('SMOPT_TYPE_STRLIST', 1);
7e6d5ea3 22define('SMOPT_TYPE_TEXTAREA', 2);
a3ec3c91 23define('SMOPT_TYPE_INTEGER', 3);
24define('SMOPT_TYPE_FLOAT', 4);
25define('SMOPT_TYPE_BOOLEAN', 5);
2a50fbd7 26define('SMOPT_TYPE_HIDDEN', 6);
bbcafebd 27define('SMOPT_TYPE_COMMENT', 7);
be2d5495 28define('SMOPT_TYPE_FLDRLIST', 8);
a3ec3c91 29
30/* Define constants for the options refresh levels. */
31define('SMOPT_REFRESH_NONE', 0);
32define('SMOPT_REFRESH_FOLDERLIST', 1);
33define('SMOPT_REFRESH_ALL', 2);
34
bbcafebd 35/* Define constants for the options size. */
36define('SMOPT_SIZE_TINY', 0);
37define('SMOPT_SIZE_SMALL', 1);
38define('SMOPT_SIZE_MEDIUM', 2);
39define('SMOPT_SIZE_LARGE', 3);
40define('SMOPT_SIZE_HUGE', 4);
88cb1b4d 41define('SMOPT_SIZE_NORMAL', 5);
bbcafebd 42
cbe5423b 43define('SMOPT_SAVE_DEFAULT', 'save_option');
44define('SMOPT_SAVE_NOOP', 'save_option_noop');
45
9962527a 46/**
47 * SquirrelOption: An option for Squirrelmail.
48 *
8f6f9ba5 49 * @package squirrelmail
b4856b14 50 * @subpackage prefs
9962527a 51 */
52class SquirrelOption {
b4856b14 53 /**
54 * The name of this setting
55 * @var string
56 */
9962527a 57 var $name;
b4856b14 58 /**
59 * The text that prefaces setting on the preferences page
60 * @var string
61 */
9962527a 62 var $caption;
b4856b14 63 /**
64 * The type of INPUT element
65 *
66 * See SMOPT_TYPE_* defines
67 * @var integer
68 */
9962527a 69 var $type;
b4856b14 70 /**
71 * Indicates if a link should be shown to refresh part
72 * or all of the window
73 *
74 * See SMOPT_REFRESH_* defines
75 * @var integer
76 */
a3ec3c91 77 var $refresh_level;
b4856b14 78 /**
79 * Specifies the size of certain input items
80 *
81 * See SMOPT_SIZE_* defines
82 * @var integer
83 */
bbcafebd 84 var $size;
b4856b14 85 /**
86 * Text that follows a text input or
87 * select list input on the preferences page
88 *
89 * useful for indicating units, meanings of special values, etc.
90 * @var string
91 */
361d6e1b 92 var $trailing_text;
b4856b14 93 /**
94 * text displayed to the user
95 *
96 * Used with SMOPT_TYPE_COMMENT options
97 * @var string
98 */
bbcafebd 99 var $comment;
b4856b14 100 /**
101 * additional javascript or other code added to the user input
102 * @var string
103 */
cbe5423b 104 var $script;
b4856b14 105 /**
106 * script (usually Javascript) that will be placed after (outside of)
107 * the INPUT tag
108 * @var string
109 */
6ae9e729 110 var $post_script;
cbe5423b 111
b4856b14 112 /**
113 * The name of the Save Function for this option.
114 * @var string
115 */
cbe5423b 116 var $save_function;
9962527a 117
118 /* The various 'values' for this options. */
b4856b14 119 /**
120 * default/preselected value for this option
121 * @var mixed
122 */
9962527a 123 var $value;
b4856b14 124 /**
125 * new option value
126 * @var mixed
127 */
9962527a 128 var $new_value;
b4856b14 129 /**
130 * associative array, where each key is an actual input value
131 * and the corresponding value is what is displayed to the user
132 * for that list item in the drop-down list
133 * @var array
134 */
a3ec3c91 135 var $possible_values;
b4856b14 136 /**
137 * disables html sanitizing.
138 *
139 * WARNING - don't use it, if user input is possible in option
140 * or use own sanitizing functions. Currently works only with
141 * SMOPT_TYPE_STRLIST.
142 * @var bool
143 */
28520c87 144 var $htmlencoded=false;
9962527a 145
b4856b14 146 /**
147 * Constructor function
148 * @param string $name
149 * @param string $caption
150 * @param integer $type
151 * @param integer $refresh_level
152 * @param mixed $initial_value
153 * @param array $possible_values
154 * @param bool $htmlencoded
155 */
9962527a 156 function SquirrelOption
28520c87 157 ($name, $caption, $type, $refresh_level, $initial_value = '', $possible_values = '', $htmlencoded = false) {
9962527a 158 /* Set the basic stuff. */
159 $this->name = $name;
160 $this->caption = $caption;
9962527a 161 $this->type = $type;
a3ec3c91 162 $this->refresh_level = $refresh_level;
163 $this->possible_values = $possible_values;
28520c87 164 $this->htmlencoded = $htmlencoded;
bbcafebd 165 $this->size = SMOPT_SIZE_MEDIUM;
361d6e1b 166 $this->trailing_text = '';
bbcafebd 167 $this->comment = '';
cbe5423b 168 $this->script = '';
6ae9e729 169 $this->post_script = '';
a3ec3c91 170
171 /* Check for a current value. */
6ae9e729 172 if (!empty($initial_value)) {
173 $this->value = $initial_value;
174 } else if (isset($GLOBALS[$name])) {
a3ec3c91 175 $this->value = $GLOBALS[$name];
176 } else {
177 $this->value = '';
178 }
9962527a 179
a3ec3c91 180 /* Check for a new value. */
b4856b14 181 if ( !sqgetGlobalVar("new_$name", $this->new_value, SQ_POST ) ) {
a3ec3c91 182 $this->new_value = '';
44ef0f47 183 }
cbe5423b 184
185 /* Set the default save function. */
2a50fbd7 186 if (($type != SMOPT_TYPE_HIDDEN) && ($type != SMOPT_TYPE_COMMENT)) {
cbe5423b 187 $this->save_function = SMOPT_SAVE_DEFAULT;
188 } else {
189 $this->save_function = SMOPT_SAVE_NOOP;
190 }
191 }
192
b4856b14 193 /**
194 * Set the value for this option.
195 * @param mixed $value
196 */
cbe5423b 197 function setValue($value) {
198 $this->value = $value;
199 }
200
b4856b14 201 /**
202 * Set the new value for this option.
203 * @param mixed $new_value
204 */
cbe5423b 205 function setNewValue($new_value) {
206 $this->new_value = $new_value;
9962527a 207 }
44ef0f47 208
b4856b14 209 /**
210 * Set the size for this option.
211 * @param integer $size
212 */
bbcafebd 213 function setSize($size) {
214 $this->size = $size;
215 }
216
b4856b14 217 /**
218 * Set the trailing_text for this option.
219 * @param string $trailing_text
220 */
361d6e1b 221 function setTrailingText($trailing_text) {
222 $this->trailing_text = $trailing_text;
223 }
224
b4856b14 225 /**
226 * Set the comment for this option.
227 * @param string $comment
228 */
bbcafebd 229 function setComment($comment) {
230 $this->comment = $comment;
231 }
232
b4856b14 233 /**
234 * Set the script for this option.
235 * @param string $script
236 */
cbe5423b 237 function setScript($script) {
238 $this->script = $script;
239 }
240
b4856b14 241 /**
242 * Set the "post script" for this option.
243 * @param string $post_script
244 */
6ae9e729 245 function setPostScript($post_script) {
246 $this->post_script = $post_script;
247 }
248
b4856b14 249 /**
250 * Set the save function for this option.
251 * @param string $save_function
252 */
cbe5423b 253 function setSaveFunction($save_function) {
254 $this->save_function = $save_function;
255 }
256
b4856b14 257 /**
258 * Creates fields on option pages according to option type
259 *
260 * Function that calls other createWidget* functions.
261 * @return string html formated option field
262 */
a3ec3c91 263 function createHTMLWidget() {
ce68b76b 264 global $color;
cbe5423b 265
62f7daa5 266 // Use new value if available
74e44765 267 if (!empty($this->new_value)) {
268 $tempValue = $this->value;
269 $this->value = $this->new_value;
270 }
271
cbe5423b 272 /* Get the widget for this option type. */
a3ec3c91 273 switch ($this->type) {
274 case SMOPT_TYPE_STRING:
37a3ed17 275 $result = $this->createWidget_String();
a3ec3c91 276 break;
277 case SMOPT_TYPE_STRLIST:
37a3ed17 278 $result = $this->createWidget_StrList();
a3ec3c91 279 break;
7e6d5ea3 280 case SMOPT_TYPE_TEXTAREA:
37a3ed17 281 $result = $this->createWidget_TextArea();
a3ec3c91 282 break;
283 case SMOPT_TYPE_INTEGER:
37a3ed17 284 $result = $this->createWidget_Integer();
a3ec3c91 285 break;
286 case SMOPT_TYPE_FLOAT:
37a3ed17 287 $result = $this->createWidget_Float();
a3ec3c91 288 break;
289 case SMOPT_TYPE_BOOLEAN:
37a3ed17 290 $result = $this->createWidget_Boolean();
a3ec3c91 291 break;
2a50fbd7 292 case SMOPT_TYPE_HIDDEN:
37a3ed17 293 $result = $this->createWidget_Hidden();
a3ec3c91 294 break;
bbcafebd 295 case SMOPT_TYPE_COMMENT:
37a3ed17 296 $result = $this->createWidget_Comment();
bbcafebd 297 break;
be2d5495 298 case SMOPT_TYPE_FLDRLIST:
37a3ed17 299 $result = $this->createWidget_FolderList();
be2d5495 300 break;
a3ec3c91 301 default:
6b4bd11f 302 $result = '<font color="' . $color[2] . '">'
a3ec3c91 303 . sprintf(_("Option Type '%s' Not Found"), $this->type)
6b4bd11f 304 . '</font>';
a3ec3c91 305 }
306
6ae9e729 307 /* Add the "post script" for this option. */
308 $result .= $this->post_script;
62f7daa5 309
74e44765 310 // put correct value back if need be
311 if (!empty($this->new_value)) {
312 $this->value = $tempValue;
313 }
314
a3ec3c91 315 /* Now, return the created widget. */
316 return ($result);
317 }
318
b4856b14 319 /**
320 * Create string field
321 * @return string html formated option field
322 */
37a3ed17 323 function createWidget_String() {
bbcafebd 324 switch ($this->size) {
88cb1b4d 325 case SMOPT_SIZE_TINY:
326 $width = 5;
327 break;
328 case SMOPT_SIZE_SMALL:
329 $width = 12;
330 break;
331 case SMOPT_SIZE_LARGE:
332 $width = 38;
333 break;
334 case SMOPT_SIZE_HUGE:
335 $width = 50;
336 break;
bbcafebd 337 case SMOPT_SIZE_NORMAL:
88cb1b4d 338 default:
339 $width = 25;
bbcafebd 340 }
341
88440172 342 $result = "<input type=\"text\" name=\"new_$this->name\" value=\"" .
62f7daa5 343 htmlspecialchars($this->value) .
361d6e1b 344 "\" size=\"$width\" $this->script />$this->trailing_text\n";
a3ec3c91 345 return ($result);
346 }
347
b4856b14 348 /**
349 * Create selection box
350 * @return string html formated selection box
351 */
37a3ed17 352 function createWidget_StrList() {
a3ec3c91 353 /* Begin the select tag. */
d6150d69 354 $result = "<select name=\"new_$this->name\" $this->script>\n";
a3ec3c91 355
356 /* Add each possible value to the select list. */
357 foreach ($this->possible_values as $real_value => $disp_value) {
358 /* Start the next new option string. */
62f7daa5 359 $new_option = '<option value="' .
28520c87 360 ($this->htmlencoded ? $real_value : htmlspecialchars($real_value)) . '"';
a3ec3c91 361
362 /* If this value is the current value, select it. */
363 if ($real_value == $this->value) {
d6150d69 364 $new_option .= ' selected="selected"';
a3ec3c91 365 }
366
367 /* Add the display value to our option string. */
28520c87 368 $new_option .= '>' . ($this->htmlencoded ? $disp_value : htmlspecialchars($disp_value)) . "</option>\n";
a3ec3c91 369
370 /* And add the new option string to our select tag. */
371 $result .= $new_option;
372 }
373
374 /* Close the select tag and return our happy result. */
361d6e1b 375 $result .= "</select>$this->trailing_text\n";
a3ec3c91 376 return ($result);
377 }
378
b4856b14 379 /**
380 * Create folder selection box
381 * @return string html formated selection box
382 */
37a3ed17 383 function createWidget_FolderList() {
be2d5495 384 $selected = array(strtolower($this->value));
385
386 /* Begin the select tag. */
d6150d69 387 $result = "<select name=\"new_$this->name\" $this->script>\n";
be2d5495 388
389 /* Add each possible value to the select list. */
390 foreach ($this->possible_values as $real_value => $disp_value) {
62f7daa5 391 if ( is_array($disp_value) ) {
be2d5495 392 /* For folder list, we passed in the array of boxes.. */
393 $new_option = sqimap_mailbox_option_list(0, $selected, 0, $disp_value);
394 } else {
395 /* Start the next new option string. */
d6150d69 396 $new_option = '<option value="' . htmlspecialchars($real_value) . '"';
62f7daa5 397
be2d5495 398 /* If this value is the current value, select it. */
399 if ($real_value == $this->value) {
d6150d69 400 $new_option .= ' selected="selected"';
be2d5495 401 }
62f7daa5 402
be2d5495 403 /* Add the display value to our option string. */
d6150d69 404 $new_option .= '>' . htmlspecialchars($disp_value) . "</option>\n";
be2d5495 405 }
406 /* And add the new option string to our select tag. */
407 $result .= $new_option;
62f7daa5 408 }
be2d5495 409 /* Close the select tag and return our happy result. */
d6150d69 410 $result .= "</select>\n";
be2d5495 411 return ($result);
412 }
413
b4856b14 414 /**
415 * Creates textarea
416 * @return string html formated textarea field
417 */
37a3ed17 418 function createWidget_TextArea() {
bbcafebd 419 switch ($this->size) {
420 case SMOPT_SIZE_TINY: $rows = 3; $cols = 10; break;
421 case SMOPT_SIZE_SMALL: $rows = 4; $cols = 30; break;
422 case SMOPT_SIZE_LARGE: $rows = 10; $cols = 60; break;
423 case SMOPT_SIZE_HUGE: $rows = 20; $cols = 80; break;
424 case SMOPT_SIZE_NORMAL:
425 default: $rows = 5; $cols = 50;
426 }
6b4bd11f 427 $result = "<textarea name=\"new_$this->name\" rows=\"$rows\" "
d6150d69 428 . "cols=\"$cols\" $this->script>"
429 . htmlspecialchars($this->value) . "</textarea>\n";
bbcafebd 430 return ($result);
a3ec3c91 431 }
432
b4856b14 433 /**
434 * Creates field for integer
435 *
436 * Difference from createWidget_String is visible only when javascript is enabled
437 * @return string html formated option field
438 */
37a3ed17 439 function createWidget_Integer() {
b65d1a08 440 global $javascript_on;
0d08ea5a 441
b65d1a08 442 // add onChange javascript handler to a regular string widget
443 // which will strip out all non-numeric chars
444 if ($javascript_on)
d6150d69 445 return preg_replace('/\/>/', ' onChange="origVal=this.value; newVal=\'\'; '
b65d1a08 446 . 'for (i=0;i<origVal.length;i++) { if (origVal.charAt(i)>=\'0\' '
447 . '&& origVal.charAt(i)<=\'9\') newVal += origVal.charAt(i); } '
d6150d69 448 . 'this.value=newVal;" />', $this->createWidget_String());
b65d1a08 449 else
37a3ed17 450 return $this->createWidget_String();
a3ec3c91 451 }
452
b4856b14 453 /**
454 * Creates field for floating number
455 * Difference from createWidget_String is visible only when javascript is enabled
456 * @return string html formated option field
457 */
37a3ed17 458 function createWidget_Float() {
37a3ed17 459 global $javascript_on;
460
b65d1a08 461 // add onChange javascript handler to a regular string widget
62f7daa5 462 // which will strip out all non-numeric (period also OK) chars
b65d1a08 463 if ($javascript_on)
d6150d69 464 return preg_replace('/\/>/', ' onChange="origVal=this.value; newVal=\'\'; '
b65d1a08 465 . 'for (i=0;i<origVal.length;i++) { if ((origVal.charAt(i)>=\'0\' '
466 . '&& origVal.charAt(i)<=\'9\') || origVal.charAt(i)==\'.\') '
d6150d69 467 . 'newVal += origVal.charAt(i); } this.value=newVal;" />'
37a3ed17 468 , $this->createWidget_String());
b65d1a08 469 else
37a3ed17 470 return $this->createWidget_String();
a3ec3c91 471 }
472
b4856b14 473 /**
474 * Creates radio field (yes/no)
475 * @return string html formated radio field
476 */
37a3ed17 477 function createWidget_Boolean() {
fd87494d 478 /* Do the whole current value thing. */
479 if ($this->value != SMPREF_NO) {
62f7daa5 480 $yes_chk = ' checked="checked"';
fd87494d 481 $no_chk = '';
482 } else {
483 $yes_chk = '';
62f7daa5 484 $no_chk = ' checked="checked"';
fd87494d 485 }
486
487 /* Build the yes choice. */
f4c37e3c 488 $yes_option = '<input type="radio" id="new_' . $this->name . '_yes" '
489 . 'name="new_' . $this->name . '" value="' . SMPREF_YES . '"'
d6150d69 490 . $yes_chk . ' ' . $this->script . ' />&nbsp;'
f4c37e3c 491 . '<label for="new_'.$this->name.'_yes">' . _("Yes") . '</label>';
fd87494d 492
493 /* Build the no choice. */
f4c37e3c 494 $no_option = '<input type="radio" id="new_' . $this->name . '_no" '
495 . 'name="new_' . $this->name . '" value="' . SMPREF_NO . '"'
d6150d69 496 . $no_chk . ' ' . $this->script . ' />&nbsp;'
f4c37e3c 497 . '<label for="new_'.$this->name.'_no">' . _("No") . '</label>';
fd87494d 498
499 /* Build and return the combined "boolean widget". */
500 $result = "$yes_option&nbsp;&nbsp;&nbsp;&nbsp;$no_option";
501 return ($result);
a3ec3c91 502 }
503
b4856b14 504 /**
505 * Creates hidden field
506 * @return string html formated hidden input field
507 */
37a3ed17 508 function createWidget_Hidden() {
6b4bd11f 509 $result = '<input type="hidden" name="new_' . $this->name
d6150d69 510 . '" value="' . htmlspecialchars($this->value)
511 . '" ' . $this->script . ' />';
a3ec3c91 512 return ($result);
513 }
514
b4856b14 515 /**
516 * Creates comment
517 * @return string comment
518 */
37a3ed17 519 function createWidget_Comment() {
bbcafebd 520 $result = $this->comment;
521 return ($result);
522 }
523
b4856b14 524 /**
525 *
526 */
cbe5423b 527 function save() {
528 $function = $this->save_function;
529 $function($this);
44ef0f47 530 }
cbe5423b 531
b4856b14 532 /**
533 *
534 */
cbe5423b 535 function changed() {
6206f6c4 536 return ($this->value != $this->new_value);
cbe5423b 537 }
b4856b14 538} /* End of SquirrelOption class*/
cbe5423b 539
b4856b14 540/**
541 * Saves option
542 * @param object $option object that holds option name and new_value
543 */
cbe5423b 544function save_option($option) {
dac16606 545 if ( !sqgetGlobalVar('username', $username, SQ_SESSION ) ) {
546 /* Can't save the pref if we don't have the username */
547 return;
0b97a708 548 }
549 global $data_dir;
0b97a708 550 setPref($data_dir, $username, $option->name, $option->new_value);
cbe5423b 551}
552
b4856b14 553/**
554 * save function that does not save
555 * @param object $option
556 */
cbe5423b 557function save_option_noop($option) {
558 /* Do nothing here... */
9962527a 559}
44ef0f47 560
b4856b14 561/**
562 * Create hidden 'optpage' input field with value set by argument
563 * @param string $optpage identification of option page
564 * @return string html formated hidden input field
565 */
cbe5423b 566function create_optpage_element($optpage) {
567 return create_hidden_element('optpage', $optpage);
568}
569
b4856b14 570/**
571 * Create hidden 'optmode' input field with value set by argument
572 * @param string $optmode
573 * @return string html formated hidden input field
574 */
cbe5423b 575function create_optmode_element($optmode) {
576 return create_hidden_element('optmode', $optmode);
577}
578
b4856b14 579/**
580 * Create hidden field.
581 * @param string $name field name
582 * @param string $value field value
583 * @return string html formated hidden input field
584 */
cbe5423b 585function create_hidden_element($name, $value) {
6b4bd11f 586 $result = '<input type="hidden" '
587 . 'name="' . $name . '" '
d6150d69 588 . 'value="' . htmlspecialchars($value) . '" />';
cbe5423b 589 return ($result);
590}
591
b4856b14 592/**
593 * @param array $optgrps
594 * @param array $optvals
595 * @return array
596 */
cbe5423b 597function create_option_groups($optgrps, $optvals) {
a3ec3c91 598 /* Build a simple array with which to start. */
599 $result = array();
600
bbcafebd 601 /* Create option group for each option group name. */
602 foreach ($optgrps as $grpkey => $grpname) {
603 $result[$grpkey] = array();
604 $result[$grpkey]['name'] = $grpname;
605 $result[$grpkey]['options'] = array();
606 }
607
a3ec3c91 608 /* Create a new SquirrelOption for each set of option values. */
bbcafebd 609 foreach ($optvals as $grpkey => $grpopts) {
610 foreach ($grpopts as $optset) {
28520c87 611 /* Create a new option with all values given. */
612 $next_option = new SquirrelOption(
613 $optset['name'],
614 $optset['caption'],
615 $optset['type'],
616 (isset($optset['refresh']) ? $optset['refresh'] : SMOPT_REFRESH_NONE),
617 (isset($optset['initial_value']) ? $optset['initial_value'] : ''),
618 (isset($optset['posvals']) ? $optset['posvals'] : ''),
619 (isset($optset['htmlencoded']) ? $optset['htmlencoded'] : false)
620 );
bbcafebd 621
622 /* If provided, set the size for this option. */
623 if (isset($optset['size'])) {
624 $next_option->setSize($optset['size']);
625 }
626
361d6e1b 627 /* If provided, set the trailing_text for this option. */
628 if (isset($optset['trailing_text'])) {
629 $next_option->setTrailingText($optset['trailing_text']);
630 }
631
bbcafebd 632 /* If provided, set the comment for this option. */
633 if (isset($optset['comment'])) {
634 $next_option->setComment($optset['comment']);
635 }
636
cbe5423b 637 /* If provided, set the save function for this option. */
638 if (isset($optset['save'])) {
639 $next_option->setSaveFunction($optset['save']);
640 }
641
642 /* If provided, set the script for this option. */
643 if (isset($optset['script'])) {
644 $next_option->setScript($optset['script']);
645 }
646
6ae9e729 647 /* If provided, set the "post script" for this option. */
648 if (isset($optset['post_script'])) {
649 $next_option->setPostScript($optset['post_script']);
650 }
651
bbcafebd 652 /* Add this option to the option array. */
653 $result[$grpkey]['options'][] = $next_option;
a3ec3c91 654 }
655 }
656
657 /* Return our resulting array. */
658 return ($result);
659}
660
b4856b14 661/**
662 * @param array $option_groups
663 */
cbe5423b 664function print_option_groups($option_groups) {
2fad95fa 665 /* Print each option group. */
bbcafebd 666 foreach ($option_groups as $next_optgrp) {
2fad95fa 667 /* If it is not blank, print the name for this option group. */
668 if ($next_optgrp['name'] != '') {
6b4bd11f 669 echo html_tag( 'tr', "\n".
670 html_tag( 'td',
671 '<b>' . $next_optgrp['name'] . '</b>' ,
c435f076 672 'center' ,'', 'valign="middle" colspan="2" style="white-space: nowrap;"' )
6b4bd11f 673 ) ."\n";
7e235a1a 674 }
675
676 /* Print each option in this option group. */
bbcafebd 677 foreach ($next_optgrp['options'] as $option) {
2a50fbd7 678 if ($option->type != SMOPT_TYPE_HIDDEN) {
6b4bd11f 679 echo html_tag( 'tr', "\n".
680 html_tag( 'td', $option->caption . ':', 'right' ,'', 'valign="middle"' ) .
681 html_tag( 'td', $option->createHTMLWidget(), 'left' )
682 ) ."\n";
bbcafebd 683 } else {
684 echo $option->createHTMLWidget();
685 }
686 }
7e235a1a 687
688 /* Print an empty row after this option group. */
6b4bd11f 689 echo html_tag( 'tr',
690 html_tag( 'td', '&nbsp;', 'left', '', 'colspan="2"' )
691 ) . "\n";
bbcafebd 692 }
693}
694
b4856b14 695/**
696 * Create submit button inside table row.
697 * @param string $name
698 */
9962527a 699function OptionSubmit( $name ) {
6b4bd11f 700 echo html_tag( 'tr',
6fd95361 701 html_tag( 'td', '<input type="submit" value="' . _("Submit") . '" name="' . $name . '" />&nbsp;&nbsp;&nbsp;&nbsp;', 'right', '', 'colspan="2"' )
6b4bd11f 702 ) . "\n";
9962527a 703}
02ddcd00 704
d6150d69 705// vim: et ts=4
6fd95361 706?>