1<?php 2if(!defined('DOKU_INC')) die(); 3if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 4require_once(DOKU_PLUGIN.'action.php'); 5 6 7class action_plugin_notfound extends DokuWiki_Action_Plugin { 8 9 10 function getInfo(){ 11 return confToHash(dirname(__FILE__).'/info.txt'); 12 } 13 14 15 function register(&$controller) { 16 $controller->register_hook('ACTION_ACT_PREPROCESS','BEFORE', $this, '_check404'); 17 $controller->register_hook('TPL_CONTENT_DISPLAY','BEFORE', $this, '_show404'); 18 } 19 20 21 function _check404(&$event , $param) { 22 if($event->data != 'show') return false; 23 global $INFO; 24 if($INFO['exists']) return false; 25 26 $event->data = 'notfound'; 27 $event->stopPropagation(); 28 $event->preventDefault(); 29 return true; 30 } 31 32 function _show404(&$event, $param) { 33 global $ACT; 34 if($ACT != 'notfound') return false; 35 $event->stopPropagation(); 36 $event->preventDefault(); 37 38 global $ID; 39 $oldid = $ID; 40 $ID = $this->getConf('404page'); 41 echo p_wiki_xhtml($ID,'',false); 42 $ID = $oldid; 43 $ACT='show'; 44 45 return true; 46 } 47} 48