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) { /** * Save the H1 even if the heading dokuwiki is not enable */ if (!PluginUtility::getConfValue(syntax_plugin_combo_headingwiki::CONF_WIKI_HEADING_ENABLE)) { /** * $ACT == 'show' * Otherwise we may capture the title of the admin page ... */ global $ACT; if ($ACT == 'show') { syntax_plugin_combo_heading::processHeadingMetadataH1($level, $text); } } // 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 syntax_plugin_combo_heading::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; $adsCounter = 0; foreach ($this->sections as $sectionNumber => $section) { $sectionContent = $section['content']; if ($section['level'] == 1 and $section['position'] == 1) { // Add the hierarchical breadcrumb detail after the first header global $conf; // Deprecated // As the main slot is read before the main header and footer // there is no way to known at the end if it was used // // // if ($conf['youarehere']) { // $sectionContent .= syntax_plugin_combo_breadcrumb::toBreadCrumbHtml(); // } if (TocUtility::showToc($this)) { $sectionContent .= TocUtility::renderToc($this); } } # 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 && $isSidebar == FALSE) { $this->doc .= "

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

"; } $this->doc .= $sectionContent; // No ads on private page $isLastSection = $sectionNumber === count($this->sections) - 1; if (AdsUtility::showAds( $sectionLineCount, $currentLineCountSinceLastAd, $sectionNumber, $adsCounter, $isLastSection )) { // Counter $adsCounter += 1; $currentLineCountSinceLastAd = 0; $attributes = array("name" => AdsUtility::PREFIX_IN_ARTICLE_ADS . $adsCounter); $this->doc .= AdsUtility::render($attributes); } } parent::document_end(); } /** * Start a table * * @param int $maxcols maximum number of columns * @param int $numrows NOT IMPLEMENTED * @param int $pos byte position in the original source * @param string|string[] classes - have to be valid, do not pass unfiltered user input */ function table_open($maxcols = null, $numrows = null, $pos = null, $classes = NULL) { // initialize the row counter used for classes $this->_counter['row_counter'] = 0; TableUtility::tableOpen($this, $pos); } }