/** * Parses row values from a chunk * @param ical\parser\Chunk $chunk * @return void * @throws UnexpectedValueException */ public function parseProperties(\ical\parser\Chunk $chunk) { if ($chunk->type !== \ical\parser\Chunk::TYPE_CALENDAR) { throw new \UnexpectedValueException("Invalid chunk type:" . $chunk->type . ", expected:" . \ical\parser\Chunk::TYPE_CALENDAR); } foreach ($chunk->getLines() as $line) { switch ($line->name) { case 'VERSION': $this->version = $line->value; break; case 'PRODID': $this->prodid = $line->value; break; case 'CALSCALE': $this->calscale = $line->value; break; case 'METHOD': $this->method = $line->value; break; case 'X-WR-TIMEZONE': \ical\Event::setDefaultTimezone(new \DateTimeZone($line->value)); break; default: if ('X-' === substr($line->name, 0, 2)) { $this->extended[$line->name] = $line->value; } break; } } }
/** * Parse properties from a chunk * @param \ical\parser\Chunk $chunk * @return void */ protected function parseProperties(\ical\parser\Chunk $chunk) { if ($chunk->type !== \ical\parser\Chunk::TYPE_EVENT) { throw new \InvalidValueException("Invalid chunk type:" . $chunk->type . ", expected:" . \ical\parser\Chunk::TYPE_EVENT); } foreach ($chunk->getLines() as $line) { switch ($line->name) { case "UID": $this->setProperty("uid", $line->value); break; case "SEQUENCE": $this->setProperty("sequence", intval($line->value)); break; case "DTSTART": if ($line->getParam("VALUE") === "DATE") { $this->setProperty("dtstart", \ical\util\DateTimeFactory::createFromRow($line, self::$defaultTimezone)); } else { $this->setProperty("dtstart", \ical\util\DateTimeFactory::createFromRow($line, self::$defaultTimezone)); } break; case "DTEND": if ($line->getParam("VALUE") === "DATE") { $this->setProperty("dtend", \ical\util\DateTimeFactory::createFromRow($line, self::$defaultTimezone)); } else { $this->setProperty("dtend", \ical\util\DateTimeFactory::createFromRow($line, self::$defaultTimezone)); } break; case "CREATED": $this->setProperty("created", \ical\util\DateTimeFactory::createFromRow($line, self::$defaultTimezone)); break; case "LAST-MODIFIED": $this->setProperty("lastModified", \ical\util\DateTimeFactory::createFromRow($line, self::$defaultTimezone)); break; case "DTSTAMP": $this->setProperty("dtstamp", \ical\util\DateTimeFactory::createFromRow($line, self::$defaultTimezone)); break; case "RRULE": $this->setProperty("rrule", new \ical\event\Rrule($line)); break; case "EXDATE": foreach (explode(",", $line->value) as $date) { $this->addException(\ical\util\DateTimeFactory::createFromRow($line, self::$defaultTimezone)); } break; case "EXRULE": $this->setProperty("exrule", new \ical\event\Rrule($line)); break; case "SUMMARY": $this->setProperty("summary", $line->value); break; case "DESCRIPTION": $this->setProperty("description", $line->value); break; case "LOCATION": $this->setProperty("location", $line->value); break; case "STATUS": $this->setProperty("status", $line->value); break; /* * @todo */ /* * @todo */ case "DURATION": break; /* * @todo */ /* * @todo */ case "TRANSP": break; /* * @todo */ /* * @todo */ case "ATTENDEE": break; /* * @todo */ /* * @todo */ case "CATEGORIES": break; /* * @todo */ /* * @todo */ case "RECURRENCE-ID": break; default: if ("X-" === substr($line->name, 0, 2)) { $this->extended[$line->name] = $line->value; } break; } } }