9 * @author Christian Weiske <cweiske@cweiske.de>
10 * @copyright 2014 Christian Weiske
11 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
12 * @link http://cweiske.de/bdrem.htm
17 * Renders events in an iCalendar file
21 * @author Christian Weiske <cweiske@cweiske.de>
22 * @copyright 2014 Christian Weiske
23 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
24 * @version Release: @package_version@
25 * @link http://cweiske.de/bdrem.htm
26 * @link http://severinghaus.org/projects/icv/ iCal validator
28 class Renderer_Ical extends Renderer
34 protected $httpContentType = 'text/calendar; charset=utf-8';
37 * Render the events in an iCalendar file
39 * X-WR-CALNAME is supported by claws mail's vcalendar plugin; it
42 * @param array $arEvents Event objects to render
44 * @return string iCal file
46 public function render($arEvents)
48 $s = "BEGIN:VCALENDAR\n"
51 . "X-WR-CALNAME:birthdays\n";
52 foreach ($arEvents as $event) {
53 $props = array('BEGIN' => 'VEVENT');
55 $props['UID'] = str_replace(
56 array('-', '????'), array('', '0000'), $event->localDate
59 . '.' . md5($event->title . '/' . $event->type)
61 $props['DTSTART;VALUE=DATE'] = str_replace('-', '', $event->localDate);
62 $props['DURATION'] = 'P1D';
63 $props['SUMMARY'] = sprintf(
64 '%s - %s. %s', $event->title, $event->age, $event->type
66 $props['END'] = 'VEVENT';
68 foreach ($props as $key => $value) {
69 $s .= $key . ':' . $value . "\n";
72 $s .= "END:VCALENDAR\n";