calendar-row-ical-node.tpl.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. *
  4. * $event['uid'] - a unique id for the event (usually the url).
  5. * $event['summary'] - the name of the event.
  6. * $event['start'] - the formatted start date of the event.
  7. * $event['end'] - the formatted end date of the event.
  8. * $event['all_day'] - whether the item is an all day event.
  9. * $event['rrule'] - the RRULE of the event, if any.
  10. * $event['timezone'] - the formatted timezone name of the event, if any.
  11. * $event['url'] - the url for the event.
  12. * $event['location'] - the name of the event location.
  13. * $event['description'] - a description of the event.
  14. *
  15. * Note that there are empty spaces after RRULE, URL, LOCATION, etc
  16. * that are needed to make sure we get the required line break.
  17. *
  18. * If you are editing this file, remember that all output lines generated by it
  19. * must end with DOS-style \r\n line endings, and not Unix-style \n, in order to
  20. * be compliant with the iCal spec (see http://tools.ietf.org/html/rfc5545#section-3.1)
  21. */
  22. $date = date_now('UTC');
  23. $current_date = !empty($event['current_date']) ? $event['current_date'] : $date->format(DATE_FORMAT_ICAL);
  24. print "BEGIN:VEVENT\r\n";
  25. print "UID:" . $event['uid'] . "\r\n";
  26. print "SUMMARY:" . $event['summary'] . "\r\n";
  27. print "DTSTAMP:" . $current_date . "Z\r\n";
  28. if ($event['all_day']):
  29. print "DTSTART;VALUE=DATE:" . $event['start'] . "\r\n";
  30. else:
  31. print "DTSTART:" . $event['start'] . "Z\r\n";
  32. endif;
  33. if (!empty($event['end'])):
  34. if (!empty($event['all_day'])):
  35. print "DTEND;VALUE=DATE:" . $event['end'] . "\r\n";
  36. else:
  37. print "DTEND:" . $event['end'] . "Z\r\n";
  38. endif;
  39. endif;
  40. if (!empty($event['rrule'])) {
  41. print $event['rrule'] . "\r\n";
  42. }
  43. if (!empty($event['url'])) {
  44. print "URL;VALUE=URI:" . $event['url'] . "\r\n";
  45. }
  46. if (!empty($event['location'])) {
  47. print "LOCATION:" . $event['location'] . "\r\n";
  48. }
  49. if (!empty($event['description'])) {
  50. print "DESCRIPTION:" . $event['description'] . "\r\n";
  51. }
  52. print "END:VEVENT\r\n";