本文整理汇总了PHP中X2Html::css方法的典型用法代码示例。如果您正苦于以下问题:PHP X2Html::css方法的具体用法?PHP X2Html::css怎么用?PHP X2Html::css使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X2Html
的用法示例。
在下文中一共展示了X2Html::css方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderHead
/**
* 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";
}
}
//.........这里部分代码省略.........
示例2: renderHead
/**
* 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;
}
}
}