本文整理汇总了PHP中CMain::__GetCssSelectCnt方法的典型用法代码示例。如果您正苦于以下问题:PHP CMain::__GetCssSelectCnt方法的具体用法?PHP CMain::__GetCssSelectCnt怎么用?PHP CMain::__GetCssSelectCnt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMain
的用法示例。
在下文中一共展示了CMain::__GetCssSelectCnt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __OptimizeCssJs
/**
* Optimize css and js files
*
* @param array $arFile - Full path for a source css or js file
* @param array $arSrcFile - Full path for a source css or js file with timestamp
* @param string $site_template - Site template name
* @param bool $unique - Create unique file for all site in a current template
* @param string $sufix - Some sufix for css or js files
* @param string $type - file type, css or js
* @param bool $bXhtmlStyle - Xhtml or not
* @return string - String for including css or js in html page
*/
private function __OptimizeCssJs($arFile = array(), $arSrcFile = array(), $site_template, $unique = false, $sufix = 'default', $type = 'css', $bXhtmlStyle)
{
if (!is_array($arFile) || count($arFile) < 1) {
return '';
}
if (!is_array($arSrcFile) || count($arSrcFile) < 1) {
return '';
}
$res = '';
$fileMTime = '';
$upOptim = 'NO';
$unsetKey = array();
$arFilesInfo = array();
$arFilesInfo['CUR_SEL_CNT'] = 0;
$arFilesInfo['CUR_IE_CNT'] = 0;
$sufix = trim($sufix);
$sufix = strlen($sufix) < 1 ? 'default' : $sufix;
foreach ($arSrcFile as $key => $filePath) {
if (!$bExternalLink && strpos($filePath, '?') === false) {
$filePath = CUtil::GetAdditionalFileURL($filePath);
$arSrcFile[$key] = $filePath;
}
}
if (!$unique) {
$fileMTime = '_' . md5(implode('_', $arSrcFile));
$sufix .= '_' . md5(implode('_', $arFile));
}
$type = $type == 'js' ? 'js' : 'css';
$optimPath = BX_PERSONAL_ROOT . '/cache/' . $type . '/' . SITE_ID . '/' . $site_template . '/' . $sufix . '/';
$infoFile = BX_PERSONAL_ROOT . '/managed_cache/' . $GLOBALS['DB']->type . '/' . $type . '/' . SITE_ID . '/' . $site_template . '/' . $sufix . '/info.php';
if ($type == 'css') {
$maxAddCssSelect = 3950;
$maxCssSelect = 4000;
$optimFName = $optimPath . 'styles' . $fileMTime . '.css';
$cssFNameIE = $optimPath . 'styles' . $fileMTime . '#CNT#.css';
} else {
$optimFName = $optimPath . $sufix . $fileMTime . '.js';
}
if ($unique && file_exists($_SERVER["DOCUMENT_ROOT"] . $optimFName)) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $infoFile)) {
include $_SERVER['DOCUMENT_ROOT'] . $infoFile;
foreach ($arFile as $key => $fp) {
$fp = $_SERVER['DOCUMENT_ROOT'] . $fp;
if (array_key_exists($fp, $arFilesInfo['FILES'])) {
if ($_SERVER['DOCUMENT_ROOT'] . $arSrcFile[$key] != $fp . '?' . $arFilesInfo['FILES'][$fp]) {
$upOptim = 'NEW';
break;
} else {
$unsetKey[] = $key;
}
} else {
$upOptim = 'UP';
}
}
} 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;
}
}
}
//.........这里部分代码省略.........
示例2: __OptimizeCss
function __OptimizeCss($cssFile, $cssSrcFile, $site_template, $addTemplateStyle, $arTemplateCss, $bXhtmlStyle)
{
$cssOptPath = BX_PERSONAL_ROOT."/cache/css/".SITE_ID.'/'.$site_template.'/';
$cssFName = $cssOptPath.'styles.css';
$cssFNameIE = $cssOptPath.'styles#CNT#.css';
$cssTemplateFName = $cssOptPath.'template_styles.css';
$cssInfoFile = BX_PERSONAL_ROOT."/managed_cache/".$GLOBALS['DB']->type.'/css/'.SITE_ID.'/'.$site_template.'_styles.php';
$res = '';
$upCSS = 'NO';
$unsetKey = array();
$arCSSInfo = array();
$arCSSInfo['CUR_SEL_CNT'] = 0;
$arCSSInfo['CUR_IE_CNT'] = 0;
$arCSSInfo['CSS_MD5'] = 0;
$maxAddCssSelect = 3950;
$maxCssSelect = 4000;
if($addTemplateStyle)
{
foreach($arTemplateCss as $css_path)
{
if(!$bExternalLink && strpos($css_path, '?') === false)
$css_path = CUtil::GetAdditionalFileURL($css_path);
$cssMD5 .= $css_path;
}
$cssMD5 = md5($cssMD5);
}
if(file_exists($_SERVER['DOCUMENT_ROOT'].$cssInfoFile))
{
include($_SERVER['DOCUMENT_ROOT'].$cssInfoFile);
$oldCssMD5 = $arCSSInfo['CSS_MD5'];
foreach($cssFile as $key => $css)
{
if(array_key_exists($css, $arCSSInfo['CSS']))
{
if($cssSrcFile[$key] != $css.'?'.$arCSSInfo['CSS'][$css])
{
$upCSS = 'NEW';
break;
}
else
{
$unsetKey[] = $key;
}
}
else
{
$upCSS = 'UP';
}
}
}
else
{
$upCSS = 'NEW';
}
if(!file_exists($_SERVER["DOCUMENT_ROOT"].$cssFName) || $upCSS == 'NEW')
{
$upCSS = 'NEW';
$arCSSInfo = array();
$arCSSInfo['CUR_SEL_CNT'] = 0;
$arCSSInfo['CUR_IE_CNT'] = 0;
$arCSSInfo['CSS_MD5'] = 0;
DeleteDirFilesEx($cssOptPath);
}
if($upCSS != 'NO')
{
$contents = '';
$arIEContent = array();
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);
//.........这里部分代码省略.........