Changeset 4297 in subversion


Ignore:
Timestamp:
Dec 1, 2010 1:04:23 PM (2 years ago)
Author:
thomasb
Message:

Render contact data groups as fieldsets w. legend; show vcard photos in UI (not yet editable)

Location:
branches/devel-addressbook
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-addressbook/index.php

    r4088 r4297  
    213213  'addressbook' => array( 
    214214    'add' => 'edit.inc', 
     215    'photo' => 'show.inc', 
    215216    'group-create' => 'groups.inc', 
    216217    'group-rename' => 'groups.inc', 
  • branches/devel-addressbook/program/include/html.php

    r4239 r4297  
    7272    public static function tag($tagname, $attrib = array(), $content = null, $allowed_attrib = null) 
    7373    { 
     74        if (is_string($attrib)) 
     75            $attrib = array('class' => $attrib); 
     76 
    7477        $inline_tags = array('a','span','img'); 
    7578        $suffix = $attrib['nl'] || ($content && $attrib['nl'] !== false && !in_array($tagname, $inline_tags)) ? "\n" : ''; 
  • branches/devel-addressbook/program/include/rcube_browser.php

    r3989 r4297  
    6969        $this->pngalpha = $this->mz || $this->safari || ($this->ie && $this->ver>=5.5) || 
    7070            ($this->ie && $this->ver>=5 && $this->mac) || ($this->opera && $this->ver>=7) ? true : false; 
     71        $this->imgdata = !$this->ie; 
    7172    } 
    7273} 
  • branches/devel-addressbook/program/include/rcube_contacts.php

    r4271 r4297  
    5757    public $coltypes = array('name', 'firstname', 'surname', 'middlename', 'prefix', 'suffix', 'nickname', 
    5858      'jobtitle', 'organization', 'department', 'gender', 'maidenname', 'email', 'phone', 'address', 
    59       'birthday', 'website', 'im', 'notes'); 
     59      'birthday', 'website', 'im', 'notes', 'photo'); 
    6060 
    6161 
  • branches/devel-addressbook/program/include/rcube_vcard.php

    r4289 r4297  
    3333    'N' => array(array('','','','','')), 
    3434  ); 
    35   private $fieldmap = array('phone' => 'TEL', 'birthday' => 'BDAY', 'website' => 'URL', 'notes' => 'NOTE', 'email' => 'EMAIL', 'address' => 'ADR', 'gender' => 'X-GENDER', 'maidenname' => 'X-MAIDENNAME', 'gender' => 'X-GENDER'); 
     35  private $fieldmap = array('photo' => 'PHOTO', 'phone' => 'TEL', 'birthday' => 'BDAY', 'website' => 'URL', 'notes' => 'NOTE', 'email' => 'EMAIL', 'address' => 'ADR', 'gender' => 'X-GENDER', 'maidenname' => 'X-MAIDENNAME', 'gender' => 'X-GENDER'); 
    3636  private $typemap = array('iPhone' => 'mobile', 'CELL' => 'mobile'); 
    3737  private $phonetypemap = array('HOME1' => 'HOME', 'BUSINESS1' => 'WORK', 'BUSINESS2' => 'WORK2', 'WORKFAX' => 'BUSINESSFAX'); 
  • branches/devel-addressbook/program/js/app.js

    r4265 r4297  
    324324          for (var col in this.env.coltypes) 
    325325            this.init_edit_field(col, null); 
     326             
     327          $('#contactpicframe').click(function(){ ref.upload_contact_photo(this); return false; }); 
    326328 
    327329          $('.contactfieldgroup .row a.deletebutton').click(function(){ ref.delete_edit_field(this); return false }); 
     
    40054007       
    40064008      if (!appendcontainer.length) 
    4007         appendcontainer = $('<div>').addClass('contactfieldgroup contactcontroller'+col).insertAfter($('#contactsection'+section+' .contactfieldgroup').last()); 
    4008  
    4009       if (appendcontainer.length && appendcontainer.get(0).nodeName == 'DIV') { 
     4009        appendcontainer = $('<fieldset>').addClass('contactfieldgroup contactcontroller'+col).insertAfter($('#contactsection'+section+' .contactfieldgroup').last()); 
     4010 
     4011      if (appendcontainer.length && appendcontainer.get(0).nodeName == 'FIELDSET') { 
    40104012        var input, colprop = this.env.coltypes[col], 
    40114013          row = $('<div>').addClass('row'), 
     
    40664068            .appendTo(cell); 
    40674069           
    4068           row.append(label).append(cell).appendTo(appendcontainer); 
     4070          row.append(label).append(cell).appendTo(appendcontainer.show()); 
    40694071          input.first().focus(); 
    40704072           
     
    40784080  }; 
    40794081 
    4080   this.delete_edit_field = function(elem){ 
     4082  this.delete_edit_field = function(elem) 
     4083  { 
    40814084    var col = $(elem).attr('rel'), 
    40824085      colprop = this.env.coltypes[col], 
     
    41024105 
    41034106 
     4107  this.upload_contact_photo = function(frame) 
     4108  { 
     4109    // TODO: implement this 
     4110  }; 
     4111 
     4112 
    41044113  /*********************************************************/ 
    41054114  /*********        user settings methods          *********/ 
  • branches/devel-addressbook/program/steps/addressbook/export.inc

    r4265 r4297  
    3131 
    3232while ($result && ($row = $result->next())) { 
     33  // we already have a vcard record 
     34  if ($row['vcard']) { 
     35    echo $row['vcard']; 
     36  } 
    3337  // copy values into vcard object 
    34   $vcard = new rcube_vcard($row['vcard']); 
    35   $vcard->reset(); 
    36   foreach ($row as $key => $values) { 
     38  else { 
     39    $vcard = new rcube_vcard($row['vcard']); 
     40    $vcard->reset(); 
     41    foreach ($row as $key => $values) { 
    3742      list($field, $section) = explode(':', $key); 
    3843      foreach ((array)$values as $value) { 
    39           if (is_array($value) || strlen($value)) 
    40               $vcard->set($field, $value, strtoupper($section)); 
     44        if (is_array($value) || strlen($value)) 
     45          $vcard->set($field, $value, strtoupper($section)); 
    4146      } 
     47    } 
     48     
     49    echo $vcard->export(); 
    4250  } 
    43    
    44   echo $vcard->export(); 
    4551} 
    4652 
  • branches/devel-addressbook/program/steps/addressbook/func.inc

    r4289 r4297  
    8484  'im'           => array('type' => 'text', 'size' => 40, 'label' => rcube_label('instantmessenger'), 'subtypes' => array('aim','icq','msn','yahoo','jabber','other')), 
    8585  'notes'        => array('type' => 'textarea', 'size' => 40, 'rows' => 15, 'label' => rcube_label('notes'), 'limit' => 1), 
     86  'photo'        => array('type' => 'image', 'limit' => 1), 
    8687  // TODO: define fields for vcards GEO, PHOTO, KEY, X-ANNIVERSARY, X-ASSISTANT, X-MANAGER 
    8788); 
     
    288289    $record = $plugin['record']; 
    289290    $formdata = array(); 
     291    $edit_mode = $RCMAIL->action != 'show'; 
     292    $pic_img = $attrib['picplaceholder'] ? $CONFIG['skin_path'] . $attrib['picplaceholder'] : 'program/blank.gif'; 
    290293    $del_button = $attrib['deleteicon'] ? html::img(array('src' => $CONFIG['skin_path'] . $attrib['deleteicon'], 'alt' => rcube_label('delete'))) : rcube_label('delete'); 
    291     $edit_mode = $RCMAIL->action != 'show'; 
     294    unset($attrib['picplaceholder'], $attrib['deleteicon']); 
    292295    $out = ''; 
    293296     
     
    319322        if ($section == 'head') { 
    320323            $content = ''; 
     324             
     325            if ($coltypes['photo']) { 
     326                if ($record['photo']) 
     327                    $pic_img = $browser->imgdata ? 'data:image/jpeg;base64,' . $data : $RCMAIL->url(array('_action' => 'photo', '_cid' => $record['ID'], '_source' => $_REQUEST['_source'])); 
     328                $img = html::img(array('src' => $pic_img, 'border' => 1, 'alt' => '')); 
     329                if ($edit_mode) { 
     330                    $label = $record['photo'] ? rcube_label('replacephoto') : rcube_label('addphoto'); 
     331                    $img = html::a(array('href' => '#', 'id' => 'contactpicframe', 'title' => $label), $img); 
     332                } 
     333                $content .= html::div('contactpic', $img); 
     334            } 
    321335             
    322336            $names_arr = array($record['prefix'], $record['firstname'], $record['middlename'], $record['surname'], $record['suffix']); 
     
    492506                 
    493507                // wrap rows in fieldgroup container 
    494                 $content .= html::div('contactfieldgroup contactcontroller' . $col, $rows); 
     508                $content .= html::tag('fieldset', array('class' => 'contactfieldgroup contactcontroller' . $col, 'style' => ($rows ? null : 'display:none')), 
     509                  ($colprop['subtypes'] ? html::tag('legend', null, Q($colprop['label'])) : ' ') . 
     510                  $rows); 
    495511            } 
    496512 
  • branches/devel-addressbook/program/steps/addressbook/show.inc

    r4242 r4297  
    2424if (($cid = get_input_value('_cid', RCUBE_INPUT_GPC)) && ($record = $CONTACTS->get_record($cid, true))) { 
    2525    $OUTPUT->set_env('cid', $record['ID']); 
     26} 
     27 
     28// return raw photo of the given contact 
     29if ($RCMAIL->action == 'photo') { 
     30    if ($record['photo']) { 
     31        // assume image/jpg base64 encoded 
     32        $data = base64_decode(is_array($record['photo']) ? $record['photo'][0] : $record['photo'], true); 
     33    } 
     34     
     35    header('Content-Type: image/jpeg'); 
     36    echo $data ? $data : file_get_contents('program/blank.gif'); 
     37    exit; 
    2638} 
    2739 
  • branches/devel-addressbook/skins/default/addressbook.css

    r4268 r4297  
    270270} 
    271271 
    272  
    273272#contacthead .addnames input.ff_name 
    274273{ 
     
    276275} 
    277276 
    278 .contactfieldgroup 
    279 { 
    280         margin: 1em 0; 
    281 } 
    282  
    283 form .contactfieldgroup 
    284 { 
    285         margin: 1.3em 0; 
     277#contacthead .contactpic 
     278{ 
     279        float: right; 
     280        width: 50px; 
     281        height: 50px; 
     282        border: 1px solid #ccc; 
     283        background: white; 
     284        margin-left: 3em; 
     285} 
     286 
     287fieldset.contactfieldgroup 
     288{ 
     289        border: 0; 
     290        margin: 0.5em 0; 
     291        padding: 0.5em 2px; 
     292} 
     293 
     294fieldset.contactfieldgroup legend 
     295{ 
     296        font-size: 0.8em; 
    286297} 
    287298 
     
    317328.contactfieldgroup .contactfieldcontent 
    318329{ 
    319         margin-left: 90px; 
     330        padding-left: 90px; 
    320331        min-height: 1em; 
    321332} 
    322333 
    323334.contactcontrolleraddress .contactfieldcontent { 
    324         width: 40em; 
     335        width: 30em; 
    325336} 
    326337 
  • branches/devel-addressbook/skins/default/functions.js

    r4070 r4297  
    2626function rcube_init_tabs(id, current) 
    2727{ 
    28   var content = document.getElementById(id), 
    29     fs = $('fieldset', content); 
     28  var content = $('#'+id), 
     29    fs = content.children('fieldset'); 
    3030 
    3131  current = current ? current : 0; 
     
    3939  // convert fildsets into tabs 
    4040  fs.each(function(idx) { 
    41     var tab, a, elm = $(this), legend = $('legend', elm); 
     41    var tab, a, elm = $(this), legend = elm.children('legend'); 
    4242 
    4343    // create a tab 
     
    6161function rcube_show_tab(id, index) 
    6262{ 
    63   var content = document.getElementById(id), 
    64     fs = $('fieldset', content); 
     63  var fs = $('#'+id).children('fieldset'); 
    6564 
    6665  fs.each(function(idx) { 
  • branches/devel-addressbook/skins/default/iehacks.css

    r3813 r4297  
    241241  margin-top: 2px; 
    242242} 
     243 
     244.contactfieldgroup legend 
     245{ 
     246        padding: 0 0 0.5em 0; 
     247        margin-left: -4px; 
     248} 
  • branches/devel-addressbook/skins/default/templates/contact.html

    r4227 r4297  
    1010<div id="contact-title" class="boxtitle"><roundcube:label name="contactproperties" /></div> 
    1111<div id="contact-details" class="boxcontent"> 
    12   <roundcube:object name="contacthead" id="contacthead" /> 
     12  <roundcube:object name="contacthead" id="contacthead" picPlaceholder="/images/contactpic.png" /> 
    1313  <div id="contacttabs"> 
    1414    <roundcube:object name="contactdetails" /> 
  • branches/devel-addressbook/skins/default/templates/contactadd.html

    r4239 r4297  
    1111<div id="contact-details" class="boxcontent"> 
    1212<form name="editform" method="post" action="./"> 
    13   <roundcube:object name="contactedithead" id="contacthead" size="16" form="editform" /> 
     13  <roundcube:object name="contactedithead" id="contacthead" size="16" form="editform" picPlaceholder="/images/contactpic.png" /> 
    1414  <div id="contacttabs"> 
    1515    <roundcube:object name="contacteditform" size="40" textareacols="60" deleteIcon="/images/icons/delete.png" form="editform" /> 
  • branches/devel-addressbook/skins/default/templates/contactedit.html

    r4239 r4297  
    1111<div id="contact-details" class="boxcontent"> 
    1212<form name="editform" method="post" action="./"> 
    13   <roundcube:object name="contactedithead" id="contacthead" size="16" form="editform" /> 
     13  <roundcube:object name="contactedithead" id="contacthead" size="16" form="editform" picPlaceholder="/images/contactpic.png" /> 
    1414  <div id="contacttabs"> 
    1515    <roundcube:object name="contacteditform" size="40" textareacols="60" deleteIcon="/images/icons/delete.png" form="editform" /> 
Note: See TracChangeset for help on using the changeset viewer.