sections * This variblae is used in the function document_end to recreate the whole doc. * - add the numbering to the header text * * @param string $text the text to display * @param int $level header level * @param int $pos byte position in the original source */ function header($text, $level, $pos, $returnonly = false) { // We are going from 2 to 3 // The parent is 2 if ($level > $this->previousNodeLevel) { $nodePosition = 1; // Keep the position of the parent $this->nodeParentPosition[$this->previousNodeLevel] = $this->previousNodePosition; } elseif // We are going from 3 to 2 // The parent is 1 ($level < $this->previousNodeLevel ) { $nodePosition = $this->nodeParentPosition[$level] + 1; } else { $nodePosition = $this->previousNodePosition + 1; } // Grab the doc from the previous section $this->sections[$this->sectionNumber] = array( 'level' => $this->previousNodeLevel, 'position' => $this->previousNodePosition, 'content' => $this->doc, 'text' => $this->previousSectionTextHeader); // And reset it $this->doc = ''; // Set the looping variable $this->sectionNumber = $this->sectionNumber + 1; $this->previousNodeLevel = $level; $this->previousNodePosition = $nodePosition; $this->previousSectionTextHeader = $text; /** * Rendering is done by the parent * And should be the last one * Because we delete the heading * with {@link HeadingTag::reduceToFirstOpeningTagAndReturnAttributes()} * in order to be able to add the toc and section * */ parent::header($text, $level, $pos); } function document_end() { global $ID; // The id of the page (not of the sidebar) $id = $ID; $isSidebar = FsWikiUtility::isSideBar(); // Pump the last doc $this->sections[$this->sectionNumber] = array('level' => $this->previousNodeLevel, 'position' => $this->previousNodePosition, 'content' => $this->doc, 'text' => $this->previousSectionTextHeader); // Recreate the doc $this->doc = ''; $rollingLineCount = 0; $currentLineCountSinceLastAd = 0; foreach ($this->sections as $sectionNumber => $section) { $sectionContent = $section['content']; # Split by element line # element p, h, br, tr, li, pre (one line for pre) $sectionLineCount = XhtmlUtility::countLines($sectionContent); $currentLineCountSinceLastAd += $sectionLineCount; $rollingLineCount += $sectionLineCount; // The content if ($this->getConf('ShowCount') == 1) { $this->doc .= "

Section " . $sectionNumber . ": (" . $sectionLineCount . "|" . $currentLineCountSinceLastAd . "|" . $rollingLineCount . ")

"; } $this->doc .= $sectionContent; } parent::document_end(); } }