Added initial_value and post_script options for widgets

This commit is contained in:
pdontthink 2003-07-06 02:13:21 +00:00
parent 6f596532a4
commit 0ebe105bea

View file

@ -62,6 +62,7 @@ class SquirrelOption {
var $size; var $size;
var $comment; var $comment;
var $script; var $script;
var $post_script;
/* The name of the Save Function for this option. */ /* The name of the Save Function for this option. */
var $save_function; var $save_function;
@ -72,7 +73,7 @@ class SquirrelOption {
var $possible_values; var $possible_values;
function SquirrelOption function SquirrelOption
($name, $caption, $type, $refresh_level, $possible_values = '') { ($name, $caption, $type, $refresh_level, $initial_value = '', $possible_values = '') {
/* Set the basic stuff. */ /* Set the basic stuff. */
$this->name = $name; $this->name = $name;
$this->caption = $caption; $this->caption = $caption;
@ -82,9 +83,12 @@ class SquirrelOption {
$this->size = SMOPT_SIZE_MEDIUM; $this->size = SMOPT_SIZE_MEDIUM;
$this->comment = ''; $this->comment = '';
$this->script = ''; $this->script = '';
$this->post_script = '';
/* Check for a current value. */ /* Check for a current value. */
if (isset($GLOBALS[$name])) { if (!empty($initial_value)) {
$this->value = $initial_value;
} else if (isset($GLOBALS[$name])) {
$this->value = $GLOBALS[$name]; $this->value = $GLOBALS[$name];
} else { } else {
$this->value = ''; $this->value = '';
@ -128,6 +132,11 @@ class SquirrelOption {
$this->script = $script; $this->script = $script;
} }
/* Set the "post script" for this option. */
function setPostScript($post_script) {
$this->post_script = $post_script;
}
/* Set the save function for this option. */ /* Set the save function for this option. */
function setSaveFunction($save_function) { function setSaveFunction($save_function) {
$this->save_function = $save_function; $this->save_function = $save_function;
@ -171,6 +180,9 @@ class SquirrelOption {
. '</font>'; . '</font>';
} }
/* Add the "post script" for this option. */
$result .= $this->post_script;
/* Now, return the created widget. */ /* Now, return the created widget. */
return ($result); return ($result);
} }
@ -328,7 +340,7 @@ class SquirrelOption {
function createWidget_Hidden() { function createWidget_Hidden() {
$result = '<input type="hidden" name="new_' . $this->name $result = '<input type="hidden" name="new_' . $this->name
. '" value="' . $this->value . ' ' . $this->script . '">'; . '" value="' . $this->value . '" ' . $this->script . '>';
return ($result); return ($result);
} }
@ -396,6 +408,7 @@ function create_option_groups($optgrps, $optvals) {
$optset['caption'], $optset['caption'],
$optset['type'], $optset['type'],
$optset['refresh'], $optset['refresh'],
(isset($optset['initial_value']) ? $optset['initial_value'] : ''),
$optset['posvals'] $optset['posvals']
); );
} else { } else {
@ -404,7 +417,8 @@ function create_option_groups($optgrps, $optvals) {
$optset['name'], $optset['name'],
$optset['caption'], $optset['caption'],
$optset['type'], $optset['type'],
$optset['refresh'] $optset['refresh'],
(isset($optset['initial_value']) ? $optset['initial_value'] : '')
); );
} }
@ -428,6 +442,11 @@ function create_option_groups($optgrps, $optvals) {
$next_option->setScript($optset['script']); $next_option->setScript($optset['script']);
} }
/* If provided, set the "post script" for this option. */
if (isset($optset['post_script'])) {
$next_option->setPostScript($optset['post_script']);
}
/* Add this option to the option array. */ /* Add this option to the option array. */
$result[$grpkey]['options'][] = $next_option; $result[$grpkey]['options'][] = $next_option;
} }