From 809f9d11bddc97272e116483bcc24e1db79bdc28 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Wed, 28 May 2014 06:28:51 -0400
Subject: [PATCH] Merge branch 'master' of github.com:roundcube/roundcubemail

---
 CHANGELOG                                |    1 
 program/include/rcmail_output_html.php   |    1 
 program/localization/de_DE/csv2vcard.inc |  110 ++++++++++++++++++++++
 program/lib/Roundcube/rcube_imap.php     |   15 +--
 program/js/app.js                        |   41 +++++---
 program/localization/de_CH/csv2vcard.inc |  110 ++++++++++++++++++++++
 6 files changed, 252 insertions(+), 26 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 112ef28..981201f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -31,6 +31,7 @@
 - Fix so responses menu hides on click in classic skin (#1489915)
 - Fix unintentional line-height style modification in HTML messages (#1489917)
 - Fix broken normalize_string(), add support for ISO-8859-2 (#1489918)
+- Support csv contacts import in German localization (#1489920)
 
 RELEASE 1.0.1
 -------------
diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php
index 2a90f6a..43d73a6 100644
--- a/program/include/rcmail_output_html.php
+++ b/program/include/rcmail_output_html.php
@@ -68,6 +68,7 @@
         $this->set_env('task', $task);
         $this->set_env('x_frame_options', $this->config->get('x_frame_options', 'sameorigin'));
         $this->set_env('standard_windows', (bool) $this->config->get('standard_windows'));
+        $this->set_env('locale', $_SESSION['language']);
 
         // add cookie info
         $this->set_env('cookie_domain', ini_get('session.cookie_domain'));
diff --git a/program/js/app.js b/program/js/app.js
index 670a8e0..670e78b 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -5898,7 +5898,8 @@
     if (!this.gui_objects.subscriptionlist)
       return false;
 
-    var row, n, i, tmp, tmp_name, rowid, folders = [], list = [], slist = [],
+    var row, n, i, tmp, tmp_name, rowid, collator,
+      folders = [], list = [], slist = [],
       tbody = this.gui_objects.subscriptionlist.tBodies[0],
       refrow = $('tr', tbody).get(1),
       id = 'rcmrow'+((new Date).getTime());
@@ -5925,24 +5926,32 @@
     // add to folder/row-ID map
     this.env.subscriptionrows[id] = [name, display_name, false];
 
-    // sort folders (to find a place where to insert the row)
-    // replace delimiter with \0 character to fix sorting
-    // issue where 'Abc Abc' would be placed before 'Abc/def'
-    var replace_from = RegExp(RegExp.escape(this.env.delimiter), 'g'),
-      replace_to = String.fromCharCode(0);
+    // copy folders data to an array for sorting
+    $.each(this.env.subscriptionrows, function(k, v) { folders.push(v); });
 
-    $.each(this.env.subscriptionrows, function(k,v) {
-      if (v.length < 4) {
-        var n = v[0];
-        n = n.replace(replace_from, replace_to);
-        v.push(n);
-      }
-      folders.push(v);
-    });
+    try {
+      // use collator if supported (FF29, IE11, Opera15, Chrome24)
+      collator = new Intl.Collator(this.env.locale.replace('_', '-'));
+    }
+    catch (e) {};
 
+    // sort folders
     folders.sort(function(a, b) {
-      var len = a.length - 1; n1 = a[len], n2 = b[len];
-      return n1 < n2 ? -1 : 1;
+      var i, f1, f2,
+        path1 = a[0].split(ref.env.delimiter),
+        path2 = b[0].split(ref.env.delimiter);
+
+      for (i=0; i<path1.length; i++) {
+        f1 = path1[i];
+        f2 = path2[i];
+
+        if (f1 !== f2) {
+          if (collator)
+            return collator.compare(f1, f2);
+          else
+            return f1 < f2 ? -1 : 1;
+        }
+      }
     });
 
     for (n in folders) {
diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php
index e4b77a0..78073ab 100644
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -4142,19 +4142,15 @@
      */
     public function sort_folder_list($a_folders, $skip_default = false)
     {
-        $delimiter = $this->get_hierarchy_delimiter();
         $specials  = array_merge(array('INBOX'), array_values($this->get_special_folders()));
-        $folders   = array_flip($a_folders);
+        $folders   = array();
 
         // convert names to UTF-8 and skip folders starting with '.'
         foreach ($a_folders as $folder) {
             if ($folder[0] != '.') {
                 // for better performance skip encoding conversion
                 // if the string does not look like UTF7-IMAP
-                $folders[$folder] = strpos($folder, '+') === false ? $folder : rcube_charset::convert($folder, 'UTF7-IMAP');
-            }
-            else {
-                unset($folders[$idx]);
+                $folders[$folder] = strpos($folder, '&') === false ? $folder : rcube_charset::convert($folder, 'UTF7-IMAP');
             }
         }
 
@@ -4175,7 +4171,7 @@
 
         // place default folders on top
         foreach ($specials as $special) {
-            $prefix = $special . $delimiter;
+            $prefix = $special . $this->delimiter;
 
             foreach ($folders as $idx => $folder) {
                 if ($folder === $special) {
@@ -4200,9 +4196,8 @@
      */
     protected function sort_folder_comparator($str1, $str2)
     {
-        $delimiter = $this->get_hierarchy_delimiter();
-        $path1     = explode($delimiter, $str1);
-        $path2     = explode($delimiter, $str2);
+        $path1 = explode($this->delimiter, $str1);
+        $path2 = explode($this->delimiter, $str2);
 
         foreach ($path1 as $idx => $folder1) {
             $folder2 = $path2[$idx];
diff --git a/program/localization/de_CH/csv2vcard.inc b/program/localization/de_CH/csv2vcard.inc
new file mode 100644
index 0000000..c6c2c59
--- /dev/null
+++ b/program/localization/de_CH/csv2vcard.inc
@@ -0,0 +1,110 @@
+<?php
+
+/*
++-----------------------------------------------------------------------+
+| localization/de_CH/csv2vcard.inc                                      |
+|                                                                       |
+| Localization file of the Roundcube Webmail client                     |
+| Copyright (C) 2005-2014, The Roundcube Dev Team                       |
+|                                                                       |
+| Licensed under the GNU General Public License version 3 or            |
+| any later version with exceptions for skins & plugins.                |
+| See the README file for a full license statement.                     |
+|                                                                       |
++-----------------------------------------------------------------------+
+| Author: Aleksander Machniak <alec@alec.pl>                            |
++-----------------------------------------------------------------------+
+*/
+
+// This is a list of CSV column names specified in CSV file header
+// These must be original texts used in Outlook/Thunderbird exported csv files
+// Encoding UTF-8
+
+$map = array();
+
+// MS Outlook 2010
+$map['anniversary'] = "Jahrestag";
+$map['assistants_name'] = "Name Assistent";
+$map['assistants_phone'] = "Telefon Assistent";
+$map['birthday'] = "Geburtstag";
+$map['business_city'] = "Ort geschäftlich";
+$map['business_countryregion'] = "Region geschäftlich";
+$map['business_fax'] = "Fax geschäftlich";
+$map['business_phone'] = "Telefon geschäftlich";
+$map['business_phone_2'] = "Telefon geschäftlich 2";
+$map['business_postal_code'] = "Postleitzahl geschäftlich";
+$map['business_state'] = "Land geschäftlich";
+$map['business_street'] = "Straße geschäftlich";
+$map['car_phone'] = "Autotelefon";
+$map['categories'] = "Kategorien";
+$map['company'] = "Firma";
+$map['department'] = "Abteilung";
+$map['email_address'] = "E-Mail-Adresse";
+$map['first_name'] = "Vorname";
+$map['gender'] = "Geschlecht";
+$map['home_city'] = "Ort privat";
+$map['home_countryregion'] = "Region privat";
+$map['home_fax'] = "Fax privat";
+$map['home_phone'] = "Telefon privat";
+$map['home_phone_2'] = "Telefon privat 2";
+$map['home_postal_code'] = "Postleitzahl privat";
+$map['home_state'] = "Land privat";
+$map['home_street'] = "Straße privat";
+$map['job_title'] = "Position";
+$map['last_name'] = "Nachname";
+$map['managers_name'] = "Manager's Name";
+$map['middle_name'] = "Weitere Vornamen";
+$map['mobile_phone'] = "Mobiltelefon";
+$map['notes'] = "Notizen";
+$map['other_city'] = "Weiterer Ort";
+$map['other_countryregion'] = "Weitere Region";
+$map['other_fax'] = "Weiteres Fax";
+$map['other_phone'] = "Weiteres Telefon";
+$map['other_postal_code'] = "Weitere Postleitzahl";
+$map['other_state'] = "Weiteres Land";
+$map['other_street'] = "Weitere Straße";
+$map['pager'] = "Pager";
+$map['primary_phone'] = "Haupttelefon";
+$map['spouse'] = "Spouse";
+$map['suffix'] = "Suffix";
+$map['title'] = "Title";
+$map['web_page'] = "Webseite";
+
+// Thunderbird
+$map['birth_day'] = "Geburtstag";
+$map['birth_month'] = "Geburtsmonat";
+$map['birth_year'] = "Geburtsjahr";
+$map['display_name'] = "Anzeigename";
+$map['fax_number'] = "Fax-Nummer";
+$map['home_address'] = "Privat: Adresse";
+$map['home_country'] = "Privat: Land";
+$map['home_zipcode'] = "Privat: PLZ";
+$map['mobile_number'] = "Mobil-Tel.-Nr.";
+$map['nickname'] = "Spitzname";
+$map['organization'] = "Organisation";
+$map['pager_number'] = "Pager-Nummer";
+$map['primary_email'] = "Primäre E-Mail-Adresse";
+$map['secondary_email'] = "Sekundäre E-Mail-Adresse";
+$map['web_page_1'] = "Webseite 1";
+$map['web_page_2'] = "Webseite 2";
+$map['work_phone'] = "Tel. dienstlich";
+$map['work_address'] = "Dienstlich: Adresse";
+$map['work_country'] = "Dienstlich: Land";
+$map['work_zipcode'] = "Dienstlich: PLZ";
+
+// Atmail
+$map['date_of_birth'] = "Date of Birth";
+$map['email'] = "Email";
+$map['home_mobile'] = "Home Mobile";
+$map['home_zip'] = "Home Zip";
+$map['info'] = "Info";
+$map['user_photo'] = "User Photo";
+$map['url'] = "URL";
+$map['work_city'] = "Work City";
+$map['work_company'] = "Work Company";
+$map['work_dept'] = "Work Dept";
+$map['work_fax'] = "Work Fax";
+$map['work_mobile'] = "Work Mobile";
+$map['work_state'] = "Work State";
+$map['work_title'] = "Work Title";
+$map['work_zip'] = "Work Zip";
diff --git a/program/localization/de_DE/csv2vcard.inc b/program/localization/de_DE/csv2vcard.inc
new file mode 100644
index 0000000..116349d
--- /dev/null
+++ b/program/localization/de_DE/csv2vcard.inc
@@ -0,0 +1,110 @@
+<?php
+
+/*
++-----------------------------------------------------------------------+
+| localization/de_DE/csv2vcard.inc                                      |
+|                                                                       |
+| Localization file of the Roundcube Webmail client                     |
+| Copyright (C) 2005-2014, The Roundcube Dev Team                       |
+|                                                                       |
+| Licensed under the GNU General Public License version 3 or            |
+| any later version with exceptions for skins & plugins.                |
+| See the README file for a full license statement.                     |
+|                                                                       |
++-----------------------------------------------------------------------+
+| Author: Aleksander Machniak <alec@alec.pl>                            |
++-----------------------------------------------------------------------+
+*/
+
+// This is a list of CSV column names specified in CSV file header
+// These must be original texts used in Outlook/Thunderbird exported csv files
+// Encoding UTF-8
+
+$map = array();
+
+// MS Outlook 2010
+$map['anniversary'] = "Jahrestag";
+$map['assistants_name'] = "Name Assistent";
+$map['assistants_phone'] = "Telefon Assistent";
+$map['birthday'] = "Geburtstag";
+$map['business_city'] = "Ort geschäftlich";
+$map['business_countryregion'] = "Region geschäftlich";
+$map['business_fax'] = "Fax geschäftlich";
+$map['business_phone'] = "Telefon geschäftlich";
+$map['business_phone_2'] = "Telefon geschäftlich 2";
+$map['business_postal_code'] = "Postleitzahl geschäftlich";
+$map['business_state'] = "Land geschäftlich";
+$map['business_street'] = "Straße geschäftlich";
+$map['car_phone'] = "Autotelefon";
+$map['categories'] = "Kategorien";
+$map['company'] = "Firma";
+$map['department'] = "Abteilung";
+$map['email_address'] = "E-Mail-Adresse";
+$map['first_name'] = "Vorname";
+$map['gender'] = "Geschlecht";
+$map['home_city'] = "Ort privat";
+$map['home_countryregion'] = "Region privat";
+$map['home_fax'] = "Fax privat";
+$map['home_phone'] = "Telefon privat";
+$map['home_phone_2'] = "Telefon privat 2";
+$map['home_postal_code'] = "Postleitzahl privat";
+$map['home_state'] = "Land privat";
+$map['home_street'] = "Straße privat";
+$map['job_title'] = "Position";
+$map['last_name'] = "Nachname";
+$map['managers_name'] = "Manager's Name";
+$map['middle_name'] = "Weitere Vornamen";
+$map['mobile_phone'] = "Mobiltelefon";
+$map['notes'] = "Notizen";
+$map['other_city'] = "Weiterer Ort";
+$map['other_countryregion'] = "Weitere Region";
+$map['other_fax'] = "Weiteres Fax";
+$map['other_phone'] = "Weiteres Telefon";
+$map['other_postal_code'] = "Weitere Postleitzahl";
+$map['other_state'] = "Weiteres Land";
+$map['other_street'] = "Weitere Straße";
+$map['pager'] = "Pager";
+$map['primary_phone'] = "Haupttelefon";
+$map['spouse'] = "Spouse";
+$map['suffix'] = "Suffix";
+$map['title'] = "Title";
+$map['web_page'] = "Webseite";
+
+// Thunderbird
+$map['birth_day'] = "Geburtstag";
+$map['birth_month'] = "Geburtsmonat";
+$map['birth_year'] = "Geburtsjahr";
+$map['display_name'] = "Anzeigename";
+$map['fax_number'] = "Fax-Nummer";
+$map['home_address'] = "Privat: Adresse";
+$map['home_country'] = "Privat: Land";
+$map['home_zipcode'] = "Privat: PLZ";
+$map['mobile_number'] = "Mobil-Tel.-Nr.";
+$map['nickname'] = "Spitzname";
+$map['organization'] = "Organisation";
+$map['pager_number'] = "Pager-Nummer";
+$map['primary_email'] = "Primäre E-Mail-Adresse";
+$map['secondary_email'] = "Sekundäre E-Mail-Adresse";
+$map['web_page_1'] = "Webseite 1";
+$map['web_page_2'] = "Webseite 2";
+$map['work_phone'] = "Tel. dienstlich";
+$map['work_address'] = "Dienstlich: Adresse";
+$map['work_country'] = "Dienstlich: Land";
+$map['work_zipcode'] = "Dienstlich: PLZ";
+
+// Atmail
+$map['date_of_birth'] = "Date of Birth";
+$map['email'] = "Email";
+$map['home_mobile'] = "Home Mobile";
+$map['home_zip'] = "Home Zip";
+$map['info'] = "Info";
+$map['user_photo'] = "User Photo";
+$map['url'] = "URL";
+$map['work_city'] = "Work City";
+$map['work_company'] = "Work Company";
+$map['work_dept'] = "Work Dept";
+$map['work_fax'] = "Work Fax";
+$map['work_mobile'] = "Work Mobile";
+$map['work_state'] = "Work State";
+$map['work_title'] = "Work Title";
+$map['work_zip'] = "Work Zip";

--
Gitblit v1.9.1