<?php
/**
 * Create a ical for the upcoming recordings
 *
 * @url         $URL: http://svn.mythtv.org/svn/branches/release-0-23-fixes/mythplugins/mythweb/modules/tv/tmpl/ical/upcoming.php $
 * @date        $Date: 2009-08-01 06:03:50 +0300 (Sat, 01 Aug 2009) $
 * @version     $Revision: 21084 $
 * @author      $Author: kormoc $
 * @license     GPL
 *
 * @package     MythWeb
 * @subpackage  TV
 *
/**/

    $calendar = new vcalendar();
    $calendar->setConfig($_SERVER['SERVER_SIGNATURE'], $_SERVER['HTTP_HOST']);
    $calendar->setProperty( 'method', 'PUBLISH' );

    foreach ($all_shows as $show) {
        $event = new vevent();
        $event->setProperty('dtstart',      array( 'year'  => date('Y', $show->starttime),
                                                   'month' => date('m', $show->starttime),
                                                   'day'   => date('d', $show->starttime),
                                                   'hour'  => date('H', $show->starttime),
                                                   'min'   => date('i', $show->starttime),
                                                   'sec'   => date('s', $show->starttime) ));
        $event->setProperty('dtend',        array( 'year'  => date('Y', $show->endtime),
                                                   'month' => date('m', $show->endtime),
                                                   'day'   => date('d', $show->endtime),
                                                   'hour'  => date('H', $show->endtime),
                                                   'min'   => date('i', $show->endtime),
                                                   'sec'   => date('s', $show->endtime) ));
        $event->setProperty('summary',      $show->title.($show->subtitle ? ' - '.$show->subtitle : ''));
        $event->setProperty('description',  $show->description."\n\n".preg_replace('/([A-Z]+)/',' $1',$show->recstatus));
        $event->setProperty('location', $show->channel->callsign); 
        $calendar->setComponent($event);
    }

    $calendar->returnCalendar();
