Converts source to DomDocument.

@param bool $applystyles Apply stylesheets yes/no. Default is true.

@return DomDocument

@todo support for passing XsltProcessor as parameter
197140
public function toDOM($applystyles = true)
    {
        if ($applystyles && !empty($this->styles)) {
            $proc = self::stylesToProc($this->styles);
            $proc->registerPhpFunctions();
        }

        switch ($this->sourceType) {
            case self::SOURCE_TYPE_DOM:
                if ($this->source instanceof DomDocument) {
                    return $this->source;
                }

                // when parameter for constructor was DomNode
                $dom = new DomDocument('1.0', 'utf-8');
                $dome = $dom->importNode($this->source, true);
                $dom->appendChild($dome);

                return $dom;
            case self::SOURCE_TYPE_SIMPLEXML:
                // @todo detect charset from simplexml?
                $dom = new DomDocument('1.0', 'utf-8');
                $dome = dom_import_simplexml($this->source);
                $dome = $dom->importNode($dome, true);
                $dom->appendChild($dome);

                return $dom;
            case self::SOURCE_TYPE_OBJECT:
                $dom = $this->objectToDom($this->source);
                break;
            case self::SOURCE_TYPE_FILE:
                $dom = new DomDocument();
                $dom->load($this->source);
                break;
            case self::SOURCE_TYPE_STRING:
                $dom = new DomDocument();
                $dom->loadXML($this->source);
        }

        return isset($proc) ? $proc->transformToDoc($dom) : $dom;
    }
751418
public function renderStandalone()
    {
        $domDocument                = new \DOMDocument("1.0", "utf-8");
        $domDocument->xmlStandalone = true;

        $domElement = $domDocument->createElement("ui_properties");
        $domDocument->appendChild($domElement);

        $allProperties = $this->getProperties();
        foreach ($allProperties as $property => $propertySettings) {
            if (!$propertySettings) {
                continue;
            }

            $propertyDomElement = $domDocument->createElement($property);
            $domElement->appendChild($propertyDomElement);

            foreach ($propertySettings as $settingName => $settingValue) {
                $settingValueString = (is_string($settingValue) ? $settingValue : var_export($settingValue, true));
                $propertyDomElement->setAttribute($settingName, $settingValueString);
            }
        }

        return $domDocument;
    }
527960
public function renderStandalone()
    {
        $domDocument                = new \DOMDocument("1.0", "utf-8");
        $domDocument->xmlStandalone = true;

        $domElement = $this->render($domDocument);
        $domDocument->appendChild($domElement);

        return $domDocument;
    }
1298849
public static function stylesToDOM($files = array())
    {
        foreach ($files as $primary => &$v) {
            if (!$v instanceof DomDocument) {
                $dom = new DomDocument();
                $dom->load($v);
            } else {
                $dom = $v;
            }

            if ($dom->firstChild->nodeName === 'xsl:stylesheet') {
                break;
            }

            unset($primary);
        }

        if (!isset($primary)) {
            throw new RuntimeException('No valid XML stylesheets were found for XSLT parser.');
        }

        foreach ($files as $k => &$v) {
            if ($k === $primary) {
                continue;
            }

            if ($v instanceof DomDocument) {
                if ($v->firstChild->nodeName !== 'xsl:stylesheet') {
                    continue;
                }

                foreach ($v->firstChild->childNodes as $include) {
                    $dom->appendChild($dom->importNode($include, true));
                }
            } else {
                $include = $dom->createElementNS('http://www.w3.org/1999/XSL/Transform', 'xsl:include');
                $include->setAttributeNode(new DomAttr('href', $v));
                $dom->firstChild->appendChild($include);
            }
        }

        return $dom;
    }
835023
public function buildForm($macros)
	{
		try
		{
			$form = new EForms_Form($this, $macros[1]);
		}
		catch (Exception $e)
		{
			return $macros[0];
		}

		return $form->getHTML();
	}
271680
protected function getCssContent()
    {
        $styleString = "";

        if (class_exists("\\DOMDocument")) {
            $doc = new \DOMDocument();
            $doc->loadHTML($this->getHtmlContent());

            // Extract styles from the HTML file
            foreach($doc->getElementsByTagName('style') as $styleNode) {
                $styleString .= $styleNode->nodeValue . "\r\n";
            }
        } else {
            throw new \RuntimeException("Required extension 'dom' seems to be missing.");
        }

        return $styleString;
    }
988157
public function applyHtmlSpecialCharsOnAllFields(array $documents)
    {
        $trustedSolrFields = $this->typoScriptConfiguration->getSearchTrustedFieldsArray();

        foreach ($documents as $key => $document) {
            $fieldNames = array_keys($document->getFields() ?? []);

            foreach ($fieldNames as $fieldName) {
                if (is_array($trustedSolrFields) && in_array($fieldName, $trustedSolrFields)) {
                    // we skip this field, since it was marked as secure
                    continue;
                }

                $value = $this->applyHtmlSpecialCharsOnSingleFieldValue($document[$fieldName]);
                $document->setField($fieldName, $value);
            }

            $documents[$key] = $document;
        }

        return $documents;
    }
986805
public function convert(DOMDocument $document)
    {
        foreach ($this->converters as $converter) {
            $converter->convert($document);
        }

        return $document;
    }
1314089
public function asXml(bool $pretty = false)
    {
        $doc = new \SimpleXMLElement('<problem></problem>');

        $this->arrayToXml($this->compile(), $doc);

        $dom = dom_import_simplexml($doc);
        if ($pretty) {
            $dom->ownerDocument->preserveWhiteSpace = false;
            $dom->ownerDocument->formatOutput = true;
        }
        return $dom->ownerDocument->saveXML();
    }
98589
public function toDoc(): \DOMDocument
    {
        if (null === $this->document) {
            throw new XslProcessorException(
                    'Can not transform, set document or xml file to transform first'
            );
        }

        $this->registerCallbacks();
        $result = $this->xsltProcessor->transformToDoc($this->document);
        if (false === $result) {
            throw new XslProcessorException($this->createMessage());
        }

        return $result;
    }
268835
public function compile($matches)
    {
        list($_, $directive, $expression) = $matches;

        return $this->callDirective($directive, $expression);
    }
903039
private function createDomDocument(array $context): \DOMDocument
    {
        $document = new \DOMDocument();

        // Set an attribute on the DOM document specifying, as part of the XML declaration,
        $xmlOptions = [
            // nicely formats output with indentation and extra space
            self::FORMAT_OUTPUT => 'formatOutput',
            // the version number of the document
            self::VERSION => 'xmlVersion',
            // the encoding of the document
            self::ENCODING => 'encoding',
            // whether the document is standalone
            self::STANDALONE => 'xmlStandalone',
        ];
        foreach ($xmlOptions as $xmlOption => $documentProperty) {
            if ($contextOption = $context[$xmlOption] ?? $this->defaultContext[$xmlOption] ?? false) {
                $document->$documentProperty = $contextOption;
            }
        }

        return $document;
    }
556806
private function _transform($sContent, $sTemplateName, $bFirst = false, $bDoCompilation = true) 
	{
	    if ($this->_bIsLayout === true && self::$_aDisableRenderLevel[1] === true 
	       && self::$_aDisableRenderLevel[2] === true) { 

	        $sContent = '';
	    }
	    else if ($this->_bIsLayout === true && self::$_aDisableRenderLevel[1] === true 
	       && self::$_aDisableRenderLevel[2] === false) { 

	        $sContent = preg_replace('/^(.*)\{include file=\$model\}(.*)$/msi', '$1$2', $sContent);
	    }
	    else if ($this->_bIsLayout === true && self::$_iRenderLevel < 2) { 

	        $sContent = preg_replace('/^.*(\{include file=\$model\}).*$/msi', '$1', $sContent);
	    }
	    else if (self::$_iRenderLevel < 1 || self::$_aDisableRenderLevel[1] === true) { 

	        $sContent = '';
	    }
	    
		//*****************************************************************************************************************************
		// NEW version
		// @deprecated
		//
		// {$foo[section_name]}? http://www.smarty.net/docs/en/language.syntax.variables.tpl
		//*****************************************************************************************************************************

		$sTmpDirectory = self::$_sCachePath;
		$sTmpDirectory = str_replace('\\', '\\\\\\', $sTmpDirectory);

		$sViewDirectory = self::$_sBasePath;

		$_aProtectedVar = $this->_aVar;
		$_aProtectedVar['app']['config'] = array();
		$_aProtectedVar['app']['server'] = $_SERVER;
		$_aProtectedVar['app']['get'] = $_GET;
		$_aProtectedVar['app']['post'] = $_POST;
		$_aProtectedVar['app']['cookies'] = $_COOKIE;
		$_aProtectedVar['app']['env'] = $_ENV;
		
		if (isset($_SESSION)) { $_aProtectedVar['app']['session'] = $_SESSION; }
		else { $_aProtectedVar['app']['session'] = array(); }
		
		$_aProtectedVar['app']['request'] = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV);
		$_aProtectedVar['app']['now'] = time();
		$_aProtectedVar['app']['const'] = get_defined_constants();
		$_aProtectedVar['app']['capture'] = array();					// link to {capture} -> to do it
		$_aProtectedVar['app']['section'] = array();					// link to {section} -> to do it
		$_aProtectedVar['app']['template'] = $this->_sTemplateName;
		$_aProtectedVar['app']['template_object'] = $this;
		$_aProtectedVar['app']['current_dir'] = $sViewDirectory;
		$_aProtectedVar['app']['version'] = self::VERSION;
		$_aProtectedVar['app']['block'] = array();						// link to {block} -> to do it
		$_aProtectedVar['app']['block']['child'] = null;
		$_aProtectedVar['app']['block']['parent'] = null;
		$_aProtectedVar['app']['ldelim'] = $this->_sLeftDelimiter;
		$_aProtectedVar['app']['rdelim'] = $this->_sRightDelimiter;

		//*****************************************************************************************************************************
		// tags: {counter}, {$SCRIPT_NAME}
		//*****************************************************************************************************************************

		$sContent = str_replace('{counter}', '$_aProtectedVar[\'i\']', $sContent);
		$sContent = str_replace('{$SCRIPT_NAME}', '$_aProtectedVar[\'app\'][\'SERVER\'][\'SCRIPT_NAME\']', $sContent);

		//*****************************************************************************************************************************
		// comments: {* this is a comment *}
		//*****************************************************************************************************************************

		$sContent = preg_replace('|\{\*|', '<?php /*', $sContent);
		$sContent = preg_replace('|\*\}|', '*/ ?>', $sContent);

		//*****************************************************************************************************************************
		// escape: {literal}function bazzy {alert('foobar!');}{/literal}
		//*****************************************************************************************************************************

		$sContent = preg_replace('|'.preg_quote($this->getLeftDelimiter()).'|', "\n".'<?php echo <<<EOF'."\n", $sContent);
		$sContent = preg_replace('|'.preg_quote($this->getRightDelimiter()).'|', "\n".'EOF;'."\n".'?>'."\n", $sContent);

		while (preg_match('|(<<<EOF(?:(?<!EOF;).)+?)\$(.+?EOF;)|msi', $sContent)) {

			$sContent = preg_replace('|(<<<EOF(?:(?<!EOF;).)+?)\$(.+?EOF;)|msi', '$1#DOLLAR#$2', $sContent);
		}


		//*****************************************************************************************************************************
		// variables: {$foo}, {$foo[4]}, {$foo.bar}, {$foo.$bar}, {$foo->bar}, {$foo->bar()}, {$foo.bar.baz}, {$foo.$bar.$baz},
		//				{$foo[4].baz}, {$foo[4].$baz}, {$foo.bar.baz[4]}, {$foo->bar($baz,2,$bar)}, {$app.config.foo},
		//				{$app.server.SERVER_NAME}, {$x+$y}, {$foo[$x+3]}, {$foo={counter}+3}, {$foo="this is message {counter}"},
		//				{$foo=$bar+2}, {$foo = strlen($bar)}, {$foo = myfunct( ($x+$y)*3 )}, {$foo.bar=1}, {$foo.bar.baz=1},
		//				{$foo[]=1}, {$foo.a.b.c}, {$foo.a.$b.c}, {$foo.a.{$b+4}.c}, {$foo.a.{$b.c}}, {$foo['bar']}, {$foo['bar'][1]},
		//				{$foo[$x+$x]}, {$foo[$bar[1]]}, $foo_{$bar}, $foo_{$x+$y}, $foo_{$bar}_buh_{$blar}, {$foo_{$x}}, {time()}
		//				{$foo+1}, {$foo*$bar}, {$app.get.page}, {$app.post.page}, {$app.cookies.page}, , {$app.anv.path},
		//				{$app.session.page}, {$app.request.page}, {$app.now}, {$app.const.page}, {$smarty.capture}, {$smarty.section},
		//				{$smarty.template}, {$smarty.current_dir}, {$smarty.version}, {$smarty.template_object}, {$smarty.block.child},
		//				{$smarty.block.parent}, {$app.ldelim}, {$app.rdelim}
		// particulier ;
		// version 1 forbiden : {$app['security']}, {$app['user']}, {$app['environment']}, {$app['debug']}
		//*****************************************************************************************************************************

		while (preg_match('|\{(.*?)\$([^_\(][a-z0-9_\[\]\->\(\)\+/*\']+)\.([a-z0-9_]+)(.*?)\}|msi', $sContent, $ret)) {

			$sContent = preg_replace('|\{(.*?)\$([^_\(][a-z0-9_\[\]\->\(\)\+/*\']+)\.([a-z0-9_]+)(.*?)\}|msi',
							'{'.'$1'.'$'.'$2[\'$3\']'.'$4'.'}', $sContent);
		}



		// {$foo.$bar.baz}

		$sContent = preg_replace('|\{(.*?)\$([^_\(][a-z0-9_]*)([a-z0-9_\[\].\->\(\)\+/*\']*)\.\$([^_][a-z0-9_]*)([a-z0-9_\[\]\->\(\)\+/*\']*)(.*?)\}|msi',
			'{'.'$1'.'$_aProtectedVar[\'$2\']$3[$_aProtectedVar[\'$4\']$5]'.'$6'.'}', $sContent);

		// {$foo.a.{$b.c}}

		$sContent = preg_replace('|\{(.*?)\$([^_\(][a-z0-9_]*)([a-z0-9_\[\].\->\(\)\+/*\']*)\.\{\$([^_][a-z0-9_]*)([a-z0-9_\[\]\->.\(\)\+/*\']*)\}(.*?)\}|msi',
						'{'.'$1'.'$_aProtectedVar[\'$2\']$3[$_aProtectedVar[\'$4\']$5]'.'$6'.'}', $sContent);

		// $foo_{$bar}, $foo_{$x+$y}, $foo_{$bar}_buh_{$blar}, {$foo_{$x}}

		$sContent = preg_replace('|\{(.*?)\$([^_\(][a-z0-9_]*?)_\{([a-z0-9_\+/*\->\$\(\)\[\]]*)([a-z0-9_\[\]\->\(\)\+/*\']*)\}(.*?)\}|msi',
						'{'.'$1'.'$_aProtectedVar[\'$2\'.($3)]'.'$5'.'}', $sContent);

		while (preg_match('|\{(.*?)\$([^_\(][a-z0-9_]*)([a-z0-9_\[\].\->\(\)\+/*\']*)(.*?)\}|msi', $sContent)) {

			$sContent = preg_replace('|\{(.*?)\$([^_\(][a-z0-9_]*)([a-z0-9_\[\].\->\(\)\+/*\']*)(.*?)\}|msi',
							'{'.'$1'.'$_aProtectedVar[\'$2\']$3'.'$4'.'}', $sContent);
		}

		//*****************************************************************************************************************************
		// var modifiers : {$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}
		//*****************************************************************************************************************************

		preg_match_all('#\{(\$_aProtectedVar[a-z0-9_\[\].\->\(\)\+/*\']*)\|([^:\}]+)([^\}]*)\}#msi', $sContent, $aMatchs, PREG_SET_ORDER);

		foreach ($aMatchs as $aOne) {

			$sName = ucfirst($aOne[2]);

			$sName = preg_replace('|_([a-z])|e', 'strtoupper("$1")', $sName);
			// replace the name of modifier which are a key name of php
			$sName = str_replace(array('Default'), array('StringDefault'), $sName);

			if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.'Modifiers'.DIRECTORY_SEPARATOR.$sName.'.php')) {

				$sClassName = '\Apollina\Template\Modifiers\\'.$sName;
				$oFunction = new $sClassName;
				$aAttributes = explode(' ', $aOne[3]);
				preg_match_all('#:([^:]+)#msi', $aOne[3], $aMatchs2, PREG_SET_ORDER);
				$aParams = [];
				$aParams[] = $aOne[1];
				$iIndex = 1;

				foreach ($aMatchs2 as $sOne2) {

					if (!isset($aParams[$iIndex])) { $aParams[$iIndex] = $sOne2[1]; }
					else { $aParams[$iIndex] .= $sOne2[1]; }

					if (substr($aParams[$iIndex], -1) == "'" && substr($aParams[$iIndex], 0, 1) == "'") { $iIndex++; }
					else if (substr($aParams[$iIndex], -1) == '"' && substr($aParams[$iIndex], 0, 1) == '"') { $iIndex++; }
					else if (substr($aParams[$iIndex], 0, 1) != '"' && substr($aParams[$iIndex], 0, 1) != "'") { $iIndex++; }
					else { $aParams[$iIndex] .= ":"; }
				}

				$oFunction->run($aParams);
				$sContent = str_replace($aOne[0], call_user_func_array(array($oFunction, 'replaceBy') , $aParams), $sContent);
			}
		}

		//*****************************************************************************************************************************
		// transformation all : {$ssdsd} in <php echo ; >
		//*****************************************************************************************************************************

		$sContent = preg_replace('|\{(\$[a-z0-9_\[\].\->\(\)\$\+/*\'=+]+)\}|msi', '<?php echo $1; ?>', $sContent);
		$sContent = preg_replace('|\{([a-z0-9_\(\),.]+\(\$[a-z0-9_\[\].\->\(\)\$\+/*\'"]+[ a-z0-9_\(\),".]+)\}|msi', '<?php echo $1; ?>', $sContent);
		$sContent = preg_replace('|\{([a-z0-9_\(\),.]+\([^\}]+\))\}|msi', '<?php echo $1; ?>', $sContent);

		$sContent = preg_replace('|echo echo|', 'echo', $sContent);

		//*****************************************************************************************************************************
		// escape: {ldelim}function{/rdelim}
		//*****************************************************************************************************************************

		$sContent = preg_replace('|<?php echo ldelim; ?>|', '{', $sContent);
		$sContent = preg_replace('|<?php echo rdelim; ?>|', '}', $sContent);

		//*****************************************************************************************************************************
		// variables: {#foo#}
		//*****************************************************************************************************************************

		$sContent = preg_replace('|\{#([a-z0-9_]+)#\}|msi', '<?php echo $_aProtectedVar[\'app\'][\'config\'][\'$1\']; ?>', $sContent);

		//*****************************************************************************************************************************
		// variables: {"foo"}
		//*****************************************************************************************************************************

		$sContent = preg_replace('|\{"([^"]+)"\}|msi', '<?php echo "$1"; ?>', $sContent);

		//*****************************************************************************************************************************
		// {$nale='dsds'}
		//*****************************************************************************************************************************

		$sContent = preg_replace('|\{(\$_aProtectedVar[^= }]+=[\'"][^\'"}]+[\'"])\}|msi', '<?php $1'.'; ?>', $sContent);

		//*****************************************************************************************************************************
		// variables: {funcname attr1="val1" attr2="val2"}
		//				{assign var=foo value={counter}}
		//				{html_select_date display_days=true}
		//				{mailto address="smarty@example.com"}
		//				{html_options options=$companies selected=$company_id}
		//				{include file="subdir/$tpl_name.tpl"} => exception : class ToInclude
		//				{cycle values="one,two,`$smarty.config.myval`"}
		//				{config_load file='foo.conf'}
		//				{url alias='home' ...}
		//*****************************************************************************************************************************

		preg_match_all('|\{([a-z0-9_]+) +([a-z]+=[^\}]+)\}|msi', $sContent, $aMatchs, PREG_SET_ORDER);

		foreach ($aMatchs as $aOne) {

			$sName = ucfirst($aOne[1]);

			$sName = preg_replace_callback('|_([a-z])|', function ($aMatches) {
				return strtoupper($aMatches[1]);
			}, $sName);

			if ($sName == 'Include') { $sName = 'ToInclude'; }
			if ($sName == 'Foreach') { $sName = 'ToForeach'; }

			if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.'Functions'.DIRECTORY_SEPARATOR.$sName.'.php')) {

				$sClassName = 'Apollina\Template\Functions\\'.$sName;
				$oFunction = new $sClassName;
				$aAttributes = explode(' ', $aOne[2]);

				$aParams = [];

				foreach ($aAttributes as $sOne2) {

					$aSplitParams = explode('=', $sOne2);
					$aParams[$aSplitParams[0]] = $aSplitParams[1];
				}

				if ($sName == 'ToInclude') {

					if (preg_match('/_aProtectedVar/', $aParams['file'])) {

						$sModelToCall = str_replace(array("\$_aProtectedVar['", "']", "'", '"'), array('', '' , '', ''), $aParams['file']);
						$aParams['real_name'] = $_aProtectedVar[$sModelToCall];
					}
					else {

						$aParams['real_name'] = str_replace(array("'", '"'), array('', ''), $aParams['file']);
					}
				}

				$sContent = str_replace($aOne[0], $oFunction->replaceBy($aParams), $sContent);
			}
			
			foreach ($this->_aFunctionsPath as $sOnePath) {

			    if (file_exists($sOnePath['files'].DIRECTORY_SEPARATOR.$sName.'.php')) {
			    
			        $sClassName = $sOnePath['namespace'].$sName;
			        $oFunction = new $sClassName;
			        $aAttributes = explode(' ', $aOne[2]);
			    
			        $aParams = [];
			    
			        foreach ($aAttributes as $sOne2) {
			    
			            $aSplitParams = explode('=', $sOne2);
			            $aParams[$aSplitParams[0]] = $aSplitParams[1];
			        }

			        $sContent = str_replace($aOne[0], $oFunction->replaceBy($aParams), $sContent);
			    }
			}
		}

		//*****************************************************************************************************************************
		// variables: {include model}
		//*****************************************************************************************************************************

		if (preg_match('|\{include model\}|', $sContent)) {

			if ($this->_bIsMobile && file_exists(self::$_sBasePath.str_replace('.tpl', 'Mobile.tpl', $_aProtectedVar['model']))) {

				$this->_transform(file_get_contents(self::$_sBasePath.str_replace('.tpl', 'Mobile.tpl', $_aProtectedVar['model'])), str_replace('.tpl', 'Mobile.tpl', $_aProtectedVar['model']));
			}
			else {

				$this->_transform(file_get_contents(self::$_sBasePath.$sModelname), $sModelname);
			}
		}

		//*****************************************************************************************************************************
		// variables: {if $foo > 3}{elseif $foo > 3}{else}{/if}
		//				{foreachelse} execute program if the array of foreach is empty
		//				{/foreach} to close foreach
		//*****************************************************************************************************************************

		$sContent = preg_replace('|\{if ([^\}]+)\}|', '<?php if ($1) { ?>', $sContent);
		$sContent = preg_replace('|\{elseif ([^\}]+)\}|', '<?php } else if ($1) { ?>', $sContent);
		$sContent = str_replace(array('{else}', '{foreachelse}'), '<?php } else { ?>', $sContent);
		$sContent = str_replace('{/foreach}', '<?php }} ?>', $sContent);
		$sContent = str_replace(array('{/if}', '{/section}'), '<?php } ?>', $sContent);

		//*****************************************************************************************************************************
		// finition
		//*****************************************************************************************************************************

		//$sContent = preg_replace('|\{|msi', '<?php ', $sContent);
		//$sContent = preg_replace('|\}|msi', ' ? >', $sContent);

		while (preg_match('|(<<<EOF(?:(?<!EOF;).)+?)#DOLLAR#(.+?EOF;)|msi', $sContent)) {

			$sContent = preg_replace('|(<<<EOF(?:(?<!EOF;).)+?)#DOLLAR#(.+?EOF;)|msi', '$1'.'\\\$'.'$2', $sContent);
		}

		$sContent .= "\n".'<?php /* '.print_r(str_replace('\\\\\\', '/', $sTmpDirectory).$this->_getEncodeTemplateName($sTemplateName).'.cac.php', true).' */ ?>';
		$sContent .= "\n".'<?php /* template : '.$sTemplateName.' */ ?>';
		$sContent .= "\n".'<?php /* '.print_r(file_put_contents(str_replace('\\\\\\', '/', $sTmpDirectory).$this->_getEncodeTemplateName($sTemplateName).'.cac.php', $sContent), true).' */ ?>';
		$sContent .= "\n".'<?php /* '.str_replace('\\\\\\', '/', $sTmpDirectory).' = '.$sTemplateName.' = '.md5($sTemplateName).' */ ?>';
	
		if ($bFirst === true) {

			include(str_replace('\\\\\\', '/', $sTmpDirectory).$this->_getEncodeTemplateName($sTemplateName).'.cac.php');
		}
	}
524365
public function asDom(): \DOMDocument
    {
        $doc = new \DOMDocument();
        $doc->loadXML($this->writer->outputMemory());
        return $doc;
    }
1039457
public function getStylesXMLFileContent()
    {
        $content = <<<EOD
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
EOD;

        $content .= $this->getFontsSectionContent();
        $content .= $this->getFillsSectionContent();
        $content .= $this->getBordersSectionContent();
        $content .= $this->getCellStyleXfsSectionContent();
        $content .= $this->getCellXfsSectionContent();
        $content .= $this->getCellStylesSectionContent();

        $content .= <<<EOD
</styleSheet>
EOD;

        return $content;
    }
1229324
public function createWorkbookFile($worksheets)
    {
        $workbookXmlFileContents = <<<EOD
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
    <sheets>
EOD;

        /** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
        $escaper = \Box\Spout\Common\Escaper\XLSX::getInstance();

        /** @var Worksheet $worksheet */
        foreach ($worksheets as $worksheet) {
            $worksheetName = $worksheet->getExternalSheet()->getName();
            $worksheetId = $worksheet->getId();
            $workbookXmlFileContents .= '<sheet name="' . $escaper->escape($worksheetName) . '" sheetId="' . $worksheetId . '" r:id="rIdSheet' . $worksheetId . '"/>';
        }

        $workbookXmlFileContents .= <<<EOD
    </sheets>
</workbook>
EOD;

        $this->createFileWithContents($this->xlFolder, self::WORKBOOK_XML_FILE_NAME, $workbookXmlFileContents);

        return $this;
    }
354215
public function stylesheetLinkTag($sources = "application", $attributes = [])
    {
        // E.g. stylesheet_link_tag('app', ['media'=>'all']); => app-fa2ce4b45369a106436f229ca9e52bee.css
        $args = func_get_args();
        if (is_array(last($args))) {
            $attributes = array_pop($args);
        } else {
            $attributes = [];
        }
        $sources = is_array($sources) ? $sources : $args;
        if (empty($sources)) {
            $sources = ["application"];
        }

        $assetsOptions = ['host' => array_pull($attributes, 'host', $this->assetsHost)];

        $defaults = ['media' => 'all', 'type' => 'text/css'];
        $attributes = $attributes + $defaults;

        $stylesheet_tags = [];
        foreach ((array) $sources as $source) {
            $sourceName = "$source.css";
            $stylesheet_tags[] = app('html')->style($this->assetPath($sourceName, $assetsOptions), $attributes);
        }

        return implode($stylesheet_tags);
    }