Render

@param   object  $renderer
@return  string
435515
public function render($renderer=null)
	{
		if (!$renderer)
		{
			$renderer = php_sapi_name() === 'cli' ? 'console' : 'html';
		}

		return $this->setRenderer($renderer)
					->getRenderer()
					->render($this->messages());
	}
983407
public function render(Render $renderer)
	{
		$radios = [];

		foreach ($this->getContents() as $radio)
		{
			$radios[] = $renderer->render($radio);
		}

		return implode('', $radios);
	}
190904
public function render(AbstractInline $inline, CliRenderer $renderer)
    {
        if (!($inline instanceof Code)) {
            throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));
        }

        return $renderer->style($inline->getContent(), 'yellow');
    }
870808
public function render(AbstractRenderer $renderer = null, $active = null)
    {
        if (is_null($renderer)) {
            $renderer = $this->getRenderer();
        }

        return $renderer->render($this->getRelations(), $active);
    }
1355183
public function render(Renderable $item)
    {
        if ($renderer = $this->findReturningTrueOrFail('canRender', $item)) {
            return $renderer->render($item);
        }

        return '';
    }
575475
public function render(ProfilerInterface $profiler)
	{
		$render = '';

		/** @var \Joomla\Profiler\ProfilePointInterface $lastPoint **/
		$lastPoint = null;

		$points = $profiler->getPoints();

		foreach ($points as $point)
		{
			$previousTime = $lastPoint ? $lastPoint->getTime() : 0.0;
			$previousMem = $lastPoint ? $lastPoint->getMemoryMegaBytes() : 0;

			$render .= sprintf(
				'<code>%s %.3f seconds (+%.3f); %0.2f MB (%s%0.3f) - %s</code>',
				$profiler->getName(),
				$point->getTime(),
				$point->getTime() - $previousTime,
				$point->getMemoryMegaBytes(),
				($point->getMemoryMegaBytes() > $previousMem) ? '+' : '',
				$point->getMemoryMegaBytes() - $previousMem,
				$point->getName()
			);

			$render .= '<br />';

			$lastPoint = $point;
		}

		return $render;
	}
326742
public function renderAfterSuite($obj)
    {
        $print = array();
        foreach ($this->rendererList as $name => $renderer) {
            $print[$name] = $renderer->renderAfterSuite($obj);
        }

        return $print;
    }
837254
public function register(Renderer $renderer) {
        $this->registerTokenRenderer(ItalicRule::NAME . ItalicRule::OPEN, 'renderOpen', $renderer);
        $this->registerTokenRenderer(ItalicRule::NAME . ItalicRule::CLOSE, 'renderClose', $renderer);

        $this->registerTokenRenderer(ItalicAltRule::NAME . ItalicAltRule::OPEN, 'renderOpen', $renderer);
        $this->registerTokenRenderer(ItalicAltRule::NAME . ItalicAltRule::CLOSE, 'renderClose', $renderer);
    }
648072
public function register(Renderer $renderer) {
        $this->registerTokenRenderer(HeaderAtxRule::NAME, 'renderContent', $renderer);
        $this->registerTokenRenderer(HeaderSetextRule::NAME, 'renderContent', $renderer);
    }
399220
public function register(Renderer $renderer) {
        $this->registerTokenRenderer(TableRule::NAME . TableRule::OPEN, 'renderOpen', $renderer);
        $this->registerTokenRenderer(TableRule::NAME . TableRule::CLOSE, 'renderClose', $renderer);
        $this->registerTokenRenderer(TableRule::NAME . '_HEADER_OPEN', 'renderHeaderOpen', $renderer);
        $this->registerTokenRenderer(TableRule::NAME . '_HEADER_CLOSE', 'renderHeaderClose', $renderer);
        $this->registerTokenRenderer(TableRule::NAME . '_ROW_OPEN', 'renderRowOpen', $renderer);
        $this->registerTokenRenderer(TableRule::NAME . '_ROW_CLOSE', 'renderRowClose', $renderer);
        $this->registerTokenRenderer(TableRule::NAME . '_HEAD_COLL_OPEN', 'renderHeadCollOpen', $renderer);
        $this->registerTokenRenderer(TableRule::NAME . '_HEAD_COLL_CLOSE', 'renderHeadCollClose', $renderer);
        $this->registerTokenRenderer(TableRule::NAME . '_COLL_OPEN', 'renderCollOpen', $renderer);
        $this->registerTokenRenderer(TableRule::NAME . '_COLL_CLOSE', 'renderCollClose', $renderer);
    }
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;
        }
    }
1001035
public function render( RendererInterface $renderer )
    {
        if ( empty( $this->paragraphId ) )
        {
            return '';
        }

        return $renderer->htmlTag(
            'a',
            $this->getDescription(),
            array(
                'title' => $this->originalTitle,
                'href'  => '/app/' . $this->locale .
                           '/paragraph/render/' . $this->paragraphId,
            )
        );
    }
967080
public function render(AbstractInline $inline, CliRenderer $renderer)
    {
        if (!($inline instanceof Link)) {
            throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));
        }

        return $renderer->style($renderer->renderInlines($inline->children()), ['underline', 'bold', 'light_blue']);
    }
1178918
public function render($key, RendererInterface $renderer = null)
	{
		if (!$this->hasMenu($key)) {
			return '';
		}

		return $this->renderMenu($this->getMenu($key), $renderer);
	}
737128
public function renderFootnote($renderer)
    {
        if ($renderer->getCurrentStyle() != $this->styleName) {
            $renderer->setCurrentStyle($this->styleName);
        }
        $temptext = str_replace('#PAGENUM#', (string) $renderer->PageNo(), $this->text);
        // Set the link to this y/page position
        $renderer->SetLink($this->addlink, -1, -1);
        // Print first the source number
        // working
        if ($renderer->getRTL()) {
            $renderer->writeHTML('<span> .' . $this->num . '</span>', false, false, false, false, '');
        } else {
            $temptext = '<span>' . $this->num . '. </span>' . $temptext;
        }
        // underline «title» part of Source item
        $temptext = str_replace([
            '«',
            '»',
        ], [
            '<u>',
            '</u>',
        ], $temptext);
        $renderer->writeHTML($temptext, true, false, true, false, '');
    }
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));
                    }
                }
            }
        }
    }
1195088
public function html(PhpRenderer $renderer = null) {
        $view = new View();
        $view->setResponse(new Response());
        $resolver = new TemplateMapResolver();

        if($renderer === null) {
            $renderer = new PhpRenderer();
            $resolver->add($this->getTemplate(), $this->getDefaultTemplatePath($this->getTemplate()));
            $renderer->setResolver($resolver);
        } else {
            $renderer->resolver()->attach($resolver);
        }

        $view->getEventManager()->attach(new PhpRendererStrategy($renderer));

        $view->render($this);

        return $view->getResponse()->getContent();
    }