1<?php
2/**
3 * DokuWiki Plugin t2t (Action Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Eric Forgeot, derivative from Andreas Gohr work
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_txt2tags 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 $ID;
23      // The next line enables txt2tags markup ONLY on pages which have the .t2t extension.
24       // If you want it for the whole website, just delete or comment out the line below:
25		if(substr($ID,-4) != '.t2t') return true;
26	  // The next line will only be useful when the previous line is commented and txt2tags syntax
27	   // is enabled for the whole website: it will allow you to disable txt2tags on pages
28	   // which have the .dok extension, so the dokuwiki syntax will be used instead.
29		if(substr($ID,-4) == '.dok')
30		{
31			return true;
32		}
33		else
34		{
35			   $event->data = "<t2t>\n".$event->data."\n</t2t>";
36		}
37	   }
38
39}
40