<?php
/**
* options.php
*
* Functions needed to display the options pages.
*
* @copyright 1999-2020 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: options.php 14840 2020年01月07日 07:42:38Z pdontthink $
* @package squirrelmail
* @subpackage prefs
*/
/**********************************************/
/* Define constants used in the options code. */
/**********************************************/
/* Define constants for the various option types. */
define ('SMOPT_TYPE_STRING', 0);
define ('SMOPT_TYPE_STRLIST', 1);
define ('SMOPT_TYPE_TEXTAREA', 2);
define ('SMOPT_TYPE_INTEGER', 3);
define ('SMOPT_TYPE_FLOAT', 4);
define ('SMOPT_TYPE_BOOLEAN', 5);
define ('SMOPT_TYPE_HIDDEN', 6);
define ('SMOPT_TYPE_COMMENT', 7);
define ('SMOPT_TYPE_FLDRLIST', 8);
define ('SMOPT_TYPE_FLDRLIST_MULTI', 9);
define ('SMOPT_TYPE_EDIT_LIST', 10);
define ('SMOPT_TYPE_EDIT_LIST_ASSOCIATIVE', 11);
define ('SMOPT_TYPE_STRLIST_MULTI', 12);
define ('SMOPT_TYPE_BOOLEAN_CHECKBOX', 13);
define ('SMOPT_TYPE_BOOLEAN_RADIO', 14);
define ('SMOPT_TYPE_STRLIST_RADIO', 15);
define ('SMOPT_TYPE_SUBMIT', 16);
define ('SMOPT_TYPE_INFO', 17);
define ('SMOPT_TYPE_PASSWORD', 18);
/* Define constants for the layout scheme for edit lists. */
define ('SMOPT_EDIT_LIST_LAYOUT_LIST', 0);
define ('SMOPT_EDIT_LIST_LAYOUT_SELECT', 1);
/* Define constants for the options refresh levels. */
define ('SMOPT_REFRESH_NONE', 0);
define ('SMOPT_REFRESH_FOLDERLIST', 1);
define ('SMOPT_REFRESH_ALL', 2);
/* Define constants for the options size. */
define ('SMOPT_SIZE_TINY', 0);
define ('SMOPT_SIZE_SMALL', 1);
define ('SMOPT_SIZE_MEDIUM', 2);
define ('SMOPT_SIZE_LARGE', 3);
define ('SMOPT_SIZE_HUGE', 4);
define ('SMOPT_SIZE_NORMAL', 5);
define ('SMOPT_SAVE_DEFAULT', 'save_option');
define ('SMOPT_SAVE_NOOP', 'save_option_noop');
/**
* SquirrelOption: An option for Squirrelmail.
*
* This class is a work in progress. When complete, it will handle
* presentation and saving of Squirrelmail user options in a simple,
* streamline manner. Stay tuned for more stuff.
*
* Also, I'd like to ask that people leave this alone (mostly :) until
* I get it a little further along. That should only be a day or two or
* three. I will remove this message when it is ready for primetime usage.
* @package squirrelmail
*/
/* The basic stuff. */
/* The name of the Save Function for this option. */
/* The various 'values' for this options. */
/**
* Constructor (PHP5 style, required in some future version of PHP)
*/
($raw_option_array, $name, $caption, $type, $refresh_level, $initial_value = '', $possible_values = '', $htmlencoded = false) {
/* Set the basic stuff. */
// FIXME: why isn't this set by default to NORMAL?
/* Check for a current value. */
if (isset($GLOBALS[$name])) {
$this->value =
$GLOBALS[$name];
// TODO: This code should be something more like the following, but who knows what would break if it was changed at this point
// } else if (initial_value !== '') {
} else if (!empty($initial_value)) {
$this->value =
$initial_value;
} else {
}
/* Check for a new value. */
}
/* Set the default save function. */
} else {
}
}
/**
* Constructor (PHP4 style, kept for compatibility reasons)
*/
($raw_option_array, $name, $caption, $type, $refresh_level, $initial_value = '', $possible_values = '', $htmlencoded = false) {
self::__construct($raw_option_array, $name, $caption, $type, $refresh_level, $initial_value, $possible_values, $htmlencoded);
}
/** Convenience function that identifies which types of
widgets are stored as (serialized) array values. */
}
/* Set the value for this option. */
}
/* Set the new value for this option. */
}
/* Set whether the caption is allowed to wrap for this option. */
}
/* Set the size for this option. */
}
/* Set the trailing text for this option. */
}
/* Set the trailing text for this option. */
}
/* Set the trailing text for this option. */
}
/* Set the yes text for this option. */
}
/* Set the no text for this option. */
}
/* Set the "use add widget" value for this option. */
}
/* Set the "use delete widget" value for this option. */
}
/* Set the "poss value folders" value for this option.
See the associative edit list widget, which uses this
to offer folder list selection for the values */
}
/* Set the layout type for this option. */
}
/* Set the comment for this option. */
}
/* Set the script for this option. */
}
/* Set the "post script" for this option. */
}
/* Set the save function for this option. */
}
global $javascript_on, $color;
// Use new value if available
$tempValue =
$this->value ;
}
/* Get the widget for this option type. */
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
default:
$result = '<font color="' . $color[2] . '">'
. '</font>';
}
/* Add the "post script" for this option. */
// put correct value back if need be
$this->value =
$tempValue;
}
/* Now, return the created widget. */
return $result;
}
// $result = sm_encode_html_special_chars($this->value) . "\n";
// like COMMENT, allow HTML here
$result =
$this->value .
"\n";
return $result;
}
/**
* Create text box
*
* @param boolean $password When TRUE, the text in the input
* widget will be obscured (OPTIONAL;
* default = FALSE).
*
* @return string html formated text input
*
*/
$width = 5;
break;
$width = 12;
break;
$width = 38;
break;
$width = 50;
break;
default:
$width = 25;
}
$result = "<input type=\""
. ($password ? 'password' : 'text')
.
"\" name=\"new_$this->name\" value=\""
.
"\" size=\"$width\" $this->script /> "
. "\n";
return $result;
}
/**
* Create selection box or radio group
*
* When $this->htmlencoded is TRUE, the keys and values in
* $this->possible_values are assumed to be display-safe.
* Use with care!
*
* Note that when building radio buttons instead of a select
* widget, if the "size" attribute is SMOPT_SIZE_TINY, the
* radio buttons will be output one after another without
* linebreaks between them. Otherwise, each radio button
* goes on a line of its own.
*
* @param boolean $multiple_select When TRUE, the select widget
* will allow multiple selections
* (OPTIONAL; default is FALSE
* (single select list))
* @param boolean $radio_buttons When TRUE, the widget will
* instead be built as a group
* of radio buttons (and
* $multiple_select will be
* forced to FALSE) (OPTIONAL;
* default is FALSE (select widget))
*
* @return string html formated selection box or radio buttons
*
*/
// radio buttons instead of select widget?
//
if ($radio_buttons) {
$result = '';
$result .=
"\n" .
'<input type="radio" name="new_' .
$this->name
.
'" id="new_' .
$this->name .
'_'
. '" value="'
.
'"' .
($real_value ==
$this->value ?
' checked="checked"' :
'')
.
' /> <label for="new_' .
$this->name .
'_'
. '">'
. '</label>';
$result .= '<br />';
}
return $result;
}
// everything below applies to select widgets
//
//FIXME: not sure about these sizes... seems like we could add another on the "large" side...
$height = 3;
break;
$height = 8;
break;
$height = 15;
break;
$height = 25;
break;
default:
$height = 5;
}
// multiple select lists should already have array values
$selected =
$this->value ;
else
/* Begin the select tag. */
$result =
'<select name="new_' .
$this->name
. ($multiple_select ? '[]" multiple="multiple" size="' . $height . '" ' : '" ')
/* Add each possible value to the select list. */
/* Start the next new option string. */
$new_option = '<option value="' .
// multiple select lists have possibly more than one default selection
if ($multiple_select) {
foreach ($selected as $default) {
if ((string)$default == (string)$real_value) {
$new_option .= ' selected="selected"';
break;
}
}
}
/* If this value is the current value, select it. */
else if ($real_value ==
$this->value ) {
$new_option .= ' selected="selected"';
}
/* Add the display value to our option string. */
/* And add the new option string to our select tag. */
$result .= $new_option;
}
/* Close the select tag and return our happy result. */
$result .= '</select> '
. "\n";
return $result;
}
/**
* Create folder selection box
*
* @param boolean $multiple_select When TRUE, the select widget
* will allow multiple selections
* (OPTIONAL; default is FALSE
* (single select list))
*
* @return string html formated selection box
*
*/
//FIXME: not sure about these sizes... seems like we could add another on the "large" side...
$height = 3;
break;
$height = 8;
break;
$height = 15;
break;
$height = 25;
break;
default:
$height = 5;
}
// multiple select lists should already have array values
$selected =
$this->value ;
else
/* Begin the select tag. */
$result =
'<select name="new_' .
$this->name
. ($multiple_select ? '[]" multiple="multiple" size="' . $height . '"' : '"')
/* Add each possible value to the select list. */
/* For folder list, we passed in the array of boxes.. */
$selected_lowercase = array();
foreach ($selected as $i => $box)
} else {
/* Start the next new option string. */
// multiple select lists have possibly more than one default selection
if ($multiple_select) {
foreach ($selected as $default) {
if ((string)$default == (string)$real_value) {
$new_option .= ' selected="selected"';
break;
}
}
}
/* If this value is the current value, select it. */
else if ($real_value ==
$this->value ) {
$new_option .= ' selected="selected"';
}
/* Add the display value to our option string. */
}
/* And add the new option string to our select tag. */
$result .= $new_option;
}
/* Close the select tag and return our happy result. */
$result .= '</select> '
. "\n";
return $result;
}
default: $rows = 5; $cols = 50;
}
$result =
"<textarea name=\"new_$this->name\" rows=\"$rows\" "
.
"cols=\"$cols\" $this->script>\n"
return ($result);
}
global $javascript_on;
// add onChange javascript handler to a regular string widget
// which will strip out all non-numeric chars
if ($javascript_on)
return preg_replace ('/\/>/', ' onChange="origVal=this.value; newVal=\'\'; '
. 'for (i=0;i<origVal.length;i++) { if (origVal.charAt(i)>=\'0\' '
. '&& origVal.charAt(i)<=\'9\') newVal += origVal.charAt(i); } '
else
}
global $javascript_on;
// add onChange javascript handler to a regular string widget
// which will strip out all non-numeric (period also OK) chars
if ($javascript_on)
return preg_replace ('/\/>/', ' onChange="origVal=this.value; newVal=\'\'; '
. 'for (i=0;i<origVal.length;i++) { if ((origVal.charAt(i)>=\'0\' '
. '&& origVal.charAt(i)<=\'9\') || origVal.charAt(i)==\'.\') '
. 'newVal += origVal.charAt(i); } this.value=newVal;" />'
else
}
/**
* Create boolean widget
*
* When creating Yes/No radio buttons, the "yes_text"
* and "no_text" option attributes are used to override
* the typical "Yes" and "No" text.
*
* @param boolean $checkbox When TRUE, the widget will be
* constructed as a checkbox,
* otherwise it will be a set of
* Yes/No radio buttons (OPTIONAL;
* default is TRUE (checkbox)).
*
* @return string html formated boolean widget
*
*/
/* Do the whole current value thing. */
$yes_chk = ' checked="checked"';
$no_chk = '';
} else {
$yes_chk = '';
$no_chk = ' checked="checked"';
}
// checkbox...
//
if ($checkbox) {
$result =
'<input type="checkbox" name="new_' .
$this->name
.
"\" $yes_chk " .
$this->script .
' /> '
.
'<label for="new_' .
$this->name .
'">'
. '</label>';
}
// radio buttons...
//
else {
/* Build the yes choice. */
$yes_option =
'<input type="radio" name="new_' .
$this->name
.
'" id="new_' .
$this->name .
'_yes"'
/* Build the no choice. */
$no_option =
'<input type="radio" name="new_' .
$this->name
.
'" id="new_' .
$this->name .
'_no"'
/* Build the combined "boolean widget". */
$result = "$yes_option $no_option "
}
return ($result);
}
$result =
'<input type="hidden" name="new_' .
$this->name
.
'" ' .
$this->script .
' />';
return ($result);
}
return ($result);
}
/**
* Creates a (non-associative) edit list
*
* Note that multiple layout types are supported for this widget.
* $this->layout_type must be one of the SMOPT_EDIT_LIST_LAYOUT_*
* constants.
*
* @return string html formated list of edit fields and
* their associated controls
*/
$height = 3;
break;
$height = 8;
break;
$height = 15;
break;
$height = 25;
break;
$height = 40;
break;
default:
$height = 5;
}
// ensure correct format of current value(s)
//
global $javascript_on, $color;
$result = '';
$result .=
_ ("Add") .
' <input name="add_' .
$this->name
. '" size="38" /><br />'
$result .=
'<select name="new_' .
$this->name
. '[]" multiple="multiple" size="' . $height . '"'
.
($javascript_on ?
' 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; i=f-1; j=e-1; } 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].text; break; } }"' :
'')
// NOTE: i=f-1; j=e-1 is in lieu of break 2
.
' ' .
$this->script .
">\n";
$selected =
$this->value ;
else
$selected =
array($this->value );
// Add each possible value to the select list.
//
// Start the next new option string.
//
// having a selected item in the edit list doesn't have
// any meaning, but maybe someone will think of a way to
// use it, so we might as well put the code in
//
foreach ($selected as $default) {
if ((string)$default == (string)$value) {
$result .= ' selected="selected"';
break;
}
}
// Add the display value to our option string.
//
}
$result .= '</select>';
$result .= '<br /><input type="checkbox" name="delete_'
.
$this->name .
'" id="delete_' .
$this->name
. '" value="1" /> <label for="delete_'
.
$this->name .
'">' .
_ ("Delete Selected")
. '</label>';
break;
$result = '<table width="80%" cellpadding="1" cellspacing="0" border="0" bgcolor="'
. $color[0] . '"><tr><td>';
$result .=
_ ("Add") .
' <input name="add_' .
$this->name
. '" size="38" /><br />'
$result .= '<table width="100%" cellpadding="1" cellspacing="0" border="0" bgcolor="' . $color[5] . '">';
$bgcolor = 4;
if (!isset($color[12]))
$color[12] = '#EAEAEA';
$index = 0;
$selected =
$this->value ;
else
$selected =
array($this->value );
if ($bgcolor == 4) $bgcolor = 12;
else $bgcolor = 4;
$result .= '<tr bgcolor="' . $color[$bgcolor] . '">'
. '<td width="1%"><input type="checkbox" name="new_'
.
$this->name .
'[' .
($index++
) .
']" id="' .
$this->name
. '_list_item_' . $key . '" value="'
// having a selected item in the edit list doesn't have
// any meaning, but maybe someone will think of a way to
// use it, so we might as well put the code in
//
foreach ($selected as $default) {
if ((string)$default == (string)$value) {
$result .= '" checked="checked';
break;
}
}
$result .= '"></td>'
.
'<td><label for="' .
$this->name .
'_list_item_' .
$key
. "</tr>\n";
}
$result .= '</table>';
$result .= '<input type="checkbox" name="delete_'
.
$this->name .
'" id="delete_' .
$this->name
.
'" value="1" /> <label for="delete_' .
$this->name .
'">'
.
_ ("Delete Selected") .
'</label>';
$result .= '</td></tr></table>';
break;
default:
$result = '<font color="' . $color[2] . '">'
. '</font>';
}
return $result;
}
/**
* Creates an associative edit list
*
* Note that multiple layout types are supported for this widget.
* $this->layout_type must be one of the SMOPT_EDIT_LIST_LAYOUT_*
* constants.
*
* @return string html formated list of edit fields and
* their associated controls
*/
$height = 3;
break;
$height = 8;
break;
$height = 15;
break;
$height = 25;
break;
$height = 40;
break;
default:
$height = 5;
}
// ensure correct format of current value(s)
//
global $javascript_on, $color;
$result = '';
//FIXME implement poss_key_folders here? probably not worth the trouble, is there a use case?
$result .=
_ ("Add") .
' <input name="add_' .
$this->name
. '_key" size="22" /> ';
// FIXME: shall we allow these "poss value folders" (folder list selection for edit list values) for NON-Associative EDIT_LIST widgets?
$result .=
'<select name="add_' .
$this->name .
'_value">';
/* Add each possible value to the select list. */
/* For folder list, we passed in the array of boxes.. */
} else {
/* Start the next new option string. */
/* Add the display value to our option string. */
}
/* And add the new option string to our select tag. */
$result .= $new_option;
}
/* Close the select tag and return our happy result. */
$result .= '</select>';
}
else
$result .=
'<input name="add_' .
$this->name
. '_value" size="12" /><br />';
}
$result .=
'<select name="new_' .
$this->name
. '[]" multiple="multiple" size="' . $height . '"'
// FIXME: this can be fooled by having the delimiter " = " in a key value - in general, we may want to use a different delimiter other than " = "
.
($javascript_on ?
' onchange="if (typeof(window.addinput_key_' .
$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 .
'_key\' ) { pos = j; j=e-1; i=f-1; } j++; } i++; } if( pos >= 0 ) { window.addinput_key_' .
$this->name .
' = document.forms[i-1].elements[pos]; } } if (typeof(window.addinput_value_' .
$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 .
'_value\' ) { pos = j; j=e-1; i=f-1; } j++; } i++; } if( pos >= 0 ) { window.addinput_value_' .
$this->name .
' = document.forms[i-1].elements[pos]; } } for (x = 0; x < this.length; x++) { if (this.options[x].selected) { pos = this.options[x].text.indexOf(\' = \'); if (pos > -1) { window.addinput_key_' .
$this->name .
'.value = this.options[x].text.substr(0, pos); if (typeof(window.addinput_value_' .
$this->name .
') != \'undefined\') window.addinput_value_' .
$this->name .
'.value = this.options[x].text.substr(pos + 3); } break; } }"' :
'')
// NOTE: i=f-1; j=e-1 is in lieu of break 2
.
' ' .
$this->script .
">\n";
$selected =
$this->value ;
else
$selected =
array($this->value );
// Add each possible value to the select list.
//
// Start the next new option string.
//
$result .=
'<option value="' .
urlencode ($key) .
'"';
// having a selected item in the edit list doesn't have
// any meaning, but maybe someone will think of a way to
// use it, so we might as well put the code in
//
foreach ($selected as $default) {
if ((string)$default == (string)$key) {
$result .= ' selected="selected"';
break;
}
}
// Add the display value to our option string.
//
foreach ($disp_value as $folder_info) {
if ($value == $folder_info['unformatted']) {
break 2;
}
}
}
else
if ($value == $disp_value) {
break;
}
}
}
else
$result .= "</option>\n";
}
$result .= '</select>';
$result .= '<br /><input type="checkbox" name="delete_'
.
$this->name .
'" id="delete_' .
$this->name
. '" value="1" /> <label for="delete_'
.
$this->name .
'">' .
_ ("Delete Selected")
. '</label>';
break;
$result = '<table width="80%" cellpadding="1" cellspacing="0" border="0" bgcolor="'
. $color[0] . '"><tr><td>';
//FIXME implement poss_key_folders here? probably not worth the trouble, is there a use case?
$result .=
_ ("Add") .
' <input name="add_' .
$this->name
. '_key" size="22" /> ';
$result .=
'<select name="add_' .
$this->name .
'_value">';
/* Add each possible value to the select list. */
/* For folder list, we passed in the array of boxes.. */
} else {
/* Start the next new option string. */
/* Add the display value to our option string. */
}
/* And add the new option string to our select tag. */
$result .= $new_option;
}
/* Close the select tag and return our happy result. */
$result .= '</select>';
}
else
$result .=
'<input name="add_' .
$this->name
. '_value" size="12" /><br />';
}
$result .= '<table width="100%" cellpadding="1" cellspacing="0" border="0" bgcolor="' . $color[5] . '">';
$bgcolor = 4;
if (!isset($color[12]))
$color[12] = '#EAEAEA';
$selected =
$this->value ;
else
$selected =
array($this->value );
if ($bgcolor == 4) $bgcolor = 12;
else $bgcolor = 4;
$result .= '<tr bgcolor="' . $color[$bgcolor] . '">'
. '<td width="1%"><input type="checkbox" name="new_'
// having a selected item in the edit list doesn't have
// any meaning, but maybe someone will think of a way to
// use it, so we might as well put the code in
//
foreach ($selected as $default) {
if ((string)$default == (string)$key) {
$result .= '" checked="checked';
break;
}
}
$result .= '"></td>'
.
'<td><label for="' .
$this->name .
'_list_item_'
foreach ($disp_value as $folder_info) {
if ($value == $folder_info['unformatted']) {
break 2;
}
}
}
else
if ($value == $disp_value) {
break;
}
}
}
else
$result .= '</label></td>'
. "</tr>\n";
}
$result .= '</table>';
$result .= '<input type="checkbox" name="delete_'
.
$this->name .
'" id="delete_' .
$this->name
.
'" value="1" /> <label for="delete_' .
$this->name .
'">'
.
_ ("Delete Selected") .
'</label>';
$result .= '</td></tr></table>';
break;
default:
$result = '<font color="' . $color[2] . '">'
. '</font>';
}
return $result;
}
/**
* Creates a submit button
*
* @return string html formated submit button widget
*
*/
$result =
"<input type=\"submit\" name=\"$this->name\" value=\""
. "\n";
return $result;
}
$function($this);
}
// edit lists have a lot going on, so we'll always process them
//
return TRUE;
}
}
// Can't save the pref if we don't have the username
//
return;
}
// if the widget is a selection list, make sure the new
// value is actually in the selection list and is not an
// injection attack
//
return;
// all other widgets except TEXTAREAs should never be allowed to have newlines
//
// edit lists: first add new elements to list, then
// remove any selected ones (note that we must add
// before deleting because the javascript that populates
// the "add" textbox when selecting items in the list
// (for deletion))
//
// add element if given
//
&&
sqGetGlobalVar('add_' .
$option->name , $new_element, SQ_POST )) {
$new_element =
trim ($new_element);
if (!empty($new_element)
}
// delete selected elements if needed
//
&&
sqGetGlobalVar('delete_' .
$option->name , $ignore, SQ_POST ))
// save full list (stored in "possible_values")
//
// associative edit lists are handled similar to
// non-associative ones
//
// add element if given
//
$new_element_key = '';
$new_element_value = '';
$retrieve_key =
sqGetGlobalVar('add_' .
$option->name .
'_key', $new_element_key, SQ_POST );
$retrieve_value =
sqGetGlobalVar('add_' .
$option->name .
'_value', $new_element_value, SQ_POST );
&& ($retrieve_key || $retrieve_value)) {
$new_element_key =
trim ($new_element_key);
$new_element_value =
trim ($new_element_value);
$new_element_value = '';
if (!empty($new_element_key) || !empty($new_element_value)) {
if (empty($new_element_key)) $new_element_key = '0';
}
}
// delete selected elements if needed
//
&&
sqGetGlobalVar('delete_' .
$option->name , $ignore, SQ_POST )) {
}
else
}
// save full list (stored in "possible_values")
//
// Certain option types need to be serialized because
// they are not scalar
//
// Checkboxes, when unchecked, don't submit anything in
// the POST, so set to SMPREF_OFF if not found
//
// For integer fields, make sure we only have digits...
// We'll be nice and instead of just converting to an integer,
// we'll physically remove each non-digit in the string.
//
}
else
// if a checkbox or multi select is zeroed/cleared out, it
// needs to have an empty value pushed into its "new_value" slot
//
}
/* Do nothing here... */
}
}
}
$result = '<input type="hidden" '
. 'name="' . $name . '" '
return ($result);
}
/* Build a simple array with which to start. */
$result = array();
/* Create option group for each option group name. */
foreach ($optgrps as $grpkey => $grpname) {
$result[$grpkey] = array();
$result[$grpkey]['name'] = $grpname;
$result[$grpkey]['options'] = array();
}
/* Create a new SquirrelOption for each set of option values. */
foreach ($optvals as $grpkey => $grpopts) {
foreach ($grpopts as $optset) {
/* Create a new option with all values given. */
$optset,
$optset['name'],
$optset['caption'],
$optset['type'],
(isset($optset['initial_value']) ? $optset['initial_value'] : ''),
(isset($optset['posvals']) ? $optset['posvals'] : ''),
(isset($optset['htmlencoded']) ? $optset['htmlencoded'] : false)
);
/* If provided, set if the caption is allowed to wrap for this option. */
if (isset($optset['caption_wrap'])) {
}
/* If provided, set the size for this option. */
if (isset($optset['size'])) {
$next_option->setSize ($optset['size']);
}
/* If provided, set the trailing_text for this option. */
if (isset($optset['trailing_text'])) {
}
/* If provided, set whether the trailing_text should be rendered small for this option. */
if (isset($optset['trailing_text_small'])) {
}
/* If provided, set whether the trailing_text is HTML (and thus should not be sanitized - CAREFUL!) for this option. */
if (isset($optset['trailing_text_is_html'])) {
}
/* If provided, set the yes_text for this option. */
if (isset($optset['yes_text'])) {
}
/* If provided, set the no_text for this option. */
if (isset($optset['no_text'])) {
$next_option->setNoText ($optset['no_text']);
}
/* If provided, set the use_add_widget value for this option. */
if (isset($optset['use_add_widget'])) {
}
/* If provided, set the use_delete_widget value for this option. */
if (isset($optset['use_delete_widget'])) {
}
/* If provided, set the poss_value_folders value for this option. */
if (isset($optset['poss_value_folders'])) {
}
/* If provided, set the layout type for this option. */
if (isset($optset['layout_type'])) {
}
/* If provided, set the comment for this option. */
if (isset($optset['comment'])) {
}
/* If provided, set the save function for this option. */
if (isset($optset['save'])) {
}
/* If provided, set the script for this option. */
if (isset($optset['script'])) {
}
/* If provided, set the "post script" for this option. */
if (isset($optset['post_script'])) {
}
/* Add this option to the option array. */
$result[$grpkey]['options'][] = $next_option;
}
}
/* Return our resulting array. */
return ($result);
}
/* Print each option group. */
foreach ($option_groups as $next_optgrp) {
/* If it is not blank, print the name for this option group. */
if ($next_optgrp['name'] != '') {
'<b>' . $next_optgrp['name'] . '</b>' ,
'center' ,'', 'valign="middle" colspan="2" nowrap' )
) ."\n";
}
/* Print each option in this option group. */
$hidden_options = '';
foreach ($next_optgrp['options'] as $option) {
// although trailing_text will be a label for the checkbox,
// make the caption a label too - some widgets won't have
// trailing_text and having both as labels is perfectly fine
//
$option->caption =
'<label for="new_' .
$option->name .
'">'
else if (!empty($option->caption ))
// text area trailing text just goes under the caption
//
//TODO: I guess we should change this to obey trailing_text_small, but that would break existing plugins
//TODO: What about trailing_text_is_html? Why wasn't this being sanitized with sm_encode_html_special_chars()?????
global $color;
//$info_bgcolor = 0;
$info_bgcolor = 4;
$info_width = 80;
echo
html_tag ('tr', "\n" .
html_tag ('td', "\n" .
html_tag ('table', "\n" .
html_tag ('tr', "\n" .
html_tag ('td', "\n" .
$option->createHTMLWidget ())), '', $color[$info_bgcolor], 'width="' .
$info_width .
'%"'), 'center' ,'', 'colspan="2" valign="middle"')) .
"\n";
else
) ."\n";
} else {
}
}
/* Print an empty row after this option group. */
html_tag ( 'td', ' ' .
$hidden_options, 'left', '', 'colspan="2"' )
) . "\n";
}
}
html_tag ( 'td', '<input type="submit" value="' .
_ ("Submit") .
'" name="' .
$name .
'" /> ', 'right', '', 'colspan="2"' )
) . "\n";
}