예제 #1
0
 /**
  * Returns the name of this section.
  *
  * @param boolean $full
  * @param string $separator
  * @return string
  */
 public function getName($full = false, $separator = ' - ')
 {
     if ($full &&  ! $this->_parent->isRoot()) {
         return $this->_parent->getName($full, $separator) . $separator . $this->_name;
     } else {
         return $this->_name;
     }
 }
예제 #2
0
    /**
     * 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;
    }