Update Sabre/VObject lib to version 2.1.3

This commit is contained in:
Thomas Bruederli 2013-10-16 17:00:48 +02:00
parent 1f44998d14
commit 406fd4d822
4 changed files with 108 additions and 70 deletions

View file

@ -82,7 +82,11 @@ class Parameter extends Node {
'\,', '\,',
); );
return $this->name . '=' . str_replace($src, $out, $this->value); $value = str_replace($src, $out, $this->value);
if (strpos($value,":")!==false) {
$value = '"' . $value . '"';
}
return $this->name . '=' . $value;
} }

View file

@ -188,10 +188,12 @@ class Property extends Node {
$src = array( $src = array(
'\\', '\\',
"\n", "\n",
"\r",
); );
$out = array( $out = array(
'\\\\', '\\\\',
'\n', '\n',
'',
); );
$str.=':' . str_replace($src, $out, $this->value); $str.=':' . str_replace($src, $out, $this->value);

View file

@ -105,7 +105,6 @@ class RecurrenceIterator implements \Iterator {
*/ */
public $overriddenEvents = array(); public $overriddenEvents = array();
/** /**
* Frequency is one of: secondly, minutely, hourly, daily, weekly, monthly, * Frequency is one of: secondly, minutely, hourly, daily, weekly, monthly,
* yearly. * yearly.
@ -296,6 +295,13 @@ class RecurrenceIterator implements \Iterator {
*/ */
private $nextDate; private $nextDate;
/**
* This counts the number of overridden events we've handled so far
*
* @var int
*/
private $handledOverridden = 0;
/** /**
* Creates the iterator * Creates the iterator
* *
@ -326,6 +332,9 @@ class RecurrenceIterator implements \Iterator {
} }
} }
} }
ksort($this->overriddenEvents);
if (!$this->baseEvent) { if (!$this->baseEvent) {
throw new \InvalidArgumentException('Could not find a base event with uid: ' . $uid); throw new \InvalidArgumentException('Could not find a base event with uid: ' . $uid);
} }
@ -552,8 +561,18 @@ class RecurrenceIterator implements \Iterator {
if (!is_null($this->count)) { if (!is_null($this->count)) {
return $this->counter < $this->count; return $this->counter < $this->count;
} }
if (!is_null($this->until)) { if (!is_null($this->until) && $this->currentDate > $this->until) {
return $this->currentDate <= $this->until;
// Need to make sure there's no overridden events past the
// until date.
foreach($this->overriddenEvents as $overriddenEvent) {
if ($overriddenEvent->DTSTART->getDateTime() >= $this->currentDate) {
return true;
}
}
return false;
} }
return true; return true;
@ -608,26 +627,40 @@ class RecurrenceIterator implements \Iterator {
*/ */
public function next() { public function next() {
/*
if (!is_null($this->count) && $this->counter >= $this->count) {
$this->currentDate = null;
}*/
$previousStamp = $this->currentDate->getTimeStamp(); $previousStamp = $this->currentDate->getTimeStamp();
while(true) { // Finding the next overridden event in line, and storing that for
// later use.
$overriddenEvent = null;
$overriddenDate = null;
$this->currentOverriddenEvent = null; $this->currentOverriddenEvent = null;
// If we have a next date 'stored', we use that foreach($this->overriddenEvents as $index=>$event) {
if ($index > $previousStamp) {
$overriddenEvent = $event;
$overriddenDate = clone $event->DTSTART->getDateTime();
break;
}
}
// If we have a stored 'next date', we will use that.
if ($this->nextDate) { if ($this->nextDate) {
if (!$overriddenDate || $this->nextDate < $overriddenDate) {
$this->currentDate = $this->nextDate; $this->currentDate = $this->nextDate;
$currentStamp = $this->currentDate->getTimeStamp(); $currentStamp = $this->currentDate->getTimeStamp();
$this->nextDate = null; $this->nextDate = null;
} else { } else {
$this->currentDate = clone $overriddenDate;
$this->currentOverriddenEvent = $overriddenEvent;
}
$this->counter++;
return;
}
// Otherwise, we calculate it while(true) {
// Otherwise, we find the next event in the normal RRULE
// sequence.
switch($this->frequency) { switch($this->frequency) {
case 'hourly' : case 'hourly' :
@ -653,6 +686,7 @@ class RecurrenceIterator implements \Iterator {
} }
$currentStamp = $this->currentDate->getTimeStamp(); $currentStamp = $this->currentDate->getTimeStamp();
// Checking exception dates // Checking exception dates
foreach($this->exceptionDates as $exceptionDate) { foreach($this->exceptionDates as $exceptionDate) {
if ($this->currentDate == $exceptionDate) { if ($this->currentDate == $exceptionDate) {
@ -660,40 +694,38 @@ class RecurrenceIterator implements \Iterator {
continue 2; continue 2;
} }
} }
foreach($this->overriddenDates as $overriddenDate) { foreach($this->overriddenDates as $check) {
if ($this->currentDate == $overriddenDate) { if ($this->currentDate == $check) {
continue 2; continue 2;
} }
} }
break;
} }
// Checking overridden events
foreach($this->overriddenEvents as $index=>$event) {
if ($index > $previousStamp && $index <= $currentStamp) {
// We're moving the 'next date' aside, for later use.
// Is the date we have actually higher than the next overiddenEvent?
if ($overriddenDate && $this->currentDate > $overriddenDate) {
$this->nextDate = clone $this->currentDate; $this->nextDate = clone $this->currentDate;
$this->currentDate = clone $overriddenDate;
$this->currentDate = $event->DTSTART->getDateTime(); $this->currentOverriddenEvent = $overriddenEvent;
$this->currentOverriddenEvent = $event; $this->handledOverridden++;
break;
}
} }
$this->counter++;
break;
}
/* /*
if (!is_null($this->until)) { * If we have overridden events left in the queue, but our counter is
if($this->currentDate > $this->until) { * running out, we should grab one of those.
$this->currentDate = null; */
} if (!is_null($overriddenEvent) && !is_null($this->count) && count($this->overriddenEvents) - $this->handledOverridden >= ($this->count - $this->counter)) {
}*/
$this->counter++; $this->currentOverriddenEvent = $overriddenEvent;
$this->currentDate = clone $overriddenDate;
$this->handledOverridden++;
}
} }

View file

@ -14,7 +14,7 @@ class Version {
/** /**
* Full version number * Full version number
*/ */
const VERSION = '2.1.0'; const VERSION = '2.1.3';
/** /**
* Stability : alpha, beta, stable * Stability : alpha, beta, stable