1<?php 2/** 3 * DokuWiki Plugin rst (Action Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Chris Green chris@isbd.co.uk> 7 */ 8 9// must be run within Dokuwiki 10if (!defined('DOKU_INC')) die(); 11if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 12require_once DOKU_PLUGIN.'action.php'; 13 14class action_plugin_rst extends DokuWiki_Action_Plugin { 15 16 function register(&$controller) { 17 $controller->register_hook('PARSER_WIKITEXT_PREPROCESS', 18'BEFORE', $this, 'handle_parser_wikitext_preprocess'); 19 } 20 21 function handle_parser_wikitext_preprocess(&$event, $param) { 22 global $ACT; 23 global $ID; 24 global $TEXT; 25 // Check if file is a .md page: 26 if(substr($ID,-4) != '.rst') return true; 27 // Check for default view (in this case there is only 1 parsed text) 28 // or check that the text parsed is the text being edited 29 // (see: http://www.dokuwiki.org/devel:environment#text): 30 if($ACT != 'show' && $event->data != $TEXT) return true; 31 { 32 $event->data = "<rst>\n".$event->data."\n</rst>"; 33 } 34 } 35}