roundcubemail/program/lib/Roundcube/rcube_csv2vcard.php
protected function parse_header($elements)
    {
        $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])) {
                $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]];

                // special localization label
                if ($label && $label[0] == '_') {
                    $label = substr($label, 1);
                }

                if ($label && !empty($this->csv2vcard_map[$label])) {
                    $map2[$i] = $this->csv2vcard_map[$label];
                }
            }
        }

        $this->map = count($map1) >= count($map2) ? $map1 : $map2;

        // support special Gmail format
        foreach ($this->gmail_label_map as $key => $items) {
            $num = 1;
            while (($_key = "$key $num - Type") && ($found = array_search($_key, $elements)) !== false) {
                $this->gmail_map["$key:$num"] = array('_key' => $key, '_idx' => $found);
                foreach (array_keys($items) as $item_key) {
                    $_key = "$key $num - $item_key";
                    if (($found = array_search($_key, $elements)) !== false) {
                        $this->gmail_map["$key:$num"][$item_key] = $found;
                    }
                }

                $num++;
            }
        }
    }
protected function parse_header($elements)
    {
        $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])) {
                $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]];

                // special localization label
                if ($label && $label[0] == '_') {
                    $label = substr($label, 1);
                }

                if ($label && !empty($this->csv2vcard_map[$label])) {
                    $map2[$i] = $this->csv2vcard_map[$label];
                }
            }
        }

        $this->map = count($map1) >= count($map2) ? $map1 : $map2;

        // support special Gmail format
        foreach ($this->gmail_label_map as $key => $items) {
            $num = 1;
            while (($_key = "$key $num - Type") && ($found = array_search($_key, $elements)) !== false) {
                $this->gmail_map["$key:$num"] = array('_key' => $key, '_idx' => $found);
                foreach (array_keys($items) as $item_key) {
                    $_key = "$key $num - $item_key";
                    if (($found = array_search($_key, $elements)) !== false) {
                        $this->gmail_map["$key:$num"][$item_key] = $found;
                    }
                }

                $num++;
            }
        }
    }
protected function parse_header ( $ elements ) { $ 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 ] ) ) { $ 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 ] ] ; // special localization label if ( $ label && $ label [ 0 ] == '_' ) { $ label = substr ( $ label , 1 ) ; } if ( $ label && ! empty ( $ this -> csv2vcard_map [ $ label ] ) ) { $ map2 [ $ i ] = $ this -> csv2vcard_map [ $ label ] ; } } } $ this -> map = count ( $ map1 ) >= count ( $ map2 ) ? $ map1 : $ map2 ; // support special Gmail format foreach ( $ this -> gmail_label_map as $ key => $ items ) { $ num = 1 ; while ( ( $ _key = "$key $num - Type" ) && ( $ found = array_search ( $ _key , $ elements ) ) !== false ) { $ this -> gmail_map [ "$key:$num" ] = array ( '_key' => $ key , '_idx' => $ found ) ; foreach ( array_keys ( $ items ) as $ item_key ) { $ _key = "$key $num - $item_key" ; if ( ( $ found = array_search ( $ _key , $ elements ) ) !== false ) { $ this -> gmail_map [ "$key:$num" ] [ $ item_key ] = $ found ; } } $ num ++ ; } } }
Parse CSV header line, detect fields mapping
Parse CSV header line detect fields mapping