]>
git.datanom.net - webcal.git/blob - events/eventgui.class.php
4 include_once 'config.inc.php';
5 include_once 'dateformat.class.php';
6 include_once 'caldavresource.class.php';
7 require_once 'calendar.class.php';
8 require_once 'helper.php';
27 function __construct(VEvent
$event = NULL, $referer = '', $cal = NULL) {
28 $this->event
= $event;
29 $this->referer
= urldecode($referer);
31 //print $this->referer;
35 $this->description
= '';
39 $this->localtime
= ($_SESSION['user_settings']->getTimeZone() !== NULL) ?
40 $_SESSION['user_settings']->getTimeZone() : TIMEZONE
;
42 $week_start_sunday = ($_SESSION['user_settings']->getStartWeek() !== NULL) ?
43 $_SESSION['user_settings']->getStartWeek() : WEEK_START_SUNDAY
;
44 $week_start_sunday = ($week_start_sunday) ?
0 : 1;
45 $this->startdate
= <<< __CAL1
46 <script type
="text/javascript">
47 A_TCALDEF
['imgpath'] = '{$root}js/img/';
48 A_TCALDEF
['weekstart'] = $week_start_sunday;
50 'formname': 'event_data',
51 'controlname': 'startdate'
55 $this->enddate
= <<< __CAL1
56 <script type
="text/javascript">
57 A_TCALDEF
['imgpath'] = '{$root}js/img/';
58 A_TCALDEF
['weekstart'] = $week_start_sunday;
60 'formname': 'event_data',
61 'controlname': 'enddate'
65 $this->until
= <<< __CAL1
66 <script type
="text/javascript">
67 A_TCALDEF
['imgpath'] = '{$root}js/img/';
68 A_TCALDEF
['weekstart'] = $week_start_sunday;
70 'formname': 'event_data',
71 'controlname': 'untildate'
77 private function parseEvent() {
80 $comp = $this->event
->getBaseComponent();
81 $this->summary
= $comp->GetPValue('SUMMARY');
82 $this->location
= $comp->GetPValue('LOCATION');
83 $this->description
= $comp->GetPValue('DESCRIPTION');
84 $this->start
= $comp->GetPValue('DTSTART');
85 $this->end
= $comp->GetPValue('DTEND');
86 $this->timezone
= $this->event
->getTZID();
87 $rrule = $this->event
->getRRule();
88 $this->dates
= $rrule->getEventDates();
89 $this->rrule
= $rrule->getAll();
90 //echo $this->start .':'. $this->end .'<br/>';
94 private function createDT($elem, $name) {
99 if (count($elem) > 1) {
101 $time = substr($elem[1], 0, 4);
107 for ($i = 0; $i < substr($time, 2); $i +
= 15);
110 $time = substr($time, 0, 2) . $i;
113 for ($i = 0; $i < 24; $i++
) {
114 $h = ($i < 10) ?
"0$i" : $i;
115 $stop = ($i == 23) ?
61 : 60;
116 for ($j = 0; $j < $stop; $j +
= 15) {
117 $m = ($j < 10) ?
"0$j" : $j;
122 $option = "<option value=\"$hm\"";
124 $option .= ' selected="selected"';
125 $option .= ">$hm</option>";
126 array_push($options, $option);
129 $select = "<select name=\"$name\" id=\"$name\">";
130 foreach ($options as $option)
132 $select .= '</select>';
133 $date = substr($date, 0, 4).'-'.substr($date, 4, 2).'-'.substr($date, 6);
135 $res['date'] = $date;
136 $res['time'] = $select;
140 private function createTime() {
141 include_once 'timezone.php';
143 if ($this->start
== '' ||
$this->end
== '') {
144 $this->start
= date("Ymd\THis");
145 $this->end
= date("Ymd\THis", strtotime("+1 hour"));
146 $this->timezone
= $_SESSION['user_settings']->getTimeZone();
148 //echo $this->start .':'. $this->end .'<br/>';
149 $tz = '<select name="tzid">';
150 foreach ($timezones as $timezone) {
151 $tz .= "<option value=\"$timezone\"";
152 if ($this->localtime
== $timezone)
153 $tz .= ' selected="selected"';
154 $tz .= ">$timezone</option>";
157 $dateFormat = new DateFormat();
158 $UTCStart = $dateFormat->UTC2Client($this->start
);
159 $UTCEnd = $dateFormat->UTC2Client($this->end
);
160 //echo $UTCStart .':'. $UTCEnd .'<br/>';
161 $startArray = explode('T', $UTCStart);
162 //echo "Client: ".$dateFormat->client2UTC($dateFormat->UTC2Client($this->start))."<br/>";
163 //echo "Local: ".$dateFormat->UTC2Local($this->start)."<br/>";
164 $start = $this->createDT($startArray, 'starttime');
165 $endArray = explode('T', $UTCEnd);
166 $end = $this->createDT($endArray, 'endtime');
167 $allDay = CaldavRessource
::allDayEvent($UTCStart, $UTCEnd);
168 $allDay = ($allDay) ?
'checked="checked"' : '';
169 $datetime = "<table><caption style=\"font-weight: bold\">Date & Time</caption>
171 <td>All Day Event</td>
173 <script type=\"text/javascript\">
174 var observable1 = ['starttime', 'tcalico_1', 'enddate', 'endtime'];
175 document.write('<input type=\"checkbox\" name=\"allDay\" $allDay' +
176 'id=\"allDay\" onchange=\"stateSwitch(this, observable1, 0)\"/>');
184 <script type=\"text/javascript\">
185 document.write('<input type=\"text\" name=\"startdate\" ' +
186 'id=\"startdate\" size=\"12\" onchange=\"dateAlign(' +
187 'this)\" value=\"{$start['date']}\"/>');
190 <!--{$start['date']}-->
192 <td>{$start['time']}</td>
193 <td rowspan=\"2\">$tz</td>
198 <script type=\"text/javascript\">
199 document.write('<input name=\"enddate\" type=\"text\" ' +
200 'id=\"enddate\" size=\"12\" onchange=\"dateAlign(' +
201 'this)\" value=\"{$end['date']}\"/>');
204 <!--{$end['date']}-->
208 <script type=\"text/javascript\">
209 var observable4 = ['starttime', 'tcalico_1', 'enddate', 'endtime'];
210 stateSwitch(document.getElementById('allDay'), observable4, 1);
218 private function recurRule($checked) {
219 $choices = array('DAILY', 'WEEKLY', 'MONTHLY', 'YEARLY');
220 $rule = '<span style="font-weight: bold">Recurrence Types</span><br/>';
221 foreach ($choices as $choice) {
222 $rule .= "<input type=\"radio\" name=\"recurrence\" value=\"$choice\"";
223 if (strtoupper($checked) == $choice)
224 $rule .= ' checked="checked"';
225 $rule .= "/>$choice<br/>";
230 private function rangeRule($rules) {
237 $range = $rules['until'][0];
239 $range = $rules['count'][0];
242 $count_check = 'checked="checked"';
245 $no_check = 'checked="checked"';
249 $until = substr($range, 0, 4).'-'.substr($range, 4, 2).
250 '-'.substr($range, 6, 2);
251 $until_check = 'checked="checked"';
254 <span style="font-weight: bold">Recurrence Range</span><br/>
255 <input type="radio" name="range" value="UNLIMITED" $no_check/>
257 <input type="radio" name="range" value="COUNT" $count_check/>
259 <input type="text" name="times" size="4"
260 value="$times"/> Occurrence(s)<br/>
261 <input type="radio" name="range" value="UNTIL" $until_check/>
263 <input type="text" name="untildate" size="12" value="$until"/>
269 private function createRecur() {
273 $rrule = array_diff_key($this->rrule, array('freq' => ''));
274 switch ($this->rrule['freq'][0]) {
275 case 'DAILY': $recur = 'DAILY'; break;
276 case 'WEEKLY': $recur = 'WEEKLY'; break;
277 case 'MONTHLY': $recur = 'MONTHLY'; break;
278 case 'YEARLY': $recur = 'YEARLY'; break;
281 $recur = $this->recurRule($recur);
282 $range = $this->rangeRule($rrule);
283 //print htmlentities($recur);
285 <table cellpadding="10">
286 <caption style="font-weight: bold">Recurrence Rule</caption>
288 <td valign="top">$recur</td>
289 <td valign="top">$range</td>
297 $title = '<input name="summary" size="53" value="_SUM_"/>';
298 $location = '<input name="location" size="53" value="_LOC_"/>';
300 '<textarea name="description" cols="60" rows="5">_DESC_</textarea>';
301 if ($this->parseEvent()) {
302 $title = str_replace('_SUM_', $this->summary, $title);
303 $location = str_replace('_LOC_', $this->location, $location);
304 $description = str_replace('_DESC_', $this->description, $description);
307 $title = str_replace('_SUM_', '', $title);
308 $location = str_replace('_LOC_', '', $location);
309 $description = str_replace('_DESC_', '', $description);
311 $btn_label = ($_SESSION['EVENT_ACTION'] == 'NEW') ? "Create" : "Update";
312 unset($_SESSION['EVENT_ACTION']);
314 $etag = $this->event->getEtag();
315 $url = $this->event->getUrl();
316 $view = dirname($_SERVER['PHP_SELF']).'/delete_event.php';
317 //['starttime', 'enddate', 'endtime']
318 $view = "<div id=\"event\">
319 <form id=\"event_data\" method=\"post\" action=\"{$_SERVER['PHP_SELF']}\"
320 onsubmit=\"return enableAll(['starttime', 'enddate', 'endtime'])\">
322 <caption style=\"font-weight: bold\">General</caption>
324 <td>Title</td><td>$title</td>
327 <td>Location</td><td>$location</td>
330 <td>Description</td><td>$description</td>
333 $this->createTime()."<p/>".
334 $this->createRecur().
335 "<p style=\"text-align: center\">
336 <input type=\"hidden\" value=\"$this->referer\" name=\"referer\"/>
337 <input type=\"button\" value=\"Cancel\"
338 onclick=\"document.location.href='$this->referer'\"/>
339 <input type=\"submit\" value=\"$btn_label\"/>
340 <!--onclick=\"document.getElementById('event_data').submit()\"/>-->
341 <input type=\"button\" value=\"Delete\"
342 onclick=\"document.location.href='$view?etag=$etag&url=$url'+
343 '&cal=$this->cal&referer=$this->referer'\"/>
344 <!--onclick=\"javascript: alert('Update not available')\"/>-->
345 <!--<input type=\"submit\" name=\"update\" value=\"Update\"/>-->
This page took 0.103107 seconds and 6 git commands to generate.