calendarimporter 1.1 final:

- ics exporter
 - improved ics fileparser
 - fixed ExtJS Problem in chrome

KNOWN PROBLEMS: 
 - importer ignores some fields (priority, status...)
 - attechments are ignored
 - timezone handling is not perfect
 - recurrent events are not handled properly (im/export)
This commit is contained in:
2012-12-09 21:39:49 +00:00
parent d7ea948372
commit c0e51e294b
4 changed files with 10466 additions and 74 deletions

10338
php/ical/class.icalcreator.php Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -61,6 +61,7 @@ class ICal {
foreach ($lines as $line) {
$line = trim($line);
$add = $this->keyValueFromString($line);
error_log("line: " . $line);
if ($add === false) {
$this->addCalendarComponentWithKeyAndValue($type, false, $line);
continue;
@@ -121,47 +122,48 @@ class ICal {
$keyword = $this->last_keyword;
switch ($component) {
case 'VEVENT':
if (stristr($keyword, "DTSTART") or stristr($keyword, "DTEND")) {
$ts = $this->iCalDateToUnixTimestamp($value);
$value = $ts * 1000;
}
$value = str_replace("\\n", "\n", $value);
$value = $this->cal[$component][$this->event_count - 1]
[$keyword].$value;
break;
case 'VTODO' :
$value = $this->cal[$component][$this->todo_count - 1]
[$keyword].$value;
break;
case 'VEVENT':
if (stristr($keyword, "DTSTART") or stristr($keyword, "DTEND")) {
$ts = $this->iCalDateToUnixTimestamp($value);
$value = $ts * 1000;
}
$value = str_replace("\\n", "\n", $value);
$value = $this->cal[$component][$this->event_count - 1]
[$keyword].$value;
break;
case 'VTODO' :
$value = $this->cal[$component][$this->todo_count - 1]
[$keyword].$value;
break;
}
}
if (stristr($keyword, "DTSTART") or stristr($keyword, "DTEND")) {
$keyword = explode(";", $keyword);
$keyword = $keyword[0]; // remove additional content like VALUE=DATE
}
//always strip additional content....
//if (stristr($keyword, "DTSTART") or stristr($keyword, "DTEND")) {
$keyword = explode(";", $keyword);
$keyword = $keyword[0]; // remove additional content like VALUE=DATE
//}
if (stristr($keyword, "TIMEZONE")) {
$this->default_timezone = $value; // store the calendertimezone
}
switch ($component) {
case "VTODO":
$this->cal[$component][$this->todo_count - 1][$keyword] = $value;
//$this->cal[$component][$this->todo_count]['Unix'] = $unixtime;
break;
case "VEVENT":
if (stristr($keyword, "DTSTART") or stristr($keyword, "DTEND")) {
$ts = $this->iCalDateToUnixTimestamp($value);
$value = $ts * 1000;
}
$value = str_replace("\\n", "\n", $value);
$this->cal[$component][$this->event_count - 1][$keyword] = $value;
break;
default:
$this->cal[$component][$keyword] = $value;
break;
case "VTODO":
$this->cal[$component][$this->todo_count - 1][$keyword] = $value;
//$this->cal[$component][$this->todo_count]['Unix'] = $unixtime;
break;
case "VEVENT":
if (stristr($keyword, "DTSTART") or stristr($keyword, "DTEND")) {
$ts = $this->iCalDateToUnixTimestamp($value);
$value = $ts * 1000;
}
$value = str_replace("\\n", "\n", $value);
$this->cal[$component][$this->event_count - 1][$keyword] = $value;
break;
default:
$this->cal[$component][$keyword] = $value;
break;
}
$this->last_keyword = $keyword;
}
@@ -174,10 +176,13 @@ class ICal {
* @return {array} array("VCALENDAR", "Begin")
*/
public function keyValueFromString($text) {
preg_match("/(^[^a-z:]+)[:]([\w\W]*)/", $text, $matches);
preg_match("/(^[^a-z:]+[;a-zA-Z=\/]*)[:]([\w\W]*)/", $text, $matches);
error_log("macthes: " . count($matches). " " . $text);
if (count($matches) == 0) {
return false;
}
$matches = array_splice($matches, 1, 2);
return $matches;
}