function XCalFormatView::render in Services 6.3
Overrides RESTServerView::render
File
- servers/
rest_server/ formats/ XCalFormatView.inc, line 11 - This file will parse the xcal view for the rest server
Class
- XCalFormatView
- @file This file will parse the xcal view for the rest server
Code
function render() {
$ical = isset($this->arguments['transform']) && $this->arguments['transform'] == 'ical';
if ($ical) {
return $this
->render_ical();
}
$doc = new DomDocument('1.0', 'utf-8');
$icalendar = $doc
->appendChild($doc
->createElement('iCalendar'));
$icalendar
->setAttribute('xmlns', 'http://www.ietf.org/rfc/rfc2445');
$vc = $icalendar
->appendChild($doc
->createElement('vcalendar'));
$this
->value($doc, $vc, 'version', '2.0');
$this
->value($doc, $vc, 'prodid', $this
->prodid());
foreach ($this->model as $item) {
$vevent = $vc
->appendChild($doc
->createElement('vevent'));
$this
->value($doc, $vevent, 'summary', $item
->getName());
$this
->value($doc, $vevent, 'dtstart', date(self::DATE_FORMAT, $item
->getStarts()));
$this
->value($doc, $vevent, 'dtend', date(self::DATE_FORMAT, $item
->getEnds()));
$this
->value($doc, $vevent, 'description', $item
->getDescription());
$this
->value($doc, $vevent, 'url', $item
->getUrl());
}
$doc->formatOutput = TRUE;
return $doc
->saveXml();
}