6 * Functions needed to display the options pages.
8 * @copyright © 1999-2007 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
15 /**********************************************/
16 /* Define constants used in the options code. */
17 /**********************************************/
19 /* Define constants for the various option types. */
20 define('SMOPT_TYPE_STRING', 0);
21 define('SMOPT_TYPE_STRLIST', 1);
22 define('SMOPT_TYPE_TEXTAREA', 2);
23 define('SMOPT_TYPE_INTEGER', 3);
24 define('SMOPT_TYPE_FLOAT', 4);
25 define('SMOPT_TYPE_BOOLEAN', 5);
26 define('SMOPT_TYPE_HIDDEN', 6);
27 define('SMOPT_TYPE_COMMENT', 7);
28 define('SMOPT_TYPE_FLDRLIST', 8);
29 define('SMOPT_TYPE_FLDRLIST_MULTI', 9);
30 define('SMOPT_TYPE_EDIT_LIST', 10);
31 define('SMOPT_TYPE_STRLIST_MULTI', 11);
32 define('SMOPT_TYPE_BOOLEAN_CHECKBOX', 12);
33 define('SMOPT_TYPE_BOOLEAN_RADIO', 13);
34 define('SMOPT_TYPE_STRLIST_RADIO', 14);
36 /* Define constants for the layout scheme for edit lists. */
37 define('SMOPT_EDIT_LIST_LAYOUT_LIST', 0);
38 define('SMOPT_EDIT_LIST_LAYOUT_SELECT', 1);
40 /* Define constants for the options refresh levels. */
41 define('SMOPT_REFRESH_NONE', 0);
42 define('SMOPT_REFRESH_FOLDERLIST', 1);
43 define('SMOPT_REFRESH_ALL', 2);
45 /* Define constants for the options size. */
46 define('SMOPT_SIZE_TINY', 0);
47 define('SMOPT_SIZE_SMALL', 1);
48 define('SMOPT_SIZE_MEDIUM', 2);
49 define('SMOPT_SIZE_LARGE', 3);
50 define('SMOPT_SIZE_HUGE', 4);
51 define('SMOPT_SIZE_NORMAL', 5);
53 define('SMOPT_SAVE_DEFAULT', 'save_option');
54 define('SMOPT_SAVE_NOOP', 'save_option_noop');
57 * SquirrelOption: An option for SquirrelMail.
59 * @package squirrelmail
62 class SquirrelOption
{
64 * The name of this setting
69 * The text that prefaces setting on the preferences page
74 * The type of INPUT element
76 * See SMOPT_TYPE_* defines
81 * Indicates if a link should be shown to refresh part
82 * or all of the window
84 * See SMOPT_REFRESH_* defines
89 * Specifies the size of certain input items
91 * See SMOPT_SIZE_* defines
96 * Text that follows a text input or
97 * select list input on the preferences page
99 * useful for indicating units, meanings of special values, etc.
104 * Text that overrides the "Yes" label for boolean
105 * radio option widgets
111 * Text that overrides the "No" label for boolean
112 * radio option widgets
118 * Some widgets support more than one layout type
124 * text displayed to the user
126 * Used with SMOPT_TYPE_COMMENT options
131 * additional javascript or other widget attributes added to the
132 * user input; must be an array where keys are attribute names
133 * ("onclick", etc) and values are the attribute values.
138 * script (usually Javascript) that will be placed after (outside of)
145 * The name of the Save Function for this option.
150 /* The various 'values' for this options. */
152 * default/preselected value for this option
162 * associative array, where each key is an actual input value
163 * and the corresponding value is what is displayed to the user
164 * for that list item in the drop-down list
167 var $possible_values;
169 * disables html sanitizing.
171 * WARNING - don't use it, if user input is possible in option
172 * or use own sanitizing functions. Currently only works for SMOPT_TYPE_STRLIST.
175 var $htmlencoded=false;
177 * Controls folder list limits in SMOPT_TYPE_FLDRLIST and
178 * SMOPT_TYPE_FLDRLIST_MULTI widgets.
179 * See $flag argument in sqimap_mailbox_option_list() function.
183 var $folder_filter='noselect';
186 * Constructor function
187 * @param string $name
188 * @param string $caption
189 * @param integer $type
190 * @param integer $refresh_level
191 * @param mixed $initial_value
192 * @param array $possible_values
193 * @param bool $htmlencoded
195 function SquirrelOption
196 ($name, $caption, $type, $refresh_level, $initial_value = '', $possible_values = '', $htmlencoded = false) {
197 /* Set the basic stuff. */
199 $this->caption
= $caption;
201 $this->refresh_level
= $refresh_level;
202 $this->possible_values
= $possible_values;
203 $this->htmlencoded
= $htmlencoded;
204 $this->size
= SMOPT_SIZE_MEDIUM
;
205 $this->trailing_text
= '';
206 $this->yes_text
= '';
209 $this->layout_type
= 0;
210 $this->aExtraAttribs
= array();
211 $this->post_script
= '';
213 //Check for a current value.
214 if (isset($GLOBALS[$name])) {
215 $this->value
= $GLOBALS[$name];
216 } else if (!empty($initial_value)) {
217 $this->value
= $initial_value;
222 /* Check for a new value. */
223 if ( !sqgetGlobalVar("new_$name", $this->new_value
, SQ_POST
) ) {
224 $this->new_value
= NULL;
227 /* Set the default save function. */
228 if (($type != SMOPT_TYPE_HIDDEN
) && ($type != SMOPT_TYPE_COMMENT
)) {
229 $this->save_function
= SMOPT_SAVE_DEFAULT
;
231 $this->save_function
= SMOPT_SAVE_NOOP
;
235 /** Convenience function that identifies which types of
236 widgets are stored as (serialized) array values. */
237 function is_multiple_valued() {
238 return ($this->type
== SMOPT_TYPE_FLDRLIST_MULTI
239 ||
$this->type
== SMOPT_TYPE_STRLIST_MULTI
240 ||
$this->type
== SMOPT_TYPE_EDIT_LIST
);
244 * Set the value for this option.
245 * @param mixed $value
247 function setValue($value) {
248 $this->value
= $value;
252 * Set the new value for this option.
253 * @param mixed $new_value
255 function setNewValue($new_value) {
256 $this->new_value
= $new_value;
260 * Set the size for this option.
261 * @param integer $size
263 function setSize($size) {
268 * Set the trailing_text for this option.
269 * @param string $trailing_text
271 function setTrailingText($trailing_text) {
272 $this->trailing_text
= $trailing_text;
276 * Set the yes_text for this option.
277 * @param string $yes_text
279 function setYesText($yes_text) {
280 $this->yes_text
= $yes_text;
284 * Set the no_text for this option.
285 * @param string $no_text
287 function setNoText($no_text) {
288 $this->no_text
= $no_text;
292 * Set the layout type for this option.
293 * @param int $layout_type
295 function setLayoutType($layout_type) {
296 $this->layout_type
= $layout_type;
300 * Set the comment for this option.
301 * @param string $comment
303 function setComment($comment) {
304 $this->comment
= $comment;
308 * Set the extra attributes for this option.
309 * @param array $aExtraAttribs
311 function setExtraAttributes($aExtraAttribs) {
312 $this->aExtraAttribs
= $aExtraAttribs;
316 * Set the "post script" for this option.
317 * @param string $post_script
319 function setPostScript($post_script) {
320 $this->post_script
= $post_script;
324 * Set the save function for this option.
325 * @param string $save_function
327 function setSaveFunction($save_function) {
328 $this->save_function
= $save_function;
332 * Set the folder_filter for this option.
333 * @param string $folder_filter
336 function setFolderFilter($folder_filter) {
337 $this->folder_filter
= $folder_filter;
341 * Creates fields on option pages according to option type
343 * This is the function that calls all other createWidget* functions.
345 * @return string The formated option field
348 function createWidget() {
351 // Use new value if available
352 if (!is_null($this->new_value
)) {
353 $tempValue = $this->value
;
354 $this->value
= $this->new_value
;
357 /* Get the widget for this option type. */
358 switch ($this->type
) {
359 case SMOPT_TYPE_STRING
:
360 $result = $this->createWidget_String();
362 case SMOPT_TYPE_STRLIST
:
363 $result = $this->createWidget_StrList();
365 case SMOPT_TYPE_TEXTAREA
:
366 $result = $this->createWidget_TextArea();
368 case SMOPT_TYPE_INTEGER
:
369 $result = $this->createWidget_Integer();
371 case SMOPT_TYPE_FLOAT
:
372 $result = $this->createWidget_Float();
374 case SMOPT_TYPE_BOOLEAN
:
375 $result = $this->createWidget_Boolean();
377 case SMOPT_TYPE_BOOLEAN_CHECKBOX
:
378 $result = $this->createWidget_Boolean(TRUE);
380 case SMOPT_TYPE_BOOLEAN_RADIO
:
381 $result = $this->createWidget_Boolean(FALSE);
383 case SMOPT_TYPE_HIDDEN
:
384 $result = $this->createWidget_Hidden();
386 case SMOPT_TYPE_COMMENT
:
387 $result = $this->createWidget_Comment();
389 case SMOPT_TYPE_FLDRLIST
:
390 $result = $this->createWidget_FolderList();
392 case SMOPT_TYPE_FLDRLIST_MULTI
:
393 $result = $this->createWidget_FolderList(TRUE);
395 case SMOPT_TYPE_EDIT_LIST
:
396 $result = $this->createWidget_EditList();
398 case SMOPT_TYPE_STRLIST_MULTI
:
399 $result = $this->createWidget_StrList(TRUE);
401 case SMOPT_TYPE_STRLIST_RADIO
:
402 $result = $this->createWidget_StrList(FALSE, TRUE);
406 sprintf(_("Option Type '%s' Not Found"), $this->type
)
410 /* Add the "post script" for this option. */
411 $result .= $this->post_script
;
413 // put correct value back if need be
414 if (!is_null($this->new_value
)) {
415 $this->value
= $tempValue;
418 /* Now, return the created widget. */
423 * Create string field
424 * @return string html formated option field
426 function createWidget_String() {
427 switch ($this->size
) {
428 case SMOPT_SIZE_TINY
:
431 case SMOPT_SIZE_SMALL
:
434 case SMOPT_SIZE_LARGE
:
437 case SMOPT_SIZE_HUGE
:
440 case SMOPT_SIZE_NORMAL
:
445 return addInput('new_' . $this->name
, $this->value
, $width, 0, $this->aExtraAttribs
) . htmlspecialchars($this->trailing_text
);
449 * Create selection box or radio button group
451 * When $this->htmlencoded is TRUE, the keys and values in
452 * $this->possible_values are assumed to be display-safe.
455 * Note that when building radio buttons instead of a select
456 * widget, if the "size" attribute is SMOPT_SIZE_TINY, the
457 * radio buttons will be output one after another without
458 * linebreaks between them. Otherwise, each radio button
459 * goes on a line of its own.
461 * @param boolean $multiple_select When TRUE, the select widget
462 * will allow multiple selections
463 * (OPTIONAL; default is FALSE
464 * (single select list))
465 * @param boolean $radio_buttons When TRUE, the widget will
466 * instead be built as a group
467 * of radio buttons (and
468 * $multiple_select will be
469 * forced to FALSE) (OPTIONAL;
470 * default is FALSE (select widget))
472 * @return string html formated selection box or radio buttons
475 function createWidget_StrList($multiple_select=FALSE, $radio_buttons=FALSE) {
476 //FIXME: Currently, $this->htmlencoded is ignored here -- was removed when changing to template-based output; a fix is available as part of proposed centralized sanitizing patch
478 // radio buttons instead of select widget?
480 if ($radio_buttons) {
484 foreach ($this->possible_values
as $real_value => $disp_value) {
485 $result .= addRadioBox('new_' . $this->name
, ($this->value
== $real_value), $real_value, array_merge(array('id' => 'new_' . $this->name
. '_' . $real_value), $this->aExtraAttribs
)) . $nbsp . create_label($disp_value, 'new_' . $this->name
. '_' . $real_value);
486 if ($this->size
!= SMOPT_SIZE_TINY
)
494 // everything below applies to select widgets
496 switch ($this->size
) {
497 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
498 case SMOPT_SIZE_TINY
:
501 case SMOPT_SIZE_SMALL
:
504 case SMOPT_SIZE_LARGE
:
507 case SMOPT_SIZE_HUGE
:
510 case SMOPT_SIZE_NORMAL
:
515 return addSelect('new_' . $this->name
, $this->possible_values
, $this->value
, TRUE, $this->aExtraAttribs
, $multiple_select, $height, !$this->htmlencoded
) . htmlspecialchars($this->trailing_text
);
520 * Create folder selection box
522 * @param boolean $multiple_select When TRUE, the select widget
523 * will allow multiple selections
524 * (OPTIONAL; default is FALSE
525 * (single select list))
527 * @return string html formated selection box
530 function createWidget_FolderList($multiple_select=FALSE) {
532 switch ($this->size
) {
533 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
534 case SMOPT_SIZE_TINY
:
537 case SMOPT_SIZE_SMALL
:
540 case SMOPT_SIZE_LARGE
:
543 case SMOPT_SIZE_HUGE
:
546 case SMOPT_SIZE_NORMAL
:
551 // possible values might include a nested array of
552 // possible values (list of folders)
554 $option_list = array();
555 foreach ($this->possible_values
as $value => $text) {
557 // list of folders (boxes array)
559 if (is_array($text)) {
560 $option_list = array_merge($option_list, sqimap_mailbox_option_array(0, 0, $text, $this->folder_filter
));
562 // just one option here
565 $option_list = array_merge($option_list, array($value => $text));
569 if (empty($option_list))
570 $option_list = array('ignore' => _("unavailable"));
573 return addSelect('new_' . $this->name
, $option_list, $this->value
, TRUE, $this->aExtraAttribs
, $multiple_select, $height) . htmlspecialchars($this->trailing_text
);
579 * @return string html formated textarea field
581 function createWidget_TextArea() {
582 switch ($this->size
) {
583 case SMOPT_SIZE_TINY
: $rows = 3; $cols = 10; break;
584 case SMOPT_SIZE_SMALL
: $rows = 4; $cols = 30; break;
585 case SMOPT_SIZE_LARGE
: $rows = 10; $cols = 60; break;
586 case SMOPT_SIZE_HUGE
: $rows = 20; $cols = 80; break;
587 case SMOPT_SIZE_NORMAL
:
588 default: $rows = 5; $cols = 50;
590 return addTextArea('new_' . $this->name
, $this->value
, $cols, $rows, $this->aExtraAttribs
);
594 * Creates field for integer
596 * Difference from createWidget_String is visible only when javascript is enabled
597 * @return string html formated option field
599 function createWidget_Integer() {
601 // add onChange javascript handler to a regular string widget
602 // which will strip out all non-numeric chars
603 if (checkForJavascript())
604 $this->aExtraAttribs
['onchange'] = 'origVal=this.value; newVal=\'\'; '
605 . 'for (i=0;i<origVal.length;i++) { if (origVal.charAt(i)>=\'0\' '
606 . '&& origVal.charAt(i)<=\'9\') newVal += origVal.charAt(i); } '
607 . 'this.value=newVal;';
609 return $this->createWidget_String();
613 * Creates field for floating number
614 * Difference from createWidget_String is visible only when javascript is enabled
615 * @return string html formated option field
617 function createWidget_Float() {
619 // add onChange javascript handler to a regular string widget
620 // which will strip out all non-numeric (period also OK) chars
621 if (checkForJavascript())
622 $this->aExtraAttribs
['onchange'] = 'origVal=this.value; newVal=\'\'; '
623 . 'for (i=0;i<origVal.length;i++) { if ((origVal.charAt(i)>=\'0\' '
624 . '&& origVal.charAt(i)<=\'9\') || origVal.charAt(i)==\'.\') '
625 . 'newVal += origVal.charAt(i); } this.value=newVal;';
627 return $this->createWidget_String();
631 * Create boolean widget
633 * When creating Yes/No radio buttons, the "yes_text"
634 * and "no_text" option attributes are used to override
635 * the typical "Yes" and "No" text.
637 * @param boolean $checkbox When TRUE, the widget will be
638 * constructed as a checkbox,
639 * otherwise it will be a set of
640 * Yes/No radio buttons (OPTIONAL;
641 * default is TRUE (checkbox)).
643 * @return string html formated boolean widget
646 function createWidget_Boolean($checkbox=TRUE) {
648 global $oTemplate, $nbsp;
654 $result = addCheckbox('new_' . $this->name
, ($this->value
!= SMPREF_NO
), SMPREF_YES
, array_merge(array('id' => 'new_' . $this->name
), $this->aExtraAttribs
)) . $nbsp . create_label($this->trailing_text
, 'new_' . $this->name
);
661 /* Build the yes choice. */
662 $yes_option = addRadioBox('new_' . $this->name
, ($this->value
!= SMPREF_NO
), SMPREF_YES
, array_merge(array('id' => 'new_' . $this->name
. '_yes'), $this->aExtraAttribs
)) . $nbsp . create_label((!empty($this->yes_text
) ?
$this->yes_text
: _("Yes")), 'new_' . $this->name
. '_yes');
664 /* Build the no choice. */
665 $no_option = addRadioBox('new_' . $this->name
, ($this->value
== SMPREF_NO
), SMPREF_NO
, array_merge(array('id' => 'new_' . $this->name
. '_no'), $this->aExtraAttribs
)) . $nbsp . create_label((!empty($this->no_text
) ?
$this->no_text
: _("No")), 'new_' . $this->name
. '_no');
667 /* Build the combined "boolean widget". */
668 $result = "$yes_option$nbsp$nbsp$nbsp$nbsp$no_option";
676 * Creates hidden field
677 * @return string html formated hidden input field
679 function createWidget_Hidden() {
680 return addHidden('new_' . $this->name
, $this->value
, $this->aExtraAttribs
);
685 * @return string comment
687 function createWidget_Comment() {
688 $result = $this->comment
;
693 * Creates an edit list
695 * Note that multiple layout types are supported for this widget.
696 * $this->layout_type must be one of the SMOPT_EDIT_LIST_LAYOUT_*
699 * @return string html formated list of edit fields and
700 * their associated controls
702 function createWidget_EditList() {
706 switch ($this->size
) {
707 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
708 case SMOPT_SIZE_TINY
:
711 case SMOPT_SIZE_SMALL
:
714 case SMOPT_SIZE_LARGE
:
717 case SMOPT_SIZE_HUGE
:
720 case SMOPT_SIZE_NORMAL
:
725 if (empty($this->possible_values
)) $this->possible_values
= array();
726 if (!is_array($this->possible_values
)) $this->possible_values
= array($this->possible_values
);
728 //FIXME: $this->aExtraAttribs probably should only be used in one place
729 $oTemplate->assign('input_widget', addInput('add_' . $this->name
, '', 38, 0, $this->aExtraAttribs
));
730 $oTemplate->assign('trailing_text', $this->trailing_text
);
731 $oTemplate->assign('possible_values', $this->possible_values
);
732 $oTemplate->assign('select_widget', addSelect('new_' . $this->name
, $this->possible_values
, $this->value
, FALSE, !checkForJavascript() ?
$this->aExtraAttribs
: array_merge(array('onchange' => 'if (typeof(window.addinput_' . $this->name
. ') == \'undefined\') { var f = document.forms.length; var i = 0; var pos = -1; while( pos == -1 && i < f ) { var e = document.forms[i].elements.length; var j = 0; while( pos == -1 && j < e ) { if ( document.forms[i].elements[j].type == \'text\' && document.forms[i].elements[j].name == \'add_' . $this->name
. '\' ) { pos = j; } j++; } i++; } if( pos >= 0 ) { window.addinput_' . $this->name
. ' = document.forms[i-1].elements[pos]; } } for (x = 0; x < this.length; x++) { if (this.options[x].selected) { window.addinput_' . $this->name
. '.value = this.options[x].value; break; } }'), $this->aExtraAttribs
), TRUE, $height));
733 $oTemplate->assign('checkbox_widget', addCheckBox('delete_' . $this->name
, FALSE, SMPREF_YES
, array_merge(array('id' => 'delete_' . $this->name
), $this->aExtraAttribs
)));
734 $oTemplate->assign('name', $this->name
);
736 switch ($this->layout_type
) {
737 case SMOPT_EDIT_LIST_LAYOUT_SELECT
:
738 return $oTemplate->fetch('edit_list_widget.tpl');
739 case SMOPT_EDIT_LIST_LAYOUT_LIST
:
740 return $oTemplate->fetch('edit_list_widget_list_style.tpl');
742 error_box(sprintf(_("Edit List Layout Type '%s' Not Found"), $layout_type));
751 $function = $this->save_function
;
760 // edit lists have a lot going on, so we'll always process them
762 if ($this->type
== SMOPT_TYPE_EDIT_LIST
) return TRUE;
764 return ($this->value
!= $this->new_value
);
766 } /* End of SquirrelOption class*/
769 * Saves the option value (this is the default save function
770 * unless overridden by the user)
772 * @param object $option object that holds option name and new_value
774 function save_option($option) {
776 // Can't save the pref if we don't have the username
778 if ( !sqgetGlobalVar('username', $username, SQ_SESSION
) ) {
784 // edit lists: first add new elements to list, then
785 // remove any selected ones (note that we must add
786 // before deleting because the javascript that populates
787 // the "add" textbox when selecting items in the list
790 if ($option->type
== SMOPT_TYPE_EDIT_LIST
) {
792 if (empty($option->possible_values
)) $option->possible_values
= array();
793 if (!is_array($option->possible_values
)) $option->possible_values
= array($option->possible_values
);
795 // add element if given
797 if (sqGetGlobalVar('add_' . $option->name
, $new_element, SQ_POST
)) {
798 $new_element = trim($new_element);
799 if (!empty($new_element)
800 && !in_array($new_element, $option->possible_values
))
801 $option->possible_values
[] = $new_element;
804 // delete selected elements if needed
806 if (is_array($option->new_value
)
807 && sqGetGlobalVar('delete_' . $option->name
, $ignore, SQ_POST
))
808 $option->possible_values
= array_diff($option->possible_values
, $option->new_value
);
810 // save full list (stored in "possible_values")
812 setPref($data_dir, $username, $option->name
, serialize($option->possible_values
));
814 // Certain option types need to be serialized because
815 // they are not scalar
817 } else if ($option->is_multiple_valued())
818 setPref($data_dir, $username, $option->name
, serialize($option->new_value
));
820 // Checkboxes, when unchecked, don't submit anything in
821 // the POST, so set to SMPREF_OFF if not found
823 else if (($option->type
== SMOPT_TYPE_BOOLEAN
824 ||
$option->type
== SMOPT_TYPE_BOOLEAN_CHECKBOX
)
825 && empty($option->new_value
))
826 setPref($data_dir, $username, $option->name
, SMPREF_OFF
);
829 setPref($data_dir, $username, $option->name
, $option->new_value
);
832 // if a checkbox or multi select is zeroed/cleared out, it
833 // needs to have an empty value pushed into its "new_value" slot
835 if (($option->type
== SMOPT_TYPE_STRLIST_MULTI
836 ||
$option->type
== SMOPT_TYPE_BOOLEAN_CHECKBOX
)
837 && is_null($option->new_value
))
838 $option->new_value
= '';
843 * save function that does not save
844 * @param object $option
846 function save_option_noop($option) {
847 /* Do nothing here... */
851 * Create hidden 'optpage' input field with value set by argument
852 * @param string $optpage identification of option page
853 * @return string html formated hidden input field
855 function create_optpage_element($optpage) {
856 return addHidden('optpage', $optpage);
860 * Create hidden 'optmode' input field with value set by argument
861 * @param string $optmode
862 * @return string html formated hidden input field
864 function create_optmode_element($optmode) {
865 return addHidden('optmode', $optmode);
869 * @param array $optgrps
870 * @param array $optvals
873 function create_option_groups($optgrps, $optvals) {
874 /* Build a simple array with which to start. */
877 /* Create option group for each option group name. */
878 foreach ($optgrps as $grpkey => $grpname) {
879 $result[$grpkey] = array();
880 $result[$grpkey]['name'] = $grpname;
881 $result[$grpkey]['options'] = array();
884 /* Create a new SquirrelOption for each set of option values. */
885 foreach ($optvals as $grpkey => $grpopts) {
886 foreach ($grpopts as $optset) {
887 /* Create a new option with all values given. */
888 $next_option = new SquirrelOption(
892 (isset($optset['refresh']) ?
$optset['refresh'] : SMOPT_REFRESH_NONE
),
893 (isset($optset['initial_value']) ?
$optset['initial_value'] : ''),
894 (isset($optset['posvals']) ?
$optset['posvals'] : ''),
895 (isset($optset['htmlencoded']) ?
$optset['htmlencoded'] : false)
898 /* If provided, set the size for this option. */
899 if (isset($optset['size'])) {
900 $next_option->setSize($optset['size']);
903 /* If provided, set the trailing_text for this option. */
904 if (isset($optset['trailing_text'])) {
905 $next_option->setTrailingText($optset['trailing_text']);
908 /* If provided, set the yes_text for this option. */
909 if (isset($optset['yes_text'])) {
910 $next_option->setYesText($optset['yes_text']);
913 /* If provided, set the no_text for this option. */
914 if (isset($optset['no_text'])) {
915 $next_option->setNoText($optset['no_text']);
918 /* If provided, set the layout type for this option. */
919 if (isset($optset['layout_type'])) {
920 $next_option->setLayoutType($optset['layout_type']);
923 /* If provided, set the comment for this option. */
924 if (isset($optset['comment'])) {
925 $next_option->setComment($optset['comment']);
928 /* If provided, set the save function for this option. */
929 if (isset($optset['save'])) {
930 $next_option->setSaveFunction($optset['save']);
933 /* If provided, set the extra attributes for this option. */
934 if (isset($optset['extra_attributes'])) {
935 $next_option->setExtraAttributes($optset['extra_attributes']);
938 /* If provided, set the "post script" for this option. */
939 if (isset($optset['post_script'])) {
940 $next_option->setPostScript($optset['post_script']);
943 /* If provided, set the folder_filter for this option. */
944 if (isset($optset['folder_filter'])) {
945 $next_option->setFolderFilter($optset['folder_filter']);
948 /* Add this option to the option array. */
949 $result[$grpkey]['options'][] = $next_option;
953 /* Return our resulting array. */