* $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. */
/**************************************************************/
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");
?>
*
* $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.
*
/* 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 */
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 = '<FONT COLOR=RED>'
+ . sprintf(_("Option Type '%s' Not Found"), $this->type)
+ . '</FONT>';
+ }
+
+ /* Now, return the created widget. */
+ return ($result);
+ }
+
+ function createWidget_String() {
+ $result = "<INPUT NAME=\"new_$this->name\" value=\"$this->value\" size=\"5\">";
+ return ($result);
+ }
+
+ function createWidget_StrList() {
+ /* Begin the select tag. */
+ $result = "<SELECT NAME=\"new_$this->name\">";
+
+ /* Add each possible value to the select list. */
+ foreach ($this->possible_values as $real_value => $disp_value) {
+ /* Start the next new option string. */
+ $new_option = "<OPTION VALUE=\"$real_value\"";
+
+ /* If this value is the current value, select it. */
+ if ($real_value == $this->value) {
+ $new_option .= ' SELECTED';
+ }
+
+ /* Add the display value to our option string. */
+ $new_option .= ">$disp_value</OPTION>";
+
+ /* And add the new option string to our select tag. */
+ $result .= $new_option;
}
+
+ /* Close the select tag and return our happy result. */
+ $result .= '</SELECT>';
+ 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 = '<INPUT TYPE="HIDDEN" NAME="new_' . $this->name
+ . '" VALUE="' . $this->value . '">';
+ return ($result);
}
function hasChanged() {
}
}
+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 "<tr><td align=right valign=middle nowrap>$title: </td><td>" .
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) {
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);
"</table>\n";
}
-?>
\ No newline at end of file
+?>
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 "<TR>\n";
+ echo ' <TD ALIGN="RIGHT" VALIGN="MIDDLE" NOWRAP><font color=red><b>'
+ . $option->caption . "</b></font>:</TD>\n";
+ echo ' <TD>' . $option->createHTMLWidget() . "</TD>\n";
+ echo "</TR>\n";
+ } else {
+ echo $option->createHTMLWidget();
+ }
+ }
+
+ /*** END OPTIONS CLASS EXPERMINENTATION ***/
+
for ($i = 100; $i <= 300; $i += 10) {
$res[$i] = $i . _("pixels");
}
</table>
<SCRIPT LANGUAGE="JavaScript"><!--
- document.forms[0].js_autodetect_results.value = '<?php echo SMPREF_JS_ON; ?>';
+ document.forms[0].new_js_autodetect_results.value = '<?php echo SMPREF_JS_ON; ?>';
// --></SCRIPT>
</td></tr>