Render the table.

@param Document $reportDom
@param Config $config
484982
public function render(Document $reportDom, Config $config)
    {
        $template = $config['template'];
        $out = strtr(
            $config['file'],
            [
                '%report_name%' => $reportDom->firstChild->getAttribute('name'),
            ]
        );

        if (!file_exists($template)) {
            throw new \RuntimeException(sprintf(
                'XSLT template file "%s" does not exist',
                $template
            ));
        }

        foreach ($reportDom->query('.//row') as $rowEl) {
            $formatterParams = [];

            foreach ($rowEl->query('./formatter-param') as $paramEl) {
                $formatterParams[$paramEl->getAttribute('name')] = $paramEl->nodeValue;
            }

            foreach ($rowEl->query('./cell') as $cellEl) {
                $value = $cellEl->nodeValue;

                if ('' !== $value && $cellEl->hasAttribute('class')) {
                    $classes = explode(' ', $cellEl->getAttribute('class'));
                    $value = $this->formatter->applyClasses($classes, $value, $formatterParams);
                    $cellEl->nodeValue = $value;
                }
            }
        }

        $stylesheetDom = new \DOMDocument('1.0');
        $stylesheetDom->load($template);
        $xsltProcessor = new \XSLTProcessor();
        $xsltProcessor->importStylesheet($stylesheetDom);
        $xsltProcessor->setParameter('', 'title', $config['title']);
        $xsltProcessor->setParameter('', 'phpbench-version', PhpBench::VERSION);
        $xsltProcessor->setParameter('', 'date', date('Y-m-d H:i:s'));
        $output = $xsltProcessor->transformToXml($reportDom);

        if (!$output) {
            throw new \InvalidArgumentException(sprintf(
                'Could not render report with XSL file "%s"',
                $template
            ));
        }

        if ($out) {
            file_put_contents($out, $output);
            $this->output->writeln('Dumped XSLT report:');
            $this->output->writeln($out);
        } else {
            $this->output->write($output);
        }
    }
821969
public function renderChildIntoParentColumn(
        $columns,
        &$child,
        &$parentGridData,
        &$parentRecordNumbers,
        $typoScriptSetup = []
    ) {
        $column_number = (int)$child['tx_gridelements_columns'];
        $columnKey = $column_number . '.';
        $columnSetupKey = isset($typoScriptSetup['columns.'][$columnKey]) ? $columnKey : 'default.';

        if ($child['uid'] <= 0) {
            return;
        }
        // update SYS_LASTCHANGED if necessary
        $this->cObj->lastChanged($child['tstamp']);
        $this->cObj->start(array_merge($child, $parentGridData), 'tt_content');

        $parentRecordNumbers[$columnKey]++;
        $this->cObj->parentRecordNumber = $parentRecordNumbers[$columnKey];

        // we render each child into the children key to provide them prerendered for usage with your own templating
        $child = $this->cObj->cObjGetSingle(
            $typoScriptSetup['columns.'][$columnSetupKey]['renderObj'],
            $typoScriptSetup['columns.'][$columnSetupKey]['renderObj.']
        );
        // then we assign the prerendered child to the appropriate column
        if (isset($columns[$column_number])) {
            $parentGridData['tx_gridelements_view_columns'][$column_number] .= $child;
        }
    }
758354
protected function createXmlResponse(array $data, array $config)
    {
        if (! \is_null($root = $config['root'] ?? null)) {
            $data = $data[$root] ?? [];
        }

        if ($data instanceof Arrayable) {
            $data = $data->toArray();
        }

        $data = \array_map([$this, 'transformToArray'], $data);

        return function () use ($data, $config) {
            return ArrayToXml::convert($data, $config['document-root'] ?? $root);
        };
    }
184332
public function html(MailConfig $config, array $data)
    {
        return $this->views->make($config->template(), $data)->render();
    }
879696
public function render(\DOMDocument $domDocument)
    {
        $frame = new Frame();
        $frame->setId($this->frameId);
        $frame->setAlign($this->hAlign, $this->vAlign);
        $frame->setPosition($this->startX, $this->startY);
        $frame->addClasses($this->frameClasses);
        $sizeY = 0;
        $sizeX = 0;
        /** @var Control $oldElement */
        $oldElement = null;
        foreach ($this->elements as $idx => $element) {

            if ($idx === 0) {
                $start = $this->getRelativeStartPosition($element);
            } else {
                $start = $this->getStartPosition($oldElement) + $this->margin;
            }

            if ($oldElement) {

                if ($oldElement->getHorizontalAlign() == "center" && $element->getHorizontalAlign() == "center") {
                    $element->setX($start + $oldElement->getWidth() + ($element->getWidth() / 2));
                } elseif ($oldElement->getHorizontalAlign() == "left" && $element->getHorizontalAlign() == "center") {
                    $element->setX($start + $oldElement->getWidth() + ($element->getWidth() / 2));
                } elseif ($oldElement->getHorizontalAlign() == "center" && $element->getHorizontalAlign() == "left") {
                    $element->setX($start + $oldElement->getWidth());
                } elseif ($oldElement->getHorizontalAlign() == "center" && $element->getHorizontalAlign() == "right") {
                    $element->setX($start + $oldElement->getWidth() + $element->getWidth());
                } elseif ($oldElement->getHorizontalAlign() == "right" && $element->getHorizontalAlign() == "right") {
                    $element->setX($start + $element->getWidth());
                } elseif ($oldElement->getHorizontalAlign() == "right" && $element->getHorizontalAlign() == "center") {
                    $element->setX($start + ($element->getWidth() / 2));
                } elseif ($oldElement->getHorizontalAlign() == "left" && $element->getHorizontalAlign() == "right") {
                    $element->setX($start + $oldElement->getWidth() + $element->getWidth());
                } elseif ($oldElement->getHorizontalAlign() == "right" && $element->getHorizontalAlign() == "left") {
                    $element->setX($start);
                } else {
                    $element->setX($start + $oldElement->getWidth());
                }
            } else {
                $element->setX($start);
            }

            if ((abs($element->getY()) + $element->getHeight()) > $sizeY) {
                $sizeY = abs($element->getY()) + $element->getHeight();
                $this->setHeight($sizeY);
            }
            $frame->addChild($element);
            $oldElement = $element;
            $sizeX += $element->getWidth() + $this->margin;
        }

        $this->setWidth($sizeX);

        return $frame->render($domDocument);
    }
207112
public void render(OutputStream outputStream, Format format, int dpi) throws PrintingException {
		try {
			if (baos == null) {
				prepare();
			}
			writeDocument(outputStream, format, dpi);
		} catch (Exception e) { // NOSONAR
			throw new PrintingException(e, PrintingException.DOCUMENT_RENDER_PROBLEM);
		}
	}
175589
protected function renderControl(ElementInterface $element, $elementString, $id, $controlWrapper = null)
    {
        $description = $this->getDescriptionHelper()->render($element);
        $label       = $this->renderLabel($element);
        $control     = $this->renderControlWrapper($id, $element, $elementString, $description, $controlWrapper);
        if ($label) {
            switch ($this->labelPosition) {
                case self::LABEL_PREPEND:
                    return $label . $control;
                case self::LABEL_APPEND:
                default:
                    return $control . $label;
            }
        }
        return $control;
    }
777736
protected static function renderNode($node, $document)
    {
        if (static::isTag($node)) {
            # Strip the leading "#"
            $tagName    = substr(array_shift($node), 1);
            $attributes = array();

            if (sizeof($node) > 2) {
                throw new \UnexpectedValueException(
                    "Tags must not consist of more than three elements"
                );
            }

            foreach ($node as $argv) {
                # Is the argument an associative array of attributes?
                if (is_array($argv) and count(array_filter(array_keys($argv), "is_string")) > 0) {
                    $attributes = $argv;
                } else {
                    $content = $argv;
                }
            }

            $el = $document->createElement($tagName);

            foreach ($attributes as $attr => $value) {
                if (is_array($value)) $value = join(" ", $value);

                $el->setAttribute($attr, (string) $value);
            }

            if (isset($content)) {
                $el->appendChild(static::renderNode($content, $document));
            }
        } else if (is_array($node)) {
            $el = $document->createDocumentFragment();

            foreach ($node as $child) {
                $el->appendChild(static::renderNode($child, $document));
            }
        } else {
            $node = (string) $node;
            if (!empty($node)) $node .= "\n";
            $el = $document->createTextNode($node);
        }

        return $el;
    }
1373072
private function runGoldilocks(XmlDocument $doc, GoldilocksRenderingEngine $renderer)
    {
        $arguments = $this->getArguments();
        $profile = $arguments['flavour'];

        $xml = $renderer->render($doc->getDocumentComponent());
        
        $header = '';
        $footer = '';
        $indent = '';
        $nl = '';
        
        if ($arguments['format'] === true) {
            $xml->formatOutput = true;
            $indent .= "\x20\x20";
            $nl .= "\n";
        }
        
        if ($arguments['document'] === true) {
            $header .= "<!doctype html>\n";
        }
        
        $xpath = new DOMXPath($xml);
        $assessmentItemElts = $xpath->query("//div[contains(@class, 'qti-assessmentItem')]");
        
        if ($assessmentItemElts->length > 0 && $arguments['document'] === true) {
            $rootComponent = $doc->getDocumentComponent();
            $htmlAttributes = array();
    
            // Take the content of <assessmentItem> and put it into <html>.
            $attributes = $assessmentItemElts->item(0)->attributes;
            foreach ($attributes as $name => $attr) {
                $htmlAttributes[$name] = $name . '="'. XmlUtils::escapeXmlSpecialChars($attr->value, true) . '"';
            }
    
            while ($attributes->length > 0) {
                $assessmentItemElts->item(0)->removeAttribute($attributes->item(0)->name);
            }
            
            $header .= "<html " . implode(' ', $htmlAttributes) . ">${nl}";
            $header .= "${indent}<head>${nl}";
            $header .= "${indent}${indent}<meta charset=\"utf-8\">${nl}";
            $header .= "${indent}${indent}<title>" . XmlUtils::escapeXmlSpecialChars($rootComponent->getTitle()) . "</title>${nl}";
            $header .= "${indent}${indent}" . $renderer->getStylesheets()->ownerDocument->saveXML($renderer->getStylesheets());
            $header .= "${indent}</head>${nl}";
    
            $itemBodyElts = $xpath->query("//div[contains(@class, 'qti-itemBody')]");
            if ($itemBodyElts->length > 0) {
                $body = $xml->saveXml($itemBodyElts->item(0));
                $body = substr($body, strlen('<div>'));
                $body = substr($body, 0, strlen('</div>') * -1);
                $body = "<body ${body}</body>${nl}";
            } else {
                $body = $xml->saveXml($xml->documentElement) . "${nl}";
            }
        
            if ($arguments['document'] === true) {
                $footer = "</html>\n";
            }
        } else {
            $body = $xml->saveXml($xml->documentElement) . "${nl}";
        }
        
        // Indent body...
        $indentBody = '';
        
        if ($arguments['document'] === null) {
            $indent = '';
        }
        
        foreach (preg_split('/\n|\r/u', $body, -1, PREG_SPLIT_NO_EMPTY) as $bodyLine) {
            // do stuff with $line
            $indentBody .= "${indent}${bodyLine}${nl}";
        }
        
        $body = $indentBody;
        
        return "{$header}{$body}{$footer}";
    }
465396
@Override
    public void writeText(PDDocument doc, Writer outputStream) throws IOException
    {
        try
        {
            DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
            DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS");
            LSSerializer writer = impl.createLSSerializer();
            LSOutput output = impl.createLSOutput();
            writer.getDomConfig().setParameter("format-pretty-print", true);
            output.setCharacterStream(outputStream);
            createDOM(doc);
            writer.write(getDocument(), output);
        } catch (ClassCastException e) {
            throw new IOException("Error: cannot initialize the DOM serializer", e);
        } catch (ClassNotFoundException e) {
            throw new IOException("Error: cannot initialize the DOM serializer", e);
        } catch (InstantiationException e) {
            throw new IOException("Error: cannot initialize the DOM serializer", e);
        } catch (IllegalAccessException e) {
            throw new IOException("Error: cannot initialize the DOM serializer", e);
        }
    }
1248828
protected function composeExcel(array $data, array $config, string $writerType): SymfonyResponse
    {
        $filename = $config['filename'] ?? 'export';

        return $this->convertToExcel($data, $config)->exportExcel($filename, $writerType);
    }
1286592
private function writeDocument(\DOMDocument $dom)
    {
        $dom->formatOutput = true;
        $this->write($dom->saveXML());
    }
1348508
public function render($config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'toolbar' => null,
            'title'   => null,
        ));

        //Set a custom title
        if($config->title) {
            $config->toolbar->setTitle($config->title);
        }

        $title = $this->getObject('translator')->translate($config->toolbar->getTitle());
        $html  = '';

        if (!empty($title))
        {
            $mobile = ($config->mobile === '' || $config->mobile) ? 'k-title-bar--mobile' : '';

            $html .= '
            <div class="k-title-bar k-js-title-bar '.$mobile.'">
                <div class="k-title-bar__heading">' . $title . '</div>
            </div>';
        }

        return $html;
    }
1020070
public function render_set($res, $name, $dload, $sep, $config, $mix){
		$output="";
		$index=0;
		$conn = $this->conn;
		$this->mix($config, $mix);
		$conn->event->trigger("beforeRenderSet",$conn,$res,$config);
		while ($data=$conn->sql->get_next($res)){
			$data = $this->simple_mix($mix, $data);

			$data = new $name($data,$config,$index);
			if ($data->get_id()===false)
				$data->set_id($conn->uuid());
			$conn->event->trigger("beforeRender",$data);
			$output.=$data->to_xml().$sep;
			$index++;
		}
		$this->unmix($config, $mix);
		return $output;
	}
846084
protected function generatePDF($content, $filename, $config = []) {
        unset($config['contentBefore'], $config['contentAfter']);
        $config = array_replace_recursive([
            // set to use core fonts only
            'mode' => Pdf::MODE_UTF8,
            // set mPDF properties on the fly
            'options' => [
                'autoLangToFont' => true,
                'autoScriptToLang' => true,
                'autoVietnamese' => true,
                'autoArabic' => true,
            ],
            // call mPDF methods on the fly
            'methods' => [
                'SetFooter' => ['{PAGENO}'],
            ]
                ], $config);
        $config['filename'] = $filename;
        $config['methods']['SetAuthor'] = ['CCIZA LTD.'];
        $config['methods']['SetCreator'] = ['CZA Extension'];
        $config['content'] = $content;
        $pdf = new Pdf($config);
        echo $pdf->render();
    }
684247
public function handle(Document $document, array $config)
    {
        $content = $document->getContent();

        $pattern = '/<!---([\w\W]*?)-->/';
        if (preg_match($pattern, $content, $matches) === 1) {
        // not really required when using html doc tags. But in case it's frontmatter, it should be removed
            $content    = preg_replace($pattern, '', $content);
            $attributes = array_replace_recursive($document->getAttributes(), Yaml::parse($matches[1]));

            $document->setAttributes($attributes);
        }

        $document->setContent($content);
    }
28662
protected static function processTableFormat($reportMetadata, $report, $reportColumns)
    {
        $finalReport = $report;
        if (empty($reportMetadata['dimension'])) {
            $simpleReportMetrics = $report->getFirstRow();
            if ($simpleReportMetrics) {
                $finalReport = new Simple();
                foreach ($simpleReportMetrics->getColumns() as $metricId => $metric) {
                    $newRow = new Row();
                    $newRow->addColumn("label", $reportColumns[$metricId]);
                    $newRow->addColumn("value", $metric);
                    $finalReport->addRow($newRow);
                }
            }

            $reportColumns = array(
                'label' => Piwik::translate('General_Name'),
                'value' => Piwik::translate('General_Value'),
            );
        }

        return array(
            $finalReport,
            $reportColumns,
        );
    }