Another big chunk of changes to options pages.
[squirrelmail.git] / src / options_display.php
index f92b017023ef39d13a0bb28b8a1259802e9d9b42..07899f0754f4f053f7e37b4952504648f29db885 100644 (file)
 <?php
 
     /* Build a simple array into which we will build options. */
-    $optvals = array(); 
+    $optgrps = array();
+    $optvals = array();
 
+    /******************************************************/
+    /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
+    /******************************************************/
+    define('SMOPT_GRP_GENERAL', 0);
+    define('SMOPT_GRP_MAILBOX', 1);
+    define('SMOPT_GRP_MESSAGE', 2);
+
+    /*** Load the General Options into the array ***/
+    $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options");
+    $optvals[SMOPT_GRP_GENERAL] = array();
+
+    /* Load the theme option. */
     $theme_values = array();
     foreach ($theme as $theme_key => $theme_attributes) {
         $theme_values[$theme_attributes['PATH']] = $theme_attributes['NAME'];
     }
-    $optvals[] = array(
+    $optvals[SMOPT_GRP_GENERAL][] = array(
         'name'    => 'chosen_theme',
         'caption' => _("Theme"),
         'type'    => SMOPT_TYPE_STRLIST,
@@ -54,7 +67,7 @@
             $language_values[$lang_key] = $lang_attributes['NAME'];
         }
     }
-    $optvals[] = array(
+    $optvals[SMOPT_GRP_GENERAL][] = array(
         'name'    => 'language',
         'caption' => _("Language"),
         'type'    => SMOPT_TYPE_STRLIST,
@@ -63,7 +76,7 @@
     );
 
     /* Set values for the "use javascript" option. */
-    $optvals[] = array(
+    $optvals[SMOPT_GRP_GENERAL][] = array(
         'name'    => 'javascript_setting',
         'caption' => _("Use Javascript"),
         'type'    => SMOPT_TYPE_STRLIST,
     );
 
     $js_autodetect_results = SMPREF_JS_OFF;
-    $optvals[] = array(
+    $optvals[SMOPT_GRP_GENERAL][] = array(
         'name'    => 'js_autodetect_results',
         'caption' => '',
         'type'    => SMOPT_TYPE_HIDDEN,
         'refresh' => SMOPT_REFRESH_NONE
     );
 
-    $optvals[] = array(
+    /*** Load the General Options into the array ***/
+    $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
+    $optvals[SMOPT_GRP_MAILBOX] = array();
+
+    $optvals[SMOPT_GRP_MAILBOX][] = array(
         'name'    => 'show_num',
         'caption' => _("Number of Messages to Index"),
         'type'    => SMOPT_TYPE_INTEGER,
-        'refresh' => SMOPT_REFRESH_NONE
+        'refresh' => SMOPT_REFRESH_NONE,
+        'size'    => SMOPT_SIZE_TINY
     );
 
-    $optvals[] = array(
+    $optvals[SMOPT_GRP_MAILBOX][] = array(
         'name'    => 'alt_index_colors',
         'caption' => _("Enable Alternating Row Colors"),
         'type'    => SMOPT_TYPE_BOOLEAN,
         'refresh' => SMOPT_REFRESH_NONE
     );
 
-    $optvals[] = array(
+    $optvals[SMOPT_GRP_MAILBOX][] = array(
         'name'    => 'page_selector',
         'caption' => _("Enable Page Selector"),
         'type'    => SMOPT_TYPE_BOOLEAN,
         'refresh' => SMOPT_REFRESH_NONE
     );
 
-    $optvals[] = array(
+    $optvals[SMOPT_GRP_MAILBOX][] = array(
         'name'    => 'page_selector_max',
         'caption' => _("Maximum Number of Pages to Show"),
         'type'    => SMOPT_TYPE_INTEGER,
-        'refresh' => SMOPT_REFRESH_NONE
+        'refresh' => SMOPT_REFRESH_NONE,
+        'size'    => SMOPT_SIZE_TINY
     );
 
-    $optvals[] = array(
+    /*** Load the General Options into the array ***/
+    $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display and Composition");
+    $optvals[SMOPT_GRP_MESSAGE] = array();
+
+    $optvals[SMOPT_GRP_MESSAGE][] = array(
         'name'    => 'wrap_at',
         'caption' => _("Wrap Incoming Text At"),
         'type'    => SMOPT_TYPE_INTEGER,
-        'refresh' => SMOPT_REFRESH_NONE
+        'refresh' => SMOPT_REFRESH_NONE,
+        'size'    => SMOPT_SIZE_TINY
     );
 
-    $optvals[] = array(
+    $optvals[SMOPT_GRP_MESSAGE][] = array(
         'name'    => 'editor_size',
         'caption' => _("Size of Editor Window"),
         'type'    => SMOPT_TYPE_INTEGER,
-        'refresh' => SMOPT_REFRESH_NONE
+        'refresh' => SMOPT_REFRESH_NONE,
+        'size'    => SMOPT_SIZE_TINY
     );
 
-    $optvals[] = array(
+    $optvals[SMOPT_GRP_MESSAGE][] = array(
         'name'    => 'location_of_buttons',
         'caption' => _("Location of Buttons when Composing"),
         'type'    => SMOPT_TYPE_STRLIST,
                            SMPREF_LOC_BOTTOM  => _("After message body"))
     );
 
-    $optvals[] = array(
+    $optvals[SMOPT_GRP_MESSAGE][] = array(
         'name'    => 'use_javascript_addr_book',
         'caption' => _("Addressbook Display Format"),
         'type'    => SMOPT_TYPE_STRLIST,
                            '0' => _("HTML"))
     );
 
-    $optvals[] = array(
+    $optvals[SMOPT_GRP_MESSAGE][] = array(
         'name'    => 'show_html_default',
         'caption' => _("Show HTML Version by Default"),
         'type'    => SMOPT_TYPE_BOOLEAN,
         'refresh' => SMOPT_REFRESH_NONE
     );
 
-    $optvals[] = array(
+    $optvals[SMOPT_GRP_MESSAGE][] = array(
         'name'    => 'include_self_reply_all',
-        'caption' => _("Remove Me from CC when I Reply All"),
+        'caption' => _("Include Me in CC when I Reply All"),
         'type'    => SMOPT_TYPE_BOOLEAN,
         'refresh' => SMOPT_REFRESH_NONE
     );
 
-    $optvals[] = array(
+    $optvals[SMOPT_GRP_MESSAGE][] = array(
         'name'    => 'show_xmailer_default',
         'caption' => _("Enable Mailer Display"),
         'type'    => SMOPT_TYPE_BOOLEAN,
         'refresh' => SMOPT_REFRESH_NONE
     );
 
-    /* Build all these values into an array of SquirrelOptions objects. */
-    $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>'
-               . $option->caption . ":</TD>\n";
-            echo '  <TD>' . $option->createHTMLWidget() . "</TD>\n";
-            echo "</TR>\n";
-        } else {
-            echo $option->createHTMLWidget();
-        }
-    }
+    /* Build and output the option groups. */
+    $option_groups = createOptionGroups($optgrps, $optvals);
+    printOptionGroups($option_groups);
+    
+    do_hook('options_display_inside');
+    echo "<TR><TD>&nbsp;</TD></TR>\n";
 
-   echo '<tr><td colspan=2><hr noshade></td></tr>';
-   do_hook('options_display_inside');
-   OptionSubmit( 'submit_display' );
+    OptionSubmit( 'submit_display' );
 ?>
 
       </table>