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
16 * SquirrelOption: An option for SquirrelMail.
18 * @package squirrelmail
21 class SquirrelOption
{
23 * The original option configuration array
26 var $raw_option_array;
28 * The name of this setting
33 * The text that prefaces setting on the preferences page
38 * The type of INPUT element
40 * See SMOPT_TYPE_* defines
45 * Indicates if a link should be shown to refresh part
46 * or all of the window
48 * See SMOPT_REFRESH_* defines
53 * Specifies the size of certain input items
55 * See SMOPT_SIZE_* defines
60 * Text that follows a text input or
61 * select list input on the preferences page
63 * useful for indicating units, meanings of special values, etc.
68 * Text that overrides the "Yes" label for boolean
69 * radio option widgets
75 * Text that overrides the "No" label for boolean
76 * radio option widgets
82 * Some widgets support more than one layout type
88 * Indicates if the Add widget should be included
95 * Indicates if the Delete widget should be included
100 var $use_delete_widget;
102 * text displayed to the user
104 * Used with SMOPT_TYPE_COMMENT options
109 * additional javascript or other widget attributes added to the
110 * user input; must be an array where keys are attribute names
111 * ("onclick", etc) and values are the attribute values.
116 * script (usually Javascript) that will be placed after (outside of)
123 * The name of the Save Function for this option.
128 /* The various 'values' for this options. */
130 * default/preselected value for this option
140 * associative array, where each key is an actual input value
141 * and the corresponding value is what is displayed to the user
142 * for that list item in the drop-down list
145 var $possible_values;
147 * disables html sanitizing.
149 * WARNING - don't use it, if user input is possible in option
150 * or use own sanitizing functions. Currently only works for SMOPT_TYPE_STRLIST.
153 var $htmlencoded=false;
155 * Controls folder list limits in SMOPT_TYPE_FLDRLIST and
156 * SMOPT_TYPE_FLDRLIST_MULTI widgets.
157 * See $flag argument in sqimap_mailbox_option_list() function.
161 var $folder_filter='noselect';
164 * Constructor function
165 * @param array $raw_option_array
166 * @param string $name
167 * @param string $caption
168 * @param integer $type
169 * @param integer $refresh_level
170 * @param mixed $initial_value
171 * @param array $possible_values
172 * @param bool $htmlencoded
174 function SquirrelOption
175 ($raw_option_array, $name, $caption, $type, $refresh_level, $initial_value = '', $possible_values = '', $htmlencoded = false) {
176 /* Set the basic stuff. */
177 $this->raw_option_array
= $raw_option_array;
179 $this->caption
= $caption;
181 $this->refresh_level
= $refresh_level;
182 $this->possible_values
= $possible_values;
183 $this->htmlencoded
= $htmlencoded;
184 $this->size
= SMOPT_SIZE_NORMAL
;
185 $this->trailing_text
= '';
186 $this->yes_text
= '';
189 $this->layout_type
= 0;
190 $this->use_add_widget
= TRUE;
191 $this->use_delete_widget
= TRUE;
192 $this->aExtraAttribs
= array();
193 $this->post_script
= '';
195 //Check for a current value.
196 if (isset($GLOBALS[$name])) {
197 $this->value
= $GLOBALS[$name];
198 } else if (!empty($initial_value)) {
199 $this->value
= $initial_value;
204 /* Check for a new value. */
205 if ( !sqgetGlobalVar("new_$name", $this->new_value
, SQ_POST
) ) {
206 $this->new_value
= NULL;
209 /* Set the default save function. */
210 if (($type != SMOPT_TYPE_HIDDEN
) && ($type != SMOPT_TYPE_COMMENT
)) {
211 $this->save_function
= SMOPT_SAVE_DEFAULT
;
213 $this->save_function
= SMOPT_SAVE_NOOP
;
217 /** Convenience function that identifies which types of
218 widgets are stored as (serialized) array values. */
219 function is_multiple_valued() {
220 return ($this->type
== SMOPT_TYPE_FLDRLIST_MULTI
221 ||
$this->type
== SMOPT_TYPE_STRLIST_MULTI
222 ||
$this->type
== SMOPT_TYPE_EDIT_LIST
);
226 * Set the value for this option.
227 * @param mixed $value
229 function setValue($value) {
230 $this->value
= $value;
234 * Set the new value for this option.
235 * @param mixed $new_value
237 function setNewValue($new_value) {
238 $this->new_value
= $new_value;
242 * Set the size for this option.
243 * @param integer $size
245 function setSize($size) {
250 * Set the trailing_text for this option.
251 * @param string $trailing_text
253 function setTrailingText($trailing_text) {
254 $this->trailing_text
= $trailing_text;
258 * Set the yes_text for this option.
259 * @param string $yes_text
261 function setYesText($yes_text) {
262 $this->yes_text
= $yes_text;
266 * Set the no_text for this option.
267 * @param string $no_text
269 function setNoText($no_text) {
270 $this->no_text
= $no_text;
273 /* Set the "use add widget" value for this option. */
274 function setUseAddWidget($use_add_widget) {
275 $this->use_add_widget
= $use_add_widget;
278 /* Set the "use delete widget" value for this option. */
279 function setUseDeleteWidget($use_delete_widget) {
280 $this->use_delete_widget
= $use_delete_widget;
284 * Set the layout type for this option.
285 * @param int $layout_type
287 function setLayoutType($layout_type) {
288 $this->layout_type
= $layout_type;
292 * Set the comment for this option.
293 * @param string $comment
295 function setComment($comment) {
296 $this->comment
= $comment;
300 * Set the extra attributes for this option.
301 * @param array $aExtraAttribs
303 function setExtraAttributes($aExtraAttribs) {
304 $this->aExtraAttribs
= $aExtraAttribs;
308 * Set the "post script" for this option.
309 * @param string $post_script
311 function setPostScript($post_script) {
312 $this->post_script
= $post_script;
316 * Set the save function for this option.
317 * @param string $save_function
319 function setSaveFunction($save_function) {
320 $this->save_function
= $save_function;
324 * Set the folder_filter for this option.
325 * @param string $folder_filter
328 function setFolderFilter($folder_filter) {
329 $this->folder_filter
= $folder_filter;
333 * Creates fields on option pages according to option type
335 * This is the function that calls all other createWidget* functions.
337 * @return string The formated option field
340 function createWidget() {
343 // Use new value if available
344 if (!is_null($this->new_value
)) {
345 $tempValue = $this->value
;
346 $this->value
= $this->new_value
;
349 /* Get the widget for this option type. */
350 switch ($this->type
) {
351 case SMOPT_TYPE_STRING
:
352 $result = $this->createWidget_String();
354 case SMOPT_TYPE_STRLIST
:
355 $result = $this->createWidget_StrList();
357 case SMOPT_TYPE_TEXTAREA
:
358 $result = $this->createWidget_TextArea();
360 case SMOPT_TYPE_INTEGER
:
361 $result = $this->createWidget_Integer();
363 case SMOPT_TYPE_FLOAT
:
364 $result = $this->createWidget_Float();
366 case SMOPT_TYPE_BOOLEAN
:
367 $result = $this->createWidget_Boolean();
369 case SMOPT_TYPE_BOOLEAN_CHECKBOX
:
370 $result = $this->createWidget_Boolean(TRUE);
372 case SMOPT_TYPE_BOOLEAN_RADIO
:
373 $result = $this->createWidget_Boolean(FALSE);
375 case SMOPT_TYPE_HIDDEN
:
376 $result = $this->createWidget_Hidden();
378 case SMOPT_TYPE_COMMENT
:
379 $result = $this->createWidget_Comment();
381 case SMOPT_TYPE_FLDRLIST
:
382 $result = $this->createWidget_FolderList();
384 case SMOPT_TYPE_FLDRLIST_MULTI
:
385 $result = $this->createWidget_FolderList(TRUE);
387 case SMOPT_TYPE_EDIT_LIST
:
388 $result = $this->createWidget_EditList();
390 case SMOPT_TYPE_STRLIST_MULTI
:
391 $result = $this->createWidget_StrList(TRUE);
393 case SMOPT_TYPE_STRLIST_RADIO
:
394 $result = $this->createWidget_StrList(FALSE, TRUE);
396 case SMOPT_TYPE_SUBMIT
:
397 $result = $this->createWidget_Submit();
401 sprintf(_("Option Type '%s' Not Found"), $this->type
)
405 /* Add the "post script" for this option. */
406 $result .= $this->post_script
;
408 // put correct value back if need be
409 if (!is_null($this->new_value
)) {
410 $this->value
= $tempValue;
413 /* Now, return the created widget. */
418 * Create string field
419 * @return string html formated option field
421 function createWidget_String() {
422 switch ($this->size
) {
423 case SMOPT_SIZE_TINY
:
426 case SMOPT_SIZE_SMALL
:
429 case SMOPT_SIZE_LARGE
:
432 case SMOPT_SIZE_HUGE
:
435 case SMOPT_SIZE_NORMAL
:
440 return addInput('new_' . $this->name
, $this->value
, $width, 0, $this->aExtraAttribs
) . htmlspecialchars($this->trailing_text
);
444 * Create selection box or radio button group
446 * When $this->htmlencoded is TRUE, the keys and values in
447 * $this->possible_values are assumed to be display-safe.
450 * Note that when building radio buttons instead of a select
451 * widget, if the "size" attribute is SMOPT_SIZE_TINY, the
452 * radio buttons will be output one after another without
453 * linebreaks between them. Otherwise, each radio button
454 * goes on a line of its own.
456 * @param boolean $multiple_select When TRUE, the select widget
457 * will allow multiple selections
458 * (OPTIONAL; default is FALSE
459 * (single select list))
460 * @param boolean $radio_buttons When TRUE, the widget will
461 * instead be built as a group
462 * of radio buttons (and
463 * $multiple_select will be
464 * forced to FALSE) (OPTIONAL;
465 * default is FALSE (select widget))
467 * @return string html formated selection box or radio buttons
470 function createWidget_StrList($multiple_select=FALSE, $radio_buttons=FALSE) {
471 //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
473 // radio buttons instead of select widget?
475 if ($radio_buttons) {
479 foreach ($this->possible_values
as $real_value => $disp_value) {
480 $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);
481 if ($this->size
!= SMOPT_SIZE_TINY
)
489 // everything below applies to select widgets
491 switch ($this->size
) {
492 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
493 case SMOPT_SIZE_TINY
:
496 case SMOPT_SIZE_SMALL
:
499 case SMOPT_SIZE_LARGE
:
502 case SMOPT_SIZE_HUGE
:
505 case SMOPT_SIZE_NORMAL
:
510 return addSelect('new_' . $this->name
, $this->possible_values
, $this->value
, TRUE, $this->aExtraAttribs
, $multiple_select, $height, !$this->htmlencoded
) . htmlspecialchars($this->trailing_text
);
515 * Create folder selection box
517 * @param boolean $multiple_select When TRUE, the select widget
518 * will allow multiple selections
519 * (OPTIONAL; default is FALSE
520 * (single select list))
522 * @return string html formated selection box
525 function createWidget_FolderList($multiple_select=FALSE) {
527 switch ($this->size
) {
528 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
529 case SMOPT_SIZE_TINY
:
532 case SMOPT_SIZE_SMALL
:
535 case SMOPT_SIZE_LARGE
:
538 case SMOPT_SIZE_HUGE
:
541 case SMOPT_SIZE_NORMAL
:
546 // possible values might include a nested array of
547 // possible values (list of folders)
549 $option_list = array();
550 foreach ($this->possible_values
as $value => $text) {
552 // list of folders (boxes array)
554 if (is_array($text)) {
555 $option_list = array_merge($option_list, sqimap_mailbox_option_array(0, 0, $text, $this->folder_filter
));
557 // just one option here
560 $option_list = array_merge($option_list, array($value => $text));
564 if (empty($option_list))
565 $option_list = array('ignore' => _("unavailable"));
568 return addSelect('new_' . $this->name
, $option_list, $this->value
, TRUE, $this->aExtraAttribs
, $multiple_select, $height) . htmlspecialchars($this->trailing_text
);
574 * @return string html formated textarea field
576 function createWidget_TextArea() {
577 switch ($this->size
) {
578 case SMOPT_SIZE_TINY
: $rows = 3; $cols = 10; break;
579 case SMOPT_SIZE_SMALL
: $rows = 4; $cols = 30; break;
580 case SMOPT_SIZE_LARGE
: $rows = 10; $cols = 60; break;
581 case SMOPT_SIZE_HUGE
: $rows = 20; $cols = 80; break;
582 case SMOPT_SIZE_NORMAL
:
583 default: $rows = 5; $cols = 50;
585 return addTextArea('new_' . $this->name
, $this->value
, $cols, $rows, $this->aExtraAttribs
);
589 * Creates field for integer
591 * Difference from createWidget_String is visible only when javascript is enabled
592 * @return string html formated option field
594 function createWidget_Integer() {
596 // add onChange javascript handler to a regular string widget
597 // which will strip out all non-numeric chars
598 if (checkForJavascript())
599 $this->aExtraAttribs
['onchange'] = 'origVal=this.value; newVal=\'\'; '
600 . 'for (i=0;i<origVal.length;i++) { if (origVal.charAt(i)>=\'0\' '
601 . '&& origVal.charAt(i)<=\'9\') newVal += origVal.charAt(i); } '
602 . 'this.value=newVal;';
604 return $this->createWidget_String();
608 * Creates field for floating number
609 * Difference from createWidget_String is visible only when javascript is enabled
610 * @return string html formated option field
612 function createWidget_Float() {
614 // add onChange javascript handler to a regular string widget
615 // which will strip out all non-numeric (period also OK) chars
616 if (checkForJavascript())
617 $this->aExtraAttribs
['onchange'] = 'origVal=this.value; newVal=\'\'; '
618 . 'for (i=0;i<origVal.length;i++) { if ((origVal.charAt(i)>=\'0\' '
619 . '&& origVal.charAt(i)<=\'9\') || origVal.charAt(i)==\'.\') '
620 . 'newVal += origVal.charAt(i); } this.value=newVal;';
622 return $this->createWidget_String();
626 * Create boolean widget
628 * When creating Yes/No radio buttons, the "yes_text"
629 * and "no_text" option attributes are used to override
630 * the typical "Yes" and "No" text.
632 * @param boolean $checkbox When TRUE, the widget will be
633 * constructed as a checkbox,
634 * otherwise it will be a set of
635 * Yes/No radio buttons (OPTIONAL;
636 * default is TRUE (checkbox)).
638 * @return string html formated boolean widget
641 function createWidget_Boolean($checkbox=TRUE) {
643 global $oTemplate, $nbsp;
649 $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
);
656 /* Build the yes choice. */
657 $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');
659 /* Build the no choice. */
660 $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');
662 /* Build the combined "boolean widget". */
663 $result = "$yes_option$nbsp$nbsp$nbsp$nbsp$no_option";
671 * Creates hidden field
672 * @return string html formated hidden input field
674 function createWidget_Hidden() {
675 return addHidden('new_' . $this->name
, $this->value
, $this->aExtraAttribs
);
680 * @return string comment
682 function createWidget_Comment() {
683 $result = $this->comment
;
688 * Creates an edit list
690 * Note that multiple layout types are supported for this widget.
691 * $this->layout_type must be one of the SMOPT_EDIT_LIST_LAYOUT_*
694 * @return string html formated list of edit fields and
695 * their associated controls
697 function createWidget_EditList() {
701 switch ($this->size
) {
702 case SMOPT_SIZE_TINY
:
705 case SMOPT_SIZE_SMALL
:
708 case SMOPT_SIZE_MEDIUM
:
711 case SMOPT_SIZE_LARGE
:
714 case SMOPT_SIZE_HUGE
:
717 case SMOPT_SIZE_NORMAL
:
722 if (empty($this->possible_values
)) $this->possible_values
= array();
723 if (!is_array($this->possible_values
)) $this->possible_values
= array($this->possible_values
);
725 //FIXME: $this->aExtraAttribs probably should only be used in one place
726 $oTemplate->assign('input_widget', addInput('add_' . $this->name
, '', 38, 0, $this->aExtraAttribs
));
727 $oTemplate->assign('use_input_widget', $this->use_add_widget
);
728 $oTemplate->assign('use_delete_widget', $this->use_delete_widget
);
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));
748 * Creates a submit button
750 * @return string html formated submit button widget
753 function createWidget_Submit() {
755 return addSubmit($this->comment
, $this->name
, $this->aExtraAttribs
) . htmlspecialchars($this->trailing_text
);
763 $function = $this->save_function
;
772 // edit lists have a lot going on, so we'll always process them
774 if ($this->type
== SMOPT_TYPE_EDIT_LIST
) return TRUE;
776 return ($this->value
!= $this->new_value
);
778 } /* End of SquirrelOption class*/
781 * Saves the option value (this is the default save function
782 * unless overridden by the user)
784 * @param object $option object that holds option name and new_value
786 function save_option($option) {
788 // Can't save the pref if we don't have the username
790 if ( !sqgetGlobalVar('username', $username, SQ_SESSION
) ) {
796 // edit lists: first add new elements to list, then
797 // remove any selected ones (note that we must add
798 // before deleting because the javascript that populates
799 // the "add" textbox when selecting items in the list
802 if ($option->type
== SMOPT_TYPE_EDIT_LIST
) {
804 if (empty($option->possible_values
)) $option->possible_values
= array();
805 if (!is_array($option->possible_values
)) $option->possible_values
= array($option->possible_values
);
807 // add element if given
809 if ((isset($option->use_add_widget
) && $option->use_add_widget
)
810 && sqGetGlobalVar('add_' . $option->name
, $new_element, SQ_POST
)) {
811 $new_element = trim($new_element);
812 if (!empty($new_element)
813 && !in_array($new_element, $option->possible_values
))
814 $option->possible_values
[] = $new_element;
817 // delete selected elements if needed
819 if ((isset($option->use_delete_widget
) && $option->use_delete_widget
)
820 && is_array($option->new_value
)
821 && sqGetGlobalVar('delete_' . $option->name
, $ignore, SQ_POST
))
822 $option->possible_values
= array_diff($option->possible_values
, $option->new_value
);
824 // save full list (stored in "possible_values")
826 setPref($data_dir, $username, $option->name
, serialize($option->possible_values
));
828 // Certain option types need to be serialized because
829 // they are not scalar
831 } else if ($option->is_multiple_valued())
832 setPref($data_dir, $username, $option->name
, serialize($option->new_value
));
834 // Checkboxes, when unchecked, don't submit anything in
835 // the POST, so set to SMPREF_OFF if not found
837 else if (($option->type
== SMOPT_TYPE_BOOLEAN
838 ||
$option->type
== SMOPT_TYPE_BOOLEAN_CHECKBOX
)
839 && empty($option->new_value
))
840 setPref($data_dir, $username, $option->name
, SMPREF_OFF
);
843 setPref($data_dir, $username, $option->name
, $option->new_value
);
846 // if a checkbox or multi select is zeroed/cleared out, it
847 // needs to have an empty value pushed into its "new_value" slot
849 if (($option->type
== SMOPT_TYPE_STRLIST_MULTI
850 ||
$option->type
== SMOPT_TYPE_BOOLEAN_CHECKBOX
)
851 && is_null($option->new_value
))
852 $option->new_value
= '';
857 * save function that does not save
858 * @param object $option
860 function save_option_noop($option) {
861 /* Do nothing here... */
865 * Create hidden 'optpage' input field with value set by argument
866 * @param string $optpage identification of option page
867 * @return string html formated hidden input field
869 function create_optpage_element($optpage) {
870 return addHidden('optpage', $optpage);
874 * Create hidden 'optmode' input field with value set by argument
875 * @param string $optmode
876 * @return string html formated hidden input field
878 function create_optmode_element($optmode) {
879 return addHidden('optmode', $optmode);
883 * @param array $optgrps
884 * @param array $optvals
887 function create_option_groups($optgrps, $optvals) {
888 /* Build a simple array with which to start. */
891 /* Create option group for each option group name. */
892 foreach ($optgrps as $grpkey => $grpname) {
893 $result[$grpkey] = array();
894 $result[$grpkey]['name'] = $grpname;
895 $result[$grpkey]['options'] = array();
898 /* Create a new SquirrelOption for each set of option values. */
899 foreach ($optvals as $grpkey => $grpopts) {
900 foreach ($grpopts as $optset) {
901 /* Create a new option with all values given. */
902 $next_option = new SquirrelOption(
907 (isset($optset['refresh']) ?
$optset['refresh'] : SMOPT_REFRESH_NONE
),
908 (isset($optset['initial_value']) ?
$optset['initial_value'] : ''),
909 (isset($optset['posvals']) ?
$optset['posvals'] : ''),
910 (isset($optset['htmlencoded']) ?
$optset['htmlencoded'] : false)
913 /* If provided, set the size for this option. */
914 if (isset($optset['size'])) {
915 $next_option->setSize($optset['size']);
918 /* If provided, set the trailing_text for this option. */
919 if (isset($optset['trailing_text'])) {
920 $next_option->setTrailingText($optset['trailing_text']);
923 /* If provided, set the yes_text for this option. */
924 if (isset($optset['yes_text'])) {
925 $next_option->setYesText($optset['yes_text']);
928 /* If provided, set the no_text for this option. */
929 if (isset($optset['no_text'])) {
930 $next_option->setNoText($optset['no_text']);
933 /* If provided, set the layout type for this option. */
934 if (isset($optset['layout_type'])) {
935 $next_option->setLayoutType($optset['layout_type']);
938 /* If provided, set the use_add_widget value for this option. */
939 if (isset($optset['use_add_widget'])) {
940 $next_option->setUseAddWidget($optset['use_add_widget']);
943 /* If provided, set the use_delete_widget value for this option. */
944 if (isset($optset['use_delete_widget'])) {
945 $next_option->setUseDeleteWidget($optset['use_delete_widget']);
948 /* If provided, set the comment for this option. */
949 if (isset($optset['comment'])) {
950 $next_option->setComment($optset['comment']);
953 /* If provided, set the save function for this option. */
954 if (isset($optset['save'])) {
955 $next_option->setSaveFunction($optset['save']);
958 /* If provided, set the extra attributes for this option. */
959 if (isset($optset['extra_attributes'])) {
960 $next_option->setExtraAttributes($optset['extra_attributes']);
963 /* If provided, set the "post script" for this option. */
964 if (isset($optset['post_script'])) {
965 $next_option->setPostScript($optset['post_script']);
968 /* If provided, set the folder_filter for this option. */
969 if (isset($optset['folder_filter'])) {
970 $next_option->setFolderFilter($optset['folder_filter']);
973 /* Add this option to the option array. */
974 $result[$grpkey]['options'][] = $next_option;
978 /* Return our resulting array. */