1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* DokuWiki Actions |
4
|
|
|
* |
5
|
|
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) |
6
|
|
|
* @author Andreas Gohr <[email protected]> |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
if(!defined('DOKU_INC')) die('meh.'); |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
function act_dispatch(){ |
13
|
|
|
$router = \dokuwiki\ActionRouter::getInstance(); // is this needed here or could we delegate it to tpl_content() later? |
14
|
|
|
|
15
|
|
|
$headers = array('Content-Type: text/html; charset=utf-8'); |
16
|
|
|
trigger_event('ACTION_HEADERS_SEND',$headers,'act_sendheaders'); |
17
|
|
|
|
18
|
|
|
// clear internal variables |
19
|
|
|
unset($router); |
20
|
|
|
unset($headers); |
21
|
|
|
// make all globals available to the template |
22
|
|
|
extract($GLOBALS); |
23
|
|
|
|
24
|
|
|
include(template('main.php')); |
25
|
|
|
// output for the commands is now handled in inc/templates.php |
26
|
|
|
// in function tpl_content() |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Send the given headers using header() |
31
|
|
|
* |
32
|
|
|
* @param array $headers The headers that shall be sent |
33
|
|
|
*/ |
34
|
|
|
function act_sendheaders($headers) { |
35
|
|
|
foreach ($headers as $hdr) header($hdr); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Sanitize the action command |
40
|
|
|
* |
41
|
|
|
* @author Andreas Gohr <[email protected]> |
42
|
|
|
* |
43
|
|
|
* @param array|string $act |
44
|
|
|
* @return string |
45
|
|
|
*/ |
46
|
|
|
function act_clean($act){ |
47
|
|
|
// check if the action was given as array key |
48
|
|
|
if(is_array($act)){ |
49
|
|
|
list($act) = array_keys($act); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
//remove all bad chars |
53
|
|
|
$act = strtolower($act); |
54
|
|
|
$act = preg_replace('/[^1-9a-z_]+/','',$act); |
55
|
|
|
|
56
|
|
|
if($act == 'export_html') $act = 'export_xhtml'; |
57
|
|
|
if($act == 'export_htmlbody') $act = 'export_xhtmlbody'; |
58
|
|
|
|
59
|
|
|
if($act === '') $act = 'show'; |
60
|
|
|
return $act; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Handle 'draftdel' |
65
|
|
|
* |
66
|
|
|
* Deletes the draft for the current page and user |
67
|
|
|
* |
68
|
|
|
* @param string $act action command |
69
|
|
|
* @return string action command |
70
|
|
|
*/ |
71
|
|
|
function act_draftdel($act){ |
|
|
|
|
72
|
|
|
global $INFO; |
73
|
|
|
@unlink($INFO['draft']); |
|
|
|
|
74
|
|
|
$INFO['draft'] = null; |
75
|
|
|
return 'show'; |
76
|
|
|
} |
77
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.