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; public $id;
/**
* Should this block count as content for the sake of
* the 404 handler
*
* @var boolean
*/
public $is_content = true;
/** /**
* Construct a block. * Construct a block.
* *

View File

@ -42,7 +42,9 @@ class Blocks extends Extension {
foreach($blocks as $block) { foreach($blocks as $block) {
$path = implode("/", $event->args); $path = implode("/", $event->args);
if(strlen($path) < 4000 && fnmatch($block['pages'], $path)) { 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 // loads the chatbox at the set location
$html = "<div id=\"yshout\"></div>"; $html = "<div id=\"yshout\"></div>";
$chatblock = new Block("Chatbox", $html, "main", 97); $chatblock = new Block("Chatbox", $html, "main", 97);
$chatblock->is_content = false;
$page->add_block($chatblock); $page->add_block($chatblock);
} }
} }

View File

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