6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
7 * @author Andreas Gohr <andi@splitbrain.org>
10 use dokuwiki\ActionRouter
;
11 use dokuwiki\Extension\Event
;
14 * All action processing starts here
16 function act_dispatch()
18 // always initialize on first dispatch (test request may dispatch mutliple times on one request)
19 $router = ActionRouter
::getInstance(true);
21 $headers = ['Content-Type: text/html; charset=utf-8'];
22 Event
::createAndTrigger('ACTION_HEADERS_SEND', $headers, 'act_sendheaders');
24 // clear internal variables
27 // make all globals available to the template
30 include(template('main.php'));
31 // output for the commands is now handled in inc/templates.php
32 // in function tpl_content()
36 * Send the given headers using header()
38 * @param array $headers The headers that shall be sent
40 function act_sendheaders($headers)
42 foreach ($headers as $hdr) header($hdr);
46 * Sanitize the action command
48 * @author Andreas Gohr <andi@splitbrain.org>
50 * @param array|string $act
53 function act_clean($act)
55 // check if the action was given as array key
57 [$act] = array_keys($act);
61 if ($act === null) return 'show';
63 //remove all bad chars
64 $act = strtolower($act);
65 $act = preg_replace('/[^1-9a-z_]+/', '', $act);
67 if ($act == 'export_html') $act = 'export_xhtml';
68 if ($act == 'export_htmlbody') $act = 'export_xhtmlbody';
70 if ($act === '') $act = 'show';