| | |
| | | 'spouse' => 'X-SPOUSE', |
| | | 'edit' => 'X-AB-EDIT', |
| | | ); |
| | | private $typemap = array('iPhone' => 'mobile', 'CELL' => 'mobile'); |
| | | private $phonetypemap = array('HOME1' => 'HOME', 'BUSINESS1' => 'WORK', 'BUSINESS2' => 'WORK2', 'BUSINESSFAX' => 'WORKFAX'); |
| | | private $typemap = array('iPhone' => 'mobile', 'CELL' => 'mobile', 'WORK,FAX' => 'workfax'); |
| | | private $phonetypemap = array('HOME1' => 'HOME', 'BUSINESS1' => 'WORK', 'BUSINESS2' => 'WORK2', 'BUSINESSFAX' => 'WORK,FAX', 'WORKFAX' => 'WORK,FAX'); |
| | | private $addresstypemap = array('BUSINESS' => 'WORK'); |
| | | private $immap = array('X-JABBER' => 'jabber', 'X-ICQ' => 'icq', 'X-MSN' => 'msn', 'X-AIM' => 'aim', 'X-YAHOO' => 'yahoo', 'X-SKYPE' => 'skype', 'X-SKYPE-USERNAME' => 'skype'); |
| | | |
| | |
| | | $subtype = ''; |
| | | |
| | | if (!empty($raw['type'])) { |
| | | $subtype = $typemap[$raw['type'][++$k]] ? $typemap[$raw['type'][$k]] : strtolower($raw['type'][$k]); |
| | | $combined = join(',', self::array_filter((array)$raw['type'], 'internet,pref', true)); |
| | | $subtype = $typemap[$combined] ? $typemap[$combined] : ($typemap[$raw['type'][++$k]] ? $typemap[$raw['type'][$k]] : strtolower($raw['type'][$k])); |
| | | while ($k < count($raw['type']) && ($subtype == 'internet' || $subtype == 'pref')) |
| | | $subtype = $typemap[$raw['type'][++$k]] ? $typemap[$raw['type'][$k]] : strtolower($raw['type'][$k]); |
| | | } |
| | |
| | | $index = count($this->raw[$tag]); |
| | | $this->raw[$tag][$index] = (array)$value; |
| | | if ($type) |
| | | $this->raw[$tag][$index]['type'] = array(($typemap[$type] ? $typemap[$type] : $type)); |
| | | $this->raw[$tag][$index]['type'] = explode(',', ($typemap[$type] ? $typemap[$type] : $type)); |
| | | } |
| | | break; |
| | | } |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * Extract array values by a filter |
| | | * |
| | | * @param array Array to filter |
| | | * @param keys Array or comma separated list of values to keep |
| | | * @param boolean Invert key selection: remove the listed values |
| | | * @return array The filtered array |
| | | */ |
| | | private static function array_filter($arr, $values, $inverse = false) |
| | | { |
| | | if (!is_array($values)) |
| | | $values = explode(',', $values); |
| | | |
| | | $result = array(); |
| | | $keep = array_flip((array)$values); |
| | | foreach ($arr as $key => $val) |
| | | if ($inverse != isset($keep[strtolower($val)])) |
| | | $result[$key] = $val; |
| | | |
| | | return $result; |
| | | } |
| | | |
| | | /** |
| | | * Returns UNICODE type based on BOM (Byte Order Mark) |