tree = $tree; $this->cover = $cover; } protected function getStyles() { // TODO :: un-hardcode that return ''; } protected function getPageUrl($page) { return "file_" . str_replace('/', '_', $page->getUrl()); } protected function buildNavigation(Directory $tree) { $nav = []; foreach ($tree->getEntries() as $node) { if ($node instanceof Content) { if ($node->isIndex()) { continue; } $nav[] = [ 'title' => $node->getTitle(), 'href' => "#" . $this->getPageUrl($node), ]; } elseif ($node instanceof Directory) { if (!$node->hasContent()) { continue; } $page_index = ($index = $node->getIndexPage()) ? $index : $node->getFirstPage(); $nav[] = [ 'title' => $node->getTitle(), 'href' => "#" . $this->getPageUrl($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']}
" . '