本文整理汇总了PHP中SPLoader::CssFile方法的典型用法代码示例。如果您正苦于以下问题:PHP SPLoader::CssFile方法的具体用法?PHP SPLoader::CssFile怎么用?PHP SPLoader::CssFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPLoader
的用法示例。
在下文中一共展示了SPLoader::CssFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _cssFiles
private function _cssFiles()
{
if (Sobi::Cfg('cache.include_css_files', false) && !defined('SOBIPRO_ADM')) {
if (count($this->_cache['css'])) {
/* * create the right checksum */
$check = array('section' => Sobi::Section());
foreach ($this->_cache['css'] as $file) {
if (file_exists($file)) {
$check[$file] = filemtime($file);
}
}
$check = md5(serialize($check));
if (!SPFs::exists(SOBI_PATH . "/var/css/{$check}.css")) {
$cssContent = "\n/* Created at: " . date(SPFactory::config()->key('date.log_format', 'D M j G:i:s T Y')) . " */\n";
foreach ($this->_cache['css'] as $file) {
$fName = str_replace(Sobi::FixPath(SOBI_ROOT), null, $file);
$cssContent .= "\n/** \n========\nFile: {$fName}\n========\n*/\n";
$fc = SPFs::read($file);
preg_match_all('/[^\\(]*url\\(([^\\)]*)/', $fc, $matches);
// we have to replace url relative path
$fPath = str_replace(Sobi::FixPath(SOBI_ROOT . '/'), SPFactory::config()->get('live_site'), $file);
$fPath = str_replace('\\', '/', $fPath);
$fPath = explode('/', $fPath);
if (count($matches[1])) {
foreach ($matches[1] as $url) {
// if it is already absolute - skip or from root
if (preg_match('|http(s)?://|', $url) || preg_match('|url\\(["\\s]*/|', $url)) {
continue;
} elseif (strpos($url, '/') === 0) {
continue;
}
$c = preg_match_all('|\\.\\./|', $url, $c) + 1;
$tempFile = array_reverse($fPath);
for ($i = 0; $i < $c; $i++) {
unset($tempFile[$i]);
}
$rPath = Sobi::FixPath(implode('/', array_reverse($tempFile)));
if ($c > 1) {
//WHY?!!
//$realUrl = Sobi::FixPath( str_replace( '..', $rPath, $url ) );
$realUrl = Sobi::FixPath($rPath . '/' . str_replace('../', null, $url));
} else {
$realUrl = Sobi::FixPath($rPath . '/' . $url);
}
$realUrl = str_replace(array('"', "'", ' '), null, $realUrl);
$fc = str_replace($url, $realUrl, $fc);
}
}
// and add to content
$cssContent .= $fc;
}
SPFs::write(SOBI_PATH . "/var/css/{$check}.css", $cssContent);
}
$cfile = SPLoader::CssFile('front.var.css.' . $check, false, true, true);
$this->cssFiles[++$this->count] = "<link rel=\"stylesheet\" href=\"{$cfile}\" type=\"text/css\" />";
}
}
return $this->cssFiles;
}