Example #1
0
 public function __construct($cal, $siteId = null)
 {
     if (!isset($cal) || !is_array($cal) && !is_string($cal)) {
         return;
     }
     $this->component = new CDavICalendarComponent();
     if (is_string($cal)) {
         $this->component->InitializeFromString($cal);
     } else {
         $this->component->SetType('VCALENDAR');
         $this->component->SetProperties(array(new CDavICalendarProperty('VERSION:2.0'), new CDavICalendarProperty('PRODID:-//davical.org//NONSGML AWL Calendar//EN'), new CDavICalendarProperty('METHOD:PUBLISH')));
         $arComps = array();
         $tz = CDavICalendarTimeZone::GetTimezone(CDavICalendarTimeZone::getTimeZoneId());
         if (!empty($tz)) {
             $comptz = new CDavICalendarComponent();
             $comptz->InitializeFromString($tz);
             $arComps[] = $comptz;
         }
         $comp = new CDavICalendarComponent();
         $comp->InitializeFromArray($cal);
         $arComps[] = $comp;
         $this->component->SetComponents($arComps);
     }
 }