/** * Returns the index of this section. * * @param string $separator * @return string */ public function getIndex($separator = '.') { if ($this->_parent->_name !== null) { return $this->_parent->getIndex($separator) . $separator . ($this->_index + 1); } else { return ($this->_index + 1); } }
/** * Renders a sections and its children * * @param $section Sensei_Doc_Section section to be rendered * @return string rendered sections */ protected function _renderSection(Sensei_Doc_Section $section) { $output = ''; $title = $section->getIndex() . ' ' . $section->getName(); $level = $section->getLevel(); if ($level === 1) { $class = ' class="chapter"'; $title = 'Chapter ' . $title; } else { $class = ' class="section"'; } $output .= '<div' . $class .'>' . "\n"; $output .= "<h$level>"; if ( ! ($this->_options['section'] instanceof Sensei_Doc_Section) || ($level > $this->_options['section']->getLevel())) { $anchor = $this->makeAnchor($section); $output .= '<a href="#' . $anchor . '" id="' . $anchor . '">'; $output .= $title . '</a>'; } else { $output .= $title; } $output .= "</h$level>"; // Transform section contents from wiki syntax to XHTML $output .= $this->_wiki->transform($section->getText()); // Render children of this section recursively for ($i = 0; $i < count($section); $i++) { $output .= $this->_renderSection($section->getChild($i)); } $output .= '</div>' . "\n"; return $output; }