本文整理汇总了PHP中CMain::__OptimizeCss方法的典型用法代码示例。如果您正苦于以下问题:PHP CMain::__OptimizeCss方法的具体用法?PHP CMain::__OptimizeCss怎么用?PHP CMain::__OptimizeCss使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMain
的用法示例。
在下文中一共展示了CMain::__OptimizeCss方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetCSS
//.........这里部分代码省略.........
$site_template = '.default';
$path = BX_PERSONAL_ROOT."/templates/.default";
$arTemplateCss[] = $path."/styles.css";
$arTemplateCss[] = $path."/template_styles.css";
}
if($optimizeCSS == 'Y')
{
$cssFile = array();
$cssSrcFile = array();
$cssMD5 = '';
$oldCssMD5 = '';
}
else
{
$arCSS[] = $arTemplateCss[0];
$arCSS[] = $arTemplateCss[1];
}
$arCSS = array_unique($arCSS);
$isIE = IsIE();
$cnt = 0;
$res_content = '';
$ruleCount = 0;
foreach($arCSS as $css_path)
{
$bExternalLink = (strncmp($css_path, 'http://', 7) == 0 || strncmp($css_path, 'https://', 8) == 0);
if(!$bExternalLink)
{
if(($p = strpos($css_path, "?"))>0)
$css_file = substr($css_path, 0, $p);
else
$css_file = $css_path;
$filename = $_SERVER["DOCUMENT_ROOT"].$css_file;
}
$bLink = ($bExternalLink || substr($css_file, -4, 4) != '.css');
$addCSS = (strncmp($css_path, '/bitrix/themes/', 15) != 0);
if((($cnt < $cMaxStylesCnt || ($optimizeCSS == 'Y' && $addCSS) || !$isIE) || $bLink) && strncmp($css_path, '/bitrix/modules/', 16) != 0)
{
if($bExternalLink || file_exists($filename))
{
if($res_content != '')
{
$res .= '<style type="text/css">'."\n".$res_content."\n</style>\n";
$res_content = '';
}
if(!$bExternalLink && strpos($css_path, '?') === false)
$css_path = CUtil::GetAdditionalFileURL($css_path, true);
if($optimizeCSS == 'Y' && $addCSS)
{
$cssSrcFile[] = $css_path;
$cssFile[] = $css_file;
}
else
{
$res .= '<link href="'.$css_path.'" type="text/css" rel="stylesheet"'.($bXhtmlStyle? ' /':'').'>'."\n";
}
$cnt++;
}
}
elseif(!$bLink && file_exists($filename) && filesize($filename) > 0)
{
$contents = file_get_contents($filename);
if($contents != '')
{
$contents = preg_replace('#([;\s:]+url\s*\(\s*)([^\)]+)\)#sie', "'\\1'.CMain::__ReplaceUrlCSS('\\2', '".AddSlashes($css_path)."').')'", $contents);
if($isIE)
{
$c = CMain::__GetCssSelectCnt($contents);
$ruleCount += $c;
if($ruleCount > 4000)
{
$ruleCount = $c;
if($res_content <> '')
$res_content .= "</style>\n<style type=\"text/css\">";
}
}
$res_content .= "\n".$contents."\n";
}
}
}
if($optimizeCSS == 'Y' && $cnt > 0)
{
$res .= CMain::__OptimizeCss($cssFile, $cssSrcFile, $site_template, $addTemplateStyle, $arTemplateCss, $bXhtmlStyle);
unset($cssFile, $cssSrcFile, $addTemplateStyle);
}
if($res_content!='')
$res .= '<style type="text/css">'."\n".$res_content."\n</style>\n";
return $res;
}