Extract managed extensions from rendererAdapter and store it.

@param RendererAdapterInterface $rendererAdapter
480308
private function addManagedExtensions(RendererAdapterInterface $rendererAdapter)
    {
        $key = $this->getRendererAdapterKey($rendererAdapter);
        foreach ($rendererAdapter->getManagedFileExtensions() as $ext) {
            $rendererAdapters = array($key);
            if ($this->manageableExt->has($ext)) {
                $rendererAdapters = $this->manageableExt->get($ext);
                $rendererAdapters[] = $key;
            }

            $this->manageableExt->set($ext, $rendererAdapters);
        }
    }
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;
    }
4626
public function register(Renderer $renderer) {
        $this->registerTokenRenderer(LinkInlineRule::NAME, 'renderInline', $renderer);
        $this->registerTokenRenderer(LinkReferenceRule::NAME, 'renderReference', $renderer);
        $this->registerTokenRenderer(LinkAutoRule::NAME, 'renderAuto', $renderer);
    }
273187
public function render($renderer)
    {
        // checkFootnote
        $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 ReportBaseFootnote) {
                    // 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 ReportBaseFootnote) || 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, $newelements);

        $cP = 0; // Class Padding

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

        // If current position (left)
        if ($this->left === ReportBaseElement::CURRENT_POSITION) {
            $cX = $renderer->getX();
        } else {
            $cX = $this->left;
            $renderer->setX($cX);
        }
        // If current position (top)
        if ($this->top === ReportBaseElement::CURRENT_POSITION) {
            $this->top = $renderer->getY();
        } else {
            $renderer->setY($this->top);
        }

        // 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->getRemainingWidth()) {
            $this->width = $renderer->getRemainingWidth();
        }
        // Setup the CellPadding
        if ($this->padding) {
            $cP = $renderer->cPadding;
        }

        // For padding, we have to use less wrap width
        $cW = $this->width - ($cP * 2);

        //-- calculate the text box height
        // Number of lines, will be converted to height
        $cHT = 0;
        // Element height (exept text)
        $eH = 0;
        // Footnote height (in points)
        $fH = 0;
        $w  = 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);
        for ($i = 0; $i < $cE; $i++) {
            if (is_object($this->elements[$i])) {
                $ew = $this->elements[$i]->setWrapWidth($cW - $w - 2, $cW);
                if ($ew == $cW) {
                    $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 > $cW) {
                    $w = $lw[0];
                }
                // For anything else but text (images), get the height
                $eH += $this->elements[$i]->getHeight($renderer);
            } else {
                $fH += abs($renderer->getFootnotesHeight($cW));
            }
        }

        // 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) {
                // Number of LF but at least one line
                $cHT = ($cHT + 1) * $renderer->cellHeightRatio;
                // Calculate the cell hight with the largest font size used
                $cHT *= $renderer->largestFontHeight;
                if ($cH < $cHT) {
                    $cH = $cHT;
                }
            } else {
                // This is any other element
                if ($cH < $eH) {
                    $cH = $eH;
                }
                // Add Footnote height to the rest of the height
                $cH += $fH;
            }
        }

        unset($lw, $cHT, $fH, $w);

        // Finaly, check the last cells height
        if ($cH < $renderer->lastCellHeight) {
            $cH = $renderer->lastCellHeight;
        }
        // Update max Y incase of a pagebreak
        // We don't want to over write any images or other stuff
        $renderer->addMaxY($this->top + $cH);

        // Start to print HTML
        echo '<div style="position:absolute;top:', $this->top, 'pt;';
        // LTR (left) or RTL (right)
        echo $renderer->alignRTL, ':', $cX, 'pt;';
        // Background color
        if ($this->fill) {
            if (!empty($this->bgcolor)) {
                echo ' background-color:', $this->bgcolor, ';';
            }
        }
        // Print padding only when it’s set
        if ($this->padding) {
            // Use Cell around padding to support RTL also
            echo 'padding:', $cP, 'pt;';
        }
        // Border setup
        if ($this->border) {
            echo ' border:solid black 1pt;';
            echo 'width:', ($this->width - 1 - ($cP * 2)), 'pt;height:', $cH - 1, 'pt;';
        } else {
            echo 'width:', ($this->width - ($cP * 2)), 'pt;height:', $cH, 'pt;';
        }
        echo '">';

        // Do a little "margin" trick before print
        // to get the correct current position => "."
        $cXT = $renderer->getX();
        $cYT = $renderer->getY();
        $renderer->setXy(0, 0);

        // Print the text elements
        foreach ($this->elements as $element) {
            if ($element instanceof ReportBaseElement) {
                $element->render($renderer, $cX, false);
            } elseif ($element === 'footnotetexts') {
                $renderer->footnotes();
            } elseif ($element === 'addpage') {
                $renderer->addPage();
            }
        }
        echo "</div>\n";

        // Reset "margins"
        $renderer->setXy($cXT, $cYT);
        // This will be mostly used to trick the multiple images last height
        if ($this->reseth) {
            $cH = 0;
        }
        // New line and some clean up
        if (!$this->newline) {
            $renderer->setXy($cX + $this->width, $this->top);
            $renderer->lastCellHeight = $cH;
        } else {
            $renderer->setXy(0, $this->top + $cH + ($cP * 2));
            $renderer->lastCellHeight = 0;
        }
    }
482482
public <I extends Renderable, O> Renderer<? super I, ? extends O> getRenderer(final I renderable,
            final Class<? extends RenderingFormat<? extends O>> renderingFormat) {

        RendererSelection bestMatch = null;

        final Collection<RendererBeanDescriptor<?>> descriptors =
                _descriptorProvider.getRendererBeanDescriptorsForRenderingFormat(renderingFormat);
        for (final RendererBeanDescriptor<?> descriptor : descriptors) {
            final RendererSelection rendererMatch = isRendererMatch(descriptor, renderable, bestMatch);
            if (rendererMatch != null) {
                bestMatch = rendererMatch;
            }
        }

        if (bestMatch == null) {
            logger.warn("Didn't find any matches for renderable {} (format={})", renderable, renderingFormat);
            return null;
        }

        @SuppressWarnings("unchecked") final Renderer<? super I, ? extends O> renderer =
                (Renderer<? super I, ? extends O>) bestMatch.getRenderer();

        if (logger.isInfoEnabled()) {
            logger.info("Returning renderer '{}' for renderable '{}' in format '{}'",
                    new Object[] { renderer, renderable.getClass().getName(), renderingFormat.getName() });
        }

        return renderer;
    }
1064403
public function createCustomGenerator(DataProviderParserInterface $dataProviderParser): DataProviderGeneratorInterface
    {
        return new DataProviderGenerator(
            $dataProviderParser,
            $this->createFileWriter(),
            $this->getConfig()->getDataProviderNamespace(),
            $this->getConfig()->getDataProviderExtends()
        );
    }
299163
public function render($renderer)
    {
        if (strpos($this->text, '{{:ptp:}}') !== false) {
            return;
        }
        $temptext = str_replace('#PAGENUM#', (string) $renderer->pageNo(), $this->text);
        // underline «title» part of Source item
        $temptext = str_replace([
            '«',
            '»',
        ], [
            '<u>',
            '</u>',
        ], $temptext);

        // Set up the text style
        if ($renderer->getCurrentStyle() !== $this->styleName) {
            $renderer->setCurrentStyle($this->styleName);
        }

        // If (Future-feature-enable/disable cell padding)
        $cP = $renderer->cPadding;

        // Adjust the positions
        if ($this->left === ReportBaseElement::CURRENT_POSITION) {
            $this->left = $renderer->getX();
        } else {
            $renderer->setX($this->left);
        }

        if ($this->top === ReportBaseElement::CURRENT_POSITION) {
            $this->top = $renderer->getY();
        } else {
            $renderer->setY($this->top);
        }

        // Start collecting the HTML code
        echo '<div class="', $this->styleName, '" style="position:absolute;top:', $this->top, 'pt;';
        // Use Cell around padding to support RTL also
        echo 'padding:', $cP, 'pt;';
        // LTR (left) or RTL (right)
        echo $renderer->alignRTL, ':', $this->left, 'pt;';

        // Background color
        if (!empty($this->bgcolor)) {
            echo 'background-color:', $this->bgcolor, ';';
        }

        // Borders
        $bpixX = 0;
        $bpixY = 0;
        if (!empty($this->border)) {
            // Border all around
            if ($this->border == 1) {
                echo ' border:solid ';
                if (!empty($this->bocolor)) {
                    echo $this->bocolor;
                } else {
                    echo 'black';
                }
                echo ' 1pt;';
                $bpixX = 1;
                $bpixY = 1;
            } else {
                if (stripos($this->border, 'T') !== false) {
                    echo ' border-top:solid ';
                    if (!empty($this->bocolor)) {
                        echo $this->bocolor;
                    } else {
                        echo 'black';
                    }
                    echo ' 1pt;';
                    $bpixY = 1;
                }
                if (stripos($this->border, 'B') !== false) {
                    echo ' border-bottom:solid ';
                    if (!empty($this->bocolor)) {
                        echo $this->bocolor;
                    } else {
                        echo 'black';
                    }
                    echo ' 1pt;';
                    $bpixY = 1;
                }
                if (stripos($this->border, 'R') !== false) {
                    echo ' border-right:solid ';
                    if (!empty($this->bocolor)) {
                        echo $this->bocolor;
                    } else {
                        echo 'black';
                    }
                    echo ' 1pt;';
                    $bpixX = 1;
                }
                if (stripos($this->border, 'L') !== false) {
                    echo ' border-left:solid ';
                    if (!empty($this->bocolor)) {
                        echo $this->bocolor;
                    } else {
                        echo 'black';
                    }
                    echo ' 1pt;';
                    $bpixX = 1;
                }
            }
        }
        // Check the width if set to page wide OR set by xml to larger then page wide
        if ($this->width == 0 || $this->width > $renderer->getRemainingWidth()) {
            $this->width = $renderer->getRemainingWidth();
        }
        // We have to calculate a different width for the padding, counting on both side
        $cW = $this->width - ($cP * 2);

        // If there is any text
        if (!empty($temptext)) {
            // Wrap the text
            $temptext = $renderer->textWrap($temptext, $cW);
            $tmph     = $renderer->getTextCellHeight($temptext);
            // Add some cell padding
            $this->height += $cP;
            if ($tmph > $this->height) {
                $this->height = $tmph;
            }
        }
        // Check the last cell height and adjust the current cell height if needed
        if ($renderer->lastCellHeight > $this->height) {
            $this->height = $renderer->lastCellHeight;
        }
        echo ' width:', $cW - $bpixX, 'pt;height:', $this->height - $bpixY, 'pt;';

        // Text alignment
        switch ($this->align) {
            case 'C':
                echo ' text-align:center;';
                break;
            case 'L':
                echo ' text-align:left;';
                break;
            case 'R':
                echo ' text-align:right;';
                break;
        }

        // Print the collected HTML code
        echo '">';

        // Print URL
        if (!empty($this->url)) {
            echo '<a href="', $this->url, '">';
        }
        // Print any text if exists
        if (!empty($temptext)) {
            $renderer->write($temptext, $this->tcolor, false);
        }
        if (!empty($this->url)) {
            echo '</a>';
        }
        // Finish the cell printing and start to clean up
        echo "</div>\n";

        // Where to place the next position
        if ($this->newline == 0) {
            // -> Next to this cell in the same line
            $renderer->setXy($this->left + $this->width, $this->top);
            $renderer->lastCellHeight = $this->height;
        } elseif ($this->newline == 1) {
            // -> On a new line at the margin - Default
            $renderer->setXy(0, $renderer->getY() + $this->height + ($cP * 2));
            // Reset the last cell height for the next line
            $renderer->lastCellHeight = 0;
        } elseif ($this->newline == 2) {
            // -> On a new line at the end of this cell
            $renderer->setXy($renderer->getX() + $this->width, $renderer->getY() + $this->height + ($cP * 2));
            // Reset the last cell height for the next line
            $renderer->lastCellHeight = 0;
        }
    }
568587
public function render($renderer)
    {
        $renderer->setCurrentStyle('footnotenum');
        echo '<a href="#footnote', $this->num, '"><sup>';
        $renderer->write($renderer->entityRTL . $this->num);
        echo "</sup></a>\n";
    }
1283483
public static function setRenderer($renderer) {
        if(ClassInfo::classImplements($renderer, 'IMarkdownRenderer')) {
            self::$renderer=$renderer;
        }else {
            user_error('The renderer '.$renderer.' does not implement IMarkdownRenderer', E_USER_ERROR);
        }
    }
534801
public function setRenderingContext(RenderingContextInterface $renderingContext)
    {
        $this->baseRenderingContext = $renderingContext;
        $this->baseRenderingContext->getViewHelperVariableContainer()->setView($this);
        $this->controllerContext = $renderingContext->getControllerContext();
    }
1119789
protected static function createRenderer( $renderer, ezpContent $content, ezpRestMvcController $controller )
    {
        $rendererOptions = new ezpExtensionOptions();
        $rendererOptions->iniFile = 'rest.ini';
        $rendererOptions->iniSection = 'OutputSettings';
        $rendererOptions->iniVariable = 'RendererClass';
        $rendererOptions->handlerIndex = $renderer;
        $rendererOptions->handlerParams = array( $content, $controller );

        $rendererInstance = eZExtension::getHandlerClass( $rendererOptions );

        if ( !( $rendererInstance instanceof ezpRestContentRendererInterface ) )
            throw new ezpRestContentRendererNotFoundException( $renderer );

        return $rendererInstance;
    }
870808
public function render(AbstractRenderer $renderer = null, $active = null)
    {
        if (is_null($renderer)) {
            $renderer = $this->getRenderer();
        }

        return $renderer->render($this->getRelations(), $active);
    }
1045957
private function autoloadAdapters()
    {
        $rendererConfig = $this->getApplication()->getConfig()->getRendererConfig();
        $adapters = (array) $rendererConfig['adapter'];
        foreach ($adapters as $adapter) {
            $classname = $adapter;
            $adapterConfig = [];
            if (is_array($adapter)) {
                $classname = isset($adapter['class']) ? $adapter['class'] : null;
                $adapterConfig = isset($adapter['config']) && is_array($adapter['config']) ? $adapter['config'] : [];
            }

            $this->addRendererAdapter(new $classname($this, $adapterConfig));
        }

        return $this;
    }
451998
public function input($name, RendererInterface $renderer = null)
    {
        $renderer = $renderer ?: $this->getDefaultRenderer();

        return $this->getRow($name)->input($renderer);
    }
311186
public function render($renderer)
    {
        static $lastpicbottom, $lastpicpage, $lastpicleft, $lastpicright;

        // Get the current positions
        if ($this->x === ReportBaseElement::CURRENT_POSITION) {
            $this->x = $renderer->getX();
        }
        if ($this->y === ReportBaseElement::CURRENT_POSITION) {
            //-- first check for a collision with the last picture
            if (isset($lastpicbottom)) {
                if (($renderer->pageNo() == $lastpicpage) && ($lastpicbottom >= $renderer->getY()) && ($this->x >= $lastpicleft) && ($this->x <= $lastpicright)) {
                    $renderer->setY($lastpicbottom + ($renderer->cPadding * 2));
                }
            }
            $this->y = $renderer->getY();
        }

        // Image alignment
        switch ($this->align) {
            case 'L':
                echo '<div style="position:absolute;top:', $this->y, 'pt;left:0pt;width:', $renderer->getRemainingWidth(), "pt;text-align:left;\">\n";
                echo '<img src="', $this->file, '" style="width:', $this->width, 'pt;height:', $this->height, "pt;\" alt=\"\">\n</div>\n";
                break;
            case 'C':
                echo '<div style="position:absolute;top:', $this->y, 'pt;left:0pt;width:', $renderer->getRemainingWidth(), "pt;text-align:center;\">\n";
                echo '<img src="', $this->file, '" style="width:', $this->width, 'pt;height:', $this->height, "pt;\" alt=\"\">\n</div>\n";
                break;
            case 'R':
                echo '<div style="position:absolute;top:', $this->y, 'pt;left:0pt;width:', $renderer->getRemainingWidth(), "pt;text-align:right;\">\n";
                echo '<img src="', $this->file, '" style="width:', $this->width, 'pt;height:', $this->height, "pt;\" alt=\"\">\n</div>\n";
                break;
            default:
                echo '<img src="', $this->file, '" style="position:absolute;', $renderer->alignRTL, ':', $this->x, 'pt;top:', $this->y, 'pt;width:', $this->width, 'pt;height:', $this->height, "pt;\" alt=\"\">\n";
        }

        $lastpicpage   = $renderer->pageNo();
        $lastpicleft   = $this->x;
        $lastpicright  = $this->x + $this->width;
        $lastpicbottom = $this->y + $this->height;
        // Setup for the next line
        if ($this->line === 'N') {
            $renderer->setY($lastpicbottom);
        }
        // Keep max Y updated
        $renderer->addMaxY($lastpicbottom);
    }
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;
        }
    }
21717
public function render(ResultsRenderer $renderer)
    {
        $output = '';
        if ($this->result->headersDifferent()) {
            $output .= sprintf(
                "%s      %s\n%s  %s",
                $renderer->style('YOUR HEADERS:', ['bold', 'yellow']),
                $this->headers($this->result->getActualHeaders(), $renderer),
                $renderer->style('EXPECTED HEADERS:', ['bold', 'yellow']),
                $this->headers($this->result->getExpectedHeaders(), $renderer, false)
            );
        }

        if ($this->result->bodyDifferent()) {
            if ($this->result->headersAndBodyDifferent()) {
                $output .= "\n" . $renderer->style('- - - - - - - - -', ['default', 'bold']) . "\n\n";
            }

            $output .= sprintf(
                "%s       %s\n\n%s   %s\n",
                $renderer->style('YOUR OUTPUT:', ['bold', 'yellow']),
                $renderer->style(sprintf('"%s"', $this->result->getActualOutput()), 'red'),
                $renderer->style('EXPECTED OUTPUT:', ['bold', 'yellow']),
                $renderer->style(sprintf('"%s"', $this->result->getExpectedOutput()), 'green')
            );
        }

        return $output;
    }