1, 'lang' => 'en', 'default-lang' => 'en', 'one-page' => false, 'section' => null, 'clean-url' => false, 'base-url' => ''); private $_lang = array(); public function __construct($filename) { $this->_wiki = new Text_Wiki(); $this->_wiki->disableRule('Wikilink'); $this->_toc = new Sensei_Doc_Toc($filename); } public function getOption($option) { return $this->_options[$option]; } public function setOption($option, $value) { switch ($option) { case 'max-level': if (!is_int($value)) { throw new Exception('Value must be an integer.'); } break; case 'one-page': case 'clean-url': if (!is_bool($value)) { throw new Exception('Value must be a boolean.'); } break; case 'locale': case 'base-url': if (!is_string($value)) { throw new Exception('Value must be a string.'); } break; case 'section': if (! $value instanceof Sensei_Doc_Section) { throw new Exception('Value must be an instance of Sensei_Doc_Section.'); } break; default: throw new Exception('Unknown option.'); } $this->_options[$option] = $value; } public function addLanguage(array $translations, $lang) { $this->_lang[$lang] = $translations; } public function translate($string) { $language = $this->getOption('lang'); if (array_key_exists($language, $this->_lang) && array_key_exists($string, $this->_lang[language])) { return $this->_lang[$language][$string]; } else { return $string; } } public function renderToc($toc = null) { if (!$toc) { $toc = $this->_toc; } $classes = array(); if ($toc instanceof Sensei_Doc_Toc) { $class = ''; if ($this->getOption('one-page')) { $class = ' class="one-page"'; } $classes[] = 'tree'; } else { $isParent = false; $section = $this->getOption('section'); if ($section !== null) { $current = $section; do { if ($current === $toc) { $isParent = true; break; } } while (($current = $current->getParent()) !== null); } if (! $isParent) { $classes[] = 'closed'; } } $classes = implode(' ', $classes); if ($classes === '') { echo "