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) { /** * Capture the h1 */ if ($level == 1) { /** * $ACT == 'show' * Otherwise we get the title of the admin page ... */ global $ACT; if ($ACT == 'show') { global $ID; p_set_metadata($ID, array("h1" => $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; $numbering = ""; if ($level == 2) { $numbering = $nodePosition; } if ($level == 3) { $numbering = $this->nodeParentPosition[$level - 1] . "." . $nodePosition; } if ($level == 4) { $numbering = $this->nodeParentPosition[$level - 2] . "." . $this->nodeParentPosition[$level - 1] . "." . $nodePosition; } if ($level == 5) { $numbering = $this->nodeParentPosition[$level - 3] . "." . $this->nodeParentPosition[$level - 2] . "." . $this->nodeParentPosition[$level - 1] . "." . $nodePosition; } if ($numbering <> "") { $textWithLocalization = $numbering . " - " . $text; } else { $textWithLocalization = $text; } // Rendering is done by the parent parent::header($textWithLocalization, $level, $pos); // Add the page detail after the first header if ($level == 1 and $nodePosition == 1) { $this->doc .= BreadcrumbHierarchical::render(); } } 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) { if (TocUtility::showToc($this)) { $sectionContent .= TocUtility::renderToc($this); } } # Split by element line # element p, h, br, tr, li, pre (one line for pre) $sectionLineCount = HtmlUtility::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); } /** * https://getbootstrap.com/docs/4.4/content/typography/#inline-text-elements */ public function monospace_open() { $this->doc .= ''; } public function monospace_close() { $this->doc .= ''; } }