/** * Inserts the scripts in the head section. * @param string $output the output to be inserted with scripts. * This method is Copyright (c) 2008-2014 by Yii Software LLC * http://www.yiiframework.com/license/ */ public function renderHead(&$output) { parent::renderHead($output); $html = ''; foreach ($this->metaTags as $meta) { $html .= CHtml::metaTag($meta['content'], null, null, $meta) . "\n"; } foreach ($this->linkTags as $link) { $html .= CHtml::linkTag(null, null, null, null, $link) . "\n"; } /* x2modstart */ if (Auxlib::getIEVer() < 10) { // group registered css files using import statements $mergedCss = ''; $mediaType = null; foreach ($this->cssFiles as $url => $media) { if ($mediaType === null) { $mediaType = $media; } $text = '@import url("' . $url . '");'; if ($media !== $mediaType) { $html .= CHtml::css($mergedCss, $mediaType) . "\n"; $mergedCss = ''; $mediaType = $media; } $mergedCss .= "\n" . $text; } if ($mergedCss) { $html .= CHtml::css($mergedCss, $mediaType) . "\n"; } } else { foreach ($this->cssFiles as $url => $media) { $html .= CHtml::cssFile($url, $media) . "\n"; } } if (Auxlib::getIEVer() < 10) { // merge inline css $mergedCss = ''; $mediaType = null; foreach ($this->css as $css) { $text = $css[0]; $media = $css[1]; if (is_array($text) && isset($text['text'])) { $text = $text['text']; } if ($mediaType === null) { $mediaType = $media; } if (preg_match('/@import/', $text)) { if ($mergedCss) { $html .= CHtml::css($mergedCss, $mediaType) . "\n"; } $mergedCss = ''; $mediaType = null; $html .= CHtml::css($text, $media) . "\n"; continue; } if ($media !== $mediaType) { $html .= CHtml::css($mergedCss, $mediaType) . "\n"; $mergedCss = ''; $mediaType = $media; } $mergedCss .= "\n" . $text; } if ($mergedCss) { $html .= CHtml::css($mergedCss, $mediaType) . "\n"; } } else { foreach ($this->css as $css) { $text = $css[0]; $media = $css[1]; if (is_array($text) && isset($text['text']) && isset($text['htmlOptions'])) { // special case for css registered with html options $html .= X2Html::css($text['text'], $media, $text['htmlOptions']); continue; } $html .= CHtml::css($text, $media) . "\n"; } } // prevent global css from being applied if this is an admin or guest request if (!Yii::app()->controller instanceof AdminController && !Yii::app()->user->isGuest) { $globalCssUrl = GlobalCSSFormModel::getGlobalCssUrl(); $html .= CHtml::cssFile($globalCssUrl . $this->getCacheBusterSuffix($globalCssUrl)) . "\n"; } /* x2modend */ if ($this->enableJavaScript) { if (isset($this->scriptFiles[self::POS_HEAD])) { foreach ($this->scriptFiles[self::POS_HEAD] as $scriptFileValueUrl => $scriptFileValue) { if (is_array($scriptFileValue)) { $html .= CHtml::scriptFile($scriptFileValueUrl, $scriptFileValue) . "\n"; } else { $html .= CHtml::scriptFile($scriptFileValueUrl) . "\n"; } } } if (isset($this->scripts[self::POS_HEAD])) { $html .= $this->renderScriptBatch($this->scripts[self::POS_HEAD]); } } if ($html !== '') { $count = 0; $output = preg_replace('/(<title\\b[^>]*>|<\\/head\\s*>)/is', '<###head###>$1', $output, 1, $count); if ($count) { $output = str_replace('<###head###>', $html, $output); } else { $output = $html . $output; } } }
/** * Inserts the scripts in the head section. * @param string $output the output to be inserted with scripts. * This method is Copyright (c) 2008-2014 by Yii Software LLC * http://www.yiiframework.com/license/ */ public function renderHead(&$output) { parent::renderHead($output); $html = ''; foreach ($this->metaTags as $meta) { $html .= CHtml::metaTag($meta['content'], null, null, $meta) . "\n"; } foreach ($this->linkTags as $link) { $html .= CHtml::linkTag(null, null, null, null, $link) . "\n"; } foreach ($this->cssFiles as $url => $media) { $html .= CHtml::cssFile($url, $media) . "\n"; } /* x2modstart */ if (Auxlib::getIEVer() < 10) { // merge inline css $mergedCss = array(); $mediaType = null; foreach ($this->css as $css) { $text = $css[0]; if (is_array($text) && isset($text['text'])) { $text = $text['text']; } if (preg_match('/@import/', $text)) { $html .= CHtml::css($text, $css[1]) . "\n"; continue; } if ($mediaType === null) { $mediaType = $css[1]; } if ($css[1] === $mediaType) { if (!isset($mergedCss[$mediaType])) { $mergedCss[$mediaType] = ''; } $mergedCss[$mediaType] .= "\n" . $text; } } foreach ($mergedCss as $type => $css) { $html .= CHtml::css($css, $type) . "\n"; } } else { foreach ($this->css as $css) { $text = $css[0]; $media = $css[1]; if (is_array($text) && isset($text['text']) && isset($text['htmlOptions'])) { // special case for css registered with html options $html .= X2Html::css($text['text'], $media, $text['htmlOptions']); continue; } $html .= CHtml::css($text, $media) . "\n"; } } /* x2modend */ if ($this->enableJavaScript) { if (isset($this->scriptFiles[self::POS_HEAD])) { foreach ($this->scriptFiles[self::POS_HEAD] as $scriptFileValueUrl => $scriptFileValue) { if (is_array($scriptFileValue)) { $html .= CHtml::scriptFile($scriptFileValueUrl, $scriptFileValue) . "\n"; } else { $html .= CHtml::scriptFile($scriptFileValueUrl) . "\n"; } } } if (isset($this->scripts[self::POS_HEAD])) { $html .= $this->renderScriptBatch($this->scripts[self::POS_HEAD]); } } if ($html !== '') { $count = 0; $output = preg_replace('/(<title\\b[^>]*>|<\\/head\\s*>)/is', '<###head###>$1', $output, 1, $count); if ($count) { $output = str_replace('<###head###>', $html, $output); } else { $output = $html . $output; } } }