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 original option configuration array
67 var $raw_option_array;
69 * The name of this setting
74 * The text that prefaces setting on the preferences page
79 * The type of INPUT element
81 * See SMOPT_TYPE_* defines
86 * Indicates if a link should be shown to refresh part
87 * or all of the window
89 * See SMOPT_REFRESH_* defines
94 * Specifies the size of certain input items
96 * See SMOPT_SIZE_* defines
101 * Text that follows a text input or
102 * select list input on the preferences page
104 * useful for indicating units, meanings of special values, etc.
109 * Text that overrides the "Yes" label for boolean
110 * radio option widgets
116 * Text that overrides the "No" label for boolean
117 * radio option widgets
123 * Some widgets support more than one layout type
129 * text displayed to the user
131 * Used with SMOPT_TYPE_COMMENT options
136 * additional javascript or other widget attributes added to the
137 * user input; must be an array where keys are attribute names
138 * ("onclick", etc) and values are the attribute values.
143 * script (usually Javascript) that will be placed after (outside of)
150 * The name of the Save Function for this option.
155 /* The various 'values' for this options. */
157 * default/preselected value for this option
167 * associative array, where each key is an actual input value
168 * and the corresponding value is what is displayed to the user
169 * for that list item in the drop-down list
172 var $possible_values;
174 * disables html sanitizing.
176 * WARNING - don't use it, if user input is possible in option
177 * or use own sanitizing functions. Currently only works for SMOPT_TYPE_STRLIST.
180 var $htmlencoded=false;
182 * Controls folder list limits in SMOPT_TYPE_FLDRLIST and
183 * SMOPT_TYPE_FLDRLIST_MULTI widgets.
184 * See $flag argument in sqimap_mailbox_option_list() function.
188 var $folder_filter='noselect';
191 * Constructor function
192 * @param array $raw_option_array
193 * @param string $name
194 * @param string $caption
195 * @param integer $type
196 * @param integer $refresh_level
197 * @param mixed $initial_value
198 * @param array $possible_values
199 * @param bool $htmlencoded
201 function SquirrelOption
202 ($raw_option_array, $name, $caption, $type, $refresh_level, $initial_value = '', $possible_values = '', $htmlencoded = false) {
203 /* Set the basic stuff. */
204 $this->raw_option_array
= $raw_option_array;
206 $this->caption
= $caption;
208 $this->refresh_level
= $refresh_level;
209 $this->possible_values
= $possible_values;
210 $this->htmlencoded
= $htmlencoded;
211 $this->size
= SMOPT_SIZE_NORMAL
;
212 $this->trailing_text
= '';
213 $this->yes_text
= '';
216 $this->layout_type
= 0;
217 $this->aExtraAttribs
= array();
218 $this->post_script
= '';
220 //Check for a current value.
221 if (isset($GLOBALS[$name])) {
222 $this->value
= $GLOBALS[$name];
223 } else if (!empty($initial_value)) {
224 $this->value
= $initial_value;
229 /* Check for a new value. */
230 if ( !sqgetGlobalVar("new_$name", $this->new_value
, SQ_POST
) ) {
231 $this->new_value
= NULL;
234 /* Set the default save function. */
235 if (($type != SMOPT_TYPE_HIDDEN
) && ($type != SMOPT_TYPE_COMMENT
)) {
236 $this->save_function
= SMOPT_SAVE_DEFAULT
;
238 $this->save_function
= SMOPT_SAVE_NOOP
;
242 /** Convenience function that identifies which types of
243 widgets are stored as (serialized) array values. */
244 function is_multiple_valued() {
245 return ($this->type
== SMOPT_TYPE_FLDRLIST_MULTI
246 ||
$this->type
== SMOPT_TYPE_STRLIST_MULTI
247 ||
$this->type
== SMOPT_TYPE_EDIT_LIST
);
251 * Set the value for this option.
252 * @param mixed $value
254 function setValue($value) {
255 $this->value
= $value;
259 * Set the new value for this option.
260 * @param mixed $new_value
262 function setNewValue($new_value) {
263 $this->new_value
= $new_value;
267 * Set the size for this option.
268 * @param integer $size
270 function setSize($size) {
275 * Set the trailing_text for this option.
276 * @param string $trailing_text
278 function setTrailingText($trailing_text) {
279 $this->trailing_text
= $trailing_text;
283 * Set the yes_text for this option.
284 * @param string $yes_text
286 function setYesText($yes_text) {
287 $this->yes_text
= $yes_text;
291 * Set the no_text for this option.
292 * @param string $no_text
294 function setNoText($no_text) {
295 $this->no_text
= $no_text;
299 * Set the layout type for this option.
300 * @param int $layout_type
302 function setLayoutType($layout_type) {
303 $this->layout_type
= $layout_type;
307 * Set the comment for this option.
308 * @param string $comment
310 function setComment($comment) {
311 $this->comment
= $comment;
315 * Set the extra attributes for this option.
316 * @param array $aExtraAttribs
318 function setExtraAttributes($aExtraAttribs) {
319 $this->aExtraAttribs
= $aExtraAttribs;
323 * Set the "post script" for this option.
324 * @param string $post_script
326 function setPostScript($post_script) {
327 $this->post_script
= $post_script;
331 * Set the save function for this option.
332 * @param string $save_function
334 function setSaveFunction($save_function) {
335 $this->save_function
= $save_function;
339 * Set the folder_filter for this option.
340 * @param string $folder_filter
343 function setFolderFilter($folder_filter) {
344 $this->folder_filter
= $folder_filter;
348 * Creates fields on option pages according to option type
350 * This is the function that calls all other createWidget* functions.
352 * @return string The formated option field
355 function createWidget() {
358 // Use new value if available
359 if (!is_null($this->new_value
)) {
360 $tempValue = $this->value
;
361 $this->value
= $this->new_value
;
364 /* Get the widget for this option type. */
365 switch ($this->type
) {
366 case SMOPT_TYPE_STRING
:
367 $result = $this->createWidget_String();
369 case SMOPT_TYPE_STRLIST
:
370 $result = $this->createWidget_StrList();
372 case SMOPT_TYPE_TEXTAREA
:
373 $result = $this->createWidget_TextArea();
375 case SMOPT_TYPE_INTEGER
:
376 $result = $this->createWidget_Integer();
378 case SMOPT_TYPE_FLOAT
:
379 $result = $this->createWidget_Float();
381 case SMOPT_TYPE_BOOLEAN
:
382 $result = $this->createWidget_Boolean();
384 case SMOPT_TYPE_BOOLEAN_CHECKBOX
:
385 $result = $this->createWidget_Boolean(TRUE);
387 case SMOPT_TYPE_BOOLEAN_RADIO
:
388 $result = $this->createWidget_Boolean(FALSE);
390 case SMOPT_TYPE_HIDDEN
:
391 $result = $this->createWidget_Hidden();
393 case SMOPT_TYPE_COMMENT
:
394 $result = $this->createWidget_Comment();
396 case SMOPT_TYPE_FLDRLIST
:
397 $result = $this->createWidget_FolderList();
399 case SMOPT_TYPE_FLDRLIST_MULTI
:
400 $result = $this->createWidget_FolderList(TRUE);
402 case SMOPT_TYPE_EDIT_LIST
:
403 $result = $this->createWidget_EditList();
405 case SMOPT_TYPE_STRLIST_MULTI
:
406 $result = $this->createWidget_StrList(TRUE);
408 case SMOPT_TYPE_STRLIST_RADIO
:
409 $result = $this->createWidget_StrList(FALSE, TRUE);
413 sprintf(_("Option Type '%s' Not Found"), $this->type
)
417 /* Add the "post script" for this option. */
418 $result .= $this->post_script
;
420 // put correct value back if need be
421 if (!is_null($this->new_value
)) {
422 $this->value
= $tempValue;
425 /* Now, return the created widget. */
430 * Create string field
431 * @return string html formated option field
433 function createWidget_String() {
434 switch ($this->size
) {
435 case SMOPT_SIZE_TINY
:
438 case SMOPT_SIZE_SMALL
:
441 case SMOPT_SIZE_LARGE
:
444 case SMOPT_SIZE_HUGE
:
447 case SMOPT_SIZE_NORMAL
:
452 return addInput('new_' . $this->name
, $this->value
, $width, 0, $this->aExtraAttribs
) . htmlspecialchars($this->trailing_text
);
456 * Create selection box or radio button group
458 * When $this->htmlencoded is TRUE, the keys and values in
459 * $this->possible_values are assumed to be display-safe.
462 * Note that when building radio buttons instead of a select
463 * widget, if the "size" attribute is SMOPT_SIZE_TINY, the
464 * radio buttons will be output one after another without
465 * linebreaks between them. Otherwise, each radio button
466 * goes on a line of its own.
468 * @param boolean $multiple_select When TRUE, the select widget
469 * will allow multiple selections
470 * (OPTIONAL; default is FALSE
471 * (single select list))
472 * @param boolean $radio_buttons When TRUE, the widget will
473 * instead be built as a group
474 * of radio buttons (and
475 * $multiple_select will be
476 * forced to FALSE) (OPTIONAL;
477 * default is FALSE (select widget))
479 * @return string html formated selection box or radio buttons
482 function createWidget_StrList($multiple_select=FALSE, $radio_buttons=FALSE) {
483 //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
485 // radio buttons instead of select widget?
487 if ($radio_buttons) {
491 foreach ($this->possible_values
as $real_value => $disp_value) {
492 $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);
493 if ($this->size
!= SMOPT_SIZE_TINY
)
501 // everything below applies to select widgets
503 switch ($this->size
) {
504 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
505 case SMOPT_SIZE_TINY
:
508 case SMOPT_SIZE_SMALL
:
511 case SMOPT_SIZE_LARGE
:
514 case SMOPT_SIZE_HUGE
:
517 case SMOPT_SIZE_NORMAL
:
522 return addSelect('new_' . $this->name
, $this->possible_values
, $this->value
, TRUE, $this->aExtraAttribs
, $multiple_select, $height, !$this->htmlencoded
) . htmlspecialchars($this->trailing_text
);
527 * Create folder selection box
529 * @param boolean $multiple_select When TRUE, the select widget
530 * will allow multiple selections
531 * (OPTIONAL; default is FALSE
532 * (single select list))
534 * @return string html formated selection box
537 function createWidget_FolderList($multiple_select=FALSE) {
539 switch ($this->size
) {
540 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
541 case SMOPT_SIZE_TINY
:
544 case SMOPT_SIZE_SMALL
:
547 case SMOPT_SIZE_LARGE
:
550 case SMOPT_SIZE_HUGE
:
553 case SMOPT_SIZE_NORMAL
:
558 // possible values might include a nested array of
559 // possible values (list of folders)
561 $option_list = array();
562 foreach ($this->possible_values
as $value => $text) {
564 // list of folders (boxes array)
566 if (is_array($text)) {
567 $option_list = array_merge($option_list, sqimap_mailbox_option_array(0, 0, $text, $this->folder_filter
));
569 // just one option here
572 $option_list = array_merge($option_list, array($value => $text));
576 if (empty($option_list))
577 $option_list = array('ignore' => _("unavailable"));
580 return addSelect('new_' . $this->name
, $option_list, $this->value
, TRUE, $this->aExtraAttribs
, $multiple_select, $height) . htmlspecialchars($this->trailing_text
);
586 * @return string html formated textarea field
588 function createWidget_TextArea() {
589 switch ($this->size
) {
590 case SMOPT_SIZE_TINY
: $rows = 3; $cols = 10; break;
591 case SMOPT_SIZE_SMALL
: $rows = 4; $cols = 30; break;
592 case SMOPT_SIZE_LARGE
: $rows = 10; $cols = 60; break;
593 case SMOPT_SIZE_HUGE
: $rows = 20; $cols = 80; break;
594 case SMOPT_SIZE_NORMAL
:
595 default: $rows = 5; $cols = 50;
597 return addTextArea('new_' . $this->name
, $this->value
, $cols, $rows, $this->aExtraAttribs
);
601 * Creates field for integer
603 * Difference from createWidget_String is visible only when javascript is enabled
604 * @return string html formated option field
606 function createWidget_Integer() {
608 // add onChange javascript handler to a regular string widget
609 // which will strip out all non-numeric chars
610 if (checkForJavascript())
611 $this->aExtraAttribs
['onchange'] = 'origVal=this.value; newVal=\'\'; '
612 . 'for (i=0;i<origVal.length;i++) { if (origVal.charAt(i)>=\'0\' '
613 . '&& origVal.charAt(i)<=\'9\') newVal += origVal.charAt(i); } '
614 . 'this.value=newVal;';
616 return $this->createWidget_String();
620 * Creates field for floating number
621 * Difference from createWidget_String is visible only when javascript is enabled
622 * @return string html formated option field
624 function createWidget_Float() {
626 // add onChange javascript handler to a regular string widget
627 // which will strip out all non-numeric (period also OK) chars
628 if (checkForJavascript())
629 $this->aExtraAttribs
['onchange'] = 'origVal=this.value; newVal=\'\'; '
630 . 'for (i=0;i<origVal.length;i++) { if ((origVal.charAt(i)>=\'0\' '
631 . '&& origVal.charAt(i)<=\'9\') || origVal.charAt(i)==\'.\') '
632 . 'newVal += origVal.charAt(i); } this.value=newVal;';
634 return $this->createWidget_String();
638 * Create boolean widget
640 * When creating Yes/No radio buttons, the "yes_text"
641 * and "no_text" option attributes are used to override
642 * the typical "Yes" and "No" text.
644 * @param boolean $checkbox When TRUE, the widget will be
645 * constructed as a checkbox,
646 * otherwise it will be a set of
647 * Yes/No radio buttons (OPTIONAL;
648 * default is TRUE (checkbox)).
650 * @return string html formated boolean widget
653 function createWidget_Boolean($checkbox=TRUE) {
655 global $oTemplate, $nbsp;
661 $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
);
668 /* Build the yes choice. */
669 $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');
671 /* Build the no choice. */
672 $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');
674 /* Build the combined "boolean widget". */
675 $result = "$yes_option$nbsp$nbsp$nbsp$nbsp$no_option";
683 * Creates hidden field
684 * @return string html formated hidden input field
686 function createWidget_Hidden() {
687 return addHidden('new_' . $this->name
, $this->value
, $this->aExtraAttribs
);
692 * @return string comment
694 function createWidget_Comment() {
695 $result = $this->comment
;
700 * Creates an edit list
702 * Note that multiple layout types are supported for this widget.
703 * $this->layout_type must be one of the SMOPT_EDIT_LIST_LAYOUT_*
706 * @return string html formated list of edit fields and
707 * their associated controls
709 function createWidget_EditList() {
713 switch ($this->size
) {
714 case SMOPT_SIZE_TINY
:
717 case SMOPT_SIZE_SMALL
:
720 case SMOPT_SIZE_MEDIUM
:
723 case SMOPT_SIZE_LARGE
:
726 case SMOPT_SIZE_HUGE
:
729 case SMOPT_SIZE_NORMAL
:
734 if (empty($this->possible_values
)) $this->possible_values
= array();
735 if (!is_array($this->possible_values
)) $this->possible_values
= array($this->possible_values
);
737 //FIXME: $this->aExtraAttribs probably should only be used in one place
738 $oTemplate->assign('input_widget', addInput('add_' . $this->name
, '', 38, 0, $this->aExtraAttribs
));
739 $oTemplate->assign('trailing_text', $this->trailing_text
);
740 $oTemplate->assign('possible_values', $this->possible_values
);
741 $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));
742 $oTemplate->assign('checkbox_widget', addCheckBox('delete_' . $this->name
, FALSE, SMPREF_YES
, array_merge(array('id' => 'delete_' . $this->name
), $this->aExtraAttribs
)));
743 $oTemplate->assign('name', $this->name
);
745 switch ($this->layout_type
) {
746 case SMOPT_EDIT_LIST_LAYOUT_SELECT
:
747 return $oTemplate->fetch('edit_list_widget.tpl');
748 case SMOPT_EDIT_LIST_LAYOUT_LIST
:
749 return $oTemplate->fetch('edit_list_widget_list_style.tpl');
751 error_box(sprintf(_("Edit List Layout Type '%s' Not Found"), $layout_type));
760 $function = $this->save_function
;
769 // edit lists have a lot going on, so we'll always process them
771 if ($this->type
== SMOPT_TYPE_EDIT_LIST
) return TRUE;
773 return ($this->value
!= $this->new_value
);
775 } /* End of SquirrelOption class*/
778 * Saves the option value (this is the default save function
779 * unless overridden by the user)
781 * @param object $option object that holds option name and new_value
783 function save_option($option) {
785 // Can't save the pref if we don't have the username
787 if ( !sqgetGlobalVar('username', $username, SQ_SESSION
) ) {
793 // edit lists: first add new elements to list, then
794 // remove any selected ones (note that we must add
795 // before deleting because the javascript that populates
796 // the "add" textbox when selecting items in the list
799 if ($option->type
== SMOPT_TYPE_EDIT_LIST
) {
801 if (empty($option->possible_values
)) $option->possible_values
= array();
802 if (!is_array($option->possible_values
)) $option->possible_values
= array($option->possible_values
);
804 // add element if given
806 if (sqGetGlobalVar('add_' . $option->name
, $new_element, SQ_POST
)) {
807 $new_element = trim($new_element);
808 if (!empty($new_element)
809 && !in_array($new_element, $option->possible_values
))
810 $option->possible_values
[] = $new_element;
813 // delete selected elements if needed
815 if (is_array($option->new_value
)
816 && sqGetGlobalVar('delete_' . $option->name
, $ignore, SQ_POST
))
817 $option->possible_values
= array_diff($option->possible_values
, $option->new_value
);
819 // save full list (stored in "possible_values")
821 setPref($data_dir, $username, $option->name
, serialize($option->possible_values
));
823 // Certain option types need to be serialized because
824 // they are not scalar
826 } else if ($option->is_multiple_valued())
827 setPref($data_dir, $username, $option->name
, serialize($option->new_value
));
829 // Checkboxes, when unchecked, don't submit anything in
830 // the POST, so set to SMPREF_OFF if not found
832 else if (($option->type
== SMOPT_TYPE_BOOLEAN
833 ||
$option->type
== SMOPT_TYPE_BOOLEAN_CHECKBOX
)
834 && empty($option->new_value
))
835 setPref($data_dir, $username, $option->name
, SMPREF_OFF
);
838 setPref($data_dir, $username, $option->name
, $option->new_value
);
841 // if a checkbox or multi select is zeroed/cleared out, it
842 // needs to have an empty value pushed into its "new_value" slot
844 if (($option->type
== SMOPT_TYPE_STRLIST_MULTI
845 ||
$option->type
== SMOPT_TYPE_BOOLEAN_CHECKBOX
)
846 && is_null($option->new_value
))
847 $option->new_value
= '';
852 * save function that does not save
853 * @param object $option
855 function save_option_noop($option) {
856 /* Do nothing here... */
860 * Create hidden 'optpage' input field with value set by argument
861 * @param string $optpage identification of option page
862 * @return string html formated hidden input field
864 function create_optpage_element($optpage) {
865 return addHidden('optpage', $optpage);
869 * Create hidden 'optmode' input field with value set by argument
870 * @param string $optmode
871 * @return string html formated hidden input field
873 function create_optmode_element($optmode) {
874 return addHidden('optmode', $optmode);
878 * @param array $optgrps
879 * @param array $optvals
882 function create_option_groups($optgrps, $optvals) {
883 /* Build a simple array with which to start. */
886 /* Create option group for each option group name. */
887 foreach ($optgrps as $grpkey => $grpname) {
888 $result[$grpkey] = array();
889 $result[$grpkey]['name'] = $grpname;
890 $result[$grpkey]['options'] = array();
893 /* Create a new SquirrelOption for each set of option values. */
894 foreach ($optvals as $grpkey => $grpopts) {
895 foreach ($grpopts as $optset) {
896 /* Create a new option with all values given. */
897 $next_option = new SquirrelOption(
902 (isset($optset['refresh']) ?
$optset['refresh'] : SMOPT_REFRESH_NONE
),
903 (isset($optset['initial_value']) ?
$optset['initial_value'] : ''),
904 (isset($optset['posvals']) ?
$optset['posvals'] : ''),
905 (isset($optset['htmlencoded']) ?
$optset['htmlencoded'] : false)
908 /* If provided, set the size for this option. */
909 if (isset($optset['size'])) {
910 $next_option->setSize($optset['size']);
913 /* If provided, set the trailing_text for this option. */
914 if (isset($optset['trailing_text'])) {
915 $next_option->setTrailingText($optset['trailing_text']);
918 /* If provided, set the yes_text for this option. */
919 if (isset($optset['yes_text'])) {
920 $next_option->setYesText($optset['yes_text']);
923 /* If provided, set the no_text for this option. */
924 if (isset($optset['no_text'])) {
925 $next_option->setNoText($optset['no_text']);
928 /* If provided, set the layout type for this option. */
929 if (isset($optset['layout_type'])) {
930 $next_option->setLayoutType($optset['layout_type']);
933 /* If provided, set the comment for this option. */
934 if (isset($optset['comment'])) {
935 $next_option->setComment($optset['comment']);
938 /* If provided, set the save function for this option. */
939 if (isset($optset['save'])) {
940 $next_option->setSaveFunction($optset['save']);
943 /* If provided, set the extra attributes for this option. */
944 if (isset($optset['extra_attributes'])) {
945 $next_option->setExtraAttributes($optset['extra_attributes']);
948 /* If provided, set the "post script" for this option. */
949 if (isset($optset['post_script'])) {
950 $next_option->setPostScript($optset['post_script']);
953 /* If provided, set the folder_filter for this option. */
954 if (isset($optset['folder_filter'])) {
955 $next_option->setFolderFilter($optset['folder_filter']);
958 /* Add this option to the option array. */
959 $result[$grpkey]['options'][] = $next_option;
963 /* Return our resulting array. */