Changeset 4231 in subversion


Ignore:
Timestamp:
Nov 17, 2010 8:35:58 AM (3 years ago)
Author:
thomasb
Message:

Improve vcard field name assignments

Location:
branches/devel-addressbook
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-addressbook/program/include/rcube_contacts.php

    r4230 r4231  
    483483        if ($sql_arr['vcard']) { 
    484484          $vcard = new rcube_vcard($sql_arr['vcard']); 
    485           $record += $vcard->get_assoc(); 
     485          $record += $vcard->get_assoc() + $sql_arr; 
    486486        } 
    487487        else 
  • branches/devel-addressbook/program/include/rcube_vcard.php

    r4230 r4231  
    3434  ); 
    3535  private $fieldmap = array('phone' => 'TEL', 'birthday' => 'BDAY', 'website' => 'URL', 'notes' => 'NOTE', 'email' => 'EMAIL', 'address' => 'ADR'); 
     36  private $typemap = array('iPhone' => 'mobile', 'CELL' => 'mobile'); 
    3637 
    3738  public $business = false; 
     
    106107  { 
    107108    $out = array('name' => $this->displayname); 
    108      
     109    $typemap = $this->typemap; 
     110     
     111    // copy name fields to output array 
    109112    foreach (array('firstname','surname','middlename','nickname','organization') as $col) 
    110113      $out[$col] = $this->$col; 
    111114     
     115    // convert from raw vcard data into associative data for Roundcube 
    112116    foreach (array_flip($this->fieldmap) as $tag => $col) { 
    113117      foreach ((array)$this->raw[$tag] as $i => $raw) { 
    114118        if (is_array($raw)) { 
    115           $k = 0; 
     119          $k = -1; 
    116120          $key = $col; 
    117           $subtype = strtolower($raw['type'][$k++]); 
     121          $subtype = $typemap[$raw['type'][++$k]] ?: strtolower($raw['type'][$k]); 
    118122          while ($k < count($raw['type']) && ($subtype == 'internet' || $subtype == 'pref')) 
    119             $subtype = strtolower($raw['type'][$k++]); 
     123            $subtype = $typemap[$raw['type'][++$k]] ?: strtolower($raw['type'][$k]); 
    120124          if ($subtype) 
    121125            $key .= ':' . $subtype; 
    122              
     126 
     127          // split ADR values into assoc array 
    123128          if ($tag == 'ADR') { 
    124129            list(,, $value['street'], $value['locality'], $value['region'], $value['zipcode'], $value['country']) = $raw; 
     
    134139    } 
    135140     
     141    // handle special IM fields as used by Apple 
     142    foreach (array('X-JABBER' => 'jabber', 'X-ICQ' => 'icq', 'X-MSN' => 'msn', 'X-AIM' => 'aim', 'X-YAHOO' => 'yahoo') as $tag => $type) { 
     143      foreach ((array)$this->raw[$tag] as $i => $raw) { 
     144        $out['im:'.$type][] = $raw[0]; 
     145      } 
     146    } 
     147     
    136148    return $out; 
    137149  } 
     
    152164   * @param string Field name 
    153165   * @param string Field value 
    154    * @param string Section name 
    155    */ 
    156   public function set($field, $value, $section = 'HOME') 
     166   * @param string Type/section name 
     167   */ 
     168  public function set($field, $value, $type = 'HOME') 
    157169  { 
    158170    static $touched = array(); 
     171    $typemap = array_flip($this->typemap); 
    159172     
    160173    switch ($field) { 
     
    184197          $this->raw['EMAIL'] = array(); 
    185198        $index = count($this->raw['EMAIL']); 
    186         $this->raw['EMAIL'][$index] = array(0 => $value, 'type' => array_filter(array('INTERNET', $section))); 
     199        $this->raw['EMAIL'][$index] = array(0 => $value, 'type' => array_filter(array('INTERNET', $type))); 
    187200        break; 
    188201 
     
    197210          $index = count($this->raw[$tag]); 
    198211          $this->raw[$tag][$index] = (array)$value; 
    199           if ($section) 
    200             $this->raw[$tag][$index]['type'] = array($section); 
     212          if ($type) 
     213            $this->raw[$tag][$index]['type'] = array(($typemap[$type] ?: $type)); 
    201214        } 
    202215        break; 
  • branches/devel-addressbook/program/steps/addressbook/func.inc

    r4230 r4231  
    311311                    if ($RCMAIL->action == 'show') { 
    312312                        if (!empty($record[$col])) 
    313                             $fields .= html::span('namefield', Q($record[$col])) . " "; 
     313                            $fields .= html::span('namefield ' . $col, Q($record[$col])) . " "; 
    314314                    } 
    315315                    else { 
  • branches/devel-addressbook/program/steps/addressbook/show.inc

    r4230 r4231  
    7474              'address' => array(), 
    7575              'birthday' => array('size' => $i_size), 
    76               'website' => array('size' => $i_size), 
     76              'website' => array('size' => $i_size, 'value' => array()), 
    7777              'im' => array('size' => $i_size), 
    7878            ), 
     
    8989        ), 
    9090    ); 
    91      
     91/* FIXME: this destroys subtype assignments 
    9292    foreach ((array)$record as $field => $values) { 
    9393        if (strpos($field, 'email') === 0) { 
     
    101101            } 
    102102        } 
     103        else if (strpos($field, 'website') === 0) { 
     104            foreach ((array)$values as $url) { 
     105                $prefix = preg_match('![htfps]+://!', $url) ? '' : 'http://'; 
     106                $form['info']['content']['website']['value'][] = html::a(array( 
     107                    'href' => $prefix . $url, 
     108                    'target' => '_blank', 
     109                    'class' => 'url', 
     110                ), Q($url)); 
     111            } 
     112        } 
    103113    } 
    104  
     114*/ 
    105115    return rcmail_contact_form($form, $record); 
    106116} 
  • branches/devel-addressbook/skins/default/addressbook.css

    r4230 r4231  
    239239} 
    240240 
    241 #contacthead span.namefield, 
     241#contacthead .names span.namefield, 
    242242#contacthead input.ff_firstname, 
    243243#contacthead input.ff_surname, 
     
    245245{ 
    246246        font-size: 140%; 
     247} 
     248 
     249#contacthead span.nickname:before, 
     250#contacthead span.nickname:after 
     251{ 
     252        content: '"'; 
    247253} 
    248254 
Note: See TracChangeset for help on using the changeset viewer.