annotate vendor/sabre/vobject/lib/Recur/EventIterator.php @ 7:430dbd5346f7

vendor sabre as distributed
author Charlie Root
date Sat, 13 Jan 2018 09:06:10 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1 <?php
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
3 namespace Sabre\VObject\Recur;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
4
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
5 use InvalidArgumentException;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
6 use DateTime;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
7 use DateTimeZone;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
8 use Sabre\VObject\Component;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
9 use Sabre\VObject\Component\VEvent;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
10
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
11 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
12 * This class is used to determine new for a recurring event, when the next
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
13 * events occur.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
14 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
15 * This iterator may loop infinitely in the future, therefore it is important
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
16 * that if you use this class, you set hard limits for the amount of iterations
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
17 * you want to handle.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
18 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
19 * Note that currently there is not full support for the entire iCalendar
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
20 * specification, as it's very complex and contains a lot of permutations
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
21 * that's not yet used very often in software.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
22 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
23 * For the focus has been on features as they actually appear in Calendaring
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
24 * software, but this may well get expanded as needed / on demand
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
25 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
26 * The following RRULE properties are supported
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
27 * * UNTIL
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
28 * * INTERVAL
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
29 * * COUNT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
30 * * FREQ=DAILY
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
31 * * BYDAY
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
32 * * BYHOUR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
33 * * BYMONTH
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
34 * * FREQ=WEEKLY
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
35 * * BYDAY
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
36 * * BYHOUR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
37 * * WKST
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
38 * * FREQ=MONTHLY
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
39 * * BYMONTHDAY
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
40 * * BYDAY
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
41 * * BYSETPOS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
42 * * FREQ=YEARLY
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
43 * * BYMONTH
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
44 * * BYMONTHDAY (only if BYMONTH is also set)
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
45 * * BYDAY (only if BYMONTH is also set)
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
46 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
47 * Anything beyond this is 'undefined', which means that it may get ignored, or
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
48 * you may get unexpected results. The effect is that in some applications the
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
49 * specified recurrence may look incorrect, or is missing.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
50 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
51 * The recurrence iterator also does not yet support THISANDFUTURE.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
52 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
53 * @copyright Copyright (C) 2011-2015 fruux GmbH (https://fruux.com/).
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
54 * @author Evert Pot (http://evertpot.com/)
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
55 * @license http://sabre.io/license/ Modified BSD License
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
56 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
57 class EventIterator implements \Iterator {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
58
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
59 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
60 * Reference timeZone for floating dates and times.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
61 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
62 * @var DateTimeZone
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
63 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
64 protected $timeZone;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
65
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
66 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
67 * True if we're iterating an all-day event.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
68 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
69 * @var bool
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
70 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
71 protected $allDay = false;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
72
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
73 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
74 * Creates the iterator
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
75 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
76 * You should pass a VCALENDAR component, as well as the UID of the event
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
77 * we're going to traverse.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
78 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
79 * @param Component $vcal
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
80 * @param string|null $uid
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
81 * @param DateTimeZone $timeZone Reference timezone for floating dates and
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
82 * times.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
83 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
84 public function __construct(Component $vcal, $uid = null, DateTimeZone $timeZone = null) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
85
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
86 if (is_null($this->timeZone)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
87 $timeZone = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
88 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
89 $this->timeZone = $timeZone;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
90
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
91 if ($vcal instanceof VEvent) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
92 // Single instance mode.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
93 $events = array($vcal);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
94 } else {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
95 $uid = (string)$uid;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
96 if (!$uid) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
97 throw new InvalidArgumentException('The UID argument is required when a VCALENDAR is passed to this constructor');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
98 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
99 if (!isset($vcal->VEVENT)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
100 throw new InvalidArgumentException('No events found in this calendar');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
101 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
102 $events = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
103 foreach($vcal->VEVENT as $event) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
104 if ($event->uid->getValue() === $uid) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
105 $events[] = $event;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
106 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
107 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
108
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
109 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
110
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
111 foreach($events as $vevent) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
112
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
113 if (!isset($vevent->{'RECURRENCE-ID'})) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
114
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
115 $this->masterEvent = $vevent;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
116
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
117 } else {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
118
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
119 $this->exceptions[
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
120 $vevent->{'RECURRENCE-ID'}->getDateTime($this->timeZone)->getTimeStamp()
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
121 ] = true;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
122 $this->overriddenEvents[] = $vevent;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
123
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
124 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
125
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
126 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
127
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
128 if (!$this->masterEvent) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
129 // No base event was found. CalDAV does allow cases where only
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
130 // overridden instances are stored.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
131 //
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
132 // In this particular case, we're just going to grab the first
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
133 // event and use that instead. This may not always give the
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
134 // desired result.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
135 if (!count($this->overriddenEvents)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
136 throw new InvalidArgumentException('This VCALENDAR did not have an event with UID: ' . $uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
137 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
138 $this->masterEvent = array_shift($this->overriddenEvents);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
139 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
140
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
141 $this->startDate = $this->masterEvent->DTSTART->getDateTime($this->timeZone);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
142 $this->allDay = !$this->masterEvent->DTSTART->hasTime();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
143
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
144 if (isset($this->masterEvent->EXDATE)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
145
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
146 foreach($this->masterEvent->EXDATE as $exDate) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
147
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
148 foreach($exDate->getDateTimes($this->timeZone) as $dt) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
149 $this->exceptions[$dt->getTimeStamp()] = true;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
150 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
151
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
152 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
153
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
154 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
155
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
156 if (isset($this->masterEvent->DTEND)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
157 $this->eventDuration =
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
158 $this->masterEvent->DTEND->getDateTime($this->timeZone)->getTimeStamp() -
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
159 $this->startDate->getTimeStamp();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
160 } elseif (isset($this->masterEvent->DURATION)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
161 $duration = $this->masterEvent->DURATION->getDateInterval();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
162 $end = clone $this->startDate;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
163 $end->add($duration);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
164 $this->eventDuration = $end->getTimeStamp() - $this->startDate->getTimeStamp();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
165 } elseif ($this->allDay) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
166 $this->eventDuration = 3600 * 24;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
167 } else {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
168 $this->eventDuration = 0;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
169 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
170
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
171 if (isset($this->masterEvent->RDATE)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
172 $this->recurIterator = new RDateIterator(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
173 $this->masterEvent->RDATE->getParts(),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
174 $this->startDate
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
175 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
176 } elseif (isset($this->masterEvent->RRULE)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
177 $this->recurIterator = new RRuleIterator(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
178 $this->masterEvent->RRULE->getParts(),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
179 $this->startDate
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
180 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
181 } else {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
182 $this->recurIterator = new RRuleIterator(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
183 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
184 'FREQ' => 'DAILY',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
185 'COUNT' => 1,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
186 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
187 $this->startDate
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
188 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
189 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
190
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
191 $this->rewind();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
192 if (!$this->valid()) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
193 throw new NoInstancesException('This recurrence rule does not generate any valid instances');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
194 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
195
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
196 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
197
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
198 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
199 * Returns the date for the current position of the iterator.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
200 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
201 * @return DateTime
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
202 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
203 public function current() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
204
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
205 if ($this->currentDate) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
206 return clone $this->currentDate;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
207 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
208
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
209 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
210
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
211 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
212 * This method returns the start date for the current iteration of the
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
213 * event.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
214 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
215 * @return DateTime
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
216 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
217 public function getDtStart() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
218
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
219 if ($this->currentDate) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
220 return clone $this->currentDate;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
221 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
222
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
223 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
224
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
225 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
226 * This method returns the end date for the current iteration of the
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
227 * event.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
228 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
229 * @return DateTime
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
230 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
231 public function getDtEnd() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
232
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
233 if (!$this->valid()) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
234 return null;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
235 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
236 $end = clone $this->currentDate;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
237 $end->modify('+' . $this->eventDuration . ' seconds');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
238 return $end;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
239
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
240 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
241
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
242 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
243 * Returns a VEVENT for the current iterations of the event.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
244 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
245 * This VEVENT will have a recurrence id, and it's DTSTART and DTEND
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
246 * altered.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
247 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
248 * @return VEvent
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
249 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
250 public function getEventObject() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
251
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
252 if ($this->currentOverriddenEvent) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
253 return $this->currentOverriddenEvent;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
254 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
255
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
256 $event = clone $this->masterEvent;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
257
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
258 // Ignoring the following block, because PHPUnit's code coverage
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
259 // ignores most of these lines, and this messes with our stats.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
260 //
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
261 // @codeCoverageIgnoreStart
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
262 unset(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
263 $event->RRULE,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
264 $event->EXDATE,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
265 $event->RDATE,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
266 $event->EXRULE,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
267 $event->{'RECURRENCE-ID'}
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
268 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
269 // @codeCoverageIgnoreEnd
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
270
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
271 $event->DTSTART->setDateTime($this->getDtStart());
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
272 if (isset($event->DTEND)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
273 $event->DTEND->setDateTime($this->getDtEnd());
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
274 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
275 // Including a RECURRENCE-ID to the object, unless this is the first
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
276 // object.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
277 //
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
278 // The inner recurIterator is always one step ahead, this is why we're
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
279 // checking for the key being higher than 1.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
280 if ($this->recurIterator->key() > 1) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
281 $recurid = clone $event->DTSTART;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
282 $recurid->name = 'RECURRENCE-ID';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
283 $event->add($recurid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
284 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
285 return $event;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
286
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
287 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
288
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
289 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
290 * Returns the current position of the iterator.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
291 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
292 * This is for us simply a 0-based index.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
293 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
294 * @return int
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
295 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
296 public function key() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
297
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
298 // The counter is always 1 ahead.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
299 return $this->counter - 1;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
300
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
301 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
302
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
303 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
304 * This is called after next, to see if the iterator is still at a valid
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
305 * position, or if it's at the end.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
306 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
307 * @return bool
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
308 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
309 public function valid() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
310
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
311 return !!$this->currentDate;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
312
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
313 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
314
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
315 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
316 * Sets the iterator back to the starting point.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
317 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
318 public function rewind() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
319
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
320 $this->recurIterator->rewind();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
321 // re-creating overridden event index.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
322 $index = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
323 foreach($this->overriddenEvents as $key=>$event) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
324 $stamp = $event->DTSTART->getDateTime($this->timeZone)->getTimeStamp();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
325 $index[$stamp] = $key;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
326 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
327 krsort($index);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
328 $this->counter = 0;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
329 $this->overriddenEventsIndex = $index;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
330 $this->currentOverriddenEvent = null;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
331
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
332 $this->nextDate = null;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
333 $this->currentDate = clone $this->startDate;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
334
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
335 $this->next();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
336
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
337 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
338
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
339 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
340 * Advances the iterator with one step.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
341 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
342 * @return void
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
343 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
344 public function next() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
345
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
346 $this->currentOverriddenEvent = null;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
347 $this->counter++;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
348 if ($this->nextDate) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
349 // We had a stored value.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
350 $nextDate = $this->nextDate;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
351 $this->nextDate = null;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
352 } else {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
353 // We need to ask rruleparser for the next date.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
354 // We need to do this until we find a date that's not in the
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
355 // exception list.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
356 do {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
357 if (!$this->recurIterator->valid()) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
358 $nextDate = null;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
359 break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
360 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
361 $nextDate = $this->recurIterator->current();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
362 $this->recurIterator->next();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
363 } while(isset($this->exceptions[$nextDate->getTimeStamp()]));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
364
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
365 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
366
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
367
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
368 // $nextDate now contains what rrule thinks is the next one, but an
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
369 // overridden event may cut ahead.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
370 if ($this->overriddenEventsIndex) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
371
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
372 $offset = end($this->overriddenEventsIndex);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
373 $timestamp = key($this->overriddenEventsIndex);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
374 if (!$nextDate || $timestamp < $nextDate->getTimeStamp()) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
375 // Overridden event comes first.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
376 $this->currentOverriddenEvent = $this->overriddenEvents[$offset];
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
377
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
378 // Putting the rrule next date aside.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
379 $this->nextDate = $nextDate;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
380 $this->currentDate = $this->currentOverriddenEvent->DTSTART->getDateTime($this->timeZone);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
381
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
382 // Ensuring that this item will only be used once.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
383 array_pop($this->overriddenEventsIndex);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
384
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
385 // Exit point!
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
386 return;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
387
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
388 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
389
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
390 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
391
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
392 $this->currentDate = $nextDate;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
393
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
394 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
395
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
396 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
397 * Quickly jump to a date in the future.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
398 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
399 * @param DateTime $dateTime
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
400 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
401 public function fastForward(DateTime $dateTime) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
402
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
403 while($this->valid() && $this->getDtEnd() < $dateTime ) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
404 $this->next();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
405 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
406
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
407 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
408
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
409 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
410 * Returns true if this recurring event never ends.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
411 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
412 * @return bool
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
413 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
414 public function isInfinite() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
415
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
416 return $this->recurIterator->isInfinite();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
417
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
418 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
419
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
420 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
421 * RRULE parser
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
422 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
423 * @var RRuleIterator
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
424 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
425 protected $recurIterator;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
426
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
427 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
428 * The duration, in seconds, of the master event.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
429 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
430 * We use this to calculate the DTEND for subsequent events.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
431 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
432 protected $eventDuration;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
433
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
434 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
435 * A reference to the main (master) event.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
436 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
437 * @var VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
438 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
439 protected $masterEvent;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
440
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
441 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
442 * List of overridden events.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
443 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
444 * @var array
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
445 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
446 protected $overriddenEvents = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
447
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
448 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
449 * Overridden event index.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
450 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
451 * Key is timestamp, value is the index of the item in the $overriddenEvent
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
452 * property.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
453 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
454 * @var array
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
455 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
456 protected $overriddenEventsIndex;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
457
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
458 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
459 * A list of recurrence-id's that are either part of EXDATE, or are
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
460 * overridden.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
461 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
462 * @var array
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
463 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
464 protected $exceptions = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
465
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
466 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
467 * Internal event counter
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
468 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
469 * @var int
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
470 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
471 protected $counter;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
472
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
473 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
474 * The very start of the iteration process.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
475 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
476 * @var DateTime
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
477 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
478 protected $startDate;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
479
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
480 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
481 * Where we are currently in the iteration process
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
482 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
483 * @var DateTime
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
484 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
485 protected $currentDate;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
486
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
487 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
488 * The next date from the rrule parser.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
489 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
490 * Sometimes we need to temporary store the next date, because an
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
491 * overridden event came before.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
492 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
493 * @var DateTime
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
494 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
495 protected $nextDate;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
496
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
497 }