PDF Footnotes number renderer

@param ReportTcpdf $renderer

@return void
426423
public function render($renderer)
    {
        $renderer->setCurrentStyle('footnotenum');
        $renderer->Write($renderer->getCurrentStyleHeight(), $this->numText, $this->addlink); //source link numbers after name
    }
498756
public function register(Renderer $renderer) {
        $this->registerTokenRenderer(StrikethroughRule::NAME . StrikethroughRule::OPEN, 'renderOpen', $renderer);
        $this->registerTokenRenderer(StrikethroughRule::NAME . StrikethroughRule::CLOSE, 'renderClose', $renderer);

    }
1044340
public function setRenderer($renderer)
	{
		if (is_string($renderer))
		{
			$cName = $this->scrub($renderer);

			$invokable = __NAMESPACE__ . '\\Dumper\\' . ucfirst($cName);

			if (!class_exists($invokable))
			{
				throw new RendererNotFoundException(sprintf(
					'%s: failed retrieving renderer via invokable class "%s"; class does not exist',
					__CLASS__ . '::' . __FUNCTION__,
					$invokable
				));
			}
			$renderer = new $invokable;
		}

		if (!($renderer instanceof Renderable))
		{
			throw new InvalidArgumentException(sprintf(
				'%s was unable to fetch renderer or renderer was not an instance of %s',
				get_class($this) . '::' . __FUNCTION__,
				__NAMESPACE__ . '\\Dumper\\Renderable'
			));
		}

		$this->_renderer = $renderer;

		return $this;
	}
1068028
public function checkFooter(TcTable $table, $row, $rowIndex) {
        $pdf = $table->getPdf();
        if ($rowIndex == $this->count - 1 && $pdf->GetY() + $this->height >= $this->pageBreakTrigger) {
            if ($table->trigger(TcTable::EV_PAGE_ADD, [$this->rows, $rowIndex, true]) !== false) {
                $pdf->AddPage();
                $table->trigger(TcTable::EV_PAGE_ADDED, [$this->rows, $rowIndex, true]);
            }
        }
    }
430000
public function render($renderer)
    {
        $newelements      = [];
        $lastelement      = '';
        $footnote_element = [];
        // Element counter
        $cE = count($this->elements);
        //-- collapse duplicate elements
        for ($i = 0; $i < $cE; $i++) {
            $element = $this->elements[$i];
            if ($element instanceof ReportBaseElement) {
                if ($element instanceof ReportBaseText) {
                    if (!empty($footnote_element)) {
                        ksort($footnote_element);
                        foreach ($footnote_element as $links) {
                            $newelements[] = $links;
                        }
                        $footnote_element = [];
                    }
                    if (empty($lastelement)) {
                        $lastelement = $element;
                    } else {
                        // Checking if the Text has the same style
                        if ($element->getStyleName() == $lastelement->getStyleName()) {
                            $lastelement->addText(str_replace("\n", '<br>', $element->getValue()));
                        } elseif (!empty($lastelement)) {
                            $newelements[] = $lastelement;
                            $lastelement   = $element;
                        }
                    }
                } elseif ($element instanceof ReportPdfFootnote) {
                    // Check if the Footnote has been set with it’s link number
                    $renderer->checkFootnote($element);
                    // Save first the last element if any
                    if (!empty($lastelement)) {
                        $newelements[] = $lastelement;
                        $lastelement   = [];
                    }
                    // Save the Footnote with it’s link number as key for sorting later
                    $footnote_element[$element->num] = $element;
                } elseif (!($element instanceof ReportPdfFootnote) || trim($element->getValue()) != '') {
                    // Do not keep empty footnotes
                    if (!empty($footnote_element)) {
                        ksort($footnote_element);
                        foreach ($footnote_element as $links) {
                            $newelements[] = $links;
                        }
                        $footnote_element = [];
                    }
                    if (!empty($lastelement)) {
                        $newelements[] = $lastelement;
                        $lastelement   = [];
                    }
                    $newelements[] = $element;
                }
            } else {
                if (!empty($lastelement)) {
                    $newelements[] = $lastelement;
                    $lastelement   = [];
                }
                if (!empty($footnote_element)) {
                    ksort($footnote_element);
                    foreach ($footnote_element as $links) {
                        $newelements[] = $links;
                    }
                    $footnote_element = [];
                }
                $newelements[] = $element;
            }
        }
        if (!empty($lastelement)) {
            $newelements[] = $lastelement;
        }
        if (!empty($footnote_element)) {
            ksort($footnote_element);
            foreach ($footnote_element as $links) {
                $newelements[] = $links;
            }
        }
        $this->elements = $newelements;
        unset($footnote_element, $lastelement, $links, $newelements);

        // Used with line breaks and cell height calculation within this box
        $renderer->largestFontHeight = 0;

        // If current position (left)
        if ($this->left === ReportBaseElement::CURRENT_POSITION) {
            $cX = $renderer->GetX();
        } else {
            // For static position add margin (returns and updates X)
            $cX = $renderer->addMarginX($this->left);
        }

        // If current position (top)
        if ($this->top === ReportBaseElement::CURRENT_POSITION) {
            $cY = $renderer->GetY();
        } else {
            $cY = $this->top;
            $renderer->SetY($cY);
        }

        // Check the width if set to page wide OR set by xml to larger then page width (margin)
        if ($this->width == 0 || $this->width > $renderer->getRemainingWidthPDF()) {
            $cW = $renderer->getRemainingWidthPDF();
        } else {
            $cW = $this->width;
        }

        // Save the original margins
        $cM = $renderer->getMargins();
        // Use cell padding to wrap the width
        // Temp Width with cell padding
        if (is_array($cM['cell'])) {
            $cWT = $cW - ($cM['padding_left'] + $cM['padding_right']);
        } else {
            $cWT = $cW - ($cM['cell'] * 2);
        }
        // Element height (exept text)
        $eH = 0;
        $w  = 0;
        // Temp Height
        $cHT = 0;
        //-- $lw is an array
        // 0 => last line width
        // 1 => 1 if text was wrapped, 0 if text did not wrap
        // 2 => number of LF
        $lw = [];
        // Element counter
        $cE = count($this->elements);
        //-- calculate the text box height + width
        for ($i = 0; $i < $cE; $i++) {
            if (is_object($this->elements[$i])) {
                $ew = $this->elements[$i]->setWrapWidth($cWT - $w, $cWT);
                if ($ew == $cWT) {
                    $w = 0;
                }
                $lw = $this->elements[$i]->getWidth($renderer);
                // Text is already gets the # LF
                $cHT += $lw[2];
                if ($lw[1] == 1) {
                    $w = $lw[0];
                } elseif ($lw[1] == 2) {
                    $w = 0;
                } else {
                    $w += $lw[0];
                }
                if ($w > $cWT) {
                    $w = $lw[0];
                }
                // Footnote is at the bottom of the page. No need to calculate it’s height or wrap the text!
                // We are changing the margins anyway!
                // For anything else but text (images), get the height
                $eH += $this->elements[$i]->getHeight($renderer);
            }
        }

        // Add up what’s the final height
        $cH = $this->height;
        // If any element exist
        if ($cE > 0) {
            // Check if this is text or some other element, like images
            if ($eH == 0) {
                // This is text elements. Number of LF but at least one line
                $cHT = ($cHT + 1) * $renderer->getCellHeightRatio();
                // Calculate the cell hight with the largest font size used within this Box
                $cHT *= $renderer->largestFontHeight;
                // Add cell padding
                if ($this->padding) {
                    if (is_array($cM['cell'])) {
                        $cHT += ($cM['padding_bottom'] + $cM['padding_top']);
                    } else {
                        $cHT += ($cM['cell'] * 2);
                    }
                }
                if ($cH < $cHT) {
                    $cH = $cHT;
                }
            } elseif ($cH < $eH) {
                // This is any other element
                $cH = $eH;
            }
        }
        // Finaly, check the last cells height
        if ($cH < $renderer->lastCellHeight) {
            $cH = $renderer->lastCellHeight;
        }
        // Add a new page if needed
        if ($this->pagecheck) {
            // Reset last cell height or Header/Footer will inherit it, in case of pagebreak
            $renderer->lastCellHeight = 0;
            if ($renderer->checkPageBreakPDF($cH)) {
                $cY = $renderer->GetY();
            }
        }

        // Setup the border and background color
        $cS = ''; // Class Style
        if ($this->border) {
            $cS = 'D';
        } // D or empty string: Draw (default)
        $match = [];
        // Fill the background
        if ($this->fill) {
            if (!empty($this->bgcolor)) {
                if (preg_match('/#?(..)(..)(..)/', $this->bgcolor, $match)) {
                    $cS .= 'F'; // F: Fill the background
                    $r  = hexdec($match[1]);
                    $g  = hexdec($match[2]);
                    $b  = hexdec($match[3]);
                    $renderer->SetFillColor($r, $g, $b);
                }
            }
        }
        // Clean up a bit
        unset($lw, $w, $match, $cE, $eH);
        // Draw the border
        if (!empty($cS)) {
            if (!$renderer->getRTL()) {
                $cXM = $cX;
            } else {
                $cXM = $renderer->getPageWidth() - $cX - $cW;
            }
            $renderer->Rect($cXM, $cY, $cW, $cH, $cS);
        }
        // Add cell padding if set and if any text (element) exist
        if ($this->padding) {
            if ($cHT > 0) {
                if (is_array($cM['cell'])) {
                    $renderer->SetY($cY + $cM['padding_top']);
                } else {
                    $renderer->SetY($cY + $cM['cell']);
                }
            }
        }
        // Change the margins X, Width
        if (!$renderer->getRTL()) {
            if ($this->padding) {
                if (is_array($cM['cell'])) {
                    $renderer->SetLeftMargin($cX + $cM['padding_left']);
                } else {
                    $renderer->SetLeftMargin($cX + $cM['cell']);
                }
                $renderer->SetRightMargin($renderer->getRemainingWidthPDF() - $cW + $cM['right']);
            } else {
                $renderer->SetLeftMargin($cX);
                $renderer->SetRightMargin($renderer->getRemainingWidthPDF() - $cW + $cM['right']);
            }
        } else {
            if ($this->padding) {
                if (is_array($cM['cell'])) {
                    $renderer->SetRightMargin($cX + $cM['padding_right']);
                } else {
                    $renderer->SetRightMargin($cX + $cM['cell']);
                }
                $renderer->SetLeftMargin($renderer->getRemainingWidthPDF() - $cW + $cM['left']);
            } else {
                $renderer->SetRightMargin($cX);
                $renderer->SetLeftMargin($renderer->getRemainingWidthPDF() - $cW + $cM['left']);
            }
        }
        // Save the current page number
        $cPN = $renderer->getPage();

        // Render the elements (write text, print picture...)
        foreach ($this->elements as $element) {
            if ($element instanceof ReportBaseElement) {
                $element->render($renderer);
            } elseif ($element === 'footnotetexts') {
                $renderer->footnotes();
            } elseif ($element === 'addpage') {
                $renderer->newPage();
            }
        }
        // Restore the margins
        $renderer->SetLeftMargin($cM['left']);
        $renderer->SetRightMargin($cM['right']);

        // This will be mostly used to trick the multiple images last height
        if ($this->reseth) {
            $cH = 0;
            // This can only happen with multiple images and with pagebreak
            if ($cPN != $renderer->getPage()) {
                $renderer->setPage($cPN);
            }
        }
        // New line and some clean up
        if (!$this->newline) {
            $renderer->SetXY($cX + $cW, $cY);
            $renderer->lastCellHeight = $cH;
        } else {
            // addMarginX() also updates X
            $renderer->addMarginX(0);
            $renderer->SetY($cY + $cH);
            $renderer->lastCellHeight = 0;
        }
    }
988276
function setRenderer($renderer)
    {
        if (!$renderer instanceof iViewRenderer && !is_callable($renderer))
            throw new \InvalidArgumentException(sprintf(
                'Renderer must extend of (iViewRenderer) or callable. given: (%s)'
                , \Poirot\Std\flatten($renderer)
            ));

        $this->renderer = $renderer;
        return $this;
    }
934704
public function Base_Render_Before($Sender) {
      // Add "Mark All Viewed" to main menu
      if ($Sender->Menu && Gdn::Session()->IsValid()) {
         if (C('Plugins.AllViewed.ShowInMenu', TRUE))
            $Sender->Menu->AddLink('AllViewed', T('Mark All Viewed'), '/discussions/markallviewed');
      }
   }
425836
public function addRenderer(SwatCellRenderer $renderer)
    {
        $this->renderers->addRenderer($renderer);
        $renderer->parent = $this;
    }
902261
public function init(Parser $parser, Renderer $renderer) {
        foreach ($this->ruleRenderers as $ruleRenderer) {
            $renderer->registerRenderer($ruleRenderer, $this->name);
        }

        $parser->setRenderer($renderer);

        return $this;
    }
203483
protected void renderFooter(PdfWriter writer, Document document) throws DocumentException, VectorPrintException, InstantiationException, IllegalAccessException {
      if (!debugHereAfter && !failuresHereAfter) {
         PdfPTable footerTable = elementProducer.createElement(null, PdfPTable.class, getStylers(PAGEFOOTERTABLEKEY));
         
         footerTable.addCell(createFooterCell(ValueHelper.createDate(new Date())));
         
         String pageText = writer.getPageNumber() + getSettings().getProperty(" of ", UPTO);
         
         PdfPCell c = createFooterCell(pageText);
         c.setHorizontalAlignment(Element.ALIGN_RIGHT);
         footerTable.addCell(c);
         
         footerTable.addCell(createFooterCell(new Chunk()));
         footerTable.writeSelectedRows(0, -1, document.getPageSize().getLeft() + document.leftMargin(),
             document.getPageSize().getBottom(document.bottomMargin()), writer.getDirectContentUnder());
         footerBottom = document.bottom() - footerTable.getTotalHeight();
      }
   }
1287572
private function printAndForgetOutlineFooterOnAfterEvent(Formatter $formatter, Event $event)
    {
        if (!$event instanceof AfterOutlineTested) {
            return;
        }

        $this->outlinePrinter->printFooter($formatter, $event->getTestResult());
    }
909477
public function setRenderer($renderer)
    {
        if(!$renderer instanceof ComActivitiesActivityRendererInterface)
        {
            if(is_string($renderer) && strpos($renderer, '.') === false )
            {
                $identifier         = $this->getIdentifier()->toArray();
                $identifier['path'] = array('template', 'helper');
                $identifier['name'] = $renderer;

                $identifier = $this->getIdentifier($identifier);
            }
            else $identifier = $this->getIdentifier($renderer);

            $renderer = $identifier;
        }

        $this->_renderer = $renderer;

        return $this;
    }
552498
public function render(ResultsRenderer $renderer)
    {
        $results = array_filter($this->result->getResults(), function (ResultInterface $result) {
            return $result instanceof FailureInterface;
        });

        $output = '';
        if (count($results)) {
            $output .= $renderer->center("Some executions of your solution produced incorrect output!\n");
        }

        /** @var FailureInterface $request **/
        foreach ($results as $key => $request) {
            $output .= $renderer->lineBreak();
            $output .= "\n";
            $output .= $renderer->style(sprintf('Execution %d', $key + 1), ['bold', 'underline', 'blue']);
            $output .= ' ' . $renderer->style(' FAILED ', ['bg_red', 'bold']) . "\n\n";

            $output .= $request->getArgs()->isEmpty()
                ? "Arguments: None\n"
                : sprintf("Arguments: \"%s\"\n", $request->getArgs()->implode('", "'));

            $output .= "\n" . $renderer->renderResult($request) . "\n";
        }

        return $output;
    }
319393
public function render($renderer, $curx = 0, $attrib = true)
    {
        // Set up the style
        if ($renderer->getCurrentStyle() != $this->styleName) {
            $renderer->setCurrentStyle($this->styleName);
        }
        $temptext = str_replace('#PAGENUM#', (string) $renderer->pageNo(), $this->text);
        // underline «title» part of Source item
        $temptext = str_replace([
            '«',
            '»',
        ], [
            '<u>',
            '</u>',
        ], $temptext);

        // If any text at all
        if (!empty($temptext)) {
            // If called by an other element
            if (!$attrib) {
                $renderer->write($temptext, $this->color);
            } else {
                // Save the start positions
                $startX = $renderer->getX();
                $startY = $renderer->getY();
                $width  = $renderer->getRemainingWidth();
                // If text is wider then page width then wrap it
                if ($renderer->getStringWidth($temptext) > $width) {
                    $lines = explode("\n", $temptext);
                    foreach ($lines as $line) {
                        echo '<div style="position:absolute;top:', $startY, 'pt;', $renderer->alignRTL, ':', $startX, 'pt;width:', $width, 'pt;">';
                        $line = $renderer->textWrap($line, $width);
                        $startY += $renderer->getTextCellHeight($line);
                        $renderer->setY($startY);
                        $renderer->write($line, $this->color);
                        echo "</div>\n";
                    }
                } else {
                    echo '<div style="position:absolute;top:', $startY, 'pt;', $renderer->alignRTL, ':', $startX, 'pt;width:', $width, 'pt;">';
                    $renderer->write($temptext, $this->color);
                    echo "</div>\n";
                    $renderer->setX($startX + $renderer->getStringWidth($temptext));
                    if ($renderer->countLines($temptext) != 1) {
                        $renderer->setXy(0, $startY + $renderer->getTextCellHeight($temptext));
                    }
                }
            }
        }
    }
1329172
public function getWidth($renderer)
    {
        // Setup the style name, a font must be selected to calculate the width
        if ($renderer->getCurrentStyle() != $this->styleName) {
            $renderer->setCurrentStyle($this->styleName);
        }

        // Check for the largest font size in the box
        $fsize = $renderer->getCurrentStyleHeight();
        if ($fsize > $renderer->largestFontHeight) {
            $renderer->largestFontHeight = $fsize;
        }

        // Get the line width for the text in points
        $lw = $renderer->getStringWidth($this->text);
        // Line Feed counter - Number of lines in the text
        $lfct = $renderer->countLines($this->text);
        // If there is still remaining wrap width...
        $wrapWidthRemaining = $this->wrapWidthRemaining;
        if ($wrapWidthRemaining > 0) {
            // Check with line counter too!
            if ($lw >= $wrapWidthRemaining || $lfct > 1) {
                $newtext            = '';
                $lines              = explode("\n", $this->text);
                // Go throught the text line by line
                foreach ($lines as $line) {
                    // Line width in points + a little margin
                    $lw = $renderer->getStringWidth($line);
                    // If the line has to be wraped
                    if ($lw > $wrapWidthRemaining) {
                        $words    = explode(' ', $line);
                        $addspace = count($words);
                        $lw       = 0;
                        foreach ($words as $word) {
                            $addspace--;
                            $lw += $renderer->getStringWidth($word . ' ');
                            if ($lw <= $wrapWidthRemaining) {
                                $newtext .= $word;
                                if ($addspace != 0) {
                                    $newtext .= ' ';
                                }
                            } else {
                                $lw = $renderer->getStringWidth($word . ' ');
                                $newtext .= "\n$word";
                                if ($addspace != 0) {
                                    $newtext .= ' ';
                                }
                                // Reset the wrap width to the cell width
                                $wrapWidthRemaining = $this->wrapWidthCell;
                            }
                        }
                    } else {
                        $newtext .= $line;
                    }
                    // Check the Line Feed counter
                    if ($lfct > 1) {
                        // Add a new line as long as it’s not the last line
                        $newtext .= "\n";
                        // Reset the line width
                        $lw = 0;
                        // Reset the wrap width to the cell width
                        $wrapWidthRemaining = $this->wrapWidthCell;
                    }
                    $lfct--;
                }
                $this->text = $newtext;
                $lfct       = substr_count($this->text, "\n");

                return [
                    $lw,
                    1,
                    $lfct,
                ];
            }
        }
        $l    = 0;
        $lfct = substr_count($this->text, "\n");
        if ($lfct > 0) {
            $l = 2;
        }

        return [
            $lw,
            $l,
            $lfct,
        ];
    }
1212203
public function footnotes()
    {
        $this->currentStyle = '';
        if (!empty($this->printedfootnotes)) {
            foreach ($this->printedfootnotes as $element) {
                $element->renderFootnote($this);
            }
        }
    }
989871
public function register(Renderer $renderer) {
        $this->registerTokenRenderer(CodeRule::NAME . CodeRule::OPEN, 'renderOpen', $renderer);
        $this->registerTokenRenderer(CodeRule::NAME . CodeRule::CLOSE, 'renderClose', $renderer);
        $this->registerTokenRenderer(CodeRule::NAME, 'renderContent', $renderer);

        $this->registerTokenRenderer(CodeAltRule::NAME . CodeAltRule::OPEN, 'renderOpen', $renderer);
        $this->registerTokenRenderer(CodeAltRule::NAME . CodeAltRule::CLOSE, 'renderClose', $renderer);
        $this->registerTokenRenderer(CodeAltRule::NAME, 'renderContent', $renderer);
    }