From 6f6d2a434c5ccc872f6b1856f4c517ce464bdfb3 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Thu, 28 Nov 2013 14:36:02 +0100 Subject: [PATCH] Add limiter to the max depth, add a config option later. --- syntax.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/syntax.php b/syntax.php index 362a4b1..f1622b8 100644 --- a/syntax.php +++ b/syntax.php @@ -20,6 +20,10 @@ require_once dirname (__FILE__) . DIRECTORY_SEPARATOR . 'objectrepresentation' . */ class syntax_plugin_navigation extends DokuWiki_Syntax_Plugin { + // TODO add a config option for this + private $maxDepth = 2; + private $depth = 0; + function getInfo () { return array ('author' => 'Tim Schumacher', 'email' => 'tim@bandenkrieg.hacked.jp', @@ -90,13 +94,16 @@ class syntax_plugin_navigation extends DokuWiki_Syntax_Plugin { } private function RenderNodes(DokuWikiNameSpace $node) { + $this->depth++; $output = ''; foreach ($node->getNodes() as $node) { /** @var DokuWikiNode $node */ if ($node instanceof DokuWikiPage) { $output .= '
  • ' . $node->getName() . '
  • '; } else { - $output .= '
  • ' . $node->getName() . '
  • '; + if ($this->depth <= $this->maxDepth) { + $output .= '
  • ' . $node->getName() . '
  • '; + } } } return $output;