tree = $tree; $this->cover = $cover; } protected function getStyles() { // TODO :: un-hardcode that return ''; } protected function getSectionId(Content $node) { foreach ($this->pages as $id => $page) { if ($page['page'] == $node) { return $id; } } throw new RuntimeException('Could not find the content page'); } protected function buildNavigation(Directory $tree) { $nav = []; foreach ($tree->getEntries() as $node) { if ($node instanceof Content) { if ($node->isIndex()) { continue; } $nav[] = [ 'title' => $node->getTitle(), 'href' => '#section_' . $this->getSectionId($node), ]; } elseif ($node instanceof Directory) { if (!$node->hasContent()) { continue; } $page_index = ($index = $node->getIndexPage()) ? $index : $node->getFirstPage(); $nav[] = [ 'title' => $node->getTitle(), 'href' => '#section_' . $this->getSectionId($page_index), 'children' => $this->buildNavigation($node), ]; } } return $nav; } private function renderNavigation($entries) { $nav = ''; foreach ($entries as $entry) { if (array_key_exists('children', $entry)) { if (array_key_exists('href', $entry)) { $link = '' . $entry['title'] . ''; } else { $link = '' . $entry['title'] . ''; } $link .= $this->renderNavigation($entry['children']); } else { $link = '' . $entry['title'] . ''; } $nav .= "
{$this->cover['subject']} by {$this->cover['author']}
" . '