404 handler
git-svn-id: file:///home/shish/svn/shimmie2/trunk@155 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
b5b5e56f01
commit
b1a2f5eea4
1 changed files with 19 additions and 0 deletions
19
ext/handle_404/main.php
Normal file
19
ext/handle_404/main.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
class Handle404 extends Extension {
|
||||
public function receive_event($event) {
|
||||
if(is_a($event, 'PageRequestEvent')) {
|
||||
global $page;
|
||||
// hax.
|
||||
if($page->mode == "page" && (!isset($page->mainblocks) || count($page->mainblocks) == 0)) {
|
||||
$h_pagename = html_escape($event->page);
|
||||
header("HTTP/1.0 404 Page Not Found");
|
||||
$page->set_title("404");
|
||||
$page->set_heading("404 - No Handler Found");
|
||||
$page->add_main_block(new Block("Explanation", "No handler could be found for the page '$h_pagename'"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new Handle404(), 99);
|
||||
?>
|
Reference in a new issue