Browse Source

More work done on the options stuff.

thomppj 23 years ago
parent
commit
8759ce0fbb
4 changed files with 93 additions and 60 deletions
  1. 2 0
      functions/constants.php
  2. 1 1
      src/left_main.php
  3. 11 11
      src/options.php
  4. 79 48
      src/options_display.php

+ 2 - 0
functions/constants.php

@@ -27,5 +27,7 @@
     define('SMPREF_LOC_LEFT', '');
     define('SMPREF_LOC_RIGHT', 'right');
 
+    define('SMPREF_NONE', 'none');
+
     do_hook("loading_constants");
 ?>

+ 1 - 1
src/left_main.php

@@ -158,7 +158,7 @@
     echo '<CENTER><FONT SIZE=4><B>';
     echo _("Folders") . "</B><BR></FONT>\n\n";
 
-    if($date_format != 6) { 
+    if ($date_format != 6) { 
         /* First, display the clock. */
         if ($hour_format == 1) {
           if ($date_format == 4) {

+ 11 - 11
src/options.php

@@ -66,30 +66,30 @@
       
         echo '<br><b>'._("Successfully saved personal information!").'</b><br>';
     } else if (isset($submit_display)) {
-        // Do checking to make sure $chosentheme is in the array
-        $in_ary = false;
+        /* Do checking to make sure $new_theme is in the array. */
+        $theme_in_array = false;
         for ($i=0; $i < count($theme); $i++) {
-            if ($theme[$i]['PATH'] == $chosentheme) {
-                $in_ary = true;
+            if ($theme[$i]['PATH'] == $new_chosen_theme) {
+                $theme_in_array = true;
                 break;
             }
         }
-        if (! $in_ary) {
-            $chosentheme = '';
+        if (!$theme_in_array) {
+            $new_chosen_theme = '';
         }
    
         /* Save display preferences. */
-        setPref($data_dir, $username, 'chosen_theme', $chosentheme);
-        setPref($data_dir, $username, 'language', $language);
-        setPref($data_dir, $username, 'use_javascript_addr_book', $javascript_abook);
+        setPref($data_dir, $username, 'chosen_theme', $new_chosen_theme);
+        setPref($data_dir, $username, 'language', $new_language);
+        setPref($data_dir, $username, 'use_javascript_addr_book', $new_use_javascript_addr_book);
         setPref($data_dir, $username, 'javascript_setting', $new_javascript_setting);
         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_buttons', $new_location_of_buttons);
         setPref($data_dir, $username, 'location_of_bar', $new_location_of_bar);
-        setPref($data_dir, $username, 'left_size', $leftsize);
+        setPref($data_dir, $username, 'left_size', $new_left_size);
+        setPref($data_dir, $username, 'left_refresh', $new_left_refresh);
 
         if (isset($altIndexColors) && $altIndexColors == 1) {
             setPref($data_dir, $username, 'alt_index_colors', 1);

+ 79 - 48
src/options_display.php

@@ -18,7 +18,7 @@
    require_once('../functions/options.php');
 
    displayPageHeader($color, 'None');
-   $chosen_language = getPref($data_dir, $username, 'language');
+   $language = getPref($data_dir, $username, 'language');
 ?>
    <br>
 <table width="95%" align="center" border="0" cellpadding="2" cellspacing="0">
@@ -32,24 +32,49 @@
    <form name="f" action="options.php" method="post"><br>
       <table width="100%" cellpadding="2" cellspacing="0" border="0">
 <?php
-    OptionSelect( _("Theme"), 'chosentheme', $theme, $chosen_theme, 'NAME', 'PATH' );
-    OptionSelect( _("Language"), 'language', $languages, $chosen_language, 'NAME' );
-    OptionRadio( _("Use Javascript or HTML addressbook?"),
-                 'javascript_abook',
-                 array( '1' => _("JavaScript"),
-                        '0' => _("HTML") ),
-                 $use_javascript_addr_book );
 
-    /*** BEGIN OPTIONS CLASS EXPERMINENTATION ***/
+    /* Build a simple array into which we will build options. */
+    $optvals = array(); 
 
-    /* Build a simple array with which to start. */
-    $optvals = array();
- 
+    $theme_values = array();
+    foreach ($theme as $theme_key => $theme_attributes) {
+        $theme_values[$theme_attributes['PATH']] = $theme_attributes['NAME'];
+    }
+    $optvals[] = array(
+        'name'    => 'chosen_theme',
+        'caption' => _("Theme"),
+        'type'    => SMOPT_TYPE_STRLIST,
+        'refresh' => SMOPT_REFRESH_ALL,
+        'posvals' => $theme_values
+    );
+
+    $language_values = array();
+    foreach ($languages as $lang_key => $lang_attributes) {
+        if (isset($lang_attributes['NAME'])) {
+            $language_values[$lang_key] = $lang_attributes['NAME'];
+        }
+    }
+    $optvals[] = array(
+        'name'    => 'language',
+        'caption' => _("Language"),
+        'type'    => SMOPT_TYPE_STRLIST,
+        'refresh' => SMOPT_REFRESH_ALL,
+        'posvals' => $language_values
+    );
+
+    $optvals[] = array(
+        'name'    => 'use_javascript_addr_book',
+        'caption' => _("Addressbook Display Format"),
+        'type'    => SMOPT_TYPE_STRLIST,
+        'refresh' => SMOPT_REFRESH_NONE,
+        'posvals' => array('1' => _("Javascript"),
+                           '0' => _("HTML"))
+    );
 
     /* Set values for the "use javascript" option. */
     $optvals[] = array(
         'name'    => 'javascript_setting',
-        'caption' =>_("Use Javascript"),
+        'caption' => _("Use Javascript"),
         'type'    => SMOPT_TYPE_STRLIST,
         'refresh' => SMOPT_REFRESH_ALL,
         'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
@@ -86,33 +111,57 @@
         '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 );
-
     $optvals[] = array(
         'name'    => 'location_of_buttons',
-        'caption' =>_("Location of Buttons when Composing"),
+        '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"))
+        '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"),
+        'caption' => _("Location of Folder List"),
+        'type'    => SMOPT_TYPE_STRLIST,
+        'refresh' => SMOPT_REFRESH_ALL,
+        'posvals' => array(SMPREF_LOC_LEFT  => _("Left"),
+                           SMPREF_LOC_RIGHT => _("Right"))
+    );
+
+    $left_size_values = array();
+    for ($lsv = 100; $lsv <= 300; $lsv += 10) {
+        $left_size_values[$lsv] = "$lsv " . _("pixels");
+    }
+    $optvals[] = array(
+        'name'    => 'left_size',
+        'caption' => _("Width of Folder List"),
         'type'    => SMOPT_TYPE_STRLIST,
         'refresh' => SMOPT_REFRESH_ALL,
-        'posvals' => array(SMPREF_LOC_LEFT   => _("Left"),
-                           SMPREF_LOC_RIGHT  => _("Right"))
+        'posvals' => $left_size_values
     );
 
-    /* Now, build the complete options array. */
+    $minute_str = _("Minutes");
+    $left_refresh_values = array(SMPREF_NONE => _("Never"));
+    foreach (array(30,60,120,180,300,600) as $lr_val) {
+        if ($lr_val < 60) {
+            $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
+        } else if ($lr_val == 60) {
+            $left_refresh_values[$lr_val] = "1 " . _("Minute");
+        } else {
+            $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
+        }
+    }
+    $optvals[] = array(
+        'name'    => 'left_refresh',
+        'caption' => _("Auto Refresh Folder List"),
+        'type'    => SMOPT_TYPE_STRLIST,
+        'refresh' => SMOPT_REFRESH_FOLDERLIST,
+        'posvals' => $left_refresh_values
+    );
+
+    /* Build all these values into an array of SquirrelOptions objects. */
     $options = createOptionArray($optvals);
 
     /* Print the row for each option. */
@@ -128,26 +177,8 @@
         }
     }
 
-    /*** END OPTIONS CLASS EXPERMINENTATION ***/
-
-   for ($i = 100; $i <= 300; $i += 10) {
-        $res[$i] = $i . _("pixels");
-   }
-   OptionSelect( _("Width of folder list"),
-                 'leftsize',
-                 $res,
-                 $left_size );
-   $minutes_str = _("Minutes");
-   OptionSelect( _("Auto refresh folder list"),
-                 'leftrefresh',
-                 array( 'None' => _("Never"),
-                        30 => '30 '. _("Seconds"),
-                        60 => '1 ' . _("Minute"),
-                        120 => "2 $minutes_str",
-                        180 => "3 $minutes_str",
-                        300 => "5 $minutes_str",
-                        600 => "10 $minutes_str" ),
-                 $left_refresh );
+    /*** NOT YET CONVERTED TO OPTION OBJECTS ***/
+
    OptionRadio( _("Use alternating row colors?"),
                 'altIndexColors',
                 array( 1 => _("Yes"),