Ignore:
Timestamp:
Jul 29, 2008 8:32:19 AM (5 years ago)
Author:
thomasb
Message:

Add microformats to address book + fix html output + codestyle

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/steps/addressbook/show.inc

    r543 r1615  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 | 
     8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    2222 
    2323// read contact record 
    24 if (($cid = get_input_value('_cid', RCUBE_INPUT_GPC)) && ($record = $CONTACTS->get_record($cid, true))) 
     24if (($cid = get_input_value('_cid', RCUBE_INPUT_GPC)) && ($record = $CONTACTS->get_record($cid, true))) { 
    2525  $OUTPUT->set_env('cid', $record['ID']); 
    26  
     26} 
    2727 
    2828function rcmail_contact_details($attrib) 
    29   { 
     29{ 
    3030  global $CONTACTS, $OUTPUT; 
    3131 
    3232  // check if we have a valid result 
    33   if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) 
    34   { 
     33  if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) { 
    3534    $OUTPUT->show_message('contactnotfound'); 
    3635    return false; 
     
    3837   
    3938  // a specific part is requested 
    40   if ($attrib['part']) 
     39  if ($attrib['part']) { 
    4140    return Q($record[$attrib['part']]); 
     41  } 
    4242 
    4343  // return the complete address record as table 
    44   $out = "<table>\n\n"; 
     44  $table = new html_table(array('cols' => 2)); 
    4545 
    4646  $a_show_cols = array('name', 'firstname', 'surname', 'email'); 
    47   foreach ($a_show_cols as $col) 
    48     { 
    49     if ($col=='email' && !empty($record[$col])) 
    50       $value = sprintf( 
    51         '<a href="#compose" onclick="%s.command(\'compose\', \'%s\')" title="%s">%s</a>', 
    52         JS_OBJECT_NAME, 
    53         JQ($record[$col]), 
    54         rcube_label('composeto'), 
    55         Q($record[$col])); 
     47  $microformats = array('name' => 'fn', 'email' => 'email'); 
     48 
     49  foreach ($a_show_cols as $col) { 
     50    if ($col == 'email' && !empty($record[$col])) { 
     51      $value = html::a(array( 
     52        'href' => 'mailto:' . $record[$col], 
     53        'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ($record[$col])), 
     54        'title' => rcube_label('composeto'), 
     55        'class' => $microformats[$col], 
     56      ), Q($record[$col])); 
     57    } 
     58    else if (!empty($record[$col])) { 
     59      $value = html::span($microformats[$col], Q($record[$col])); 
     60    } 
    5661    else 
    57       $value = Q($record[$col]); 
     62      $value = ''; 
    5863     
    59     $out .= sprintf("<tr><td class=\"title\">%s</td><td>%s</td></tr>\n", 
    60                     Q(rcube_label($col)), 
    61                     $value); 
    62     } 
     64    $table->add('title', Q(rcube_label($col))); 
     65    $table->add(null, $value); 
     66  } 
    6367   
    64   $out .= "\n</table>"; 
    65    
    66   return $out;   
    67   } 
     68  return $table->show($attrib + array('class' => 'vcard')); 
     69} 
    6870 
    6971 
Note: See TracChangeset for help on using the changeset viewer.