From 56d197e5d8f329f4a5925899ab62d6e6bfdd38a3 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 12 Nov 2008 11:51:14 -0700 Subject: [PATCH] Update vcard Viewer. --- framework/Mime/lib/Horde/Mime/Viewer/vcard.php | 95 ++++++++++++++++---------- 1 file changed, 59 insertions(+), 36 deletions(-) diff --git a/framework/Mime/lib/Horde/Mime/Viewer/vcard.php b/framework/Mime/lib/Horde/Mime/Viewer/vcard.php index adaa98289..659b764a8 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/vcard.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/vcard.php @@ -13,30 +13,52 @@ class Horde_Mime_Viewer_vcard extends Horde_Mime_Viewer_Driver { /** - * Render out the vcard contents. + * Can this driver render various views? * - * @param array $params Any parameters the Viewer may need. + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. * - * @return string The rendered contents. + * @return array See Horde_Mime_Viewer_Driver::render(). */ - public function render($params = null) + protected function _render() { - global $registry, $prefs, $notification; + $ret = $this->_renderInline(); + if (!empty($ret)) { + $ret['data'] = Util::bufferOutput('include', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') . + $ret['data'] . + Util::bufferOutput('include', $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc'); + } + return $ret; + } - require_once 'Horde/iCalendar.php'; + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + global $registry, $prefs, $notification; $app = false; - $data = $this->mime_part->getContents(); + $data = $this->_mimepart->getContents(); $html = ''; $import_msg = null; $title = _("vCard"); + require_once 'Horde/iCalendar.php'; $iCal = new Horde_iCalendar(); - if (!$iCal->parsevCalendar($data, 'VCALENDAR', - $this->mime_part->getCharset())) { - $notification->push( - _("There was an error reading the contact data."), - 'horde.error'); + if (!$iCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) { + $notification->push(_("There was an error reading the contact data."), 'horde.error'); } if (Util::getFormData('import') && @@ -119,24 +141,31 @@ class Horde_Mime_Viewer_vcard extends Horde_Mime_Viewer_Driver case 'HOME': $types[] = _("Home Address"); break; + case 'WORK': $types[] = _("Work Address"); break; + case 'DOM': $types[] = _("Domestic Address"); break; + case 'INTL': $types[] = _("International Address"); break; + case 'POSTAL': $types[] = _("Postal Address"); break; + case 'PARCEL': $types[] = _("Parcel Address"); break; + case 'PREF': $types[] = _("Preferred Address"); break; + default: $types[] = _("Address"); break; @@ -177,24 +206,31 @@ class Horde_Mime_Viewer_vcard extends Horde_Mime_Viewer_Driver case 'HOME': $types[] = _("Home Address"); break; + case 'WORK': $types[] = _("Work Address"); break; + case 'DOM': $types[] = _("Domestic Address"); break; + case 'INTL': $types[] = _("International Address"); break; + case 'POSTAL': $types[] = _("Postal Address"); break; + case 'PARCEL': $types[] = _("Parcel Address"); break; + case 'PREF': $types[] = _("Preferred Address"); break; + default: $types[] = _("Address"); break; @@ -337,36 +373,23 @@ class Horde_Mime_Viewer_vcard extends Horde_Mime_Viewer_Driver $html .= ''; - return - Util::bufferOutput( - 'include', - $registry->get('templates', 'horde') . '/common-header.inc') - . Util::bufferOutput(array($notification, 'notify'), - array('listeners' => 'status')) - . $html - . Util::bufferOutput( - 'include', - $registry->get('templates', 'horde') . '/common-footer.inc'); + return array( + 'data' => Util::bufferOutput(array($notification, 'notify'), array('listeners' => 'status')) . $html, + 'type' => 'text/html; charset=' . NLS::getCharset() + ); } - function _row($label, $value, $encode = true) + /** + * TODO + */ + protected function _row($label, $value, $encode = true) { if ($encode) { $label = htmlspecialchars($label); $value = htmlspecialchars($value); } - return '' . $label - . '' . nl2br($value) - . "\n"; - } - - /** - * Return the MIME content type of the rendered content. - * - * @return string The content type of the output. - */ - public function getType() - { - return 'text/html; charset=' . NLS::getCharset(); + return '' . $label . + '' . nl2br($value) . + "\n"; } } -- 2.11.0