merged 2.0 branch

This commit is contained in:
2013-03-30 13:55:18 +00:00
parent 395cadfddf
commit 3b0b5a5c0b
55 changed files with 1510 additions and 21361 deletions

View File

@@ -1,216 +0,0 @@
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Testkalender
X-WR-TIMEZONE:Europe/Berlin
X-WR-CALDESC:Nur zum testen vom Google Kalender
BEGIN:VEVENT
DTSTART:20121105T090000Z
DTEND:20121107T173000Z
DTSTAMP:20110121T195741Z
UID:15lc1nvupht8dtfiptenljoiv4@google.com
CREATED:20110121T195616Z
DESCRIPTION:This is a short description\nwith a new line. Some "special" 's
igns' may be interesting, too.
LAST-MODIFIED:20110121T195729Z
LOCATION:Kansas
SEQUENCE:2
STATUS:CONFIRMED
SUMMARY:My Holidays
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20110112
DTEND;VALUE=DATE:20110116
DTSTAMP:20110121T195741Z
UID:1koigufm110c5hnq6ln57murd4@google.com
CREATED:20110119T142901Z
DESCRIPTION:Project xyz Review Meeting Minutes\n
Agenda\n1. Review of project version 1.0 requirements.\n2.
Definition
of project processes.\n3. Review of project schedule.\n
Participants: John Smith, Jane Doe, Jim Dandy\n-It was
decided that the requirements need to be signed off by
product marketing.\n-Project processes were accepted.\n
-Project schedule needs to account for scheduled holidays
and employee vacation time. Check with HR for specific
dates.\n-New schedule will be distributed by Friday.\n-
Next weeks meeting is cancelled. No meeting until 3/23.
LAST-MODIFIED:20110119T152216Z
LOCATION:
SEQUENCE:2
STATUS:CONFIRMED
SUMMARY:test 11
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20110118
DTEND;VALUE=DATE:20110120
DTSTAMP:20110121T195741Z
UID:4dnsuc3nknin15kv25cn7ridss@google.com
CREATED:20110119T142059Z
DESCRIPTION:
LAST-MODIFIED:20110119T142106Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:test 9
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20110117
DTEND;VALUE=DATE:20110122
DTSTAMP:20110121T195741Z
UID:h6f7sdjbpt47v3dkral8lnsgcc@google.com
CREATED:20110119T142040Z
DESCRIPTION:
LAST-MODIFIED:20110119T142040Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20110117
DTEND;VALUE=DATE:20110118
DTSTAMP:20110121T195741Z
UID:up56hlrtkpqdum73rk6tl10ook@google.com
CREATED:20110119T142034Z
DESCRIPTION:
LAST-MODIFIED:20110119T142034Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:test 8
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20110118
DTEND;VALUE=DATE:20110120
DTSTAMP:20110121T195741Z
UID:8ltm205uhshsbc1huv0ooeg4nc@google.com
CREATED:20110119T142014Z
DESCRIPTION:
LAST-MODIFIED:20110119T142023Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:test 7
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20110119
DTEND;VALUE=DATE:20110121
DTSTAMP:20110121T195741Z
UID:opklai3nm8enffdf5vpna4o5fo@google.com
CREATED:20110119T141918Z
DESCRIPTION:
LAST-MODIFIED:20110119T142005Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:test 5
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20110119
DTEND;VALUE=DATE:20110120
DTSTAMP:20110121T195741Z
UID:kmbj764g57tcvua11hir61c4b8@google.com
CREATED:20110119T141923Z
DESCRIPTION:
LAST-MODIFIED:20110119T141923Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:test 6
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20110119
DTEND;VALUE=DATE:20110120
DTSTAMP:20110121T195741Z
UID:shvr7hvqdag08vjqlmj5lj0i2s@google.com
CREATED:20110119T141913Z
DESCRIPTION:
LAST-MODIFIED:20110119T141913Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:test 4
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20110119
DTEND;VALUE=DATE:20110120
DTSTAMP:20110121T195741Z
UID:77gpemlb9es0r0gtjolv3mtap0@google.com
CREATED:20110119T141909Z
DESCRIPTION:
LAST-MODIFIED:20110119T141909Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:test 3
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20110119
DTEND;VALUE=DATE:20110120
DTSTAMP:20110121T195741Z
UID:rq8jng4jgq0m1lvpj8486fttu0@google.com
CREATED:20110119T141904Z
DESCRIPTION:
LAST-MODIFIED:20110119T141904Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:test 2
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20110119
DTEND;VALUE=DATE:20110120
DTSTAMP:20110121T195741Z
UID:dh3fki5du0opa7cs5n5s87ca00@google.com
CREATED:20110119T141901Z
DESCRIPTION:
LAST-MODIFIED:20110119T141901Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:test 1
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20400201
DTEND;VALUE=DATE:20400202
DTSTAMP:20400101T195741Z
UID:dh3fki5du0opa7cs5n5s87ca01@google.com
CREATED:20400101T141901Z
DESCRIPTION:
LAST-MODIFIED:20400101T141901Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Year 2038 problem test
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:19410512
DTEND;VALUE=DATE:19410512
DTSTAMP:19410512T195741Z
UID:dh3fki5du0opa7cs5n5s87ca02@google.com
CREATED:20400101T141901Z
DESCRIPTION:
LAST-MODIFIED:20400101T141901Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Before 1970-Test: Konrad Zuse invents the Z3, the first digital Computer
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR

View File

@@ -1,33 +0,0 @@
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Testkalender
X-WR-TIMEZONE:Europe/Berlin
X-WR-CALDESC:Nur zum testen vom Google Kalender
BEGIN:VEVENT
DTSTART;TZID="W. Europe":20121227T100000
DTEND;TZID="W. Europe":20121227T120000
DTSTAMP:20110121T195741Z
UID:1koigufm110c5hnq6ln57murd4@google.com
CREATED:20110119T142901Z
DESCRIPTION:Project xyz Review Meeting Minutes\n
Agenda\n1. Review of project version 1.0 requirements.\n2.
Definition
of project processes.\n3. Review of project schedule.\n
Participants: John Smith, Jane Doe, Jim Dandy\n-It was
decided that the requirements need to be signed off by
product marketing.\n-Project processes were accepted.\n
-Project schedule needs to account for scheduled holidays
and employee vacation time. Check with HR for specific
dates.\n-New schedule will be distributed by Friday.\n-
Next weeks meeting is cancelled. No meeting until 3/23.
LAST-MODIFIED:20110119T152216Z
LOCATION:
SEQUENCE:2
STATUS:CONFIRMED
SUMMARY:test 11
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR

File diff suppressed because it is too large Load Diff

View File

@@ -1,21 +1,30 @@
<?php
/**
* Parse ics file content to array.
* class.icalparser.php zarafa calender to ics im/exporter
* http://code.google.com/p/ics-parser/
*
* PHP Version 5
* Author: Martin Thoma , Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2013 Christoph Haas
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category Parser
* @author Martin Thoma
* @author Christoph Haas <mail@h44z.net>
* @modified 17.11.2012 by Christoph Haas (original at http://code.google.com/p/ics-parser/)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @version SVN: 62
* @example $ical = new ical('calendar.ics');
* print_r( $ical->events() );
*/
/**
* This is the iCal-class
* Parse ics file content to array.
*
* @param {string} filename The name of the file which should be parsed
* @constructor
@@ -28,7 +37,7 @@ class ICal {
public /** @type {int} */ $event_count = 0;
/* Currently editing an alarm? */
private /** @type {int} */ $isalarm = false;
private /** @type {boolean} */ $isalarm = false;
/* The parsed calendar */
public /** @type {Array} */ $cal;
@@ -41,7 +50,13 @@ class ICal {
/* The default timezone, used to convert UTC Time */
private /** @type {string} */ $default_timezone = "Europe/Vienna";
/* The default timezone, used to convert UTC Time */
private /** @type {boolean} */ $timezone_set = false;
/* Ignore Daylight Saving Time */
private /** @type {boolean} */ $ignore_dst = false;
/**
* Creates the iCal-Object
*
@@ -49,12 +64,23 @@ class ICal {
*
* @return Object The iCal-Object
*/
public function __construct($filename) {
public function __construct($filename, $default_timezone, $timezone = false, $igndst = false) {
if (!$filename) {
$this->errors = "No filename specified";
return false;
}
$this->default_timezone = $default_timezone;
if(isset($timezone) && $timezone != false) {
$this->default_timezone = $timezone;
$this->timezone_set = true;
}
if(isset($igndst) && $igndst != false) {
$this->ignore_dst = true;
}
$lines = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if (stristr($lines[0], 'BEGIN:VCALENDAR') === false) {
$this->errors = "Not a valid ical file";
@@ -69,7 +95,7 @@ class ICal {
continue;
}
list($keyword, $prop, $propvalue, $value) = $add;
list($keyword, $dummy, $prop, $propvalue, $value) = $add;
switch ($line) {
// http://www.kanzaki.com/docs/ical/vtodo.html
@@ -137,8 +163,11 @@ class ICal {
if (stristr($keyword, "DTSTART") or stristr($keyword, "DTEND") or stristr($keyword, "TRIGGER")) {
$ts = $this->iCalDateToUnixTimestamp($value, $prop, $propvalue);
$value = $ts * 1000;
}
$value = str_replace("\\n", "\n", $value);
}
$value = str_replace("\\n", "\n", $value);
$value = $this->customFilters($keyword, $value);
if(!$this->isalarm) {
$value = $this->cal[$component][$this->event_count - 1][$keyword].$value;
} else {
@@ -159,7 +188,7 @@ class ICal {
//$keyword = $keyword[0]; // remove additional content like VALUE=DATE
//}
if (stristr($keyword, "TIMEZONE")) {
if (stristr($keyword, "TIMEZONE") && !$this->timezone_set) { // check if timezone already set...
$this->default_timezone = $value; // store the calendertimezone
}
@@ -175,6 +204,8 @@ class ICal {
}
$value = str_replace("\\n", "\n", $value);
$value = $this->customFilters($keyword, $value);
if(!$this->isalarm) {
$this->cal[$component][$this->event_count - 1][$keyword] = $value;
} else {
@@ -188,33 +219,56 @@ class ICal {
$this->last_keyword = $keyword;
}
/**
* Filter some chars out of the value.
*
* @param {string} $keyword keyword to which the filter is applied
* @param {string} $value to filter
* @return {string} filtered value
*/
private function customFilters($keyword, $value) {
if (stristr($keyword, "SUMMARY")) {
$value = str_replace("\n", " ", $value); // we don't need linebreaks in the summary...
}
if (stristr($keyword, "SUMMARY")) {
$value = str_replace("\,", ",", $value); // strange escaped comma
}
return $value;
}
/**
* Get a key-value pair of a string.
*
* @param {string} $text which is like "VCALENDAR:Begin" or "LOCATION:"
*
* @return {array} array("VCALENDAR", "Begin", "Optional Props")
* @return {array} array("Argument", "Optional Arg/Val", "Optional Arg", "Optional Value", "Value")
*/
public function keyValueFromString($text) {
preg_match("/(^[^a-z:;]+)[;]*([a-zA-Z]*)[=]*(.*)[:]([\w\W]*)/", $text, $matches);
preg_match('/(^[^a-z:;]+)([;]+([a-zA-Z]*)[=]*([^:"]*|"[\w\W]*"))?[:]([\w\W]*)/', $text, $matches);
// this regex has problems with multiple attributes... ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT:mailto:jsmith@example.com
// TODO: fix this
if (count($matches) == 0) {
return false;
}
$matches = array_splice($matches, 1, 4);
$matches = array_splice($matches, 1, 5); // 0 = Arg, 1 = Complete Optional Arg/Val, 2 = Optional Arg, 3 = Optional Val, 4 = Value
return $matches;
}
/**
* Return Unix timestamp from ical date time format
* Return UTC Unix timestamp from ical date time format
*
* @param {string} $icalDate A Date in the format YYYYMMDD[T]HHMMSS[Z] or
* YYYYMMDD[T]HHMMSS
*
* @return {int}
*/
public function iCalDateToUnixTimestamp($icalDate, $prop, $propvalue) {
private function iCalDateToUTCUnixTimestamp($icalDate, $prop, $propvalue) {
$timezone = false;
@@ -256,7 +310,6 @@ class ICal {
(int)$date[3],
(int)$date[1]);
if(!$utc) {
$tz = $this->default_timezone;
if($timezone != false) {
@@ -294,6 +347,53 @@ class ICal {
return ($timestamp_utc);
}
/**
* Return a timezone specific timestamp
* @param {int} $timestamp_utc UTC Timestamp to convert
* @param {string} $timezone Timezone
* @return {int}
*/
private function UTCTimestampToTZTimestamp($timestamp_utc, $timezone, $ignore_dst = false) {
$this_tz = false;
try { // Try using the default calendar timezone
$this_tz = new DateTimeZone($this->default_timezone);
} catch(Exception $e) {
error_log($e->getMessage());
$timestamp_utc = $timestamp; // if that fails, we cannot do anymore
}
if($this_tz != false) {
$transition = $this_tz->getTransitions($timestamp_utc,$timestamp_utc);
$trans_offset = $transition[0]['offset'];
$isdst = $transition[0]['isdst'];
$tz_now = new DateTime("now", $this_tz);
$tz_offset = $this_tz->getOffset($tz_now);
if(!$ignore_dst) {
$tz_offset = $trans_offset; // normaly use dst
}
return $timestamp_utc + $tz_offset;
}
return $timestamp_utc; // maybe timezone conversion will fail...
}
/**
* Return Timezone specific Unix timestamp from ical date time format
*
* @param {string} $icalDate A Date in the format YYYYMMDD[T]HHMMSS[Z] or
* YYYYMMDD[T]HHMMSS
*
* @return {int}
*/
public function iCalDateToUnixTimestamp($icalDate, $prop, $propvalue) {
$timestamp = $this->iCalDateToUTCUnixTimestamp($icalDate, $prop, $propvalue);
$timestamp = $this->UTCTimestampToTZTimestamp($timestamp, $this->default_timezone, $this->ignore_dst);
return $timestamp;
}
/**
* Returns an array of arrays with all events. Every event is an associative
* array and each property is an element it.
@@ -387,13 +487,11 @@ class ICal {
// loop through all events by adding two new elements
foreach ($events as $anEvent) {
if (!array_key_exists('UNIX_TIMESTAMP', $anEvent)) {
$anEvent['UNIX_TIMESTAMP'] =
$this->iCalDateToUnixTimestamp($anEvent['DTSTART']);
$anEvent['UNIX_TIMESTAMP'] = $this->iCalDateToUnixTimestamp($anEvent['DTSTART']);
}
if (!array_key_exists('REAL_DATETIME', $anEvent)) {
$anEvent['REAL_DATETIME'] =
date("d.m.Y", $anEvent['UNIX_TIMESTAMP']);
$anEvent['REAL_DATETIME'] = date("d.m.Y", $anEvent['UNIX_TIMESTAMP']);
}
$extendedEvents[] = $anEvent;