public function initLines($lines)
{
if (stristr($lines[0], 'BEGIN:VCALENDAR') !== false) {
$component = '';
foreach ($lines as $line) {
$line = rtrim($line);
// Trim trailing whitespace
$add = $this->keyValueFromString($line);
if ($add === false) {
$this->addCalendarComponentWithKeyAndValue($component, false, $line);
continue;
}
$keyword = $add[0];
$values = $add[1];
// Could be an array containing multiple values
if (!is_array($values)) {
if (!empty($values)) {
$values = array($values);
// Make an array as not already
$blank_array = array();
// Empty placeholder array
array_push($values, $blank_array);
} else {
$values = array();
// Use blank array to ignore this line
}
} else {
if (empty($values[0])) {
$values = array();
// Use blank array to ignore this line
}
}
$values = array_reverse($values);
// Reverse so that our array of properties is processed first
foreach ($values as $value) {
switch ($line) {
// http://www.kanzaki.com/docs/ical/vtodo.html
case 'BEGIN:VTODO':
$this->todoCount++;
$component = 'VTODO';
break;
// http://www.kanzaki.com/docs/ical/vevent.html
// http://www.kanzaki.com/docs/ical/vevent.html
case 'BEGIN:VEVENT':
if (!is_array($value)) {
$this->eventCount++;
}
$component = 'VEVENT';
break;
// http://www.kanzaki.com/docs/ical/vfreebusy.html
// http://www.kanzaki.com/docs/ical/vfreebusy.html
case 'BEGIN:VFREEBUSY':
$this->freebusyCount++;
$component = 'VFREEBUSY';
break;
// All other special strings
// All other special strings
case 'BEGIN:VCALENDAR':
case 'BEGIN:DAYLIGHT':
// http://www.kanzaki.com/docs/ical/vtimezone.html
// http://www.kanzaki.com/docs/ical/vtimezone.html
case 'BEGIN:VTIMEZONE':
case 'BEGIN:STANDARD':
case 'BEGIN:VALARM':
$component = $value;
break;
case 'END:VALARM':
case 'END:VTODO':
// End special text - goto VCALENDAR key
// End special text - goto VCALENDAR key
case 'END:VEVENT':
case 'END:VFREEBUSY':
case 'END:VCALENDAR':
case 'END:DAYLIGHT':
case 'END:VTIMEZONE':
case 'END:STANDARD':
$component = 'VCALENDAR';
break;
default:
$this->addCalendarComponentWithKeyAndValue($component, $keyword, $value);
break;
}
}
}
$this->processEvents();
$this->processRecurrences();
$this->processDateConversions();
}
}