Merge pull request #2515 from Innovailable/master
[dokuwiki.git] / inc / actions.php
blob9ba8878603ae9924102d902f46cf146866f84d03
1 <?php
2 /**
3 * DokuWiki Actions
5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author Andreas Gohr <andi@splitbrain.org>
7 */
9 if(!defined('DOKU_INC')) die('meh.');
11 /**
12 * All action processing starts here
14 function act_dispatch(){
15 // always initialize on first dispatch (test request may dispatch mutliple times on one request)
16 $router = \dokuwiki\ActionRouter::getInstance(true);
18 $headers = array('Content-Type: text/html; charset=utf-8');
19 trigger_event('ACTION_HEADERS_SEND',$headers,'act_sendheaders');
21 // clear internal variables
22 unset($router);
23 unset($headers);
24 // make all globals available to the template
25 extract($GLOBALS);
27 include(template('main.php'));
28 // output for the commands is now handled in inc/templates.php
29 // in function tpl_content()
32 /**
33 * Send the given headers using header()
35 * @param array $headers The headers that shall be sent
37 function act_sendheaders($headers) {
38 foreach ($headers as $hdr) header($hdr);
41 /**
42 * Sanitize the action command
44 * @author Andreas Gohr <andi@splitbrain.org>
46 * @param array|string $act
47 * @return string
49 function act_clean($act){
50 // check if the action was given as array key
51 if(is_array($act)){
52 list($act) = array_keys($act);
55 //remove all bad chars
56 $act = strtolower($act);
57 $act = preg_replace('/[^1-9a-z_]+/','',$act);
59 if($act == 'export_html') $act = 'export_xhtml';
60 if($act == 'export_htmlbody') $act = 'export_xhtmlbody';
62 if($act === '') $act = 'show';
63 return $act;