1<?php 2/** 3 * Plugin hcalendar: Using Microformat Calendar 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Juergen A. Lamers <jaloma.ac@googlemail.com> 7 * @seealso (http://jaloma.ac.googlepages.com/plugin:hcalendar) 8 * @seealso (http://microformats.org/wiki/internet-explorer-extensions) 9 * @seealso (http://microformats.org/wiki/firefox-extensions) 10 */ 11 12if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 13if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 14require_once(DOKU_PLUGIN.'syntax.php'); 15require_once(DOKU_PLUGIN.'hcalendar/syntax/helper.php'); 16require_once(DOKU_PLUGIN.'hcalendar/syntax/hcal_renderer_helper.php'); 17/** 18 * All DokuWiki plugins to extend the parser/rendering mechanism 19 * need to inherit from this class 20 */ 21class syntax_plugin_hcalendar_hcal extends DokuWiki_Syntax_Plugin { 22 23 function getInfo(){ 24 return array( 25 'author' => 'Juergen A. Lamers', 26 'email' => 'jaloma.ac@googlemail.com', 27 'date' => @file_get_contents(DOKU_PLUGIN . 'hcalendar/VERSION'), 28 'name' => 'HCalendar HCal Plugin', 29 'desc' => 'Adds a HCalendar Items 30 syntax: {{hcal>yyyy/mm/dd[hh:mm:ss];yyyy/mm/dd[hh:mm:ss]|summary|location}} 31See: http://microformats.org/wiki/', 32 'url' => 'http://jaloma.ac.googlepages.com/plugin:hcalendar', 33 ); 34 } 35 36 function getType() { return 'substition'; } 37 function getSort() { return 304; } 38 39 function connectTo($mode) { 40 $this->Lexer->addSpecialPattern('{{hcal>[^}]*?}}',$mode,'plugin_hcalendar_hcal'); 41 } 42 43 function handle($match, $state, $pos, &$handler){ 44 @list($summary, $location, 45 $yy_start, $mth_start, $dy_start, 46 $hh_start, $mm_start, $ss_start, 47 $tm_start, 48 $yy_end, $mth_end, $dy_end, 49 $hh_end, $mm_end, $ss_end, 50 $tm_end, 51 $err) = hcal_parseCommand($match); 52 if (isset($err)) { 53 return array('error', 54 $err); 55 } else { 56 return array('wiki', 57 $yy_start,$mth_start,$dy_start,$hh_start,$mm_start,$ss_start, $tm_start, 58 $yy_end, $mth_end, $dy_end, $hh_end, $mm_end, $ss_end, $tm_end, 59 $summary, $location); 60 } 61 } 62 63 function render($mode, &$renderer, $data) { 64 setlocale(LC_ALL,$this->getConf('locale')); 65 list($style, 66 $yy_start,$mth_start,$dy_start,$hh_start,$mm_start,$ss_start,$dt_start, 67 $yy_end ,$mth_end ,$dy_end ,$hh_end, $mm_end, $ss_end, $dt_end, 68 $summary ,$location) = $data; 69 70 if ($this->getConf('filterdate') == true) { 71 $dt_now = strtotime("now"); 72 if ($dt_start < $dt_now && $dt_end < $dt_now) { return true;} 73 } 74 if($mode == 'xhtml'){ 75 switch($style) { 76 case 'wiki': 77 $renderer->doc .= helper_plugin_hcal::buildText( 78 $yy_start,$mth_start,$dy_start,$hh_start,$mm_start,$ss_start,$dt_start, 79 $yy_end ,$mth_end ,$dy_end ,$hh_end, $mm_end, $ss_end, $dt_end, 80 $summary ,$location, false, 81 'tag_vevent', 82 'tag_summary', 83 'tag_dtstart', 84 'tag_dtend', 85 'tag_location', 86 'tag_uid', 87 'tag_dtstamp', 88 false 89 ); 90 break; 91 case 'error' : 92 $renderer->doc .= "<div class='error'>$yy_start</div>"; 93 break; 94 default: 95 $renderer->doc .= "<div class='error'>" . $this->getLang('hcal_invalid_mode') . "</div>"; 96 break; 97 } 98 return true; 99 } 100 return false; 101 } 102 103} // CLASS 104