diff --git a/lang/de-informal/lang.php b/lang/de-informal/lang.php
--- a/lang/de-informal/lang.php
+++ b/lang/de-informal/lang.php
@@ -1,57 +1,58 @@
');
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_davcal',
id: dw_davcal__modals.page,
page: dw_davcal__modals.page,
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();
};
var settingsHtml = '
' +
'';
dw_davcal__modals.$settingsDialog = jQuery(document.createElement('div'))
.dialog({
autoOpen: false,
draggable: true,
title: LANG.plugins.davcal['settings'],
resizable: true,
buttons: dialogButtons,
})
.html(
settingsHtml
)
.parent()
.attr('id','dw_davcal__settings')
.show()
.appendTo('.dokuwiki:first');
jQuery('#dw_davcal__settings').position({
my: "center",
at: "center",
of: window
});
// Initialize current settings
if(!JSINFO.plugin.davcal['disable_settings'])
{
var $tzdropdown = jQuery('#dw_davcal__settings_timezone');
jQuery('#fullCalendarTimezoneList option').each(function() {
jQuery('', {value: jQuery(this).val(),
text: jQuery(this).text()}).appendTo($tzdropdown);
});
var $tfdropdown = jQuery('#dw_davcal__settings_timeformat');
jQuery('', {value: 'lang', text: LANG.plugins.davcal['language_specific']}).appendTo($tfdropdown);
jQuery('', {value: '24h', text: '24h'}).appendTo($tfdropdown);
jQuery('', {value: '12h', text: '12h'}).appendTo($tfdropdown);
if(!JSINFO.plugin.davcal['disable_sync'])
{
jQuery('#dw_davcal__settings_syncurl_edit').on('click', function() {
jQuery(this).select();
});
jQuery('#dw_davcal__settings_principalurl_edit').on('click', function() {
jQuery(this).select();
});
}
if(!JSINFO.plugin.davcal['disable_ics'])
{
jQuery('#dw_davcal__settings_privateurl_edit').on('click', function() {
jQuery(this).select();
});
}
if(dw_davcal__modals.settings)
{
- jQuery('#dw_davcal__settings_timeformat').val(dw_davcal__modals.settings['timeformat']);
+ if(dw_davcal__modals.settings['timeformat'] !== '')
+ jQuery('#dw_davcal__settings_timeformat').val(dw_davcal__modals.settings['timeformat']);
if(dw_davcal__modals.settings['timezone'] !== '')
jQuery('#dw_davcal__settings_timezone').val(dw_davcal__modals.settings['timezone']);
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);
if(dw_davcal__modals.settings['monday'] == 1)
jQuery('#dw_davcal__settings_monday').prop('checked', true);
else
jQuery('#dw_davcal__settings_monday').prop('checked', false);
+ if(dw_davcal__modals.settings['meta']['forcetimezone'] !== 'no')
+ jQuery('#dw_davcal__settings_timezone').prop('disabled', true);
+ if(dw_davcal__modals.settings['meta']['forcetimeformat'] !== 'no')
+ jQuery('#dw_davcal__settings_timeformat').prop('disabled', true);
}
}
// attach event handlers
jQuery('#dw_davcal__settings .ui-dialog-titlebar-close').click(function(){
dw_davcal__modals.hideSettingsDialog();
});
},
/**
* Sanity-check our events.
*
* @return boolean false on failure, otherwise true
*/
checkEvents : function() {
// Retrieve dates
var allDay = jQuery('#dw_davcal__allday_edit').prop('checked');
var startDate = moment(jQuery('#dw_davcal__eventfrom_edit').val(), 'YYYY-MM-DD');
var endDate = moment(jQuery('#dw_davcal__eventto_edit').val(), 'YYYY-MM-DD');
// Do the checking
if(!allDay)
{
var startTime = moment.duration(jQuery('#dw_davcal__eventfromtime_edit').val());
var endTime = moment.duration(jQuery('#dw_davcal__eventtotime_edit').val());
startDate.add(startTime);
endDate.add(endTime);
}
if(!startDate.isValid())
{
dw_davcal__modals.msg = LANG.plugins.davcal['start_date_invalid'];
dw_davcal__modals.showDialog(false);
return false;
}
if(!endDate.isValid())
{
dw_davcal__modals.msg = LANG.plugins.davcal['end_date_invalid'];
dw_davcal__modals.showDialog(false);
return false;
}
if(endDate.isBefore(startDate))
{
dw_davcal__modals.msg = LANG.plugins.davcal['end_date_before_start_date'];
dw_davcal__modals.showDialog(false);
return false;
}
if(!allDay && endDate.isSame(startDate))
{
dw_davcal__modals.msg = LANG.plugins.davcal['end_date_is_same_as_start_date'];
dw_davcal__modals.showDialog(false);
return false;
}
return true;
},
/**
* Show the edit event dialog, which is also used to create new events
* @param {Object} event The event to create, that is the date or the calEvent
* @param {Object} edit Whether we edit (true) or create a new event (false)
*/
showEditEventDialog : function(event, edit) {
if(dw_davcal__modals.$editEventDialog)
return;
var readonly = dw_davcal__modals.settings['readonly'];
var title = '';
var dialogButtons = {};
var calEvent = [];
var recurringWarning = '';
// Buttons are dependent on edit or create
// Several possibilities:
//
// 1) Somebody tries to edit, it is not recurring and not readonly -> show
// 2) Somebody tries to edit, it is recurring and not readonly -> message
// 3) Somebody tries to edit, it is readonly -> message
// 4) Somebody tries to create and it is readonly -> message
// 5) Somebody tries to create -> show
if(edit && (event.recurring != true) && (readonly === false))
{
calEvent = event;
title = LANG.plugins.davcal['edit_event'];
dialogButtons[LANG.plugins.davcal['edit']] = function() {
if(!dw_davcal__modals.checkEvents())
return;
var postArray = { };
var attachArr = new Array();
var pageid = dw_davcal__modals.page;
if(dw_davcal__modals.settings['multi'])
{
pageid = jQuery("#dw_davcal__editevent_calendar option:selected").val();
}
jQuery('.dw_davcal__editevent_attachment_link').each(function() {
var attachment = jQuery(this).attr('href');
if(attachment != undefined)
{
attachArr.push(attachment);
}
});
postArray['attachments'] = attachArr;
jQuery("input.dw_davcal__editevent, textarea.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: pageid,
page: dw_davcal__modals.page,
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['delete']] = function() {
dw_davcal__modals.action = 'deleteEvent';
dw_davcal__modals.msg = LANG.plugins.davcal['really_delete_this_event'];
dw_davcal__modals.completeCb = 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();
}
};
dw_davcal__modals.showDialog(true);
};
}
else if(edit && (event.recurring == true) && (readonly === false))
{
calEvent = event;
title = LANG.plugins.davcal['edit_event'];
recurringWarning = LANG.plugins.davcal['recurring_cant_edit'];
}
else if(edit && (readonly === true))
{
calEvent = event;
title = LANG.plugins.davcal['edit_event'];
recurringWarning = LANG.plugins.davcal['no_permission'];
}
else if(readonly === true)
{
calEvent.start = event;
calEvent.end = moment(event);
calEvent.start.hour(12);
calEvent.start.minute(0);
calEvent.end.hour(13);
calEvent.end.minute(0);
calEvent.allDay = false;
calEvent.recurring = false;
calEvent.title = '';
calEvent.description = '';
calEvent.id = '0';
calEvent.page = dw_davcal__modals.page;
title = LANG.plugins.davcal['create_new_event'];
recurringWarning = LANG.plugins.davcal['no_permission'];
}
else
{
calEvent.start = event;
calEvent.end = moment(event);
calEvent.start.hour(12);
calEvent.start.minute(0);
calEvent.end.hour(13);
calEvent.end.minute(0);
calEvent.allDay = false;
calEvent.recurring = false;
calEvent.title = '';
calEvent.description = '';
calEvent.id = '0';
calEvent.page = dw_davcal__modals.settings['calids'][0]['page'];
title = LANG.plugins.davcal['create_new_event'];
dialogButtons[LANG.plugins.davcal['create']] = function() {
if(!dw_davcal__modals.checkEvents())
return;
var postArray = { };
var pageid = dw_davcal__modals.page;
var attachArr = new Array();
if(dw_davcal__modals.settings['multi'])
{
pageid = jQuery("#dw_davcal__editevent_calendar option:selected").val();
}
jQuery("input.dw_davcal__editevent, textarea.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__editevent_attachment_link').each(function() {
var attachment = jQuery(this).attr('href');
if(attachment != undefined)
{
attachArr.push(attachment);
}
});
postArray['attachments'] = attachArr;
jQuery('#dw_davcal__ajaxedit').html('');
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_davcal',
id: pageid,
page: dw_davcal__modals.page,
action: 'newEvent',
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();
};
dw_davcal__modals.uid = calEvent.id;
dw_davcal__modals.$editEventDialog = jQuery(document.createElement('div'))
.dialog({
autoOpen: false,
draggable: true,
title: title,
resizable: true,
buttons: dialogButtons,
})
.html(
'' +
recurringWarning +
'
' +
'
' +
'
' +
'
' +
''
)
.parent()
.attr('id','dw_davcal__edit')
.show()
.appendTo('.dokuwiki:first');
jQuery('#dw_davcal__edit').position({
my: "center",
at: "center",
of: window
});
// Populate calendar dropdown
var $dropdown = jQuery("#dw_davcal__editevent_calendar");
for(var i=0; i' + dw_davcal__modals.settings['calids'][i]['name'] + '');
}
if(edit || (dw_davcal__modals.settings['calids'].length < 1))
{
$dropdown.prop('disabled', true);
}
// Set up existing/predefined values
jQuery('#dw_davcal__tz_edit').val(dw_davcal__modals.detectedTz);
jQuery('#dw_davcal__currenttz_edit').val(dw_davcal__modals.currentTz);
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'));
jQuery('#dw_davcal__eventfromtime_edit').val(calEvent.start.format('HH:mm'));
jQuery('#dw_davcal__eventdescription_edit').val(calEvent.description);
if(calEvent.attachments && (calEvent.attachments !== null))
{
for(var i=0; i' + url + '' + LANG.plugins.davcal['delete'] + ' | ';
jQuery('#dw_davcal__editevent_attachments > tbody:last').append(row);
}
}
dw_davcal__modals.attachAttachmentDeleteHandlers();
jQuery('#dw_davcal__editevent_attach').on("click", function(e)
{
e.preventDefault();
var url = jQuery('#dw_davcal__editevent_attachment').val();
jQuery('#dw_davcal__editevent_attachment').val('http://');
var row = '' + url + ' | ' + LANG.plugins.davcal['delete'] + ' |
';
jQuery('#dw_davcal__editevent_attachments > tbody:last').append(row);
dw_davcal__modals.attachAttachmentDeleteHandlers();
return false;
});
if(calEvent.allDay && (calEvent.end === null))
{
jQuery('#dw_davcal__eventto_edit').val(calEvent.start.format('YYYY-MM-DD'));
jQuery('#dw_davcal__eventtotime_edit').val(calEvent.start.format('HH:mm'));
}
else if(calEvent.allDay)
{
endEvent = moment(calEvent.end);
endEvent.subtract(1, 'days');
jQuery('#dw_davcal__eventto_edit').val(endEvent.format('YYYY-MM-DD'));
jQuery('#dw_davcal__eventotime_edit').val(endEvent.format('HH:mm'));
}
else
{
jQuery('#dw_davcal__eventto_edit').val(calEvent.end.format('YYYY-MM-DD'));
jQuery('#dw_davcal__eventtotime_edit').val(calEvent.end.format('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',
formatDate:'YYYY-MM-DD',
datepicker: true,
timepicker: false,
});
jQuery('#dw_davcal__eventfromtime_edit').datetimepicker({format:'HH:mm',
formatTime:'HH:mm',
datepicker: false,
timepicker: true,
step: 15});
jQuery('#dw_davcal__eventto_edit').datetimepicker({format:'YYYY-MM-DD',
formatDate:'YYYY-MM-DD',
datepicker: true,
timepicker: false,
});
jQuery('#dw_davcal__eventtotime_edit').datetimepicker({format:'HH:mm',
formatTime:'HH:mm',
datepicker: false,
timepicker: true,
step:15});
jQuery('#dw_davcal__allday_edit').change(function() {
if(jQuery(this).is(":checked"))
{
jQuery('#dw_davcal__eventfromtime_edit').prop('readonly', true);
jQuery('#dw_davcal__eventtotime_edit').prop('readonly', true);
}
else
{
jQuery('#dw_davcal__eventfromtime_edit').prop('readonly', false);
jQuery('#dw_davcal__eventtotime_edit').prop('readonly', false);
}
});
jQuery('#dw_davcal__allday_edit').change();
},
/**
* Attach handles to delete the attachments to all 'delete' links
*/
attachAttachmentDeleteHandlers: function()
{
jQuery("#dw_davcal__editevent_attachments .deleteLink").on("click", function(e)
{
e.preventDefault();
var tr = jQuery(this).closest('tr');
tr.css("background-color", "#FF3700");
tr.fadeOut(400, function()
{
tr.remove();
});
return false;
});
},
/**
* Show an info/confirmation dialog
* @param {Object} confirm Whether a confirmation dialog (true) or an info dialog (false) is requested
*/
showDialog : function(confirm)
{
if(dw_davcal__modals.$confirmDialog)
return;
var dialogButtons = {};
var title = '';
if(confirm)
{
title = LANG.plugins.davcal['confirmation'];
var pageid = dw_davcal__modals.page;
if(dw_davcal__modals.settings['multi'])
{
pageid = jQuery("#dw_davcal__editevent_calendar option:selected").val();
}
dialogButtons[LANG.plugins.davcal['yes']] = function() {
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_davcal',
id: pageid,
page: dw_davcal__modals.page,
action: dw_davcal__modals.action,
params: {
uid: dw_davcal__modals.uid
}
},
function(data)
{
dw_davcal__modals.completeCb(data);
}
);
dw_davcal__modals.hideDialog();
};
dialogButtons[LANG.plugins.davcal['cancel']] = function() {
dw_davcal__modals.hideDialog();
};
}
else
{
title = LANG.plugins.davcal['info'];
dialogButtons[LANG.plugins.davcal['ok']] = function() {
dw_davcal__modals.hideDialog();
};
}
dw_davcal__modals.$dialog = jQuery(document.createElement('div'))
.dialog({
autoOpen: false,
draggable: true,
title: title,
resizable: true,
buttons: dialogButtons,
})
.html(
'' + dw_davcal__modals.msg + '
'
)
.parent()
.attr('id','dw_davcal__confirm')
.show()
.appendTo('.dokuwiki:first');
jQuery('#dw_davcal__confirm').position({
my: "center",
at: "center",
of: window
});
// attach event handlers
jQuery('#dw_davcal__confirm .ui-dialog-titlebar-close').click(function(){
dw_davcal__modals.hideDialog();
});
},
/**
* Hide the edit event dialog
*/
hideEditEventDialog : function() {
dw_davcal__modals.$editEventDialog.empty();
dw_davcal__modals.$editEventDialog.remove();
dw_davcal__modals.$editEventDialog = null;
},
/**
* Hide the confirm/info dialog
*/
hideDialog: function() {
dw_davcal__modals.$dialog.empty();
dw_davcal__modals.$dialog.remove();
dw_davcal__modals.$dialog = null;
},
/**
* Hide the settings dialog
*/
hideSettingsDialog: function() {
dw_davcal__modals.$settingsDialog.empty();
dw_davcal__modals.$settingsDialog.remove();
dw_davcal__modals.$settingsDialog = null;
}
};
diff --git a/syntax/calendar.php b/syntax/calendar.php
--- a/syntax/calendar.php
+++ b/syntax/calendar.php
@@ -1,155 +1,163 @@
*/
// 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_calendar extends DokuWiki_Syntax_Plugin {
protected $hlp = null;
// Load the helper plugin
public function syntax_plugin_davcal_calendar() {
$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_calendar');
}
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler){
global $ID;
$options = trim(substr($match,9,-2));
$options = explode(',', $options);
$data = array('name' => $ID,
'description' => $this->getLang('created_by_davcal'),
'id' => array(),
'settings' => 'show',
'view' => 'month',
- 'forcetimezone' => 'no'
+ 'forcetimezone' => 'no',
+ 'forcetimeformat' => 'no'
);
$lastid = $ID;
foreach($options as $option)
{
list($key, $val) = explode('=', $option);
$key = strtolower(trim($key));
$val = trim($val);
switch($key)
{
case 'id':
$lastid = $val;
if(!in_array($val, $data['id']))
$data['id'][$val] = '#3a87ad';
break;
case 'color':
$data['id'][$lastid] = $val;
break;
case 'view':
if(in_array($val, array('month', 'basicDay', 'basicWeek', 'agendaWeek', 'agendaDay')))
$data['view'] = $val;
else
$data['view'] = 'month';
break;
case 'forcetimezone':
$tzlist = \DateTimeZone::listIdentifiers(DateTimeZone::ALL);
if(in_array($val, $tzlist) || $val === 'no')
$data['forcetimezone'] = $val;
else
msg($this->getLang('error_timezone_not_in_list'), -1);
break;
+ case 'forcetimeformat':
+ $tfopt = array('lang', '24h', '12h');
+ if(in_array($val, $tfopt) || $val === 'no')
+ $data['forcetimeformat'] = $val;
+ else
+ msg($this->getLang('error_option_error'), -1);
+ break;
default:
$data[$key] = $val;
}
}
// Handle the default case when the user didn't enter a different ID
if(empty($data['id']))
{
$data['id'] = array($ID => '#3a87ad');
}
// Only update the calendar name/description if the ID matches the page ID.
// Otherwise, the calendar is included in another page and we don't want
// to interfere with its data.
if(in_array($ID, array_keys($data['id'])))
{
if(isset($_SERVER['REMOTE_USER']) && !is_null($_SERVER['REMOTE_USER']))
$username = $_SERVER['REMOTE_USER'];
else
$username = uniqid('davcal-');
$this->hlp->setCalendarNameForPage($data['name'], $data['description'], $ID, $username);
$this->hlp->setCalendarColorForPage($data['id'][$ID], $ID);
}
p_set_metadata($ID, array('plugin_davcal' => $data));
return $data;
}
/**
* Create output
*/
function render($format, &$R, $data) {
if($format != 'xhtml') return false;
global $ID;
$tzlist = \DateTimeZone::listIdentifiers(DateTimeZone::ALL);
// Render the Calendar. Timezone list is within a hidden div,
// the calendar ID is in a data-calendarid tag.
if($data['forcetimezone'] !== 'no')
$R->doc .= ''.sprintf($this->getLang('this_calendar_uses_timezone'), $data['forcetimezone']).'
';
$R->doc .= '';
$R->doc .= '';
$R->doc .= '
';
if(($this->getConf('hide_settings') !== 1) && ($data['settings'] !== 'hide'))
{
$R->doc .= '';
}
}
}
// vim:ts=4:sw=4:et:enc=utf-8: