fix for new layout engine

git-svn-id: file:///home/shish/svn/shimmie2/trunk@306 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2007-07-16 21:46:41 +00:00
parent b7ec475b6c
commit 6187d9a89f

View file

@ -3,9 +3,9 @@
class Handle404 extends Extension {
public function receive_event($event) {
if(is_a($event, 'PageRequestEvent')) {
global $page;
$page = $event->page_object;
// hax.
if($page->mode == "page" && (!isset($page->blocks) || count($page->blocks) == 0)) {
if($page->mode == "page" && (!isset($page->blocks) || $this->count_main($page->blocks) == 0)) {
$h_pagename = html_escape($event->page);
header("HTTP/1.0 404 Page Not Found");
$page->set_title("404");
@ -15,6 +15,14 @@ class Handle404 extends Extension {
}
}
}
private function count_main($blocks) {
$n = 0;
foreach($blocks as $block) {
if($block->section == "main") $n++; // more hax.
}
return $n;
}
}
add_event_listener(new Handle404(), 99);
add_event_listener(new Handle404(), 99); // hax++
?>