| | |
| | | //'business_street_2' => '', |
| | | //'business_street_3' => '', |
| | | 'car_phone' => 'phone:car', |
| | | 'categories' => 'categories', |
| | | 'categories' => 'groups', |
| | | //'children' => '', |
| | | 'company' => 'organization', |
| | | //'company_main_phone' => '', |
| | |
| | | //'email_2_type' => '', |
| | | //'email_3_address' => '', //@TODO |
| | | //'email_3_type' => '', |
| | | 'email_address' => 'email:main', |
| | | 'email_address' => 'email:pref', |
| | | //'email_type' => '', |
| | | 'first_name' => 'firstname', |
| | | 'gender' => 'gender', |
| | |
| | | 'work_mobile' => 'phone:work,cell', |
| | | 'work_title' => 'jobtitle', |
| | | 'work_zip' => 'zipcode:work', |
| | | 'group' => 'groups', |
| | | |
| | | // GMail |
| | | 'groups' => 'groups', |
| | | ); |
| | | |
| | | /** |
| | |
| | | 'work_mobile' => "Work Mobile", |
| | | 'work_title' => "Work Title", |
| | | 'work_zip' => "Work Zip", |
| | | 'groups' => "Group", |
| | | ); |
| | | |
| | | protected $local_label_map = array(); |
| | |
| | | { |
| | | // convert to UTF-8 |
| | | $head = substr($csv, 0, 4096); |
| | | $fallback = rcube::get_instance()->config->get('default_charset', 'ISO-8859-1'); // fallback to Latin-1? |
| | | $charset = rcube_charset::detect($head, RCUBE_CHARSET); |
| | | $csv = rcube_charset::convert($csv, $charset); |
| | | $head = ''; |
| | |
| | | $this->map = array(); |
| | | |
| | | // Parse file |
| | | foreach (preg_split("/[\r\n]+/", $csv) as $i => $line) { |
| | | foreach (preg_split("/[\r\n]+/", $csv) as $line) { |
| | | $elements = $this->parse_line($line); |
| | | if (empty($elements)) { |
| | | continue; |
| | |
| | | if (!empty($this->local_label_map)) { |
| | | for ($i = 0; $i < $size; $i++) { |
| | | $label = $this->local_label_map[$elements[$i]]; |
| | | |
| | | // special localization label |
| | | if ($label && $label[0] == '_') { |
| | | $label = substr($label, 1); |
| | | } |
| | | |
| | | if ($label && !empty($this->csv2vcard_map[$label])) { |
| | | $map2[$i] = $this->csv2vcard_map[$label]; |
| | | } |
| | |
| | | $contact['birthday'] = $contact['birthday-y'] .'-' .$contact['birthday-m'] . '-' . $contact['birthday-d']; |
| | | } |
| | | |
| | | // categories/groups separator in vCard is ',' not ';' |
| | | if (!empty($contact['groups'])) { |
| | | $contact['groups'] = str_replace(';', ',', $contact['groups']); |
| | | } |
| | | |
| | | // Empty dates, e.g. "0/0/00", "0000-00-00 00:00:00" |
| | | foreach (array('birthday', 'anniversary') as $key) { |
| | | if (!empty($contact[$key])) { |