1<?php
2/**
3 * DokuWiki Plugin pagehere (Action Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Andreas Gohr <gohr@cosmocode.de>
7 */
8
9class action_plugin_pagehere extends DokuWiki_Action_Plugin {
10
11    public function register(Doku_Event_Handler $controller) {
12       $controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'handleDokuwikiStarted');
13    }
14
15    public function handleDokuwikiStarted(Doku_Event $event, $param) {
16        if (empty($_REQUEST['pagehere'])) return;
17
18        global $ID;
19        global $conf;
20
21        $page = cleanID($_REQUEST['pagehere']);
22        if (!$this->getConf('subns')){
23            $page = str_replace(':', $conf['sepchar'], $page);
24        }
25
26        $ns = getNS($ID);
27        $newpage = cleanID($ns.':'.$page);
28
29        send_redirect(wl($newpage, ['do'=>'edit'], true, '&'));
30    }
31}
32// vim:ts=4:sw=4:et:
33