* @version $Revision$ * @package Horde_iCalendar */ class Horde_iCalendar_vcard extends Horde_iCalendar { function getType() { return 'vcard'; } function parsevCalendar($data) { return parent::parsevCalendar($data, 'vcard'); } /** * Unlike vevent and vtodo, a vcard is normally not enclosed in an * iCalendar container. (BEGIN..END) */ function exportvCalendar() { #$requiredAttributes['BODY'] = ''; $requiredAttributes['VERSION'] = '2.1'; foreach ($requiredAttributes as $name => $default_value) { if (is_a($this->getattribute($name), 'PEAR_Error')) { $this->setAttribute($name, $default_value); } } //error_log(__METHOD__.":requiredAttributes->".print_r($requiredAttributes,true)); //njv:$buffcontent = ob_get_clean(); #error_log(__METHOD__.":".print_r($buffcontent,true)); #ob_end_clean(); return $this->_exportvData('VCARD') . $this->_newline; } /** * Returns the contents of the "N" tag as a printable Name: * i.e. converts: * * N:Duck;Dagobert;T;Professor;Sen. * to * "Professor Dagobert T Duck Sen" * * @return string Full name of vcard "N" tag * or null if no N tag. */ function printableName() { $name_parts = $this->getAttributeValues('N'); if (is_a($name_parts, 'PEAR_Error')) { return null; } if (!empty($name_parts[VCARD_N_PREFIX])) { $name_arr[] = $name_parts[VCARD_N_PREFIX]; } if (!empty($name_parts[VCARD_N_GIVEN])) { $name_arr[] = $name_parts[VCARD_N_GIVEN]; } if (!empty($name_parts[VCARD_N_ADDL])) { $name_arr[] = $name_parts[VCARD_N_ADDL]; } if (!empty($name_parts[VCARD_N_FAMILY])) { $name_arr[] = $name_parts[VCARD_N_FAMILY]; } if (!empty($name_parts[VCARD_N_SUFFIX])) { $name_arr[] = $name_parts[VCARD_N_SUFFIX]; } return implode(' ', $name_arr); } /** * Static function to make a given email address rfc822 compliant. * * @param string $address An email address. * * @return string The RFC822-formatted email address. */ function getBareEmail($address) { require_once 'Mail/RFC822.php'; require_once 'Horde/MIME.php'; static $rfc822; if (is_null($rfc822)) { $rfc822 = &new Mail_RFC822(); } $rfc822->validateMailbox($address); return MIME::rfc822WriteAddress($address->mailbox, $address->host); } }