]>
git.datanom.net - webcal.git/blob - caldav/icomponent.class.php
4 require_once 'caldavresource.class.php';
6 abstract class IComponent
{
14 function __construct($etag, $url, VTYPE
$type,
15 iCalendar
$component, $new) {
18 $this->component
= $component;
23 public function isDirty() {
27 public function setDirty() {
31 public function getResource() {
32 return $this->component
;
35 public function setResource(iCalendar
$component) {
36 $this->component
= $component;
40 public function getBaseComponent() {
41 return $this->getComponent($this->type
);
44 public function getUrl() {
48 public function getEtag() {
52 public function setEtag($etag) {
56 public function getComponent($type) {
57 $ref = $this->component
;
60 if ($this->component
=== NULL)
62 else if ($type instanceof VTYPE
&& $type->ordinal() == VTYPE
::VTIMEZONE
) {
63 $ical = $ref->component
->GetComponents('VTIMEZONE');
66 //$theType = sprintf("%s", $this->type);
67 //print "self: $theType\n";
68 $component = $ref->component
->GetComponents($this->type
);
69 //print_r($component);
70 if (! $type instanceof VTYPE
)
71 $type = new VTYPE($type);
72 //$theType = sprintf("%s", $type);
73 //print "instance: $theType\n";
74 if (count($component) > 0)
75 $ical = $component[0];
76 if ($type->ordinal() != $this->type
->ordinal() && $ical) {
77 $ical = $ical->GetComponents($type);
83 public function isUTCTime() {
84 $event = $this->getBaseComponent();
85 $start = $event->GetPValue('DTSTART');
86 $end = $event->GetPValue('DTEND');
88 if (! ($start && $end))
89 throw new Exception("Not a valid iCal component");
90 return ($start[strlen($start) - 1] == 'Z' ||
91 $nd[strlen($end) - 1] == 'Z');
94 public function getDetails() {
95 $event = $this->getBaseComponent();
96 $start = strtotime($event->GetPValue('DTSTART'));
97 $start = date("Y-m-d H:m", $start);
98 $end = strtotime($event->GetPValue('DTEND'));
99 $end = date("Y-m-d H:m", $end);
100 $title = $event->GetPValue('SUMMARY');
102 return "$start-$end: $title";
105 public function getTZID() {
108 if (! $this->isUTCTime()) {
109 $timezone = $this->getTimeZone();
111 $res = $timezone->GetPValue('TZID');
113 // timezone not given assume TZID = server's timezone
114 // servers default timezone is UTC
119 function getTimeZone() {
120 $timezone = $this->getComponent(VTYPE
::VTIMEZONE
);
122 $timezone = $timezone[0];
126 public function __toString() {
127 return $this->type
->__toString();
131 * The following functions should be overloaded in
132 * the child classes if the have specific functionality
135 function isActive($start, $end) {
139 function getActiveDates() {
143 function getAlarm() {
This page took 0.075102 seconds and 6 git commands to generate.