From: thomppj Date: Sat, 10 Nov 2001 22:03:15 +0000 (+0000) Subject: Please ignore the red for now :) X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=a3ec3c9131807abe5f36603441b0a642661882bc Please ignore the red for now :) git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1718 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/constants.php b/functions/constants.php index fd98ff32..50daeecf 100644 --- a/functions/constants.php +++ b/functions/constants.php @@ -12,23 +12,6 @@ * $Id$ */ - /******************************************************/ - /* Set values for 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 constants for the options refresh levels. */ - define('SMOPT_REFRESH_NONE', 0); - define('SMOPT_REFRESH_FOLDERLIST', 1); - define('SMOPT_REFRESH_ALL', 2); - /**************************************************************/ /* Set values for constants used by Squirrelmail preferences. */ /**************************************************************/ @@ -38,5 +21,11 @@ define('SMPREF_JS_OFF', 2); define('SMPREF_JS_AUTODETECT', 3); + define('SMPREF_LOC_TOP', 'top'); + define('SMPREF_LOC_BETWEEN', 'between'); + define('SMPREF_LOC_BOTTOM', 'bottom'); + define('SMPREF_LOC_LEFT', ''); + define('SMPREF_LOC_RIGHT', 'right'); + do_hook("loading_constants"); ?> diff --git a/functions/options.php b/functions/options.php index 2f7d3036..e5eeefff 100644 --- a/functions/options.php +++ b/functions/options.php @@ -9,6 +9,25 @@ * * $Id$ */ + +/**********************************************/ +/* 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 constants for the options refresh levels. */ +define('SMOPT_REFRESH_NONE', 0); +define('SMOPT_REFRESH_FOLDERLIST', 1); +define('SMOPT_REFRESH_ALL', 2); + /** * SquirrelOption: An option for Squirrelmail. * @@ -24,13 +43,13 @@ class SquirrelOption { /* The basic stuff. */ var $name; var $caption; - var $refresh_level; var $type; + var $refresh_level; /* The various 'values' for this options. */ var $value; var $new_value; - var $possible_vals; + var $possible_values; /* This variable needs to be made private so it can not be messed with. */ /* I just don't remember how to do it right now and think it would be */ @@ -38,24 +57,113 @@ class SquirrelOption { var $changed; function SquirrelOption - ($name, $caption, $value, $refresh_level = SMOPT_REFRESH_NONE, - $type = SMOPT_TYPE_STRING, $possible_values = '') { + ($name, $caption, $type, $refresh_level, $possible_values = '') { /* Set the basic stuff. */ $this->name = $name; $this->caption = $caption; - $this->value = $value; - - /* Set the optional parameters. */ - $this->refresh_level = $refresh_level; $this->type = $type; - $this->value = $value; - $this->possible_values = $possible_value; + $this->refresh_level = $refresh_level; + $this->possible_values = $possible_values; + + /* Check for a current value. */ + if (isset($GLOBALS[$name])) { + $this->value = $GLOBALS[$name]; + } else { + $this->value = ''; + } - /* Lastly, check for a new value. */ + /* Check for a new value. */ if (isset($GLOBALS["new_$name"])) { $this->new_value = $GLOBALS["new_$name"]; $this->changed = ($this->value !== $this->new_value); + } else { + $this->new_value = ''; + $this->changed = false; + } + } + + function createHTMLWidget() { + switch ($this->type) { + case SMOPT_TYPE_STRING: + $result = $this->createWidget_String(); + break; + case SMOPT_TYPE_STRLIST: + $result = $this->createWidget_StrList(); + break; + case SMOPT_TYPE_TEXTAREA: + $result = $this->createWidget_TextArea(); + break; + case SMOPT_TYPE_INTEGER: + $result = $this->createWidget_Integer(); + break; + case SMOPT_TYPE_FLOAT: + $result = $this->createWidget_Float(); + break; + case SMOPT_TYPE_BOOLEAN: + $result = $this->createWidget_Boolean(); + break; + case SMOPT_TYPE_HIDDEN: + $result = $this->createWidget_Hidden(); + break; + default: + $result = '' + . sprintf(_("Option Type '%s' Not Found"), $this->type) + . ''; + } + + /* Now, return the created widget. */ + return ($result); + } + + function createWidget_String() { + $result = "name\" value=\"$this->value\" size=\"5\">"; + return ($result); + } + + function createWidget_StrList() { + /* Begin the select tag. */ + $result = "'; + return ($result); + } + + function createWidget_TextArea() { + } + + function createWidget_Integer() { + return ($this->createWidget_String()); + } + + function createWidget_Float() { + return ($this->createWidget_String()); + } + + function createWidget_Boolean() { + } + + function createWidget_Hidden() { + $result = ''; + return ($result); } function hasChanged() { @@ -63,6 +171,36 @@ class SquirrelOption { } } +function createOptionArray($optvals) { + /* Build a simple array with which to start. */ + $result = array(); + + /* Create a new SquirrelOption for each set of option values. */ + foreach ($optvals as $optset) { + if (isset($optset['posvals'])) { + /* Create a new option with all values given. */ + $result[] = new SquirrelOption( + $optset['name'], + $optset['caption'], + $optset['type'], + $optset['refresh'], + $optset['posvals'] + ); + } else { + /* Create a new option with all but possible values given. */ + $result[] = new SquirrelOption( + $optset['name'], + $optset['caption'], + $optset['type'], + $optset['refresh'] + ); + } + } + + /* Return our resulting array. */ + return ($result); +} + function OptionSelect( $title, $name, $data, $default, $show = '', $store = '' ) { echo "$title: " . diff --git a/src/options.php b/src/options.php index bf0c796b..5e333278 100644 --- a/src/options.php +++ b/src/options.php @@ -83,12 +83,12 @@ setPref($data_dir, $username, 'language', $language); setPref($data_dir, $username, 'use_javascript_addr_book', $javascript_abook); setPref($data_dir, $username, 'javascript_setting', $new_javascript_setting); - setPref($data_dir, $username, 'show_num', $shownum); - setPref($data_dir, $username, 'wrap_at', $wrapat); - setPref($data_dir, $username, 'editor_size', $editorsize); + setPref($data_dir, $username, 'show_num', $new_show_num); + setPref($data_dir, $username, 'wrap_at', $new_wrap_at); + setPref($data_dir, $username, 'editor_size', $new_editor_size); setPref($data_dir, $username, 'left_refresh', $leftrefresh); - setPref($data_dir, $username, 'location_of_bar', $folder_new_location); - setPref($data_dir, $username, 'location_of_buttons', $button_new_location); + setPref($data_dir, $username, 'location_of_buttons', $new_location_of_buttons); + setPref($data_dir, $username, 'location_of_bar', $new_location_of_bar); setPref($data_dir, $username, 'left_size', $leftsize); if (isset($altIndexColors) && $altIndexColors == 1) { @@ -117,7 +117,7 @@ setPref($data_dir, $username, 'page_selector', 1); } - $js_autodetect_results = (isset($js_autodetect_results) ? $js_autodetect_results : SMPREF_JS_OFF); + $js_autodetect_results = (isset($new_js_autodetect_results) ? $new_js_autodetect_results : SMPREF_JS_OFF); if ($new_javascript_setting == SMPREF_JS_AUTODETECT) { if ($js_autodetect_results == SMPREF_JS_ON) { setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON); @@ -324,4 +324,4 @@ "\n"; } -?> \ No newline at end of file +?> diff --git a/src/options_display.php b/src/options_display.php index 69cba54b..540cbf71 100644 --- a/src/options_display.php +++ b/src/options_display.php @@ -39,26 +39,97 @@ array( '1' => _("JavaScript"), '0' => _("HTML") ), $use_javascript_addr_book ); - OptionSelect( _("Use Javascript"), 'new_javascript_setting', - array(SMPREF_JS_AUTODETECT => _("Autodetect"), - SMPREF_JS_ON => _("Always"), - SMPREF_JS_OFF => _("Never") ), - $javascript_setting ); - OptionHidden('js_autodetect_results', SMPREF_JS_OFF); - OptionText( _("Number of Messages to Index"), 'shownum', $show_num, 5 ); - OptionText( _("Wrap incoming text at"), 'wrapat', $wrap_at, 5 ); - OptionText( _("Size of editor window"), 'editorsize', $editor_size, 5 ); + + /*** BEGIN OPTIONS CLASS EXPERMINENTATION ***/ + + /* Build a simple array with which to start. */ + $optvals = array(); + + + /* Set values for the "use javascript" option. */ + $optvals[] = array( + 'name' => 'javascript_setting', + 'caption' =>_("Use Javascript"), + 'type' => SMOPT_TYPE_STRLIST, + 'refresh' => SMOPT_REFRESH_ALL, + 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"), + SMPREF_JS_ON => _("Always"), + SMPREF_JS_OFF => _("Never")) + ); + + $js_autodetect_results = SMPREF_JS_OFF; + $optvals[] = array( + 'name' => 'js_autodetect_results', + 'caption' => '', + 'type' => SMOPT_TYPE_HIDDEN, + 'refresh' => SMOPT_REFRESH_NONE + ); + + $optvals[] = array( + 'name' => 'show_num', + 'caption' => _("Number of Messages to Index"), + 'type' => SMOPT_TYPE_INTEGER, + 'refresh' => SMOPT_REFRESH_NONE + ); + + $optvals[] = array( + 'name' => 'wrap_at', + 'caption' => _("Wrap Incoming Text At"), + 'type' => SMOPT_TYPE_INTEGER, + 'refresh' => SMOPT_REFRESH_NONE + ); + + $optvals[] = array( + 'name' => 'editor_size', + 'caption' => _("Size of Editor Window"), + 'type' => SMOPT_TYPE_INTEGER, + 'refresh' => SMOPT_REFRESH_NONE + ); + OptionSelect( _("Location of buttons when composing"), 'button_new_location', array( 'top' => _("Before headers"), 'between' => _("Between headers and message body"), 'bottom' => _("After message body") ), $location_of_buttons ); - OptionSelect( _("Location of folder list"), - 'folder_new_location', - array( '' => _("Left"), - 'right' => _("Right") ), - $location_of_bar ); + + $optvals[] = array( + 'name' => 'location_of_buttons', + 'caption' =>_("Location of Buttons when Composing"), + 'type' => SMOPT_TYPE_STRLIST, + 'refresh' => SMOPT_REFRESH_NONE, + 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"), + SMPREF_LOC_BETWEEN => _("Between headers and message body"), + SMPREF_LOC_BOTTOM => _("After message body")) + ); + + $optvals[] = array( + 'name' => 'location_of_bar', + 'caption' =>_("Location of Folder List"), + 'type' => SMOPT_TYPE_STRLIST, + 'refresh' => SMOPT_REFRESH_ALL, + 'posvals' => array(SMPREF_LOC_LEFT => _("Left"), + SMPREF_LOC_RIGHT => _("Right")) + ); + + /* Now, build the complete options array. */ + $options = createOptionArray($optvals); + + /* Print the row for each option. */ + foreach ($options as $option) { + if ($option->type != SMOPT_TYPE_HIDDEN) { + echo "\n"; + echo ' ' + . $option->caption . ":\n"; + echo ' ' . $option->createHTMLWidget() . "\n"; + echo "\n"; + } else { + echo $option->createHTMLWidget(); + } + } + + /*** END OPTIONS CLASS EXPERMINENTATION ***/ + for ($i = 100; $i <= 300; $i += 10) { $res[$i] = $i . _("pixels"); } @@ -112,7 +183,7 @@