diff --git a/action/ajax.php b/action/ajax.php --- a/action/ajax.php +++ b/action/ajax.php @@ -1,107 +1,127 @@ hlp =& plugin_load('helper','davcal'); } function register(Doku_Event_Handler $controller) { $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax_call_unknown'); } function handle_ajax_call_unknown(&$event, $param) { if($event->data != 'plugin_davcal') return; $event->preventDefault(); $event->stopPropagation(); global $INPUT; $action = trim($INPUT->post->str('action')); $id = trim($INPUT->post->str('id')); $params = $INPUT->post->arr('params'); $user = $_SERVER['REMOTE_USER']; $write = false; $data = array(); $data['result'] = false; $data['html'] = $this->getLang('unknown_error'); $acl = auth_quickaclcheck($id); if($acl > AUTH_READ) { $write = true; } switch($action) { case 'newEvent': if($write) { $data['result'] = true; $data['html'] = $this->getLang('event_added'); $this->hlp->addCalendarEntryToCalendarForPage($id, $user, $params); } else { $data['result'] = false; $data['html'] = $this->getLang('no_permission'); } break; case 'getEvents': $startDate = $INPUT->post->str('start'); $endDate = $INPUT->post->str('end'); $data = $this->hlp->getEventsWithinDateRange($id, $user, $startDate, $endDate); break; case 'editEvent': if($write) { $data['result'] = true; $data['html'] = $this->getLang('event_edited'); $this->hlp->editCalendarEntryForPage($id, $user, $params); } else { $data['result'] = false; $data['html'] = $this->getLang('no_permission'); } break; case 'deleteEvent': if($write) { $data['result'] = true; $data['html'] = $this->getLang('event_deleted'); $this->hlp->deleteCalendarEntryForPage($id, $params); } else { $data['result'] = false; $data['html'] = $this->getLang('no_permission'); } break; + case 'getSettings': + $data['result'] = true; + $data['settings'] = $this->hlp->getPersonalSettings($user); + break; + case 'saveSettings': + $settings = array(); + $settings['weeknumbers'] = $params['weeknumbers']; + $settings['timezone'] = $params['timezone']; + $settings['workweek'] = $params['workweek']; + if($this->hlp->savePersonalSettings($settings, $user)) + { + $data['result'] = true; + $data['html'] = $this->getLang('settings_saved'); + } + else + { + $data['result'] = false; + $data['html'] = $this->getLang('error_saving'); + } + break; } // If we are still here, JSON output is requested //json library of DokuWiki require_once DOKU_INC . 'inc/JSON.php'; $json = new JSON(); //set content type header('Content-Type: application/json'); echo $json->encode($data); } } \ No newline at end of file diff --git a/action/jsinfo.php b/action/jsinfo.php new file mode 100644 --- /dev/null +++ b/action/jsinfo.php @@ -0,0 +1,28 @@ +register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'add_jsinfo_information'); + } + + function add_jsinfo_information(&$event, $param) { + global $conf; + global $JSINFO; + + $lang = $conf['lang']; + + if(strpos($lang, "de") === 0) + { + $lc = 'de'; + } + else + { + $lc = 'en'; + } + + $JSINFO['plugin']['davcal']['language'] = $lc; + } +} diff --git a/db/latest.version b/db/latest.version --- a/db/latest.version +++ b/db/latest.version @@ -1,1 +1,1 @@ -2 +3 diff --git a/db/update0003.sql b/db/update0003.sql new file mode 100644 --- /dev/null +++ b/db/update0003.sql @@ -0,0 +1,6 @@ +CREATE TABLE calendarsettings ( + id integer primary key asc, + key text, + value text, + userid text +); diff --git a/helper.php b/helper.php --- a/helper.php +++ b/helper.php @@ -1,306 +1,342 @@ sqlite =& plugin_load('helper', 'sqlite'); if(!$this->sqlite) { msg('This plugin requires the sqlite plugin. Please install it.'); return; } if(!$this->sqlite->init('davcal', DOKU_PLUGIN.'davcal/db/')) { return; } } public function setCalendarNameForPage($name, $description, $id = null, $userid = null) { if(is_null($id)) { global $ID; $id = $ID; } if(is_null($userid)) $userid = $_SERVER['REMOTE_USER']; $calid = $this->getCalendarIdForPage($id); if($calid === false) return $this->createCalendarForPage($name, $description, $id, $userid); // Update the calendar name here } + public function savePersonalSettings($settings, $userid = null) + { + if(is_null($userid)) + $userid = $_SERVER['REMOTE_USER']; + $this->sqlite->query("BEGIN TRANSACTION"); + + foreach($settings as $key => $value) + { + $query = "INSERT OR REPLACE INTO calendarsettings (userid, key, value) VALUES (". + $this->sqlite->quote_string($userid).", ". + $this->sqlite->quote_string($key).", ". + $this->sqlite->quote_string($value).")"; + $res = $this->sqlite->query($query); + if($res === false) + return false; + } + $this->sqlite->query("COMMIT TRANSACTION"); + return true; + } + + public function getPersonalSettings($userid = null) + { + if(is_null($userid)) + $userid = $_SERVER['REMOTE_USER']; + + $settings = array(); + $query = "SELECT key, value FROM calendarsettings WHERE userid=".$this->sqlite->quote_string($userid); + $res = $this->sqlite->query($query); + $arr = $this->sqlite->res2arr($res); + foreach($arr as $row) + { + $settings[$row['key']] = $row['value']; + } + return $settings; + } + public function getCalendarIdForPage($id = null) { if(is_null($id)) { global $ID; $id = $ID; } $query = "SELECT calid FROM pagetocalendarmapping WHERE page=".$this->sqlite->quote_string($id); $res = $this->sqlite->query($query); $row = $this->sqlite->res2row($res); if(isset($row['calid'])) return $row['calid']; else return false; } public function getCalendarIdToPageMapping() { $query = "SELECT calid, page FROM pagetocalendarmapping"; $res = $this->sqlite->query($query); $arr = $this->sqlite->res2arr($res); return $arr; } public function getCalendarIdsForUser($principalUri) { $user = explode('/', $principalUri); $user = end($user); $mapping = $this->getCalendarIdToPageMapping(); $calids = array(); foreach($mapping as $row) { $id = $row['calid']; $page = $row['page']; $acl = auth_quickaclcheck($page); if($acl >= AUTH_READ) { $write = $acl > AUTH_READ; $calids[$id] = array('readonly' => !$write); } } return $calids; } public function createCalendarForPage($name, $description, $id = null, $userid = null) { if(is_null($id)) { global $ID; $id = $ID; } if(is_null($userid)) $userid = $_SERVER['REMOTE_USER']; $values = array('principals/'.$userid, $name, str_replace(array('/', ' ', ':'), '_', $id), $description, 'VEVENT,VTODO', 0, 1); $query = "INSERT INTO calendars (principaluri, displayname, uri, description, components, transparent, synctoken) VALUES (".$this->sqlite->quote_and_join($values, ',').");"; $res = $this->sqlite->query($query); if($res === false) return false; $query = "SELECT id FROM calendars WHERE principaluri=".$this->sqlite->quote_string($values[0])." AND ". "displayname=".$this->sqlite->quote_string($values[1])." AND ". "uri=".$this->sqlite->quote_string($values[2])." AND ". "description=".$this->sqlite->quote_string($values[3]); $res = $this->sqlite->query($query); $row = $this->sqlite->res2row($res); if(isset($row['id'])) { $values = array($id, $row['id']); $query = "INSERT INTO pagetocalendarmapping (page, calid) VALUES (".$this->sqlite->quote_and_join($values, ',').")"; $res = $this->sqlite->query($query); return ($res !== false); } return false; } public function addCalendarEntryToCalendarForPage($id, $user, $params) { require_once('vendor/autoload.php'); $vcalendar = new \Sabre\VObject\Component\VCalendar(); $event = $vcalendar->add('VEVENT'); $event->summary = $params['eventname']; $dtStart = new \DateTime($params['eventfrom'], new \DateTimeZone('Europe/Vienna')); // FIXME: Timezone $dtEnd = new \DateTime($params['eventto'], new \DateTimeZone('Europe/Vienna')); // FIXME: Timezone $event->DTSTART = $dtStart; $event->DTEND = $dtEnd; $calid = $this->getCalendarIdForPage($id); $uri = uniqid('dokuwiki-').'.ics'; $now = new DateTime(); $eventStr = $vcalendar->serialize(); $values = array($calid, $uri, $eventStr, $now->getTimestamp(), 'VEVENT', $event->DTSTART->getDateTime()->getTimeStamp(), $event->DTEND->getDateTime()->getTimeStamp(), strlen($eventStr), md5($eventStr), uniqid() ); $query = "INSERT INTO calendarobjects (calendarid, uri, calendardata, lastmodified, componenttype, firstoccurence, lastoccurence, size, etag, uid) VALUES (".$this->sqlite->quote_and_join($values, ',').")"; $res = $this->sqlite->query($query); if($res !== false) { $this->updateSyncTokenLog($calid, $uri, 'added'); return true; } return false; } public function getEventsWithinDateRange($id, $user, $startDate, $endDate) { $data = array(); require_once('vendor/autoload.php'); $calid = $this->getCalendarIdForPage($id); $startTs = new \DateTime($startDate); $endTs = new \DateTime($endDate); $query = "SELECT calendardata, componenttype, uid FROM calendarobjects WHERE calendarid=". $this->sqlite->quote_string($calid)." AND firstoccurence > ". $this->sqlite->quote_string($startTs->getTimestamp())." AND firstoccurence < ". $this->sqlite->quote_string($endTs->getTimestamp()); $res = $this->sqlite->query($query); $arr = $this->sqlite->res2arr($res); foreach($arr as $row) { if(isset($row['calendardata'])) { $vcal = \Sabre\VObject\Reader::read($row['calendardata']); $start = $vcal->VEVENT->DTSTART->getDateTime(); $end = $vcal->VEVENT->DTEND->getDateTime(); $summary = (string)$vcal->VEVENT->summary; $data[] = array("title" => $summary, "start" => $start->format(\DateTime::W3C), "end" => $end->format(\DateTime::W3C), "id" => $row['uid']); } } return $data; } public function getEventWithUid($uid) { $query = "SELECT calendardata, calendarid, componenttype, uri FROM calendarobjects WHERE uid=". $this->sqlite->quote_string($uid); $res = $this->sqlite->query($query); $row = $this->sqlite->res2row($res); return $row; } public function editCalendarEntryForPage($id, $user, $params) { $uid = $params['uid']; $event = $this->getEventWithUid($uid); require_once('vendor/autoload.php'); if(!isset($event['calendardata'])) return false; $uri = $event['uri']; $calid = $event['calendarid']; $vcal = \Sabre\VObject\Reader::read($event['calendardata']); $vcal->VEVENT->summary = $params['eventname']; $dtStart = new \DateTime($params['eventfrom'], new \DateTimeZone('Europe/Vienna')); // FIXME: Timezone $dtEnd = new \DateTime($params['eventto'], new \DateTimeZone('Europe/Vienna')); // FIXME: Timezone $vcal->VEVENT->DTSTART = $dtStart; $vcal->VEVENT->DTEND = $dtEnd; $now = new DateTime(); $eventStr = $vcal->serialize(); $query = "UPDATE calendarobjects SET calendardata=".$this->sqlite->quote_string($eventStr). ", lastmodified=".$this->sqlite->quote_string($now->getTimestamp()). ", firstoccurence=".$this->sqlite->quote_string($dtStart->getTimestamp()). ", lastoccurence=".$this->sqlite->quote_string($dtEnd->getTimestamp()). ", size=".strlen($eventStr). ", etag=".$this->sqlite->quote_string(md5($eventStr)). " WHERE uid=".$this->sqlite->quote_string($uid); $res = $this->sqlite->query($query); if($res !== false) { $this->updateSyncTokenLog($calid, $uri, 'modified'); return true; } return false; } public function deleteCalendarEntryForPage($id, $params) { $uid = $params['uid']; $event = $this->getEventWithUid($uid); $calid = $event['calendarid']; $uri = $event['uri']; $query = "DELETE FROM calendarobjects WHERE uid=".$this->sqlite->quote_string($uid); $res = $this->sqlite->query($query); if($res !== false) { $this->updateSyncTokenLog($calid, $uri, 'deleted'); } return true; } public function getSyncTokenForCalendar($calid) { $query = "SELECT synctoken FROM calendars WHERE id=".$this->sqlite->quote_string($calid); $res = $this->sqlite->query($query); $row = $this->sqlite->res2row($res); if(isset($row['synctoken'])) return $row['synctoken']; return false; } public function operationNameToOperation($operationName) { switch($operationName) { case 'added': return 1; break; case 'modified': return 2; break; case 'deleted': return 3; break; } return false; } private function updateSyncTokenLog($calid, $uri, $operation) { $currentToken = $this->getSyncTokenForCalendar($calid); $operationCode = $this->operationNameToOperation($operation); if(($operationCode === false) || ($currentToken === false)) return false; $values = array($uri, $currentToken, $calid, $operationCode ); $query = "INSERT INTO calendarchanges (uri, synctoken, calendarid, operation) VALUES(". $this->sqlite->quote_and_join($values, ',').")"; $res = $this->sqlite->query($query); if($res === false) return false; $currentToken++; $query = "UPDATE calendars SET synctoken=".$this->sqlite->quote_string($currentToken)." WHERE id=". $this->sqlite->quote_string($calid); $res = $this->sqlite->query($query); return ($res !== false); } } diff --git a/images/settings.png b/images/settings.png new file mode 100644 index 0000000000000000000000000000000000000000..52ef9ff3994ee3b97136ae25403cf2095714f018 GIT binary patch literal 1089 zc$`g=Z%C6-6vp3KHnl7<3yC5Ei2^IaB%&adO*b?V6+{A4O9>(hv@bysMx|7U3rQpK zlV7Za_91m_Q>Sh!&i~A9=%z!rv^l4#qax_1m!b>rdC$G~Ip;j*IkzS!J0m*kNR%W= z(Q1_db*WNecU&la;Rwg+kNQ(|Wz$@AtR2x8oQLhVk+7U@)lD>DJfR z0c>n+=ysOZ>+S37>+kRP`Fx?BH8(f6wYBARI=j2OmzS3bce~y5^YfjZovW*>OG`_` z!^5OqTU!(O+1XjF(P$L67K^2;tBa_yu`w_`Jv}6$1Ub0^xwyE94Fm$fa3FwPSy=&N zHk+wJ6jwNOVKSMh1z5mfLT0GKZD3#kXJllAb9^jd0)?d`x+ABkNOiX0tyU`;IK+B9 z9>53!9*IN?Sdi$0BZLw>!Q;bI07geg;ehXQx#)3la1e<|0+=h(LKuH@a}x}WgAsK( zB%F?HHXB#^orMFpp`jse@##JEcj1dkk%XZLK{!WV<{SEN&CJZ8KMnx!f-}CDEP2Q* zLLeh@LYOUrgA_$OIyyu)k%3q+2q?Bf3PDN0p!5$f8f5VxDTJ5{3ky6ar~*ShULf;A zF*+r)-EQYuIvfrZo0ynjh{((9LNxT8nwnx*bWJ(BfEdq%Doj?0$#4aK`a%}Q0lo1( z-~5!9Rpw^rNhw}?`SzwXGeaR&haXe1iM+2WtdOL=2e&_&^zMB;hw@7GHKp7gDUZ9f z`;*~l6GsNMA~ipLQdw(_G^NBmvqUAD59^n$QTf60=&FM7@Lv%L@}3JNvZC0u*x2e~ zZKE}?FR(wgtJm24=&dZ~;cRd7WvMXsP@2mceEKr!h34X|dei=TZDp|kOL~T{`R9o@ zk)?HdP1xGP%?}P|OH#p|!glGosxGlfBP(u+%RH}Z&8oR~_C|wNyMDEzeA0NmSFb7i z=twq~**>2O^PH?WeYYX3QSsw(>+7Q9-)~>>F0~~azSfq+r-#BH3|GHO79Ba&K~ Kt!PUtuKEMUVDha1 diff --git a/lang/en/lang.php b/lang/en/lang.php --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -1,22 +1,31 @@ '); + jQuery.post( + DOKU_BASE + 'lib/exe/ajax.php', + { + call: 'plugin_davcal', + id: JSINFO.id, + action: 'saveSettings', + params: postArray + }, + function(data) + { + var result = data['result']; + var html = data['html']; + jQuery('#dw_davcal__ajaxsettings').html(html); + if(result === true) + { + location.reload(); + } + } + ); + }; + dialogButtons[LANG.plugins.davcal['cancel']] = function () { + dw_davcal__modals.hideSettingsDialog(); + }; + + dw_davcal__modals.$settingsDialog = jQuery(document.createElement('div')) + .dialog({ + autoOpen: false, + draggable: true, + title: LANG.plugins.davcal['settings'], + resizable: true, + buttons: dialogButtons, + }) + .html( + '
' + + //'' + + '' + + '' + + '' + + '
' + LANG.plugins.davcal['use_lang_tz'] + '
' + LANG.plugins.davcal['timezone'] + 'Timezone Dropdown
' + LANG.plugins.davcal['weeknumbers'] + '
' + LANG.plugins.davcal['only_workweek'] + '
' + + '
' + + '
' + ) + .parent() + .attr('id','dw_davcal__settings') + .show() + .appendTo('.dokuwiki:first'); + + // attach event handlers + jQuery('#dw_davcal__settings .ui-dialog-titlebar-close').click(function(){ + dw_davcal__modals.hideSettingsDialog(); + }); + if(dw_davcal__modals.settings) + { + if(dw_davcal__modals.settings['weeknumbers'] == 1) + jQuery('#dw_davcal__settings_weeknumbers').prop('checked', true); + else + jQuery('#dw_davcal__settings_weeknumbers').prop('checked', false); + + if(dw_davcal__modals.settings['workweek'] == 1) + jQuery('#dw_davcal__settings_workweek').prop('checked', true); + else + jQuery('#dw_davcal__settings_workweek').prop('checked', false); + } + }, showEditEventDialog : function(calEvent) { if(dw_davcal__modals.$editEventDialog) return; var dialogButtons = {}; dialogButtons[LANG.plugins.davcal['edit']] = function() { var postArray = { }; jQuery("input[class=dw_davcal__editevent]").each(function() { if(jQuery(this).attr('type') == 'checkbox') { postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0; } else { postArray[jQuery(this).prop('name')] = jQuery(this).val(); } }); jQuery('#dw_davcal__ajaxedit').html(''); jQuery.post( DOKU_BASE + 'lib/exe/ajax.php', { call: 'plugin_davcal', id: JSINFO.id, action: 'editEvent', params: postArray }, function(data) { var result = data['result']; var html = data['html']; jQuery('#dw_davcal__ajaxedit').html(html); if(result === true) { jQuery('#fullCalendar').fullCalendar('refetchEvents'); dw_davcal__modals.hideEditEventDialog(); } } ); }; dialogButtons[LANG.plugins.davcal['cancel']] = function() { dw_davcal__modals.hideEditEventDialog(); }; dialogButtons[LANG.plugins.davcal['delete']] = function() { dw_davcal__modals.action = 'deleteEvent'; dw_davcal__modals.msg = LANG.plugins.davcal['really_delete_this_event']; dw_davcal__modals.completeCb = function(data) { if(data.result == false) { dw_davcal__modals.msg = data.errmsg; dw_davcal__modals.showInfoDialog(); } else { jQuery('#fullCalendar').fullCalendar('refetchEvents'); dw_davcal__modals.hideEditEventDialog(); } }; dw_davcal__modals.showConfirmDialog(); }; dw_davcal__modals.uid = calEvent.id; dw_davcal__modals.$editEventDialog = jQuery(document.createElement('div')) .dialog({ autoOpen: false, draggable: true, title: LANG.plugins.davcal['edit_event'], resizable: true, buttons: dialogButtons, }) .html( '
' + '' + '' + '' + '
' + LANG.plugins.davcal['title'] + '
' + LANG.plugins.davcal['from'] + '
' + LANG.plugins.davcal['to'] + '
' + LANG.plugins.davcal['allday'] + '
' + '' + '
' + '
' ) .parent() .attr('id','dw_davcal__edit') .show() .appendTo('.dokuwiki:first'); jQuery('#dw_davcal__uid_edit').val(calEvent.id); jQuery('#dw_davcal__eventname_edit').val(calEvent.title); jQuery('#dw_davcal__eventfrom_edit').val(calEvent.start.format('YYYY-MM-DD HH:mm')); jQuery('#dw_davcal__eventto_edit').val(calEvent.end.format('YYYY-MM-DD HH:mm')); jQuery('#dw_davcal__allday_edit').prop('checked', calEvent.allDay); // attach event handlers jQuery('#dw_davcal__edit .ui-dialog-titlebar-close').click(function(){ dw_davcal__modals.hideEditEventDialog(); }); jQuery('#dw_davcal__eventfrom_edit').datetimepicker({format:'YYYY-MM-DD HH:mm', formatTime:'HH:mm', formatDate:'YYYY-MM-DD', step: 15}); jQuery('#dw_davcal__eventto_edit').datetimepicker({format:'YYYY-MM-DD HH:mm', formatTime:'HH:mm', formatDate:'YYYY-MM-DD', step: 15}); jQuery('#dw_davcal__allday_edit').change(function() { if(jQuery(this).is(":checked")) { jQuery('#dw_davcal__eventfrom_edit').datetimepicker({timepicker: false}); jQuery('#dw_davcal__eventto_edit').datetimepicker({timepicker: false}); } else { jQuery('#dw_davcal__eventfrom_edit').datetimepicker({timepicker: true}); jQuery('#dw_davcal__eventto_edit').datetimepicker({timepicker: true}); } }); }, showNewEventDialog : function(date) { if(dw_davcal__modals.$newEventDialog) return; var dialogButtons = {}; dialogButtons[LANG.plugins.davcal['create']] = function() { var postArray = { }; jQuery("input[class=dw_davcal__newevent]").each(function() { if(jQuery(this).attr('type') == 'checkbox') { postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0; } else { postArray[jQuery(this).prop('name')] = jQuery(this).val(); } }); jQuery('#dw_davcal__ajaxnew').html(''); jQuery.post( DOKU_BASE + 'lib/exe/ajax.php', { call: 'plugin_davcal', id: JSINFO.id, action: 'newEvent', params: postArray }, function(data) { var result = data['result']; var html = data['html']; jQuery('#dw_davcal__ajaxnew').html(html); if(result === true) { jQuery('#fullCalendar').fullCalendar('refetchEvents'); dw_davcal__modals.hideNewEventDialog(); } } ); }; dialogButtons[LANG.plugins.davcal['cancel']] = function() { dw_davcal__modals.hideNewEventDialog(); }; dw_davcal__modals.$newEventDialog = jQuery(document.createElement('div')) .dialog({ autoOpen: false, draggable: true, title: LANG.plugins.davcal['create_new_event'], resizable: true, buttons: dialogButtons, }) .html( '
' + '' + '' + '' + '
' + LANG.plugins.davcal['title'] + '
' + LANG.plugins.davcal['from'] + '
' + LANG.plugins.davcal['to'] + '
' + LANG.plugins.davcal['allday'] + '
' + '
' + '
' ) .parent() .attr('id','dw_davcal__createnew') .show() .appendTo('.dokuwiki:first'); // attach event handlers jQuery('#dw_davcal__createnew .ui-dialog-titlebar-close').click(function(){ dw_davcal__modals.hideNewEventDialog(); }); jQuery('#dw_davcal__eventfrom').datetimepicker({format:'YYYY-MM-DD HH:mm', formatTime:'HH:mm', formatDate:'YYYY-MM-DD', step: 15}); jQuery('#dw_davcal__eventto').datetimepicker({format:'YYYY-MM-DD HH:mm', formatTime:'HH:mm', formatDate:'YYYY-MM-DD', step: 15}); jQuery('#dw_davcal__allday').change(function() { if(jQuery(this).is(":checked")) { jQuery('#dw_davcal__eventfrom').datetimepicker({timepicker: false}); jQuery('#dw_davcal__eventto').datetimepicker({timepicker: false}); } else { jQuery('#dw_davcal__eventfrom').datetimepicker({timepicker: true}); jQuery('#dw_davcal__eventto').datetimepicker({timepicker: true}); } }); }, showConfirmDialog : function() { if(dw_davcal__modals.$confirmDialog) return; var dialogButtons = {}; dialogButtons[LANG.plugins.davcal['yes']] = function() { jQuery.post( DOKU_BASE + 'lib/exe/ajax.php', { call: 'plugin_davcal', id: JSINFO.id, action: dw_davcal__modals.action, params: { uid: dw_davcal__modals.uid } }, function(data) { dw_davcal__modals.completeCb(data); } ); dw_davcal__modals.hideConfirmDialog(); }; dialogButtons[LANG.plugins.tagrevisions['cancel']] = function() { dw_davcal__modals.hideConfirmDialog(); }; dw_davcal__modals.$confirmDialog = jQuery(document.createElement('div')) .dialog({ autoOpen: false, draggable: true, title: LANG.plugins.tagrevisions['confirmation'], resizable: true, buttons: dialogButtons, }) .html( '
' + dw_davcal__modals.msg + '
' ) .parent() .attr('id','dw_davcal__confirm') .show() .appendTo('.dokuwiki:first'); // attach event handlers jQuery('#dw_davcal__confirm .ui-dialog-titlebar-close').click(function(){ dw_davcal__modals.hideConfirmDialog(); }); }, showInfoDialog : function() { if(dw_davcal__modal.$infoDialog) return; var dialogButtons = {}; dialogButtons[LANG.plugins.davcal['ok']] = function() { dw_davcal__modals.hideInfoDialog(); }; dw_davcal__modals.$infoDialog = jQuery(document.createElement('div')) .dialog({ autoOpen: false, draggable: true, title: LANG.plugins.davcal['info'], resizable: true, buttons: dialogButtons, }) .html( '
' + dw_davcal__modals.msg + '
' ) .parent() .attr('id','dw_davcal__info') .show() .appendTo('.dokuwiki:first'); // attach event handlers jQuery('#dw_davcal__info .ui-dialog-titlebar-close').click(function(){ dw_davcal__modals.hideInfoDialog(); }); }, hideNewEventDialog : function() { dw_davcal__modals.$newEventDialog.empty(); dw_davcal__modals.$newEventDialog.remove(); dw_davcal__modals.$newEventDialog = null; }, hideEditEventDialog : function() { dw_davcal__modals.$editEventDialog.empty(); dw_davcal__modals.$editEventDialog.remove(); dw_davcal__modals.$editEventDialog = null; }, hideInfoDialog : function() { dw_davcal__modals.$infoDialog.empty(); dw_davcal__modals.$infoDialog.remove(); dw_davcal__modals.$infoDialog = null; }, hideConfirmDialog: function() { dw_davcal__modals.$confirmDialog.empty(); dw_davcal__modals.$confirmDialog.remove(); dw_davcal__modals.$confirmDialog = null; + }, + + hideSettingsDialog: function() { + dw_davcal__modals.$settingsDialog.empty(); + dw_davcal__modals.$settingsDialog.remove(); + dw_davcal__modals.$settingsDialog = null; } }; diff --git a/style.css b/style.css --- a/style.css +++ b/style.css @@ -1,17 +1,38 @@ @import "fullcalendar-2.4.0/fullcalendar.less"; @import "datetimepicker-2.4.5/jquery.datetimepicker.less"; /* modal windows */ -#davcal__createnew { +#dw_davcal__createnew, +#dw_davcal__edit, +#dw_davcal__info, +#dw_davcal__settings, +#dw_davcal__confirm { position: absolute; background-color: #fff; color: #000; z-index: 20; overflow: hidden; } -#davcal__createnew .ui-dialog-content { +#dw_davcal__edit .ui-dialog-content, +#dw_davcal__info .ui-dialog-content, +#dw_davcal__confirm .ui-dialog-content, +#dw_davcal__settings .ui-dialog-content, +#dw_davcal__createnew .ui-dialog-content { padding-left: 0; padding-right: 0; } + +#dw_davcal__confirm, +#dw_davcal__info, +#dw_davcal__edit, +#dw_davcal__settings, +#dw_davcal__createnew { + position: absolute; + top: 50%; + left: 50%; + width: 300px; + height: 260px; + margin:-130px 0 0 -150px; +} \ No newline at end of file diff --git a/syntax.php b/syntax.php --- a/syntax.php +++ b/syntax.php @@ -1,88 +1,89 @@ */ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); class syntax_plugin_davcal extends DokuWiki_Syntax_Plugin { protected $hlp = null; // Load the helper plugin public function syntax_plugin_davcal() { $this->hlp =& plugin_load('helper', 'davcal'); } /** * What kind of syntax are we? */ function getType(){ return 'substition'; } /** * What about paragraphs? */ function getPType(){ return 'normal'; } /** * Where to sort in? */ function getSort(){ return 165; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern('\{\{davcal>[^}]*\}\}',$mode,'plugin_davcal'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ global $ID; $options = trim(substr($match,9,-2)); $options = explode(',', $options); $data = array('name' => '', 'description' => $this->getLang('created_by_davcal')); foreach($options as $option) { list($key, $val) = explode('=', $option); $key = strtolower(trim($key)); $val = trim($val); $data[$key] = $val; } $this->hlp->setCalendarNameForPage($data['name'], $data['description'], $ID, $_SERVER['REMOTE_USER']); return array($data); } /** * Create output */ function render($format, &$R, $data) { if($format != 'xhtml') return false; $R->doc .= '
'; + $R->doc .= ''; } } // vim:ts=4:sw=4:et:enc=utf-8: