*/ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_wikicalendar extends DokuWiki_Syntax_Plugin { /** * namespace of the calendar */ var $calendar_ns = ''; /** * namespace of the current viewed month */ var $month_ns = ''; /** * indicator if first week of the month has been generated */ var $firstWeek = false; /** * array with localisations of weekdays */ var $langDays = array(); /** * array with localistaions of month */ var $langMonth = array(); /** * the current date */ var $curDate = array(); /** * the month to show */ var $showMonth = ''; /** * the year to show */ var $showYear = ''; /** * the global timestamp for date-operations */ var $gTimestamp = ''; /** * number days of the current month */ var $numDays = ''; /** * date-date to generate the calendar */ var $viewDate = array(); /** * return some info */ function getInfo(){ return array( 'author' => 'Michael Klier (chi)', 'email' => 'chi@chimeric.de', 'date' => @file_get_contents(DOKU_PLUGIN.'wikicalendar/VERSION'), 'name' => 'WikiCalendar Plugin', 'desc' => 'Implements a simple Calendar with links to wikipages.', 'url' => 'http://dokuwiki.org/plugin:wikicalendar' ); } /** * Some Information first. */ function getType() { return 'substition'; } function getPType() { return 'block'; } function getSort() { return 125; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern('{{cal>.+?}}',$mode,'plugin_wikicalendar'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ $match = substr($match,6,-2); return array($match); } /** * Create output */ function render($mode, &$renderer, $data) { global $ID; global $conf; if($mode == 'xhtml'){ $tz = date_default_timezone_get(); if($this->getConf('timezone')) { date_default_timezone_set($this->getConf('timezone')); } // define some variables first $this->calendar_ns = ($data[0]) ? $data[0] : $ID; $this->langDays = $this->getLang('days'); $this->langMonth = $this->getLang('month'); $this->curDate = getdate(time()); $this->showMonth = (is_numeric($_REQUEST['plugin_wikicalendar_month'])) ? $_REQUEST['plugin_wikicalendar_month'] : $this->curDate['mon']; $this->showYear = (is_numeric($_REQUEST['plugin_wikicalendar_year'])) ? $_REQUEST['plugin_wikicalendar_year'] : $this->curDate['year']; $this->gTimestamp = mktime(0,0,0,$this->showMonth,1,$this->showYear); $this->numDays = date('t',$this->gTimestamp); $this->viewDate = getdate($this->gTimestamp); $this->today = ($this->viewDate['mon'] == $this->curDate['mon'] && $this->viewDate['year'] == $this->curDate['year']) ? $this->curDate['mday'] : null; // if month directory exists we keep the old scheme if(is_dir($conf['datadir'].'/'.str_replace(':','/',$this->calendar_ns.':'.$this->showYear.':'.$this->showMonth))) { $this->month_ns = $this->calendar_ns.':'.$this->showYear.':'.$this->showMonth; } else { if($this->showMonth < 10) { $this->month_ns = $this->calendar_ns.':'.$this->showYear.':0'.$this->showMonth; } else { $this->month_ns = $this->calendar_ns.':'.$this->showYear.':'.$this->showMonth; } } if($this->MonthStart == 7 && $this->getConf('weekstart') == 'Sunday') { $this->MonthStart = 0; } else { $this->MonthStart = ($this->viewDate['wday'] == 0) ? 7 : $this->viewDate['wday']; } // turn off caching $renderer->info['cache'] = false; $renderer->doc .= '
' . DOKU_LF;
}
$out .= '';
$out .= '
' . DOKU_LF;
}
$out .= '