Internationalized Folder/Subfolder in Selection List Style option
[squirrelmail.git] / include / options / folder.php
index 2098bc341bee8c169a54a2df8b1edb051e6e0ff7..128aee65239b5c82d1e143b9fa8a1e7d11137d62 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * options_folder.php
  *
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * Displays all options relating to folders
 
 /* SquirrelMail required files. */
 require_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'functions/imap_general.php');
 
 /* Define the group constants for the folder options page. */   
 define('SMOPT_GRP_SPCFOLDER', 0);
 define('SMOPT_GRP_FOLDERLIST', 1);
+define('SMOPT_GRP_FOLDERSELECT', 2);
 
 /* Define the optpage load function for the folder options page. */
 function load_optpage_data_folder() {
@@ -27,7 +29,6 @@ function load_optpage_data_folder() {
     $imapConnection =
         sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
     $boxes = sqimap_mailbox_list($imapConnection);
-    sqimap_logout($imapConnection);
 
     /* Build a simple array into which we will build options. */
     $optgrps = array();
@@ -52,43 +53,34 @@ function load_optpage_data_folder() {
         );
     }
 
-    $special_folder_values = array();
-    foreach ($boxes as $folder) {
-        if (strtolower($folder['unformatted']) != 'inbox') {
-            $real_value = $folder['unformatted-dm'];
-            $disp_value = str_replace(' ', ' ', $folder['formatted']);
-            $special_folder_values[$real_value] = $disp_value;
-        }
-    }
-
-    $trash_none = array(SMPREF_NONE => _("Do not use Trash"));
-    $trash_folder_values = array_merge($trash_none, $special_folder_values);
+    $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]',
+                                 'whatever'  => $boxes);
     $optvals[SMOPT_GRP_SPCFOLDER][] = array(
         'name'    => 'trash_folder',
         'caption' => _("Trash Folder"),
-        'type'    => SMOPT_TYPE_STRLIST,
+        'type'    => SMOPT_TYPE_FLDRLIST,
         'refresh' => SMOPT_REFRESH_FOLDERLIST,
         'posvals' => $trash_folder_values,
         'save'    => 'save_option_trash_folder'
     );
     
-    $sent_none = array(SMPREF_NONE => _("Do not use Sent"));
-    $sent_folder_values = array_merge($sent_none, $special_folder_values);
+    $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]',
+                                'whatever'  => $boxes);
     $optvals[SMOPT_GRP_SPCFOLDER][] = array(
         'name'    => 'sent_folder',
         'caption' => _("Sent Folder"),
-        'type'    => SMOPT_TYPE_STRLIST,
+        'type'    => SMOPT_TYPE_FLDRLIST,
         'refresh' => SMOPT_REFRESH_FOLDERLIST,
         'posvals' => $sent_folder_values,
         'save'    => 'save_option_sent_folder'
     );
     
-    $draft_none = array(SMPREF_NONE => _("Do not use Drafts"));
-    $draft_folder_values = array_merge($draft_none, $special_folder_values);
+    $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]',
+                                 'whatever'  => $boxes);
     $optvals[SMOPT_GRP_SPCFOLDER][] = array(
         'name'    => 'draft_folder',
         'caption' => _("Draft Folder"),
-        'type'    => SMOPT_TYPE_STRLIST,
+        'type'    => SMOPT_TYPE_FLDRLIST,
         'refresh' => SMOPT_REFRESH_FOLDERLIST,
         'posvals' => $draft_folder_values,
         'save'    => 'save_option_draft_folder'
@@ -211,11 +203,28 @@ function load_optpage_data_folder() {
                             9 => '9')
     );
 
+
+    /*** Load the General Options into the array ***/
+    $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options");
+    $optvals[SMOPT_GRP_FOLDERSELECT] = array();
+
+    $delim = sqimap_get_delimiter($imapConnection);
+    $optvals[SMOPT_GRP_FOLDERSELECT][] = array(
+        'name'    => 'mailbox_select_style',
+        'caption' => _("Selection List Style"),
+        'type'    => SMOPT_TYPE_STRLIST,
+        'refresh' => SMOPT_REFRESH_NONE,
+        'posvals' => array( 0 => _("Long: ") . '"' . _("Folder") . $delim . _("Subfolder") . '"',
+                            1 => _("Indented: ") .  '"    ' . _("Subfolder") . '"',
+                            2 => _("Delimited: ") . '". ' . _("Subfolder") . '"')
+    );
+
     /* Assemble all this together and return it as our result. */
     $result = array(
         'grps' => $optgrps,
         'vals' => $optvals
     );
+    sqimap_logout($imapConnection);
     return ($result);
 }