Skip to content

Commit

Permalink
csv2vard: store labels by key not value
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoh committed Mar 23, 2024
1 parent b1596b7 commit 3980196
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions program/lib/Roundcube/rcube_csv2vcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,6 @@ public function __construct($lang = 'en_US')
$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);
}

/**
Expand Down Expand Up @@ -481,7 +478,6 @@ public function get_fields()
// get all vcard fields
$fields = array_unique($this->csv2vcard_map);
$local_field_names = $this->local_label_map ?: $this->label_map;
$local_field_names = array_flip($local_field_names);

// translate with the local map
$map = [];
Expand Down Expand Up @@ -539,6 +535,9 @@ protected function parse_header($lines)
{
$elements = $this->parse_line($lines[0]);

$label_map = array_flip($this->label_map);
$local_label_map = array_flip($this->local_label_map);

if (count($lines) == 2) {
// first line of contents needed to properly identify fields in gmail CSV
$contents = $this->parse_line($lines[1]);
Expand All @@ -550,18 +549,18 @@ protected function parse_header($lines)

// check English labels
for ($i = 0; $i < $size; $i++) {
if (!empty($this->label_map[$elements[$i]])) {
$label = $this->label_map[$elements[$i]];
if (!empty($label_map[$elements[$i]])) {
$label = $label_map[$elements[$i]];
if ($label && !empty($this->csv2vcard_map[$label])) {
$map1[$i] = $this->csv2vcard_map[$label];
}
}
}

// check localized labels
if (!empty($this->local_label_map)) {
if (!empty($local_label_map)) {
for ($i = 0; $i < $size; $i++) {
$label = $this->local_label_map[$elements[$i]];
$label = $local_label_map[$elements[$i]];

// special localization label
if ($label && $label[0] == '_') {
Expand Down

0 comments on commit 3980196

Please sign in to comment.