当前位置: 首页>>代码示例>>PHP>>正文


PHP CMain::__WriteCssCache方法代码示例

本文整理汇总了PHP中CMain::__WriteCssCache方法的典型用法代码示例。如果您正苦于以下问题:PHP CMain::__WriteCssCache方法的具体用法?PHP CMain::__WriteCssCache怎么用?PHP CMain::__WriteCssCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CMain的用法示例。


在下文中一共展示了CMain::__WriteCssCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __OptimizeCssJs


//.........这里部分代码省略.........
                 }
             }
         } else {
             $upOptim = 'NEW';
         }
     }
     if (!file_exists($_SERVER["DOCUMENT_ROOT"] . $optimFName) || $upOptim == 'NEW') {
         $upOptim = 'NEW';
         $arFilesInfo = array();
         $arFilesInfo['CUR_SEL_CNT'] = 0;
         $arFilesInfo['CUR_IE_CNT'] = 0;
         if ($unique) {
             DeleteDirFilesEx($optimPath);
         }
     }
     if ($upOptim != 'NO') {
         $contents = '';
         $arIEContent = array();
         if ($upOptim == 'UP' && file_exists($_SERVER["DOCUMENT_ROOT"] . $optimFName)) {
             foreach ($unsetKey as $key) {
                 unset($arFile[$key], $arSrcFile[$key]);
             }
             $contents .= "\n\n" . file_get_contents($_SERVER["DOCUMENT_ROOT"] . $optimFName);
             if ($type == 'css') {
                 if ($arFilesInfo['CUR_SEL_CNT'] < $maxAddCssSelect) {
                     $css = str_replace('#CNT#', $arFilesInfo['CUR_IE_CNT'], $cssFNameIE);
                     if (file_exists($_SERVER["DOCUMENT_ROOT"] . $css)) {
                         $arIEContent[$arFilesInfo['CUR_IE_CNT']] .= file_get_contents($_SERVER["DOCUMENT_ROOT"] . $css);
                         $arFilesInfo['CUR_SEL_CNT'] = CMain::__GetCssSelectCnt($arIEContent[$arFilesInfo['CUR_IE_CNT']]);
                     }
                 } elseif ($arFilesInfo['CUR_SEL_CNT'] >= $maxAddCssSelect) {
                     $arFilesInfo['CUR_IE_CNT']++;
                     $arFilesInfo['CUR_SEL_CNT'] = 0;
                 }
             }
         }
         foreach ($arFile as $key => $filename) {
             $filename = $_SERVER['DOCUMENT_ROOT'] . $filename;
             $tmp_content = file_get_contents($filename);
             if ($type == 'css') {
                 $f_cnt = CMain::__GetCssSelectCnt($tmp_content);
                 $new_cnt = $f_cnt + $arFilesInfo['CUR_SEL_CNT'];
                 $tmp_content = "\n" . preg_replace('#([;\\s:]+url\\s*\\(\\s*)([^\\)]+)\\)#sie', "'\\1'.CMain::__ReplaceUrlCSS('\\2', '" . AddSlashes($arSrcFile[$key]) . "').')'", $tmp_content) . "\n";
                 if ($new_cnt < $maxCssSelect) {
                     $arFilesInfo['CUR_SEL_CNT'] = $new_cnt;
                     $arIEContent[$arFilesInfo['CUR_IE_CNT']] .= $tmp_content;
                 } else {
                     $arFilesInfo['CUR_SEL_CNT'] = $f_cnt;
                     $arFilesInfo['CUR_IE_CNT']++;
                     $arIEContent[$arFilesInfo['CUR_IE_CNT']] .= $tmp_content;
                 }
                 $contents .= "\n\n" . $tmp_content;
             } else {
                 $contents .= "\n;\n" . $tmp_content;
             }
             if ($unique) {
                 $arFilesInfo['FILES'][$filename] = CMain::__GetCssJsTime($arSrcFile[$key]);
             }
         }
         if (CMain::__WriteCssCache($optimFName, $contents) && $unique) {
             $cacheInfo = '<? $arFilesInfo = array( \'FILES\' => array(';
             foreach ($arFilesInfo['FILES'] as $key => $time) {
                 $cacheInfo .= "'" . EscapePHPString($key) . "' => '" . intval($time) . "',";
             }
             $cacheInfo .= "), 'CUR_SEL_CNT' => '" . $arFilesInfo['CUR_SEL_CNT'] . "', 'CUR_IE_CNT' => '" . $arFilesInfo['CUR_IE_CNT'] . "'); ?>";
             CMain::__WriteCssCache($infoFile, $cacheInfo, false);
         }
         foreach ($arIEContent as $key => $ieContent) {
             $css = str_replace('#CNT#', $key, $cssFNameIE);
             CMain::__WriteCssCache($css, $ieContent);
         }
     }
     if (IsIE() && $type == 'css') {
         for ($i = 0; $i <= $arFilesInfo['CUR_IE_CNT']; $i++) {
             $css = str_replace('#CNT#', $i, $cssFNameIE);
             $res .= '<link href="' . CUtil::GetAdditionalFileURL($css) . '" type="text/css" rel="stylesheet"' . ($bXhtmlStyle ? ' /' : '') . '>' . "\n";
         }
     } else {
         if ($type == 'css') {
             $res .= '<link href="' . CUtil::GetAdditionalFileURL($optimFName) . '" type="text/css" rel="stylesheet"' . ($bXhtmlStyle ? ' /' : '') . '>' . "\n";
             if ($unique && $sufix == 'kernel') {
                 $arF = array_keys($arFilesInfo['FILES']);
                 foreach ($arF as $key => $item) {
                     $arF[$key] = str_replace($_SERVER['DOCUMENT_ROOT'], '', $item);
                 }
                 $res .= '<script type="text/javascript">' . " var arKernelCSS = new Array('" . implode("','", $arF) . "'); </script>";
             }
         } else {
             $res .= '<script type="text/javascript" src="' . CUtil::GetAdditionalFileURL($optimFName) . '"></script>' . "\n";
             if ($unique && $sufix == 'kernel') {
                 $arF = array_keys($arFilesInfo['FILES']);
                 foreach ($arF as $key => $item) {
                     $arF[$key] = str_replace($_SERVER['DOCUMENT_ROOT'], '', $item);
                 }
                 $res .= '<script type="text/javascript">' . " BX.setKernelJS(['" . implode("','", $arF) . "']); </script>";
             }
         }
     }
     return $res;
 }
开发者ID:,项目名称:,代码行数:101,代码来源:

示例2: __OptimizeCss


//.........这里部分代码省略.........

			if($upCSS == 'UP' && file_exists($_SERVER["DOCUMENT_ROOT"].$cssFName))
			{
				foreach($unsetKey as $key)
					unset($cssFile[$key], $cssSrcFile[$key]);

				$contents .= file_get_contents($_SERVER["DOCUMENT_ROOT"].$cssFName);

				if($arCSSInfo['CUR_SEL_CNT'] < $maxAddCssSelect)
				{
					$css = str_replace('#CNT#', $arCSSInfo['CUR_IE_CNT'], $cssFNameIE);
					if(file_exists($_SERVER["DOCUMENT_ROOT"].$css))
					{
						$arIEContent[$arCSSInfo['CUR_IE_CNT']] .= file_get_contents($_SERVER["DOCUMENT_ROOT"].$css);
						$arCSSInfo['CUR_SEL_CNT'] = CMain::__GetCssSelectCnt($arIEContent[$arCSSInfo['CUR_IE_CNT']]);
					}
				}
				elseif($arCSSInfo['CUR_SEL_CNT'] >= $maxAddCssSelect)
				{
					$arCSSInfo['CUR_IE_CNT']++;
					$arCSSInfo['CUR_SEL_CNT'] = 0;
				}
			}

			foreach($cssFile as $key => $filename)
			{
				$filename = $_SERVER['DOCUMENT_ROOT'].$filename;
				$tmp_content = file_get_contents($filename);

				$f_cnt = CMain::__GetCssSelectCnt($tmp_content);
				$new_cnt = $f_cnt + $arCSSInfo['CUR_SEL_CNT'];
				$contents .= $tmp_content = "\n".preg_replace('#([;\s:]+url\s*\(\s*)([^\)]+)\)#sie', "'\\1'.CMain::__ReplaceUrlCSS('\\2', '".AddSlashes($cssSrcFile[$key])."').')'", $tmp_content)."\n";
				if($new_cnt < $maxCssSelect)
				{
					$arCSSInfo['CUR_SEL_CNT'] = $new_cnt;
					$arIEContent[$arCSSInfo['CUR_IE_CNT']] .= $tmp_content;
				}
				else
				{
					$arCSSInfo['CUR_SEL_CNT'] = $f_cnt;
					$arCSSInfo['CUR_IE_CNT']++;
					$arIEContent[$arCSSInfo['CUR_IE_CNT']] .= $tmp_content;
				}

				$arCSSInfo['CSS'][$cssFile[$key]] = CMain::__GetCssJsTime($cssSrcFile[$key]);
			}

			if(CMain::__WriteCssCache($cssFName, $contents))
			{
				$cacheInfo = '<? $arCSSInfo = array( \'CSS\' => array(';

				foreach($arCSSInfo['CSS'] as $css => $time)
					$cacheInfo .= "'".EscapePHPString($css)."' => '".intval($time)."',";

				$cacheInfo .= "), 'CUR_SEL_CNT' => '".$arCSSInfo['CUR_SEL_CNT']."', 'CUR_IE_CNT' => '".$arCSSInfo['CUR_IE_CNT']."', ";
				$cacheInfo .= "'CSS_MD5' => '".$cssMD5."'); ?>";

				CMain::__WriteCssCache($cssInfoFile, $cacheInfo, false);
			}

			foreach($arIEContent as $key => $ieContent)
			{
				$css = str_replace('#CNT#', $key, $cssFNameIE);
				CMain::__WriteCssCache($css, $ieContent);
			}
		}

		if(IsIE())
		{
			for($i = 0; $i <= $arCSSInfo['CUR_IE_CNT']; $i++)
			{
				$css = str_replace('#CNT#', $i, $cssFNameIE);
				$res .= '<link href="'.CUtil::GetAdditionalFileURL($css).'" type="text/css" rel="stylesheet"'.($bXhtmlStyle? ' /':'').'>'."\n";
			}
		}
		else
		{
			$res .= '<link href="'.CUtil::GetAdditionalFileURL($cssFName).'" type="text/css" rel="stylesheet"'.($bXhtmlStyle? ' /':'').'>'."\n";
		}

		if($addTemplateStyle)
		{
			if($cssMD5 != $oldCssMD5 || !file_exists($_SERVER['DOCUMENT_ROOT'].$cssTemplateFName))
			{
				$contents = '';
				foreach($arTemplateCss as $css)
				{
					if(file_exists($_SERVER["DOCUMENT_ROOT"].$css))
					{
						$tmp_content = file_get_contents($_SERVER["DOCUMENT_ROOT"].$css);
						$contents .= preg_replace('#([;\s:]+url\s*\(\s*)([^\)]+)\)#sie', "'\\1'.CMain::__ReplaceUrlCSS('\\2', '".AddSlashes($css)."').')'", $tmp_content);
					}
				}
				CMain::__WriteCssCache($cssTemplateFName, $contents);
			}
			$res .= '<link href="'.$cssTemplateFName.'?'.$cssMD5.'" type="text/css" rel="stylesheet"'.($bXhtmlStyle? ' /':'').'>'."\n";
		}
		unset($content, $arIEContent, $arCSSInfo, $cacheInfo);
		return $res;
	}
开发者ID:nProfessor,项目名称:Mytb,代码行数:101,代码来源:main.php


注:本文中的CMain::__WriteCssCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。