-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.php
41 lines (32 loc) · 1.12 KB
/
action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'action.php');
class action_plugin_notfound extends DokuWiki_Action_Plugin {
function register(Doku_Event_Handler $controller) {
$controller->register_hook('ACTION_ACT_PREPROCESS','BEFORE', $this, '_check404');
$controller->register_hook('TPL_CONTENT_DISPLAY','BEFORE', $this, '_show404');
}
function _check404(Doku_Event $event , $param) {
if($event->data != 'show') return false;
global $INFO;
if($INFO['exists']) return false;
$event->data = 'notfound';
$event->stopPropagation();
$event->preventDefault();
return true;
}
function _show404(Doku_Event $event, $param) {
global $ACT;
if($ACT != 'notfound') return false;
$event->stopPropagation();
$event->preventDefault();
global $ID;
$oldid = $ID;
$ID = $this->getConf('404page');
echo p_wiki_xhtml($ID,'',false);
$ID = $oldid;
$ACT='show';
return true;
}
}