1<?php 2/** 3 * Plugin iCalEvents: Renders an iCalendar file, e.g., as a table. 4 * 5 * Copyright (C) 2010-2012, 2015-2016 6 * Tim Ruffing, Robert Rackl, Elan Ruusamäe, Jannes Drost-Tenfelde 7 * 8 * This file is part of the DokuWiki iCalEvents plugin. 9 * 10 * The DokuWiki iCalEvents plugin program is free software: 11 * you can redistribute it and/or modify it under the terms of the 12 * GNU General Public License version 2 as published by the Free 13 * Software Foundation. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * version 2 along with the DokuWiki iCalEvents plugin program. If 22 * not, see <http://www.gnu.org/licenses/gpl-2.0.html>. 23 * 24 * @license https://www.gnu.org/licenses/gpl-2.0.html GPL2 25 * @author Tim Ruffing <tim@timruffing.de> 26 * @author Robert Rackl <wiki@doogie.de> 27 * @author Elan Ruusamäe <glen@delfi.ee> 28 * @author Jannes Drost-Tenfelde <info@drost-tenfelde.de> 29 * 30 */ 31 32// must be run within Dokuwiki 33if (!defined('DOKU_INC')) 34 die(); 35 36if (!defined('DOKU_PLUGIN')) 37 define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); 38 39require_once DOKU_PLUGIN . 'syntax.php'; 40 41// We require at least PHP 5.5.5. 42// The following base class implements just the basics and an error message for older PHP versions. 43// Then we define the actual class by extending the base class depending on the PHP version. 44 45class syntax_plugin_icalevents_base extends DokuWiki_Syntax_Plugin { 46 const ERROR_PREFIX = '<br/ >Error in Plugin iCalEvents: '; 47 48 function getType() { 49 return 'substition'; 50 } 51 52 function getPType() { 53 return 'block'; 54 } 55 56 function getSort() { 57 // The iCalendar plugin (and older versions of iCalEvents) used 42 here. 58 // So we need be stay below 42 to ensure an easy upgrade from iCalendar to iCalEvents. 59 return 41; 60 } 61 62 function connectTo($mode) { 63 // Subpatterns such as (iCalEvents|iCalendar) are not allowed 64 // see https://www.dokuwiki.org/devel:parser#subpatterns_not_allowed 65 $this->Lexer->addSpecialPattern('(?i:\{\{iCalEvents>.*?\}\})', $mode, 'plugin_icalevents'); 66 $this->Lexer->addSpecialPattern('(?i:\{\{iCalendar>.*?\}\})', $mode, 'plugin_icalevents'); 67 } 68 69 function handle($match, $state, $pos, Doku_Handler $handler) { 70 } 71 72 function render($mode, Doku_Renderer $renderer, $data) { 73 $renderer->doc .= static::ERROR_PREFIX . 'The plugin requires at least PHP 5.5.5.'; 74 return false; 75 } 76} 77 78 79// An 'require' ensures that older PHP versions do not even try to parse the actual code. 80if (PHP_VERSION_ID >= 50505) { 81 require __DIR__ . '/syntax-impl.php'; 82} else { 83 class syntax_plugin_icalevents extends syntax_plugin_icalevents_base { 84 } 85} 86 87 88