ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ICalendar.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use Sabre\VObject;
7 
22 class ICalendar implements SplitterInterface {
23 
29  protected $vtimezones = [];
30 
36  protected $objects = [];
37 
46  function __construct($input, $options = 0) {
47 
49 
50  if (!$data instanceof VObject\Component\VCalendar) {
51  throw new VObject\ParseException('Supplied input could not be parsed as VCALENDAR.');
52  }
53 
54  foreach ($data->children() as $component) {
55  if (!$component instanceof VObject\Component) {
56  continue;
57  }
58 
59  // Get all timezones
60  if ($component->name === 'VTIMEZONE') {
61  $this->vtimezones[(string)$component->TZID] = $component;
62  continue;
63  }
64 
65  // Get component UID for recurring Events search
66  if (!$component->UID) {
67  $component->UID = sha1(microtime()) . '-vobjectimport';
68  }
69  $uid = (string)$component->UID;
70 
71  // Take care of recurring events
72  if (!array_key_exists($uid, $this->objects)) {
73  $this->objects[$uid] = new VCalendar();
74  }
75 
76  $this->objects[$uid]->add(clone $component);
77  }
78 
79  }
80 
89  function getNext() {
90 
91  if ($object = array_shift($this->objects)) {
92 
93  // create our baseobject
94  $object->version = '2.0';
95  $object->prodid = '-//Sabre//Sabre VObject ' . VObject\Version::VERSION . '//EN';
96  $object->calscale = 'GREGORIAN';
97 
98  // add vtimezone information to obj (if we have it)
99  foreach ($this->vtimezones as $vtimezone) {
100  $object->add($vtimezone);
101  }
102 
103  return $object;
104 
105  } else {
106 
107  return;
108 
109  }
110 
111  }
112 
113 }
if($argc< 3) $input
foreach($paths as $path) if(!class_exists( 'Sabre\\VObject\\Version'))
__construct($input, $options=0)
Constructor.
Definition: ICalendar.php:46
const VERSION
Full version number.
Definition: Version.php:17
The VCalendar component.
Definition: VCalendar.php:23
getNext()
Every time getNext() is called, a new object will be parsed, until we hit the end of the stream...
Definition: ICalendar.php:89
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
Exception thrown by Reader if an invalid object was attempted to be parsed.
$data
Definition: bench.php:6