Commit 1b32883e authored by Administrator's avatar Administrator 💬

refacto: clean up a little

parent a23bebe1
......@@ -7,6 +7,7 @@ use Grav\Common\Plugin;
use Grav\Common\Uri;
use Symfony\Component\EventDispatcher\Event;
/**
* Features:
* - /sync Cheap git-sync (did not knew about it at the time)
......@@ -222,6 +223,7 @@ class M3P2Plugin extends Plugin
$uri = $this->grav['uri'];
// var_dump($uri); // best doc ftw
// GRAV's routing makes use hook 404 pages and do the URL match ourselves
if ("lessons" != $uri->paths(0)) {
return; // perhaps not
}
......@@ -247,8 +249,6 @@ class M3P2Plugin extends Plugin
}
foreach ($page_config->lessons as $lesson) {
// print("Checking lesson".print_r($lesson, true)."<br>\n");
// if ($lesson_slug == $lesson) {
if ($lesson_slug == $lesson['slug']) {
return true; // yay, this page is part of the lesson
}
......@@ -265,18 +265,21 @@ class M3P2Plugin extends Plugin
$hb = $b->header();
$fdp = function ($lesson) use ($lesson_slug) {
return $lesson["slug"] == $lesson_slug;
return trim($lesson["slug"]) === $lesson_slug;
};
// We're assuming the config exists (it should)
// NOOOOPE IT DOES NOT THERE IS A BUG TO HUNT HERE FIXME
$ma = @array_filter($ha->lessons, $fdp)[0];
$mb = @array_filter($hb->lessons, $fdp)[0];
$mar = array_filter($ha->lessons, $fdp);
assert($mar && !empty($mar), "No lesson found for $lesson_slug in page ".$a->url());
$ma = array_shift($mar);
$mbr = array_filter($hb->lessons, $fdp);
assert($mbr && !empty($mbr), "No lesson found for $lesson_slug in page ".$b->url());
$mb = array_shift($mbr);
if (isset($ma['order'])) {
if ($ma && isset($ma['order'])) {
$la = floor($ma['order']);
}
if (isset($mb['order'])) {
if ($mb && isset($mb['order'])) {
$lb = floor($mb['order']);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment