1<?php
2/**
3 * Site Export Plugin page move support for the move plugin
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Michael Hamann <michael@content-space.de>
7 */
8
9// must be run within Dokuwiki
10if (!defined('DOKU_INC')) die('Not inside DokuWiki');
11
12class action_plugin_siteexport_move extends DokuWiki_Action_Plugin {
13    /**
14     * Register Plugin in DW
15     **/
16    public function register(Doku_Event_Handler $controller) {
17        $controller->register_hook('PLUGIN_MOVE_HANDLERS_REGISTER', 'BEFORE', $this, 'register_move_handler');
18    }
19
20    /**
21     * Register the handler for the move plugin.
22     */
23    public function register_move_handler(Doku_Event $event) {
24        $event->data['handlers']['siteexport_toc'] = array($this, 'move_handler');
25    }
26
27    /**
28     * Handle rewrites for the move plugin. Currently only the link/toc syntax is handled.
29     */
30    public function move_handler($match, $state, $pos, $pluginname, $handler) {
31        if ($state === DOKU_LEXER_SPECIAL) {
32            $handler->internallink($match, $state, $pos);
33            return '';
34        } else {
35            return $match;
36        }
37    }
38}
39