[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 3 require_once 'Horde/iCalendar.php'; 4 5 // The following were shamelessly yoinked from Contact_Vcard_Build 6 // Part numbers for N components. 7 define('VCARD_N_FAMILY', 0); 8 define('VCARD_N_GIVEN', 1); 9 define('VCARD_N_ADDL', 2); 10 define('VCARD_N_PREFIX', 3); 11 define('VCARD_N_SUFFIX', 4); 12 13 // Part numbers for ADR components. 14 define('VCARD_ADR_POB', 0); 15 define('VCARD_ADR_EXTEND', 1); 16 define('VCARD_ADR_STREET', 2); 17 define('VCARD_ADR_LOCALITY', 3); 18 define('VCARD_ADR_REGION', 4); 19 define('VCARD_ADR_POSTCODE', 5); 20 define('VCARD_ADR_COUNTRY', 6); 21 22 // Part numbers for GEO components. 23 define('VCARD_GEO_LAT', 0); 24 define('VCARD_GEO_LON', 1); 25 26 /** 27 * Class representing vCard entries. 28 * 29 * $Horde: framework/iCalendar/iCalendar/vcard.php,v 1.3.10.8 2006/05/09 23:08:22 chuck Exp $ 30 * 31 * Copyright 2003-2006 Karsten Fourmont (karsten@horde.org) 32 * 33 * See the enclosed file COPYING for license information (LGPL). If you 34 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 35 * 36 * @author Karsten Fourmont <karsten@horde.org> 37 * @package Horde_iCalendar 38 */ 39 class Horde_iCalendar_vcard extends Horde_iCalendar { 40 41 function Horde_iCalendar_vcard($version = '2.1') 42 { 43 return parent::Horde_iCalendar($version); 44 } 45 46 function getType() 47 { 48 return 'vcard'; 49 } 50 51 function parsevCalendar($data) 52 { 53 return parent::parsevCalendar($data, 'vcard'); 54 } 55 56 /** 57 * Unlike vevent and vtodo, a vcard is normally not enclosed in an 58 * iCalendar container. (BEGIN..END) 59 */ 60 function exportvCalendar() 61 { 62 $requiredAttributes['BODY'] = ''; 63 $requiredAttributes['VERSION'] = '2.1'; 64 65 foreach ($requiredAttributes as $name => $default_value) { 66 if (is_a($this->getAttribute($name), 'PEAR_Error')) { 67 $this->setAttribute($name, $default_value); 68 } 69 } 70 71 return $this->_exportvData('VCARD'); 72 } 73 74 /** 75 * Returns the contents of the "N" tag as a printable Name: 76 * i.e. converts: 77 * 78 * N:Duck;Dagobert;T;Professor;Sen. 79 * to 80 * "Professor Dagobert T Duck Sen" 81 * 82 * @return string Full name of vcard "N" tag 83 * or null if no N tag. 84 */ 85 function printableName() 86 { 87 $name_parts = $this->getAttributeValues('N'); 88 if (is_a($name_parts, 'PEAR_Error')) { 89 return null; 90 } 91 92 if (!empty($name_parts[VCARD_N_PREFIX])) { 93 $name_arr[] = $name_parts[VCARD_N_PREFIX]; 94 } 95 if (!empty($name_parts[VCARD_N_GIVEN])) { 96 $name_arr[] = $name_parts[VCARD_N_GIVEN]; 97 } 98 if (!empty($name_parts[VCARD_N_ADDL])) { 99 $name_arr[] = $name_parts[VCARD_N_ADDL]; 100 } 101 if (!empty($name_parts[VCARD_N_FAMILY])) { 102 $name_arr[] = $name_parts[VCARD_N_FAMILY]; 103 } 104 if (!empty($name_parts[VCARD_N_SUFFIX])) { 105 $name_arr[] = $name_parts[VCARD_N_SUFFIX]; 106 } 107 108 return implode(' ', $name_arr); 109 } 110 111 /** 112 * Static function to make a given email address rfc822 compliant. 113 * 114 * @param string $address An email address. 115 * 116 * @return string The RFC822-formatted email address. 117 */ 118 function getBareEmail($address) 119 { 120 // Empty values are still empty. 121 if (!$address) { 122 return $address; 123 } 124 125 require_once 'Mail/RFC822.php'; 126 require_once 'Horde/MIME.php'; 127 128 static $rfc822; 129 if (is_null($rfc822)) { 130 $rfc822 = new Mail_RFC822(); 131 } 132 133 $rfc822->validateMailbox($address); 134 return MIME::rfc822WriteAddress($address->mailbox, $address->host); 135 } 136 137 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |