explicitly mark some block types as ignored when calculating 404ness

This commit is contained in:
Shish 2017-08-24 10:17:24 +01:00
parent 3c3529a4cc
commit 473c0f0bcb
4 changed files with 13 additions and 5 deletions

View file

@ -44,6 +44,14 @@ class Block {
*/
public $id;
/**
* Should this block count as content for the sake of
* the 404 handler
*
* @var boolean
*/
public $is_content = true;
/**
* Construct a block.
*

View file

@ -42,7 +42,9 @@ class Blocks extends Extension {
foreach($blocks as $block) {
$path = implode("/", $event->args);
if(strlen($path) < 4000 && fnmatch($block['pages'], $path)) {
$page->add_block(new Block($block['title'], $block['content'], $block['area'], $block['priority']));
$b = new Block($block['title'], $block['content'], $block['area'], $block['priority']);
$b->is_content = false;
$page->add_block($b);
}
}

View file

@ -30,6 +30,7 @@ class Chatbox extends Extension {
// loads the chatbox at the set location
$html = "<div id=\"yshout\"></div>";
$chatblock = new Block("Chatbox", $html, "main", 97);
$chatblock->is_content = false;
$page->add_block($chatblock);
}
}

View file

@ -43,10 +43,7 @@ class Handle404 extends Extension {
private function count_main($blocks) {
$n = 0;
foreach($blocks as $block) {
if($block->section == "main") $n++; // more hax.
}
if(ext_is_live("Chatbox")) {
$n--; // even more hax.
if($block->section == "main" && $block->is_content) $n++; // more hax.
}
return $n;
}