--- dokuwiki-plugin-icalevents-20100501/syntax.php 2010-12-05 22:33:33.062976306 +0200 +++ iCalEvents/syntax.php 2010-12-05 22:44:54.218325084 +0200 @@ -74,20 +74,32 @@ $previewSec = 60*24*3600; # two month } + # Take dateformat from params, or + # If dateformat is set in plugin configuration ('dformat'), then use it. + # Otherwise fall back to dokuwiki's default dformat from the global /conf/dokuwiki.php. + if (!empty($params['dformat'])) { + $dateFormat = $params['dformat']; + } else { + global $conf; + $dateFormat = $this->getConf('dformat') ? $this->getConf('dformat') : $conf['dformat']; + } + + $showEndDates = !empty($params['showEndDates']); + #echo "url=$icsURL from = $from previewSec = $previewSec
"; - return array($icsURL, $from, $previewSec); + return array($icsURL, $from, $previewSec, $dateFormat, $showEndDates); } /** * loads the ics file via HTTP, parses it and renders an HTML table. */ function render($mode, &$renderer, $data) { - list($url, $from, $previewSec) = $data; + list($url, $from, $previewSec, $dateFormat, $showEndDates) = $data; $ret = ''; if($mode == 'xhtml'){ # parse the ICS file - $entries = $this->_parseIcs($url, $from, $previewSec); + $entries = $this->_parseIcs($url, $from, $previewSec, $dateFormat); if ($this->error) { $renderer->doc .= "Error in Plugin iCalEvents: ".$this->error; return true; @@ -103,7 +115,7 @@ foreach ($entries as $entry) { $rowCount++; $ret .= ''; - if ($this->getConf('showEndDates')) { + if ($showEndDates || $this->getConf('showEndDates')) { $ret .= ''.$entry['startdate'].' - '.$entry['enddate'].''; } else { $ret .= ''.$entry['startdate']; @@ -130,9 +142,7 @@ * @param previewSec preview range also in seconds * @return an array of entries sorted by their startdate */ - function _parseIcs($url, $from, $previewSec) { - global $conf; - + function _parseIcs($url, $from, $previewSec, $dateFormat) { // must reset error in case we have multiple calendars on page $this->error = false; @@ -144,10 +154,6 @@ $content = $http->resp_body; $entries = array(); - # If dateformat is set in plugin configuration ('dformat'), then use it. - # Otherwise fall back to dokuwiki's default dformat from the global /conf/dokuwiki.php. - $dateFormat = $this->getConf('dformat') ? $this->getConf('dformat') : $conf['dformat']; - # regular expressions for items that we want to extract from the iCalendar file $regex_vevent = '/BEGIN:VEVENT(.*?)END:VEVENT/s'; $regex_summary = '/SUMMARY:(.*?)\n/';