Page MenuHomePhabricator

No OneTemporary

diff --git a/action/cache.php b/action/cache.php
new file mode 100644
--- /dev/null
+++ b/action/cache.php
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * DokuWiki DAVCal PlugIn - Ajax component
+ */
+
+if(!defined('DOKU_INC')) die();
+
+class action_plugin_davcal_cache extends DokuWiki_Action_Plugin {
+
+ /**
+ * @var helper_plugin_davcal
+ */
+ private $hlp = null;
+
+ function __construct() {
+ $this->hlp =& plugin_load('helper','davcal');
+ }
+
+ function register(Doku_Event_Handler $controller) {
+ $controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, 'handle_parser_cache_use');
+ }
+
+ function handle_parser_cache_use(&$event, $param) {
+ global $ID;
+ $cache = &$event->data;
+ if(!isset($cache->page)) return;
+
+ $davcalMeta = p_get_metadata($ID, 'plugin_davcal');
+ if(!$davcalMeta)
+ return;
+
+ if(isset($davcalMeta['table']) && $davcalMeta['table'] === true)
+ {
+ $event->preventDefault();
+ $event->stopPropagation();
+ $event->result = false;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/lang/en/lang.php b/lang/en/lang.php
--- a/lang/en/lang.php
+++ b/lang/en/lang.php
@@ -1,45 +1,50 @@
<?php
$lang['created_by_davcal'] = 'Created by DAVCal for DokuWiki';
$lang['unknown_error'] = 'Unknown Error';
$lang['event_added'] = 'Event added';
$lang['event_edited'] = 'Event edited';
$lang['event_deleted'] = 'Event deleted';
$lang['no_permission'] = 'You don\'t have permission to modify this calendar';
$lang['settings'] = 'Settings/Sync';
$lang['settings_saved'] = 'Settings saved successfully';
$lang['error_saving'] = 'Error saving settings.';
$lang['local_time'] = 'Local time (Browser based)';
+$lang['from'] = 'From';
+$lang['to'] = 'To';
+$lang['at'] = 'At';
+$lang['description'] = 'Description';
+$lang['title'] = 'Title';
$lang['js']['create_new_event'] = 'Create new Event';
$lang['js']['cancel'] = 'Cancel';
$lang['js']['create'] = 'Create';
$lang['js']['save'] = 'Save';
$lang['js']['settings'] = 'Settings';
$lang['js']['edit'] = 'Edit';
$lang['js']['delete'] = 'Delete';
$lang['js']['edit_event'] = 'Edit Event';
$lang['js']['allday'] = 'All Day Event';
$lang['js']['title'] = 'Title';
$lang['js']['from'] = 'From';
$lang['js']['to'] = 'To';
$lang['js']['yes'] = 'Yes';
$lang['js']['confirmation'] = 'Confirmation';
$lang['js']['ok'] = 'OK';
$lang['js']['info'] = 'Info';
$lang['js']['really_delete_this_event'] = 'Really delete this event?';
$lang['js']['timezone'] = 'Timezone';
$lang['js']['weeknumbers'] = 'Week Numbers';
$lang['js']['use_lang_tz'] = 'Use Timezone from language setting';
$lang['js']['only_workweek'] = 'Show only Work Week';
$lang['js']['sync_url'] = 'CalDAV URL';
$lang['js']['error_retrieving_data'] = 'There was an error retrieving data from the calendar server.';
$lang['js']['start_date_invalid'] = 'Start date/time is invalid.';
$lang['js']['end_date_invalid'] = 'End date/time is invalid.';
$lang['js']['end_date_before_start_date'] = 'End date/time is before start date/time.';
$lang['js']['end_date_is_same_as_start_date'] = 'End date/time is equal to start date/time.';
$lang['js']['description'] = 'Description';
$lang['js']['private_url'] = 'Private URL';
$lang['js']['recurring_cant_edit'] = 'Editing recurring events is currently not supported';
$lang['js']['no_permission'] = 'You don\'t have permission to modify this calendar';
$lang['js']['calendar'] = 'Calendar';
$lang['js']['start_monday'] = 'Week starts on Monday';
$lang['js']['nothing_to_show'] = 'Nothing to show';
diff --git a/plugin.info.txt b/plugin.info.txt
--- a/plugin.info.txt
+++ b/plugin.info.txt
@@ -1,7 +1,7 @@
base davcal
author Andreas Boehler
email dev@aboehler.at
-date 2015-10-17
+date 2015-10-20
name Calendar PlugIn with CalDAV sharing support
desc Create one calendar per page and share/subscribe via CalDAV
url http://www.dokuwiki.org/plugin:davcal
diff --git a/syntax.php b/syntax.php
--- a/syntax.php
+++ b/syntax.php
@@ -1,145 +1,224 @@
<?php
/**
* DokuWiki Plugin DAVCal (Syntax Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Andreas Böhler <dev@aboehler.at>
*/
// 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' => $ID,
'description' => $this->getLang('created_by_davcal'),
'id' => array(),
'settings' => 'show',
- 'view' => 'month'
+ 'view' => 'month',
+ 'table' => false,
+ 'startdate' => 'today',
+ 'numdays' => 30,
+ 'dateformat' => 'Y-m-d H:i',
+ 'onlystart' => false,
);
$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 'table':
+ $data['table'] = true;
+ break;
+ case 'onlystart':
+ if(($val === 'on') || ($val === 'true'))
+ $data['onlystart'] = true;
+ 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.
+ // Disable this, if we output to table.
// 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(in_array($ID, array_keys($data['id'])) && ($data['table'] === false))
{
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;
+ if(($format != 'xhtml') && ($format != 'odt')) 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.
- $R->doc .= '<div id="fullCalendar" data-calendarpage="'.$ID.'"></div>';
- $R->doc .= '<div id="fullCalendarTimezoneList" class="fullCalendarTimezoneList" style="display:none">';
- $R->doc .= '<select id="fullCalendarTimezoneDropdown">';
- $R->doc .= '<option value="local">'.$this->getLang('local_time').'</option>';
- foreach($tzlist as $tz)
+
+ // Handle creating a table
+ // For ODT output, always create the table as the calendar doesn't make sense
+ if(($data['table'] === true) || ($format == 'odt'))
{
- $R->doc .= '<option value="'.$tz.'">'.$tz.'</option>';
+ $events = array();
+ $from = $data['startdate'];
+ if($from === 'today')
+ $from = new \DateTime();
+ else
+ $from = new \DateTime($from);
+ $to = clone $from;
+ $to->add(new \DateInterval('P'.$data['numdays'].'D'));
+ foreach($data['id'] as $calPage => $color)
+ {
+ $events = array_merge($events, $this->hlp->getEventsWithinDateRange($calPage,
+ $user, $from->format('Y-m-d'), $to->format('Y-m-d')));
+ }
+ $R->table_open();
+ $R->tablethead_open();
+ $R->tableheader_open();
+ $R->doc .= $data['onlystart'] ? $this->getLang('at') : $this->getLang('from');
+ $R->tableheader_close();
+ if(!$data['onlystart'])
+ {
+ $R->tableheader_open();
+ $R->doc .= $this->getLang('to');
+ $R->tableheader_close();
+ }
+ $R->tableheader_open();
+ $R->doc .= $this->getLang('title');
+ $R->tableheader_close();
+ $R->tableheader_open();
+ $R->doc .= $this->getLang('description');
+ $R->tableheader_close();
+ $R->tablethead_close();
+ foreach($events as $event)
+ {
+ $R->tablerow_open();
+ $R->tablecell_open();
+ $from = new \DateTime($event['start']);
+ $to = new \DateTime($event['end']);
+ $R->doc .= $from->format($data['dateformat']);
+ $R->tablecell_close();
+ if(!$data['onlystart'])
+ {
+ $R->tablecell_open();
+ $R->doc .= $to->format($data['dateformat']);
+ $R->tablecell_close();
+ }
+ $R->tablecell_open();
+ $R->doc .= $event['title'];
+ $R->tablecell_close();
+ $R->tablecell_open();
+ $R->doc .= $event['description'];
+ $R->tablecell_close();
+ $R->tablerow_close();
+ }
+ $R->table_close();
}
- $R->doc .= '</select></div>';
- if(($this->getConf('hide_settings') !== 1) && ($data['settings'] !== 'hide'))
- {
- $R->doc .= '<div class="fullCalendarSettings"><a href="#" class="fullCalendarSettings"><img src="'.DOKU_URL.'lib/plugins/davcal/images/settings.png'.'">'.$this->getLang('settings').'</a></div>';
+ // Handle JavaScript calendar output
+ else
+ {
+ $tzlist = \DateTimeZone::listIdentifiers(DateTimeZone::ALL);
+
+ // Render the Calendar. Timezone list is within a hidden div,
+ // the calendar ID is in a data-calendarid tag.
+ $R->doc .= '<div id="fullCalendar" data-calendarpage="'.$ID.'"></div>';
+ $R->doc .= '<div id="fullCalendarTimezoneList" class="fullCalendarTimezoneList" style="display:none">';
+ $R->doc .= '<select id="fullCalendarTimezoneDropdown">';
+ $R->doc .= '<option value="local">'.$this->getLang('local_time').'</option>';
+ foreach($tzlist as $tz)
+ {
+ $R->doc .= '<option value="'.$tz.'">'.$tz.'</option>';
+ }
+ $R->doc .= '</select></div>';
+ if(($this->getConf('hide_settings') !== 1) && ($data['settings'] !== 'hide'))
+ {
+ $R->doc .= '<div class="fullCalendarSettings"><a href="#" class="fullCalendarSettings"><img src="'.DOKU_URL.'lib/plugins/davcal/images/settings.png'.'">'.$this->getLang('settings').'</a></div>';
+ }
}
-
}
}
// vim:ts=4:sw=4:et:enc=utf-8:

File Metadata

Mime Type
text/x-diff
Expires
Fri, Jan 24, 4:47 AM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
533760
Default Alt Text
(12 KB)

Event Timeline