From: pdontthink Date: Sun, 6 Jul 2003 02:13:21 +0000 (+0000) Subject: Added initial_value and post_script options for widgets X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=6ae9e72937a9ff3e6017c1fedcd37945df12f74a;hp=37a3ed171f56d139ba82af4a69912ed4e811d63c Added initial_value and post_script options for widgets git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5225 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/options.php b/functions/options.php index 56f81d20..bdd5df13 100644 --- a/functions/options.php +++ b/functions/options.php @@ -62,6 +62,7 @@ class SquirrelOption { var $size; var $comment; var $script; + var $post_script; /* The name of the Save Function for this option. */ var $save_function; @@ -72,7 +73,7 @@ class SquirrelOption { var $possible_values; function SquirrelOption - ($name, $caption, $type, $refresh_level, $possible_values = '') { + ($name, $caption, $type, $refresh_level, $initial_value = '', $possible_values = '') { /* Set the basic stuff. */ $this->name = $name; $this->caption = $caption; @@ -82,9 +83,12 @@ class SquirrelOption { $this->size = SMOPT_SIZE_MEDIUM; $this->comment = ''; $this->script = ''; + $this->post_script = ''; /* 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]; } else { $this->value = ''; @@ -128,6 +132,11 @@ class SquirrelOption { $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. */ function setSaveFunction($save_function) { $this->save_function = $save_function; @@ -171,6 +180,9 @@ class SquirrelOption { . ''; } + /* Add the "post script" for this option. */ + $result .= $this->post_script; + /* Now, return the created widget. */ return ($result); } @@ -328,7 +340,7 @@ class SquirrelOption { function createWidget_Hidden() { $result = ''; + . '" value="' . $this->value . '" ' . $this->script . '>'; return ($result); } @@ -396,6 +408,7 @@ function create_option_groups($optgrps, $optvals) { $optset['caption'], $optset['type'], $optset['refresh'], + (isset($optset['initial_value']) ? $optset['initial_value'] : ''), $optset['posvals'] ); } else { @@ -404,7 +417,8 @@ function create_option_groups($optgrps, $optvals) { $optset['name'], $optset['caption'], $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']); } + /* 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. */ $result[$grpkey]['options'][] = $next_option; }