diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-02-16 09:44:49 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-02-16 09:44:49 +0100 |
commit | 20553c1afe035b2e020409fd516d0288b748dc7f (patch) | |
tree | 9b7cc32ee2560d86315339b9716c1a790a680afc /3rdparty/Sabre/VObject | |
parent | 19827b8b35de6192d54bf7600e9e29800c93b21b (diff) | |
download | nextcloud-server-20553c1afe035b2e020409fd516d0288b748dc7f.tar.gz nextcloud-server-20553c1afe035b2e020409fd516d0288b748dc7f.zip |
Revert "remove the 3rdparty files. everything is now in https://gitorious.org/owncloud/3rdparty"
This reverts commit dccdeca2581f705c69eb4266aa646173f588a9de.
Diffstat (limited to '3rdparty/Sabre/VObject')
-rw-r--r-- | 3rdparty/Sabre/VObject/Component.php | 254 | ||||
-rw-r--r-- | 3rdparty/Sabre/VObject/Element.php | 15 | ||||
-rw-r--r-- | 3rdparty/Sabre/VObject/Element/DateTime.php | 245 | ||||
-rw-r--r-- | 3rdparty/Sabre/VObject/Element/MultiDateTime.php | 168 | ||||
-rw-r--r-- | 3rdparty/Sabre/VObject/ElementList.php | 172 | ||||
-rw-r--r-- | 3rdparty/Sabre/VObject/Node.php | 149 | ||||
-rw-r--r-- | 3rdparty/Sabre/VObject/Parameter.php | 81 | ||||
-rw-r--r-- | 3rdparty/Sabre/VObject/ParseException.php | 12 | ||||
-rw-r--r-- | 3rdparty/Sabre/VObject/Property.php | 289 | ||||
-rw-r--r-- | 3rdparty/Sabre/VObject/Reader.php | 191 | ||||
-rw-r--r-- | 3rdparty/Sabre/VObject/Version.php | 24 | ||||
-rw-r--r-- | 3rdparty/Sabre/VObject/includes.php | 29 |
12 files changed, 1629 insertions, 0 deletions
diff --git a/3rdparty/Sabre/VObject/Component.php b/3rdparty/Sabre/VObject/Component.php new file mode 100644 index 00000000000..47cf9f3d812 --- /dev/null +++ b/3rdparty/Sabre/VObject/Component.php @@ -0,0 +1,254 @@ +<?php + +/** + * VObject Component + * + * This class represents a VCALENDAR/VCARD component. A component is for example + * VEVENT, VTODO and also VCALENDAR. It starts with BEGIN:COMPONENTNAME and + * ends with END:COMPONENTNAME + * + * @package Sabre + * @subpackage VObject + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class Sabre_VObject_Component extends Sabre_VObject_Element { + + /** + * Name, for example VEVENT + * + * @var string + */ + public $name; + + /** + * Children properties and components + * + * @var array + */ + public $children = array(); + + + /** + * Creates a new component. + * + * By default this object will iterate over its own children, but this can + * be overridden with the iterator argument + * + * @param string $name + * @param Sabre_VObject_ElementList $iterator + */ + public function __construct($name, Sabre_VObject_ElementList $iterator = null) { + + $this->name = strtoupper($name); + if (!is_null($iterator)) $this->iterator = $iterator; + + } + + /** + * Turns the object back into a serialized blob. + * + * @return string + */ + public function serialize() { + + $str = "BEGIN:" . $this->name . "\r\n"; + foreach($this->children as $child) $str.=$child->serialize(); + $str.= "END:" . $this->name . "\r\n"; + + return $str; + + } + + + /** + * Adds a new componenten or element + * + * You can call this method with the following syntaxes: + * + * add(Sabre_VObject_Element $element) + * add(string $name, $value) + * + * The first version adds an Element + * The second adds a property as a string. + * + * @param mixed $item + * @param mixed $itemValue + * @return void + */ + public function add($item, $itemValue = null) { + + if ($item instanceof Sabre_VObject_Element) { + if (!is_null($itemValue)) { + throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject'); + } + $item->parent = $this; + $this->children[] = $item; + } elseif(is_string($item)) { + + if (!is_scalar($itemValue)) { + throw new InvalidArgumentException('The second argument must be scalar'); + } + $item = new Sabre_VObject_Property($item,$itemValue); + $item->parent = $this; + $this->children[] = $item; + + } else { + + throw new InvalidArgumentException('The first argument must either be a Sabre_VObject_Element or a string'); + + } + + } + + /** + * Returns an iterable list of children + * + * @return Sabre_VObject_ElementList + */ + public function children() { + + return new Sabre_VObject_ElementList($this->children); + + } + + /** + * Returns an array with elements that match the specified name. + * + * This function is also aware of MIME-Directory groups (as they appear in + * vcards). This means that if a property is grouped as "HOME.EMAIL", it + * will also be returned when searching for just "EMAIL". If you want to + * search for a property in a specific group, you can select on the entire + * string ("HOME.EMAIL"). If you want to search on a specific property that + * has not been assigned a group, specify ".EMAIL". + * + * Keys are retained from the 'children' array, which may be confusing in + * certain cases. + * + * @param string $name + * @return array + */ + public function select($name) { + + $group = null; + $name = strtoupper($name); + if (strpos($name,'.')!==false) { + list($group,$name) = explode('.', $name, 2); + } + + $result = array(); + foreach($this->children as $key=>$child) { + + if ( + strtoupper($child->name) === $name && + (is_null($group) || ( $child instanceof Sabre_VObject_Property && strtoupper($child->group) === $group)) + ) { + + $result[$key] = $child; + + } + } + + reset($result); + return $result; + + } + + /* Magic property accessors {{{ */ + + /** + * Using 'get' you will either get a propery or component, + * + * If there were no child-elements found with the specified name, + * null is returned. + * + * @param string $name + * @return void + */ + public function __get($name) { + + $matches = $this->select($name); + if (count($matches)===0) { + return null; + } else { + $firstMatch = current($matches); + $firstMatch->setIterator(new Sabre_VObject_ElementList(array_values($matches))); + return $firstMatch; + } + + } + + /** + * This method checks if a sub-element with the specified name exists. + * + * @param string $name + * @return bool + */ + public function __isset($name) { + + $matches = $this->select($name); + return count($matches)>0; + + } + + /** + * Using the setter method you can add properties or subcomponents + * + * You can either pass a Sabre_VObject_Component, Sabre_VObject_Property + * object, or a string to automatically create a Property. + * + * If the item already exists, it will be removed. If you want to add + * a new item with the same name, always use the add() method. + * + * @param string $name + * @param mixed $value + * @return void + */ + public function __set($name, $value) { + + $matches = $this->select($name); + $overWrite = count($matches)?key($matches):null; + + if ($value instanceof Sabre_VObject_Component || $value instanceof Sabre_VObject_Property) { + $value->parent = $this; + if (!is_null($overWrite)) { + $this->children[$overWrite] = $value; + } else { + $this->children[] = $value; + } + } elseif (is_scalar($value)) { + $property = new Sabre_VObject_Property($name,$value); + $property->parent = $this; + if (!is_null($overWrite)) { + $this->children[$overWrite] = $property; + } else { + $this->children[] = $property; + } + } else { + throw new InvalidArgumentException('You must pass a Sabre_VObject_Component, Sabre_VObject_Property or scalar type'); + } + + } + + /** + * Removes all properties and components within this component. + * + * @param string $name + * @return void + */ + public function __unset($name) { + + $matches = $this->select($name); + foreach($matches as $k=>$child) { + + unset($this->children[$k]); + $child->parent = null; + + } + + } + + /* }}} */ + +} diff --git a/3rdparty/Sabre/VObject/Element.php b/3rdparty/Sabre/VObject/Element.php new file mode 100644 index 00000000000..8d2b0aaacd1 --- /dev/null +++ b/3rdparty/Sabre/VObject/Element.php @@ -0,0 +1,15 @@ +<?php + +/** + * Base class for all elements + * + * @package Sabre + * @subpackage VObject + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +abstract class Sabre_VObject_Element extends Sabre_VObject_Node { + + +} diff --git a/3rdparty/Sabre/VObject/Element/DateTime.php b/3rdparty/Sabre/VObject/Element/DateTime.php new file mode 100644 index 00000000000..3350ec02c88 --- /dev/null +++ b/3rdparty/Sabre/VObject/Element/DateTime.php @@ -0,0 +1,245 @@ +<?php + +/** + * DateTime property + * + * This element is used for iCalendar properties such as the DTSTART property. + * It basically provides a few helper functions that make it easier to deal + * with these. It supports both DATE-TIME and DATE values. + * + * In order to use this correctly, you must call setDateTime and getDateTime to + * retrieve and modify dates respectively. + * + * If you use the 'value' or properties directly, this object does not keep + * reference and results might appear incorrectly. + * + * @package Sabre + * @subpackage VObject + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property { + + /** + * Local 'floating' time + */ + const LOCAL = 1; + + /** + * UTC-based time + */ + const UTC = 2; + + /** + * Local time plus timezone + */ + const LOCALTZ = 3; + + /** + * Only a date, time is ignored + */ + const DATE = 4; + + /** + * DateTime representation + * + * @var DateTime + */ + protected $dateTime; + + /** + * dateType + * + * @var int + */ + protected $dateType; + + /** + * Updates the Date and Time. + * + * @param DateTime $dt + * @param int $dateType + * @return void + */ + public function setDateTime(DateTime $dt, $dateType = self::LOCALTZ) { + + switch($dateType) { + + case self::LOCAL : + $this->setValue($dt->format('Ymd\\THis')); + $this->offsetUnset('VALUE'); + $this->offsetUnset('TZID'); + $this->offsetSet('VALUE','DATE-TIME'); + break; + case self::UTC : + $dt->setTimeZone(new DateTimeZone('UTC')); + $this->setValue($dt->format('Ymd\\THis\\Z')); + $this->offsetUnset('VALUE'); + $this->offsetUnset('TZID'); + $this->offsetSet('VALUE','DATE-TIME'); + break; + case self::LOCALTZ : + $this->setValue($dt->format('Ymd\\THis')); + $this->offsetUnset('VALUE'); + $this->offsetUnset('TZID'); + $this->offsetSet('VALUE','DATE-TIME'); + $this->offsetSet('TZID', $dt->getTimeZone()->getName()); + break; + case self::DATE : + $this->setValue($dt->format('Ymd')); + $this->offsetUnset('VALUE'); + $this->offsetUnset('TZID'); + $this->offsetSet('VALUE','DATE'); + break; + default : + throw new InvalidArgumentException('You must pass a valid dateType constant'); + + } + $this->dateTime = $dt; + $this->dateType = $dateType; + + } + + /** + * Returns the current DateTime value. + * + * If no value was set, this method returns null. + * + * @return DateTime|null + */ + public function getDateTime() { + + if ($this->dateTime) + return $this->dateTime; + + list( + $this->dateType, + $this->dateTime + ) = self::parseData($this->value, $this); + return $this->dateTime; + + } + + /** + * Returns the type of Date format. + * + * This method returns one of the format constants. If no date was set, + * this method will return null. + * + * @return int|null + */ + public function getDateType() { + + if ($this->dateType) + return $this->dateType; + + list( + $this->dateType, + $this->dateTime, + ) = self::parseData($this->value, $this); + return $this->dateType; + + } + + /** + * Parses the internal data structure to figure out what the current date + * and time is. + * + * The returned array contains two elements: + * 1. A 'DateType' constant (as defined on this class), or null. + * 2. A DateTime object (or null) + * + * @param string|null $propertyValue The string to parse (yymmdd or + * ymmddThhmmss, etc..) + * @param Sabre_VObject_Property|null $property The instance of the + * property we're parsing. + * @return array + */ + static public function parseData($propertyValue, Sabre_VObject_Property $property = null) { + + if (is_null($propertyValue)) { + return array(null, null); + } + + $date = '(?P<year>[1-2][0-9]{3})(?P<month>[0-1][0-9])(?P<date>[0-3][0-9])'; + $time = '(?P<hour>[0-2][0-9])(?P<minute>[0-5][0-9])(?P<second>[0-5][0-9])'; + $regex = "/^$date(T$time(?P<isutc>Z)?)?$/"; + + if (!preg_match($regex, $propertyValue, $matches)) { + throw new InvalidArgumentException($propertyValue . ' is not a valid DateTime or Date string'); + } + + if (!isset($matches['hour'])) { + // Date-only + return array( + self::DATE, + new DateTime($matches['year'] . '-' . $matches['month'] . '-' . $matches['date'] . ' 00:00:00'), + ); + } + + $dateStr = + $matches['year'] .'-' . + $matches['month'] . '-' . + $matches['date'] . ' ' . + $matches['hour'] . ':' . + $matches['minute'] . ':' . + $matches['second']; + + if (isset($matches['isutc'])) { + $dt = new DateTime($dateStr,new DateTimeZone('UTC')); + $dt->setTimeZone(new DateTimeZone('UTC')); + return array( + self::UTC, + $dt + ); + } + + // Finding the timezone. + $tzid = $property['TZID']; + if (!$tzid) { + return array( + self::LOCAL, + new DateTime($dateStr) + ); + } + + try { + $tz = new DateTimeZone($tzid->value); + } catch (Exception $e) { + + // The id was invalid, we're going to try to find the information + // through the VTIMEZONE object. + + // First we find the root object + $root = $property; + while($root->parent) { + $root = $root->parent; + } + + if (isset($root->VTIMEZONE)) { + foreach($root->VTIMEZONE as $vtimezone) { + if (((string)$vtimezone->TZID) == $tzid) { + if (isset($vtimezone->{'X-LIC-LOCATION'})) { + $tzid = (string)$vtimezone->{'X-LIC-LOCATION'}; + } + } + } + } + + $tz = new DateTimeZone($tzid); + + } + $dt = new DateTime($dateStr, $tz); + $dt->setTimeZone($tz); + + return array( + self::LOCALTZ, + $dt + ); + + } + +} + +?> diff --git a/3rdparty/Sabre/VObject/Element/MultiDateTime.php b/3rdparty/Sabre/VObject/Element/MultiDateTime.php new file mode 100644 index 00000000000..dc6ca5abb80 --- /dev/null +++ b/3rdparty/Sabre/VObject/Element/MultiDateTime.php @@ -0,0 +1,168 @@ +<?php + +/** + * Multi-DateTime property + * + * This element is used for iCalendar properties such as the EXDATE property. + * It basically provides a few helper functions that make it easier to deal + * with these. It supports both DATE-TIME and DATE values. + * + * In order to use this correctly, you must call setDateTimes and getDateTimes + * to retrieve and modify dates respectively. + * + * If you use the 'value' or properties directly, this object does not keep + * reference and results might appear incorrectly. + * + * @package Sabre + * @subpackage VObject + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class Sabre_VObject_Element_MultiDateTime extends Sabre_VObject_Property { + + /** + * DateTime representation + * + * @var DateTime[] + */ + protected $dateTimes; + + /** + * dateType + * + * This is one of the Sabre_VObject_Element_DateTime constants. + * + * @var int + */ + protected $dateType; + + /** + * Updates the value + * + * @param array $dt Must be an array of DateTime objects. + * @param int $dateType + * @return void + */ + public function setDateTimes(array $dt, $dateType = Sabre_VObject_Element_DateTime::LOCALTZ) { + + foreach($dt as $i) + if (!$i instanceof DateTime) + throw new InvalidArgumentException('You must pass an array of DateTime objects'); + + $this->offsetUnset('VALUE'); + $this->offsetUnset('TZID'); + switch($dateType) { + + case Sabre_VObject_Element_DateTime::LOCAL : + $val = array(); + foreach($dt as $i) { + $val[] = $i->format('Ymd\\THis'); + } + $this->setValue(implode(',',$val)); + $this->offsetSet('VALUE','DATE-TIME'); + break; + case Sabre_VObject_Element_DateTime::UTC : + $val = array(); + foreach($dt as $i) { + $i->setTimeZone(new DateTimeZone('UTC')); + $val[] = $i->format('Ymd\\THis\\Z'); + } + $this->setValue(implode(',',$val)); + $this->offsetSet('VALUE','DATE-TIME'); + break; + case Sabre_VObject_Element_DateTime::LOCALTZ : + $val = array(); + foreach($dt as $i) { + $val[] = $i->format('Ymd\\THis'); + } + $this->setValue(implode(',',$val)); + $this->offsetSet('VALUE','DATE-TIME'); + $this->offsetSet('TZID', $dt[0]->getTimeZone()->getName()); + break; + case Sabre_VObject_Element_DateTime::DATE : + $val = array(); + foreach($dt as $i) { + $val[] = $i->format('Ymd'); + } + $this->setValue(implode(',',$val)); + $this->offsetSet('VALUE','DATE'); + break; + default : + throw new InvalidArgumentException('You must pass a valid dateType constant'); + + } + $this->dateTimes = $dt; + $this->dateType = $dateType; + + } + + /** + * Returns the current DateTime value. + * + * If no value was set, this method returns null. + * + * @return array|null + */ + public function getDateTimes() { + + if ($this->dateTimes) + return $this->dateTimes; + + $dts = array(); + + if (!$this->value) { + $this->dateTimes = null; + $this->dateType = null; + return null; + } + + foreach(explode(',',$this->value) as $val) { + list( + $type, + $dt + ) = Sabre_VObject_Element_DateTime::parseData($val, $this); + $dts[] = $dt; + $this->dateType = $type; + } + $this->dateTimes = $dts; + return $this->dateTimes; + + } + + /** + * Returns the type of Date format. + * + * This method returns one of the format constants. If no date was set, + * this method will return null. + * + * @return int|null + */ + public function getDateType() { + + if ($this->dateType) + return $this->dateType; + + if (!$this->value) { + $this->dateTimes = null; + $this->dateType = null; + return null; + } + + $dts = array(); + foreach(explode(',',$this->value) as $val) { + list( + $type, + $dt + ) = Sabre_VObject_Element_DateTime::parseData($val, $this); + $dts[] = $dt; + $this->dateType = $type; + } + $this->dateTimes = $dts; + return $this->dateType; + + } + +} + +?> diff --git a/3rdparty/Sabre/VObject/ElementList.php b/3rdparty/Sabre/VObject/ElementList.php new file mode 100644 index 00000000000..9922cd587bc --- /dev/null +++ b/3rdparty/Sabre/VObject/ElementList.php @@ -0,0 +1,172 @@ +<?php + +/** + * VObject ElementList + * + * This class represents a list of elements. Lists are the result of queries, + * such as doing $vcalendar->vevent where there's multiple VEVENT objects. + * + * @package Sabre + * @subpackage VObject + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class Sabre_VObject_ElementList implements Iterator, Countable, ArrayAccess { + + /** + * Inner elements + * + * @var array + */ + protected $elements = array(); + + /** + * Creates the element list. + * + * @param array $elements + */ + public function __construct(array $elements) { + + $this->elements = $elements; + + } + + /* {{{ Iterator interface */ + + /** + * Current position + * + * @var int + */ + private $key = 0; + + /** + * Returns current item in iteration + * + * @return Sabre_VObject_Element + */ + public function current() { + + return $this->elements[$this->key]; + + } + + /** + * To the next item in the iterator + * + * @return void + */ + public function next() { + + $this->key++; + + } + + /** + * Returns the current iterator key + * + * @return int + */ + public function key() { + + return $this->key; + + } + + /** + * Returns true if the current position in the iterator is a valid one + * + * @return bool + */ + public function valid() { + + return isset($this->elements[$this->key]); + + } + + /** + * Rewinds the iterator + * + * @return void + */ + public function rewind() { + + $this->key = 0; + + } + + /* }}} */ + + /* {{{ Countable interface */ + + /** + * Returns the number of elements + * + * @return int + */ + public function count() { + + return count($this->elements); + + } + + /* }}} */ + + /* {{{ ArrayAccess Interface */ + + + /** + * Checks if an item exists through ArrayAccess. + * + * @param int $offset + * @return bool + */ + public function offsetExists($offset) { + + return isset($this->elements[$offset]); + + } + + /** + * Gets an item through ArrayAccess. + * + * @param int $offset + * @return mixed + */ + public function offsetGet($offset) { + + return $this->elements[$offset]; + + } + + /** + * Sets an item through ArrayAccess. + * + * @param int $offset + * @param mixed $value + * @return void + */ + public function offsetSet($offset,$value) { + + throw new LogicException('You can not add new objects to an ElementList'); + + } + + /** + * Sets an item through ArrayAccess. + * + * This method just forwards the request to the inner iterator + * + * @param int $offset + * @return void + */ + public function offsetUnset($offset) { + + throw new LogicException('You can not remove objects from an ElementList'); + + } + + /* }}} */ + +} diff --git a/3rdparty/Sabre/VObject/Node.php b/3rdparty/Sabre/VObject/Node.php new file mode 100644 index 00000000000..7100b62f1cb --- /dev/null +++ b/3rdparty/Sabre/VObject/Node.php @@ -0,0 +1,149 @@ +<?php + +/** + * Base class for all nodes + * + * @package Sabre + * @subpackage VObject + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +abstract class Sabre_VObject_Node implements IteratorAggregate, ArrayAccess, Countable { + + /** + * Turns the object back into a serialized blob. + * + * @return string + */ + abstract function serialize(); + + /** + * Iterator override + * + * @var Sabre_VObject_ElementList + */ + protected $iterator = null; + + /** + * A link to the parent node + * + * @var Sabre_VObject_Node + */ + protected $parent = null; + + /* {{{ IteratorAggregator interface */ + + /** + * Returns the iterator for this object + * + * @return Sabre_VObject_ElementList + */ + public function getIterator() { + + if (!is_null($this->iterator)) + return $this->iterator; + + return new Sabre_VObject_ElementList(array($this)); + + } + + /** + * Sets the overridden iterator + * + * Note that this is not actually part of the iterator interface + * + * @param Sabre_VObject_ElementList $iterator + * @return void + */ + public function setIterator(Sabre_VObject_ElementList $iterator) { + + $this->iterator = $iterator; + + } + + /* }}} */ + + /* {{{ Countable interface */ + + /** + * Returns the number of elements + * + * @return int + */ + public function count() { + + $it = $this->getIterator(); + return $it->count(); + + } + + /* }}} */ + + /* {{{ ArrayAccess Interface */ + + + /** + * Checks if an item exists through ArrayAccess. + * + * This method just forwards the request to the inner iterator + * + * @param int $offset + * @return bool + */ + public function offsetExists($offset) { + + $iterator = $this->getIterator(); + return $iterator->offsetExists($offset); + + } + + /** + * Gets an item through ArrayAccess. + * + * This method just forwards the request to the inner iterator + * + * @param int $offset + * @return mixed + */ + public function offsetGet($offset) { + + $iterator = $this->getIterator(); + return $iterator->offsetGet($offset); + + } + + /** + * Sets an item through ArrayAccess. + * + * This method just forwards the request to the inner iterator + * + * @param int $offset + * @param mixed $value + * @return void + */ + public function offsetSet($offset,$value) { + + $iterator = $this->getIterator(); + return $iterator->offsetSet($offset,$value); + + } + + /** + * Sets an item through ArrayAccess. + * + * This method just forwards the request to the inner iterator + * + * @param int $offset + * @return void + */ + public function offsetUnset($offset) { + + $iterator = $this->getIterator(); + return $iterator->offsetUnset($offset); + + } + + /* }}} */ + +} diff --git a/3rdparty/Sabre/VObject/Parameter.php b/3rdparty/Sabre/VObject/Parameter.php new file mode 100644 index 00000000000..9ebab6ec69b --- /dev/null +++ b/3rdparty/Sabre/VObject/Parameter.php @@ -0,0 +1,81 @@ +<?php + +/** + * VObject Parameter + * + * This class represents a parameter. A parameter is always tied to a property. + * In the case of: + * DTSTART;VALUE=DATE:20101108 + * VALUE=DATE would be the parameter name and value. + * + * @package Sabre + * @subpackage VObject + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class Sabre_VObject_Parameter extends Sabre_VObject_Node { + + /** + * Parameter name + * + * @var string + */ + public $name; + + /** + * Parameter value + * + * @var string + */ + public $value; + + /** + * Sets up the object + * + * @param string $name + * @param string $value + */ + public function __construct($name, $value = null) { + + $this->name = strtoupper($name); + $this->value = $value; + + } + + /** + * Turns the object back into a serialized blob. + * + * @return string + */ + public function serialize() { + + $src = array( + '\\', + "\n", + ';', + ',', + ); + $out = array( + '\\\\', + '\n', + '\;', + '\,', + ); + + return $this->name . '=' . str_replace($src, $out, $this->value); + + } + + /** + * Called when this object is being cast to a string + * + * @return string + */ + public function __toString() { + + return $this->value; + + } + +} diff --git a/3rdparty/Sabre/VObject/ParseException.php b/3rdparty/Sabre/VObject/ParseException.php new file mode 100644 index 00000000000..ed4ef2e8592 --- /dev/null +++ b/3rdparty/Sabre/VObject/ParseException.php @@ -0,0 +1,12 @@ +<?php + +/** + * Exception thrown by Sabre_VObject_Reader if an invalid object was attempted to be parsed. + * + * @package Sabre + * @subpackage VObject + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class Sabre_VObject_ParseException extends Exception { } diff --git a/3rdparty/Sabre/VObject/Property.php b/3rdparty/Sabre/VObject/Property.php new file mode 100644 index 00000000000..06058229043 --- /dev/null +++ b/3rdparty/Sabre/VObject/Property.php @@ -0,0 +1,289 @@ +<?php + +/** + * VObject Property + * + * A property in VObject is usually in the form PARAMNAME:paramValue. + * An example is : SUMMARY:Weekly meeting + * + * Properties can also have parameters: + * SUMMARY;LANG=en:Weekly meeting. + * + * Parameters can be accessed using the ArrayAccess interface. + * + * @package Sabre + * @subpackage VObject + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class Sabre_VObject_Property extends Sabre_VObject_Element { + + /** + * Propertyname + * + * @var string + */ + public $name; + + /** + * Group name + * + * This may be something like 'HOME' for vcards. + * + * @var string + */ + public $group; + + /** + * Property parameters + * + * @var array + */ + public $parameters = array(); + + /** + * Property value + * + * @var string + */ + public $value; + + /** + * Creates a new property object + * + * By default this object will iterate over its own children, but this can + * be overridden with the iterator argument + * + * @param string $name + * @param string $value + * @param Sabre_VObject_ElementList $iterator + */ + public function __construct($name, $value = null, $iterator = null) { + + $name = strtoupper($name); + $group = null; + if (strpos($name,'.')!==false) { + list($group, $name) = explode('.', $name); + } + $this->name = $name; + $this->group = $group; + if (!is_null($iterator)) $this->iterator = $iterator; + $this->setValue($value); + + } + + /** + * Updates the internal value + * + * @param string $value + * @return void + */ + public function setValue($value) { + + $this->value = $value; + + } + + /** + * Turns the object back into a serialized blob. + * + * @return string + */ + public function serialize() { + + $str = $this->name; + if ($this->group) $str = $this->group . '.' . $this->name; + + if (count($this->parameters)) { + foreach($this->parameters as $param) { + + $str.=';' . $param->serialize(); + + } + } + $src = array( + '\\', + "\n", + ); + $out = array( + '\\\\', + '\n', + ); + $str.=':' . str_replace($src, $out, $this->value); + + $out = ''; + while(strlen($str)>0) { + if (strlen($str)>75) { + $out.= substr($str,0,75) . "\r\n"; + $str = ' ' . substr($str,75); + } else { + $out.=$str . "\r\n"; + $str=''; + break; + } + } + + return $out; + + } + + /** + * Adds a new componenten or element + * + * You can call this method with the following syntaxes: + * + * add(Sabre_VObject_Parameter $element) + * add(string $name, $value) + * + * The first version adds an Parameter + * The second adds a property as a string. + * + * @param mixed $item + * @param mixed $itemValue + * @return void + */ + public function add($item, $itemValue = null) { + + if ($item instanceof Sabre_VObject_Parameter) { + if (!is_null($itemValue)) { + throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject'); + } + $item->parent = $this; + $this->parameters[] = $item; + } elseif(is_string($item)) { + + if (!is_scalar($itemValue)) { + throw new InvalidArgumentException('The second argument must be scalar'); + } + $parameter = new Sabre_VObject_Parameter($item,$itemValue); + $parameter->parent = $this; + $this->parameters[] = $parameter; + + } else { + + throw new InvalidArgumentException('The first argument must either be a Sabre_VObject_Element or a string'); + + } + + } + + + /* ArrayAccess interface {{{ */ + + /** + * Checks if an array element exists + * + * @param mixed $name + * @return bool + */ + public function offsetExists($name) { + + if (is_int($name)) return parent::offsetExists($name); + + $name = strtoupper($name); + + foreach($this->parameters as $parameter) { + if ($parameter->name == $name) return true; + } + return false; + + } + + /** + * Returns a parameter, or parameter list. + * + * @param string $name + * @return Sabre_VObject_Element + */ + public function offsetGet($name) { + + if (is_int($name)) return parent::offsetGet($name); + $name = strtoupper($name); + + $result = array(); + foreach($this->parameters as $parameter) { + if ($parameter->name == $name) + $result[] = $parameter; + } + + if (count($result)===0) { + return null; + } elseif (count($result)===1) { + return $result[0]; + } else { + $result[0]->setIterator(new Sabre_VObject_ElementList($result)); + return $result[0]; + } + + } + + /** + * Creates a new parameter + * + * @param string $name + * @param mixed $value + * @return void + */ + public function offsetSet($name, $value) { + + if (is_int($name)) return parent::offsetSet($name, $value); + + if (is_scalar($value)) { + if (!is_string($name)) + throw new InvalidArgumentException('A parameter name must be specified. This means you cannot use the $array[]="string" to add parameters.'); + + $this->offsetUnset($name); + $parameter = new Sabre_VObject_Parameter($name, $value); + $parameter->parent = $this; + $this->parameters[] = $parameter; + + } elseif ($value instanceof Sabre_VObject_Parameter) { + if (!is_null($name)) + throw new InvalidArgumentException('Don\'t specify a parameter name if you\'re passing a Sabre_VObject_Parameter. Add using $array[]=$parameterObject.'); + + $value->parent = $this; + $this->parameters[] = $value; + } else { + throw new InvalidArgumentException('You can only add parameters to the property object'); + } + + } + + /** + * Removes one or more parameters with the specified name + * + * @param string $name + * @return void + */ + public function offsetUnset($name) { + + if (is_int($name)) return parent::offsetUnset($name, $value); + $name = strtoupper($name); + + $result = array(); + foreach($this->parameters as $key=>$parameter) { + if ($parameter->name == $name) { + $parameter->parent = null; + unset($this->parameters[$key]); + } + + } + + } + + /* }}} */ + + /** + * Called when this object is being cast to a string + * + * @return string + */ + public function __toString() { + + return $this->value; + + } + + +} diff --git a/3rdparty/Sabre/VObject/Reader.php b/3rdparty/Sabre/VObject/Reader.php new file mode 100644 index 00000000000..7d1c282838e --- /dev/null +++ b/3rdparty/Sabre/VObject/Reader.php @@ -0,0 +1,191 @@ +<?php + +/** + * VCALENDAR/VCARD reader + * + * This class reads the vobject file, and returns a full element tree. + * + * + * TODO: this class currently completely works 'statically'. This is pointless, + * and defeats OOP principals. Needs refaxtoring in a future version. + * + * @package Sabre + * @subpackage VObject + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class Sabre_VObject_Reader { + + /** + * This array contains a list of Property names that are automatically + * mapped to specific class names. + * + * Adding to this list allows you to specify custom property classes, + * adding extra functionality. + * + * @var array + */ + static public $elementMap = array( + 'DTSTART' => 'Sabre_VObject_Element_DateTime', + 'DTEND' => 'Sabre_VObject_Element_DateTime', + 'COMPLETED' => 'Sabre_VObject_Element_DateTime', + 'DUE' => 'Sabre_VObject_Element_DateTime', + 'EXDATE' => 'Sabre_VObject_Element_MultiDateTime', + ); + + /** + * Parses the file and returns the top component + * + * @param string $data + * @return Sabre_VObject_Element + */ + static function read($data) { + + // Normalizing newlines + $data = str_replace(array("\r","\n\n"), array("\n","\n"), $data); + + $lines = explode("\n", $data); + + // Unfolding lines + $lines2 = array(); + foreach($lines as $line) { + + // Skipping empty lines + if (!$line) continue; + + if ($line[0]===" " || $line[0]==="\t") { + $lines2[count($lines2)-1].=substr($line,1); + } else { + $lines2[] = $line; + } + + } + + unset($lines); + + reset($lines2); + + return self::readLine($lines2); + + } + + /** + * Reads and parses a single line. + * + * This method receives the full array of lines. The array pointer is used + * to traverse. + * + * @param array $lines + * @return Sabre_VObject_Element + */ + static private function readLine(&$lines) { + + $line = current($lines); + $lineNr = key($lines); + next($lines); + + // Components + if (stripos($line,"BEGIN:")===0) { + + // This is a component + $obj = new Sabre_VObject_Component(strtoupper(substr($line,6))); + + $nextLine = current($lines); + + while(stripos($nextLine,"END:")!==0) { + + $obj->add(self::readLine($lines)); + $nextLine = current($lines); + + if ($nextLine===false) + throw new Sabre_VObject_ParseException('Invalid VObject. Document ended prematurely.'); + + } + + // Checking component name of the 'END:' line. + if (substr($nextLine,4)!==$obj->name) { + throw new Sabre_VObject_ParseException('Invalid VObject, expected: "END:' . $obj->name . '" got: "' . $nextLine . '"'); + } + next($lines); + + return $obj; + + } + + // Properties + //$result = preg_match('/(?P<name>[A-Z0-9-]+)(?:;(?P<parameters>^(?<!:):))(.*)$/',$line,$matches); + + + $token = '[A-Z0-9-\/\.]+'; + $parameters = "(?:;(?P<parameters>([^:^\"]|\"([^\"]*)\")*))?"; + $regex = "/^(?P<name>$token)$parameters:(?P<value>.*)$/i"; + + $result = preg_match($regex,$line,$matches); + + if (!$result) { + throw new Sabre_VObject_ParseException('Invalid VObject, line ' . ($lineNr+1) . ' did not follow the icalendar/vcard format'); + } + + $propertyName = strtoupper($matches['name']); + $propertyValue = stripcslashes($matches['value']); + + if (isset(self::$elementMap[$propertyName])) { + $className = self::$elementMap[$propertyName]; + } else { + $className = 'Sabre_VObject_Property'; + } + + $obj = new $className($propertyName, $propertyValue); + + if ($matches['parameters']) { + + foreach(self::readParameters($matches['parameters']) as $param) { + $obj->add($param); + } + } + + return $obj; + + + } + + /** + * Reads a parameter list from a property + * + * This method returns an array of Sabre_VObject_Parameter + * + * @param string $parameters + * @return array + */ + static private function readParameters($parameters) { + + $token = '[A-Z0-9-]+'; + + $paramValue = '(?P<paramValue>[^\"^;]*|"[^"]*")'; + + $regex = "/(?<=^|;)(?P<paramName>$token)(=$paramValue(?=$|;))?/i"; + preg_match_all($regex, $parameters, $matches, PREG_SET_ORDER); + + $params = array(); + foreach($matches as $match) { + + $value = isset($match['paramValue'])?$match['paramValue']:null; + + if (isset($value[0])) { + // Stripping quotes, if needed + if ($value[0] === '"') $value = substr($value,1,strlen($value)-2); + } else { + $value = ''; + } + + $params[] = new Sabre_VObject_Parameter($match['paramName'], stripcslashes($value)); + + } + + return $params; + + } + + +} diff --git a/3rdparty/Sabre/VObject/Version.php b/3rdparty/Sabre/VObject/Version.php new file mode 100644 index 00000000000..937c367e222 --- /dev/null +++ b/3rdparty/Sabre/VObject/Version.php @@ -0,0 +1,24 @@ +<?php + +/** + * This class contains the version number for the VObject package + * + * @package Sabre + * @subpackage VObject + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class Sabre_VObject_Version { + + /** + * Full version number + */ + const VERSION = '1.2.4'; + + /** + * Stability : alpha, beta, stable + */ + const STABILITY = 'stable'; + +} diff --git a/3rdparty/Sabre/VObject/includes.php b/3rdparty/Sabre/VObject/includes.php new file mode 100644 index 00000000000..f21010fb275 --- /dev/null +++ b/3rdparty/Sabre/VObject/includes.php @@ -0,0 +1,29 @@ +<?php + +/** + * VObject includes + * + * This file automatically includes all VObject classes + * + * @package Sabre + * @subpackage VObject + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ + + +include dirname(__FILE__) . '/ParseException.php'; + +include dirname(__FILE__) . '/Node.php'; +include dirname(__FILE__) . '/Element.php'; +include dirname(__FILE__) . '/ElementList.php'; +include dirname(__FILE__) . '/Parameter.php'; +include dirname(__FILE__) . '/Property.php'; +include dirname(__FILE__) . '/Component.php'; + +include dirname(__FILE__) . '/Element/DateTime.php'; +include dirname(__FILE__) . '/Element/MultiDateTime.php'; + +include dirname(__FILE__) . '/Reader.php'; +include dirname(__FILE__) . '/Version.php'; |