summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-11-17 09:04:45 +0100
committerAleksander Machniak <alec@alec.pl>2012-11-17 09:04:45 +0100
commit92bd3a7c3f60e56ec5055c96e7b2f25637d4b0ca (patch)
tree37a68f9207da19694ea7cfbc39be24ab870e9a7a /program/include
parent98128f13fcdc8dca6ebefcdc93dc94b00322abb5 (diff)
Fix parsing header in English when localized map is defined
Diffstat (limited to 'program/include')
-rw-r--r--program/include/rcube_csv2vcard.php28
1 files changed, 23 insertions, 5 deletions
diff --git a/program/include/rcube_csv2vcard.php b/program/include/rcube_csv2vcard.php
index bde8198ba..6ec2158be 100644
--- a/program/include/rcube_csv2vcard.php
+++ b/program/include/rcube_csv2vcard.php
@@ -229,8 +229,9 @@ class rcube_csv2vcard
'work_zipcode' => "Work ZipCode",
);
+ protected $local_label_map = array();
protected $vcards = array();
- protected $map = array();
+ protected $map = array();
/**
@@ -247,11 +248,12 @@ class rcube_csv2vcard
}
if (!empty($map)) {
- $this->label_map = array_merge($this->label_map, $map);
+ $this->local_label_map = array_merge($this->label_map, $map);
}
}
$this->label_map = array_flip($this->label_map);
+ $this->local_label_map = array_flip($this->local_label_map);
}
/**
@@ -307,13 +309,29 @@ class rcube_csv2vcard
* Parse CSV header line, detect fields mapping
*/
protected function parse_header($elements)
- {
- for ($i = 0, $size = count($elements); $i<$size; $i++) {
+ {
+ $map1 = array();
+ $map2 = array();
+ $size = count($elements);
+
+ // check English labels
+ for ($i = 0; $i < $size; $i++) {
$label = $this->label_map[$elements[$i]];
if ($label && !empty($this->csv2vcard_map[$label])) {
- $this->map[$i] = $this->csv2vcard_map[$label];
+ $map1[$i] = $this->csv2vcard_map[$label];
+ }
+ }
+ // check localized labels
+ if (!empty($this->local_label_map)) {
+ for ($i = 0; $i < $size; $i++) {
+ $label = $this->local_label_map[$elements[$i]];
+ if ($label && !empty($this->csv2vcard_map[$label])) {
+ $map2[$i] = $this->csv2vcard_map[$label];
+ }
}
}
+
+ $this->map = count($map1) >= count($map2) ? $map1 : $map2;
}
/**