Exemplo n.º 1
0
 /**
  * add stylesheet to the template depending on settings
  *
  * @param \Template $objTemplate
  */
 public function onParseTemplate(\Template $objTemplate)
 {
     if (TL_MODE == 'BE' && $this->useImprovedTheme() && in_array($objTemplate->getName(), $GLOBALS['TL_CONFIG']['useBackendImprovedOnTemplates'])) {
         if ($this->objCombiner->hasEntries()) {
             $objTemplate->javascripts .= '<script src="' . $this->objCombiner->getCombinedFile() . '"></script>';
         }
         $objTemplate->stylesheets .= '<link rel="stylesheet" href="system/modules/be_improved_theme/assets/style.css">' . "\r\n";
     }
 }
 /**
  * Get the combined file
  *
  * @return null|string
  */
 public function getCombinedFile()
 {
     $assets = $this->getAssets();
     if (empty($assets)) {
         return null;
     }
     $combiner = new \Combiner();
     /** @var LocalAsset $asset */
     foreach ($assets as $asset) {
         if (!$asset->isValid()) {
             continue;
         }
         $asset->setTemporaryFileExtension('css');
         $combiner->add($asset->generate());
     }
     if (!$combiner->hasEntries()) {
         return null;
     }
     return $combiner->getCombinedFile();
 }
Exemplo n.º 3
0
	/**
	 * Create all header scripts
	 * @param Database_Result
	 * @param Database_Result
	 */
	protected function createHeaderScripts(Database_Result $objPage, Database_Result $objLayout)
	{
		$strStyleSheets = '';
		$strCcStyleSheets = '';
		$arrStyleSheets = deserialize($objLayout->stylesheet);
		$strTagEnding = ($objPage->outputFormat == 'xhtml') ? ' />' : '>';

		// Google web fonts
		if ($objLayout->webfonts != '')
		{
			$protocol = $this->Environment->ssl ? 'https://' : 'http://';
			$strStyleSheets .= '<link' . (($objPage->outputFormat == 'xhtml') ? ' type="text/css"' : '') .' rel="stylesheet" href="' . $protocol . 'fonts.googleapis.com/css?family=' . $objLayout->webfonts . '"' . $strTagEnding . "\n";
		}

		$objCombiner = new Combiner();

		// Skip the Contao framework style sheet
		if (!$objLayout->skipFramework)
		{
			$objCombiner->add('system/contao.css');
		}

		// Skip the TinyMCE style sheet
		if (!$objLayout->skipTinymce && file_exists(TL_ROOT . '/' . $GLOBALS['TL_CONFIG']['uploadPath'] . '/tinymce.css'))
		{
			$objCombiner->add($GLOBALS['TL_CONFIG']['uploadPath'] . '/tinymce.css', filemtime(TL_ROOT .'/'. $GLOBALS['TL_CONFIG']['uploadPath'] . '/tinymce.css'), 'all');
		}

		// Internal style sheets
		if (is_array($GLOBALS['TL_CSS']) && !empty($GLOBALS['TL_CSS']))
		{
			foreach (array_unique($GLOBALS['TL_CSS']) as $stylesheet)
			{
				list($stylesheet, $media, $mode) = explode('|', $stylesheet);

				if ($mode == 'static')
				{
					$objCombiner->add($stylesheet, filemtime(TL_ROOT . '/' . $stylesheet), $media);
				}
				else
				{
					$strStyleSheets .= '<link' . (($objPage->outputFormat == 'xhtml') ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . $this->addStaticUrlTo($stylesheet) . '" media="' . (($media != '') ? $media : 'all') . '"' . $strTagEnding . "\n";
				}
			}
		}

		// User style sheets
		if (is_array($arrStyleSheets) && strlen($arrStyleSheets[0]))
		{
			$objStylesheets = $this->Database->execute("SELECT *, (SELECT MAX(tstamp) FROM tl_style WHERE tl_style.pid=tl_style_sheet.id) AS tstamp2, (SELECT COUNT(*) FROM tl_style WHERE tl_style.selector='@font-face' AND tl_style.pid=tl_style_sheet.id) AS hasFontFace FROM tl_style_sheet WHERE id IN (" . implode(', ', $arrStyleSheets) . ") ORDER BY FIELD(id, " . implode(', ', $arrStyleSheets) . ")");

			while ($objStylesheets->next())
			{
				$media = implode(',', deserialize($objStylesheets->media));

				// Overwrite the media type with a custom media query
				if ($objStylesheets->mediaQuery != '')
				{
					$media = $objStylesheets->mediaQuery;
				}

				// Aggregate regular style sheets
				if (!$objStylesheets->cc && !$objStylesheets->hasFontFace)
				{
					$objCombiner->add('system/scripts/' . $objStylesheets->name . '.css', max($objStylesheets->tstamp, $objStylesheets->tstamp2), $media);
				}
				else
				{
					$strStyleSheet = '<link' . (($objPage->outputFormat == 'xhtml') ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . TL_SCRIPT_URL . 'system/scripts/' . $objStylesheets->name . '.css" media="' . $media . '"' . $strTagEnding;

					if ($objStylesheets->cc)
					{
						$strStyleSheet = '<!--[' . $objStylesheets->cc . ']>' . $strStyleSheet . '<![endif]-->';
					}

					$strCcStyleSheets .= $strStyleSheet . "\n";
				}
			}
		}

		// Create the aggregated style sheet
		if ($objCombiner->hasEntries())
		{
			$strStyleSheets .= '<link' . (($objPage->outputFormat == 'xhtml') ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . $objCombiner->getCombinedFile() . '" media="all"' . $strTagEnding . "\n";
		}

		// Always add conditional style sheets at the end
		$strStyleSheets .= $strCcStyleSheets;

		$newsfeeds = deserialize($objLayout->newsfeeds);
		$calendarfeeds = deserialize($objLayout->calendarfeeds);

		// Add newsfeeds
		if (is_array($newsfeeds) && !empty($newsfeeds))
		{
			$objFeeds = $this->Database->execute("SELECT * FROM tl_news_archive WHERE makeFeed=1 AND id IN(" . implode(',', array_map('intval', $newsfeeds)) . ")");

			while($objFeeds->next())
			{
				$base = strlen($objFeeds->feedBase) ? $objFeeds->feedBase : $this->Environment->base;
				$strStyleSheets .= '<link rel="alternate" href="' . $base . $objFeeds->alias . '.xml" type="application/' . $objFeeds->format . '+xml" title="' . $objFeeds->title . '"' . $strTagEnding . "\n";
			}
		}

		// Add calendarfeeds
		if (is_array($calendarfeeds) && !empty($calendarfeeds))
		{
			$objFeeds = $this->Database->execute("SELECT * FROM tl_calendar WHERE makeFeed=1 AND id IN(" . implode(',', array_map('intval', $calendarfeeds)) . ")");

			while($objFeeds->next())
			{
				$base = strlen($objFeeds->feedBase) ? $objFeeds->feedBase : $this->Environment->base;
				$strStyleSheets .= '<link rel="alternate" href="' . $base . $objFeeds->alias . '.xml" type="application/' . $objFeeds->format . '+xml" title="' . $objFeeds->title . '"' . $strTagEnding . "\n";
			}
		}

		$strHeadTags = '';

		// Add internal scripts
		if (is_array($GLOBALS['TL_JAVASCRIPT']) && !empty($GLOBALS['TL_JAVASCRIPT']))
		{
			foreach (array_unique($GLOBALS['TL_JAVASCRIPT']) as $javascript)
			{
				$strHeadTags .= '<script' . (($objPage->outputFormat == 'xhtml') ? ' type="text/javascript"' : '') . ' src="' . $this->addStaticUrlTo($javascript) . '"></script>' . "\n";
			}
		}

		// Add internal <head> tags
		if (is_array($GLOBALS['TL_HEAD']) && !empty($GLOBALS['TL_HEAD']))
		{
			foreach (array_unique($GLOBALS['TL_HEAD']) as $head)
			{
				$strHeadTags .= trim($head) . "\n";
			}
		}

		// Add user <head> tags
		if (($strHead = trim($objLayout->head)) != false)
		{
			$strHeadTags .= $strHead . "\n";
		}

		$this->Template->stylesheets = $strStyleSheets;
		$this->Template->head = $strHeadTags;
	}
 /**
  * Replace the dynamic script tags (see #4203)
  *
  * @param string $strBuffer The string with the tags to be replaced
  *
  * @return string The string with the replaced tags
  */
 public static function replaceDynamicScriptTags($strBuffer)
 {
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['replaceDynamicScriptTags']) && is_array($GLOBALS['TL_HOOKS']['replaceDynamicScriptTags'])) {
         foreach ($GLOBALS['TL_HOOKS']['replaceDynamicScriptTags'] as $callback) {
             $strBuffer = static::importStatic($callback[0])->{$callback[1]}($strBuffer);
         }
     }
     /** @var \PageModel $objPage */
     global $objPage;
     $arrReplace = array();
     $blnXhtml = $objPage->outputFormat == 'xhtml';
     $strScripts = '';
     // Add the internal jQuery scripts
     if (!empty($GLOBALS['TL_JQUERY']) && is_array($GLOBALS['TL_JQUERY'])) {
         foreach (array_unique($GLOBALS['TL_JQUERY']) as $script) {
             $strScripts .= "\n" . trim($script) . "\n";
         }
     }
     $arrReplace['[[TL_JQUERY]]'] = $strScripts;
     $strScripts = '';
     // Add the internal MooTools scripts
     if (!empty($GLOBALS['TL_MOOTOOLS']) && is_array($GLOBALS['TL_MOOTOOLS'])) {
         foreach (array_unique($GLOBALS['TL_MOOTOOLS']) as $script) {
             $strScripts .= "\n" . trim($script) . "\n";
         }
     }
     $arrReplace['[[TL_MOOTOOLS]]'] = $strScripts;
     $strScripts = '';
     // Add the internal <body> tags
     if (!empty($GLOBALS['TL_BODY']) && is_array($GLOBALS['TL_BODY'])) {
         foreach (array_unique($GLOBALS['TL_BODY']) as $script) {
             $strScripts .= trim($script) . "\n";
         }
     }
     // Add the syntax highlighter scripts
     if (!empty($GLOBALS['TL_HIGHLIGHTER']) && is_array($GLOBALS['TL_HIGHLIGHTER'])) {
         $objCombiner = new \Combiner();
         foreach (array_unique($GLOBALS['TL_HIGHLIGHTER']) as $script) {
             $objCombiner->add($script);
         }
         $strScripts .= "\n" . \Template::generateScriptTag($objCombiner->getCombinedFile(), $blnXhtml);
         $strScripts .= "\n" . \Template::generateInlineScript('SyntaxHighlighter.defaults.toolbar=false;SyntaxHighlighter.all()', $blnXhtml) . "\n";
     }
     // Command scheduler
     if (!\Config::get('disableCron')) {
         $strScripts .= "\n" . \Template::generateInlineScript('setTimeout(function(){var e=function(e,t){try{var n=new XMLHttpRequest}catch(r){return}n.open("GET",e,!0),n.onreadystatechange=function(){this.readyState==4&&this.status==200&&typeof t=="function"&&t(this.responseText)},n.send()},t="system/cron/cron.";e(t+"txt",function(n){parseInt(n||0)<Math.round(+(new Date)/1e3)-' . \Frontend::getCronTimeout() . '&&e(t+"php")})},5e3);', $blnXhtml) . "\n";
     }
     $arrReplace['[[TL_BODY]]'] = $strScripts;
     $strScripts = '';
     $objCombiner = new \Combiner();
     // Add the CSS framework style sheets
     if (!empty($GLOBALS['TL_FRAMEWORK_CSS']) && is_array($GLOBALS['TL_FRAMEWORK_CSS'])) {
         foreach (array_unique($GLOBALS['TL_FRAMEWORK_CSS']) as $stylesheet) {
             $objCombiner->add($stylesheet);
         }
     }
     // Add the internal style sheets
     if (!empty($GLOBALS['TL_CSS']) && is_array($GLOBALS['TL_CSS'])) {
         foreach (array_unique($GLOBALS['TL_CSS']) as $stylesheet) {
             $options = \StringUtil::resolveFlaggedUrl($stylesheet);
             if ($options->static) {
                 if ($options->mtime === null) {
                     $options->mtime = filemtime(TL_ROOT . '/' . $stylesheet);
                 }
                 $objCombiner->add($stylesheet, $options->mtime, $options->media);
             } else {
                 $strScripts .= \Template::generateStyleTag(static::addStaticUrlTo($stylesheet), $options->media, $blnXhtml) . "\n";
             }
         }
     }
     // Add the user style sheets
     if (!empty($GLOBALS['TL_USER_CSS']) && is_array($GLOBALS['TL_USER_CSS'])) {
         foreach (array_unique($GLOBALS['TL_USER_CSS']) as $stylesheet) {
             $options = \StringUtil::resolveFlaggedUrl($stylesheet);
             if ($options->static) {
                 if ($options->mtime === null) {
                     $options->mtime = filemtime(TL_ROOT . '/' . $stylesheet);
                 }
                 $objCombiner->add($stylesheet, $options->mtime, $options->media);
             } else {
                 $strScripts .= \Template::generateStyleTag(static::addStaticUrlTo($stylesheet), $options->media, $blnXhtml) . "\n";
             }
         }
     }
     // Create the aggregated style sheet
     if ($objCombiner->hasEntries()) {
         $strScripts .= \Template::generateStyleTag($objCombiner->getCombinedFile(), 'all', $blnXhtml) . "\n";
     }
     $arrReplace['[[TL_CSS]]'] = $strScripts;
     $strScripts = '';
     // Add the internal scripts
     if (!empty($GLOBALS['TL_JAVASCRIPT']) && is_array($GLOBALS['TL_JAVASCRIPT'])) {
         $objCombiner = new \Combiner();
         $objCombinerAsync = new \Combiner();
         foreach (array_unique($GLOBALS['TL_JAVASCRIPT']) as $javascript) {
             $options = \StringUtil::resolveFlaggedUrl($javascript);
             if ($options->static) {
                 if ($options->mtime === null) {
                     $options->mtime = filemtime(TL_ROOT . '/' . $javascript);
                 }
                 $options->async ? $objCombinerAsync->add($javascript, $options->mtime) : $objCombiner->add($javascript, $options->mtime);
             } else {
                 $strScripts .= \Template::generateScriptTag(static::addStaticUrlTo($javascript), $blnXhtml, $options->async) . "\n";
             }
         }
         // Create the aggregated script and add it before the non-static scripts (see #4890)
         if ($objCombiner->hasEntries()) {
             $strScripts = \Template::generateScriptTag($objCombiner->getCombinedFile(), $blnXhtml) . "\n" . $strScripts;
         }
         if ($objCombinerAsync->hasEntries()) {
             $strScripts = \Template::generateScriptTag($objCombinerAsync->getCombinedFile(), $blnXhtml, true) . "\n" . $strScripts;
         }
     }
     // Add the internal <head> tags
     if (!empty($GLOBALS['TL_HEAD']) && is_array($GLOBALS['TL_HEAD'])) {
         foreach (array_unique($GLOBALS['TL_HEAD']) as $head) {
             $strScripts .= trim($head) . "\n";
         }
     }
     $arrReplace['[[TL_HEAD]]'] = $strScripts;
     return str_replace(array_keys($arrReplace), array_values($arrReplace), $strBuffer);
 }
Exemplo n.º 5
0
 /**
  * Create all header scripts
  * @param object
  * @param object
  * @throws \Exception
  */
 protected function createHeaderScripts($objPage, $objLayout)
 {
     $strStyleSheets = '';
     $strCcStyleSheets = '';
     $arrStyleSheets = deserialize($objLayout->stylesheet);
     $strTagEnding = $objPage->outputFormat == 'xhtml' ? ' />' : '>';
     // Google web fonts
     if ($objLayout->webfonts != '') {
         $protocol = \Environment::get('ssl') ? 'https://' : 'http://';
         $strStyleSheets .= '<link' . ($objPage->outputFormat == 'xhtml' ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . $protocol . 'fonts.googleapis.com/css?family=' . $objLayout->webfonts . '"' . $strTagEnding . "\n";
     }
     $objCombiner = new \Combiner();
     // Skip the Contao framework style sheet
     if (!$objLayout->skipFramework) {
         $objCombiner->add('assets/contao/framework.css');
     }
     // Skip the TinyMCE style sheet
     if (!$objLayout->skipTinymce && file_exists(TL_ROOT . '/' . $GLOBALS['TL_CONFIG']['uploadPath'] . '/tinymce.css')) {
         $objCombiner->add($GLOBALS['TL_CONFIG']['uploadPath'] . '/tinymce.css', filemtime(TL_ROOT . '/' . $GLOBALS['TL_CONFIG']['uploadPath'] . '/tinymce.css'), 'all');
     }
     // Internal style sheets
     if (is_array($GLOBALS['TL_CSS']) && !empty($GLOBALS['TL_CSS'])) {
         foreach (array_unique($GLOBALS['TL_CSS']) as $stylesheet) {
             list($stylesheet, $media, $mode) = explode('|', $stylesheet);
             if ($mode == 'static') {
                 $objCombiner->add($stylesheet, filemtime(TL_ROOT . '/' . $stylesheet), $media);
             } else {
                 $strStyleSheets .= '<link' . ($objPage->outputFormat == 'xhtml' ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . $this->addStaticUrlTo($stylesheet) . '" media="' . ($media ?: 'all') . '"' . $strTagEnding . "\n";
             }
         }
     }
     // User style sheets
     if (is_array($arrStyleSheets) && strlen($arrStyleSheets[0])) {
         $objStylesheets = \StyleSheetModel::findByIds($arrStyleSheets);
         if ($objStylesheets !== null) {
             while ($objStylesheets->next()) {
                 $media = implode(',', deserialize($objStylesheets->media));
                 // Overwrite the media type with a custom media query
                 if ($objStylesheets->mediaQuery != '') {
                     $media = $objStylesheets->mediaQuery;
                 }
                 // Aggregate regular style sheets
                 if (!$objStylesheets->cc && !$objStylesheets->hasFontFace) {
                     $objCombiner->add('assets/css/' . $objStylesheets->name . '.css', max($objStylesheets->tstamp, $objStylesheets->tstamp2), $media);
                 } else {
                     $strStyleSheet = '<link' . ($objPage->outputFormat == 'xhtml' ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . TL_SCRIPT_URL . 'css/' . $objStylesheets->name . '.css" media="' . $media . '"' . $strTagEnding;
                     if ($objStylesheets->cc) {
                         $strStyleSheet = '<!--[' . $objStylesheets->cc . ']>' . $strStyleSheet . '<![endif]-->';
                     }
                     $strCcStyleSheets .= $strStyleSheet . "\n";
                 }
             }
         }
     }
     $arrExternal = deserialize($objLayout->external);
     // External style sheets
     if (is_array($arrExternal) && !empty($arrExternal)) {
         foreach (array_unique($arrExternal) as $stylesheet) {
             if ($stylesheet == '') {
                 continue;
             }
             // Validate the file name
             if (strpos($stylesheet, '..') !== false || strncmp($stylesheet, $GLOBALS['TL_CONFIG']['uploadPath'] . '/', strlen($GLOBALS['TL_CONFIG']['uploadPath']) + 1) !== 0) {
                 throw new \Exception("Invalid path {$stylesheet}");
             }
             list($stylesheet, $media, $mode) = explode('|', $stylesheet);
             // Only .css files are allowed
             if (substr($stylesheet, -4) != '.css') {
                 throw new \Exception("Invalid file extension {$stylesheet}");
             }
             // Check whether the file exists
             if (!file_exists(TL_ROOT . '/' . $stylesheet)) {
                 continue;
             }
             // Include the file
             if ($mode == 'static') {
                 $objCombiner->add($stylesheet, filemtime(TL_ROOT . '/' . $stylesheet), $media);
             } else {
                 $strStyleSheets .= '<link' . ($objPage->outputFormat == 'xhtml' ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . $this->addStaticUrlTo($stylesheet) . '" media="' . ($media ?: 'all') . '"' . $strTagEnding . "\n";
             }
         }
     }
     // Create the aggregated style sheet
     if ($objCombiner->hasEntries()) {
         $strStyleSheets .= '<link' . ($objPage->outputFormat == 'xhtml' ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . $objCombiner->getCombinedFile() . '" media="all"' . $strTagEnding . "\n";
     }
     // Add the debug style sheet
     if ($GLOBALS['TL_CONFIG']['debugMode']) {
         $strStyleSheets .= '<link rel="stylesheet" href="' . $this->addStaticUrlTo('assets/contao/debug.css') . '" media="all">' . "\n";
     }
     // Always add conditional style sheets at the end
     $strStyleSheets .= $strCcStyleSheets;
     $newsfeeds = deserialize($objLayout->newsfeeds);
     $calendarfeeds = deserialize($objLayout->calendarfeeds);
     // Add newsfeeds
     if (is_array($newsfeeds) && !empty($newsfeeds)) {
         $objFeeds = \NewsFeedModel::findByIds($newsfeeds);
         if ($objFeeds !== null) {
             while ($objFeeds->next()) {
                 $base = $objFeeds->feedBase ?: \Environment::get('base');
                 $strStyleSheets .= '<link rel="alternate" href="' . $base . 'share/' . $objFeeds->alias . '.xml" type="application/' . $objFeeds->format . '+xml" title="' . $objFeeds->title . '"' . $strTagEnding . "\n";
             }
         }
     }
     // Add calendarfeeds
     if (is_array($calendarfeeds) && !empty($calendarfeeds)) {
         $objFeeds = \CalendarFeedModel::findByIds($calendarfeeds);
         if ($objFeeds !== null) {
             while ($objFeeds->next()) {
                 $base = $objFeeds->feedBase ?: \Environment::get('base');
                 $strStyleSheets .= '<link rel="alternate" href="' . $base . 'share/' . $objFeeds->alias . '.xml" type="application/' . $objFeeds->format . '+xml" title="' . $objFeeds->title . '"' . $strTagEnding . "\n";
             }
         }
     }
     $strHeadTags = '';
     // Add internal scripts
     if (is_array($GLOBALS['TL_JAVASCRIPT']) && !empty($GLOBALS['TL_JAVASCRIPT'])) {
         foreach (array_unique($GLOBALS['TL_JAVASCRIPT']) as $javascript) {
             $strHeadTags .= '<script' . ($objPage->outputFormat == 'xhtml' ? ' type="text/javascript"' : '') . ' src="' . $this->addStaticUrlTo($javascript) . '"></script>' . "\n";
         }
     }
     // Add internal <head> tags
     if (is_array($GLOBALS['TL_HEAD']) && !empty($GLOBALS['TL_HEAD'])) {
         foreach (array_unique($GLOBALS['TL_HEAD']) as $head) {
             $strHeadTags .= trim($head) . "\n";
         }
     }
     // Add user <head> tags
     if (($strHead = trim($objLayout->head)) != false) {
         $strHeadTags .= $strHead . "\n";
     }
     $this->Template->stylesheets = $strStyleSheets;
     $this->Template->head = $strHeadTags;
 }
Exemplo n.º 6
0
 /**
  * Replace the dynamic script tags (see #4203)
  * 
  * @param string $strBuffer The string with the tags to be replaced
  * 
  * @return string The string with the replaced tags
  */
 public static function replaceDynamicScriptTags($strBuffer)
 {
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['replaceDynamicScriptTags']) && is_array($GLOBALS['TL_HOOKS']['replaceDynamicScriptTags'])) {
         foreach ($GLOBALS['TL_HOOKS']['replaceDynamicScriptTags'] as $callback) {
             $strBuffer = static::importStatic($callback[0])->{$callback}[1]($strBuffer);
         }
     }
     global $objPage;
     $arrReplace = array();
     $blnXhtml = $objPage->outputFormat == 'xhtml';
     $strTagEnding = $blnXhtml ? ' />' : '>';
     $strScripts = '';
     // Add the internal jQuery scripts
     if (is_array($GLOBALS['TL_JQUERY']) && !empty($GLOBALS['TL_JQUERY'])) {
         foreach (array_unique($GLOBALS['TL_JQUERY']) as $script) {
             $strScripts .= "\n" . trim($script) . "\n";
         }
     }
     $arrReplace['[[TL_JQUERY]]'] = $strScripts;
     $strScripts = '';
     // Add the internal MooTools scripts
     if (is_array($GLOBALS['TL_MOOTOOLS']) && !empty($GLOBALS['TL_MOOTOOLS'])) {
         foreach (array_unique($GLOBALS['TL_MOOTOOLS']) as $script) {
             $strScripts .= "\n" . trim($script) . "\n";
         }
     }
     $arrReplace['[[TL_MOOTOOLS]]'] = $strScripts;
     $strScripts = '';
     // Add the syntax highlighter scripts
     if (is_array($GLOBALS['TL_HIGHLIGHTER']) && !empty($GLOBALS['TL_HIGHLIGHTER'])) {
         $objCombiner = new \Combiner();
         foreach (array_unique($GLOBALS['TL_HIGHLIGHTER']) as $script) {
             $objCombiner->add($script);
         }
         $strScripts .= "\n" . '<script' . ($blnXhtml ? ' type="text/javascript"' : '') . ' src="' . $objCombiner->getCombinedFile() . '"></script>';
         if ($blnXhtml) {
             $strScripts .= "\n" . '<script type="text/javascript">' . "\n/* <![CDATA[ */\n" . 'SyntaxHighlighter.defaults.toolbar=false;SyntaxHighlighter.all()' . "\n/* ]]> */\n" . '</script>' . "\n";
         } else {
             $strScripts .= "\n" . '<script>SyntaxHighlighter.defaults.toolbar=false;SyntaxHighlighter.all()</script>' . "\n";
         }
     }
     $arrReplace['[[TL_HIGHLIGHTER]]'] = $strScripts;
     $strScripts = '';
     $objCombiner = new \Combiner();
     // Add the CSS framework style sheets
     if (is_array($GLOBALS['TL_FRAMEWORK_CSS']) && !empty($GLOBALS['TL_FRAMEWORK_CSS'])) {
         foreach (array_unique($GLOBALS['TL_FRAMEWORK_CSS']) as $stylesheet) {
             $objCombiner->add($stylesheet);
         }
     }
     // Add the internal style sheets
     if (is_array($GLOBALS['TL_CSS']) && !empty($GLOBALS['TL_CSS'])) {
         foreach (array_unique($GLOBALS['TL_CSS']) as $stylesheet) {
             list($stylesheet, $media, $mode) = explode('|', $stylesheet);
             if ($mode == 'static') {
                 $objCombiner->add($stylesheet, filemtime(TL_ROOT . '/' . $stylesheet), $media);
             } else {
                 $strScripts .= '<link' . ($blnXhtml ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . static::addStaticUrlTo($stylesheet) . '"' . ($media != '' && $media != 'all' ? ' media="' . $media . '"' : '') . $strTagEnding . "\n";
             }
         }
     }
     // Add the user style sheets
     if (is_array($GLOBALS['TL_USER_CSS']) && !empty($GLOBALS['TL_USER_CSS'])) {
         foreach (array_unique($GLOBALS['TL_USER_CSS']) as $stylesheet) {
             list($stylesheet, $media, $mode, $version) = explode('|', $stylesheet);
             if (!$version) {
                 $version = filemtime(TL_ROOT . '/' . $stylesheet);
             }
             if ($mode == 'static') {
                 $objCombiner->add($stylesheet, $version, $media);
             } else {
                 $strScripts .= '<link' . ($blnXhtml ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . static::addStaticUrlTo($stylesheet) . '"' . ($media != '' && $media != 'all' ? ' media="' . $media . '"' : '') . $strTagEnding . "\n";
             }
         }
     }
     // Create the aggregated style sheet
     if ($objCombiner->hasEntries()) {
         $strScripts .= '<link' . ($blnXhtml ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . $objCombiner->getCombinedFile() . '"' . $strTagEnding . "\n";
     }
     $arrReplace['[[TL_CSS]]'] = $strScripts;
     $strScripts = '';
     // Add the internal scripts
     if (is_array($GLOBALS['TL_JAVASCRIPT']) && !empty($GLOBALS['TL_JAVASCRIPT'])) {
         $objCombiner = new \Combiner();
         foreach (array_unique($GLOBALS['TL_JAVASCRIPT']) as $javascript) {
             list($javascript, $mode) = explode('|', $javascript);
             if ($mode == 'static') {
                 $objCombiner->add($javascript, filemtime(TL_ROOT . '/' . $javascript));
             } else {
                 $strScripts .= '<script' . ($blnXhtml ? ' type="text/javascript"' : '') . ' src="' . static::addStaticUrlTo($javascript) . '"></script>' . "\n";
             }
         }
         // Create the aggregated script and add it before the non-static scripts (see #4890)
         if ($objCombiner->hasEntries()) {
             $strScripts = '<script' . ($blnXhtml ? ' type="text/javascript"' : '') . ' src="' . $objCombiner->getCombinedFile() . '"></script>' . "\n" . $strScripts;
         }
     }
     // Add the internal <head> tags
     if (is_array($GLOBALS['TL_HEAD']) && !empty($GLOBALS['TL_HEAD'])) {
         foreach (array_unique($GLOBALS['TL_HEAD']) as $head) {
             $strScripts .= trim($head) . "\n";
         }
     }
     $arrReplace['[[TL_HEAD]]'] = $strScripts;
     return str_replace(array_keys($arrReplace), array_values($arrReplace), $strBuffer);
 }