/**
* Return the rendered inline version of the Horde_Mime_Part object.
*
* @return array See parent::render().
*/
protected function _renderInline()
{
$GLOBALS['page_output']->growler = true;
$data = $this->_mimepart->getContents();
$mime_id = $this->_mimepart->getMimeId();
// Parse the iCal file.
$vCal = new Horde_Icalendar();
if (!$vCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
$status = new IMP_Mime_Status(_("The calendar data is invalid"));
$status->action(IMP_Mime_Status::ERROR);
return array($mime_id => array('data' => '', 'status' => $status, 'type' => 'text/html; charset=UTF-8'));
}
// Check if we got vcard data with the wrong vcalendar mime type.
$imp_contents = $this->getConfigParam('imp_contents');
$c = $vCal->getComponentClasses();
if (count($c) == 1 && !empty($c['horde_icalendar_vcard'])) {
return $imp_contents->renderMIMEPart($mime_id, IMP_Contents::RENDER_INLINE, array('type' => 'text/x-vcard'));
}
$imple = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_ItipRequest', array('mime_id' => $mime_id, 'muid' => strval($imp_contents->getIndicesOb())));
// Get the method type.
try {
$method = $vCal->getAttribute('METHOD');
} catch (Horde_Icalendar_Exception $e) {
$method = '';
}
$out = array();
$components = $vCal->getComponents();
foreach ($components as $key => $component) {
switch ($component->getType()) {
case 'vEvent':
try {
if ($component->getAttribute('RECURRENCE-ID')) {
break;
}
} catch (Horde_ICalendar_Exception $e) {
}
$out[] = $this->_vEvent($component, $key, $method, $components);
break;
case 'vTodo':
$out[] = $this->_vTodo($component, $key, $method);
break;
case 'vTimeZone':
// Ignore them.
break;
case 'vFreebusy':
$out[] = $this->_vFreebusy($component, $key, $method);
break;
// @todo: handle stray vcards here as well.
// @todo: handle stray vcards here as well.
default:
$out[] = sprintf(_("Unhandled component of type: %s"), $component->getType());
break;
}
}
$view = $this->_getViewOb();
$view->formid = $imple->getDomId();
$view->out = implode('', $out);
return array($mime_id => array('data' => $view->render('base'), 'type' => 'text/html; charset=UTF-8'));
}