本文整理汇总了PHP中Phpfox::getCdnPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Phpfox::getCdnPath方法的具体用法?PHP Phpfox::getCdnPath怎么用?PHP Phpfox::getCdnPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phpfox
的用法示例。
在下文中一共展示了Phpfox::getCdnPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replaceCdnImages
public function replaceCdnImages($aMatches)
{
$sImage = trim(trim($aMatches[1], '"'), "'");
$sActualFile = rtrim($this->_sStyleDir, '/') . str_replace('..', '', $sImage);
if (file_exists($sActualFile)) {
$aParts = explode('upload/', $this->_sStyleDir);
$sUrl = Phpfox::getParam('core.rackspace_url') . $aParts[1];
Phpfox::getLib('cdn')->put($sActualFile, $aParts[1] . str_replace('..', '', $sImage));
} else {
$sUrl = Phpfox::getCdnPath() . 'theme/frontend/default/style/default';
}
$sImage = str_replace('..', $sUrl, $sImage);
return 'url(\'' . $sImage . '\')';
}
示例2: minify
public function minify($aFiles, $sVersion, $bIsJS = true, $bDoInit = false, $bReturn = false, $bReplaceUrl = true)
{
static $oFormat = null;
if (!isset($oFormat)) {
$oFormat = Phpfox::getLib('parse.format');
}
if (!is_array($aFiles)) {
$aFiles = array($aFiles);
}
$sHash = md5(implode($aFiles) . $sVersion);
$sNameMd5 = md5(implode($aFiles) . $sVersion) . ($bIsJS ? '.js' : '.css');
$sFilePath = PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $sNameMd5;
$sUrl = Phpfox::getParam('core.path') . 'file/static/' . $sNameMd5;
$bExists = false;
if (Phpfox::getParam('core.allow_cdn') && Phpfox::getParam('core.push_jscss_to_cdn')) {
$sCacheId = Phpfox::getLib('cache')->set(array('jscss', $sHash));
if (Phpfox::getLib('cache')->get($sCacheId)) {
$bExists = true;
}
} else {
$bExists = file_exists($sFilePath);
}
if ($bExists) {
if (Phpfox::getParam('core.allow_cdn') && Phpfox::getParam('core.push_jscss_to_cdn')) {
$sUrl = Phpfox::getLib('cdn')->getUrl($sUrl);
}
} else {
$sMinified = '';
if ($bIsJS) {
foreach ($aFiles as $sFile) {
$sOriginal = file_get_contents(PHPFOX_DIR . $sFile);
$oJsMin = new JSMin($sOriginal);
$sCompressed = $oJsMin->min();
// $sCompressed = $oFormat->helpJS($sCompressed);
$sMinified .= "\n /* {$sFile} */" . $sCompressed;
}
} else {
$sHomeThemePath = Phpfox::getParam('core.force_https_secure_pages') && Phpfox::getParam('core.force_secure_site') ? 'https://' : 'http://';
$sHomeThemePath .= Phpfox::getParam('core.host') . Phpfox::getParam('core.folder') . 'theme';
foreach ($aFiles as $sFile) {
$sOriginal = file_get_contents(PHPFOX_DIR . $sFile);
$sCompressed = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), ' ', $sOriginal);
$sPathTo = substr($sFile, 0, strrpos($sFile, '/'));
$sPathTo = substr($sPathTo, 0, strrpos($sPathTo, '/'));
if (Phpfox::getParam('core.allow_cdn') && Phpfox::getParam('core.push_jscss_to_cdn') && defined('PHPFOX_IS_HOSTED_SCRIPT')) {
$sCompressed = str_replace('url(\'..', 'url(\'' . Phpfox::getCdnPath() . '' . $sPathTo, $sCompressed, $iCount);
$sCompressed = str_replace('url("..', 'url("' . Phpfox::getCdnPath() . '' . $sPathTo, $sCompressed, $iCount);
$sCompressed = str_replace('url(..', 'url(' . Phpfox::getCdnPath() . '' . $sPathTo, $sCompressed, $iCount);
} else {
if ($bReplaceUrl == true) {
$sCompressed = str_replace('url(\'..', 'url(\'../../' . $sPathTo, $sCompressed, $iCount);
$sCompressed = str_replace('url("..', 'url("../../' . $sPathTo, $sCompressed, $iCount);
$sCompressed = str_replace('url(..', 'url(../../' . $sPathTo, $sCompressed, $iCount);
$sCompressed = str_replace('../../theme', '' . $sHomeThemePath, $sCompressed, $iCount);
}
}
if ($bReplaceUrl == true) {
$sCompressed = str_replace('css/', 'image/', $sCompressed);
}
$sMinified .= $sCompressed;
}
}
if ($bReturn == true) {
return $sMinified;
}
if ($bIsJS && $bDoInit) {
$sMinified .= "\n" . '$Core.init();';
}
file_put_contents($sFilePath, $sMinified);
// if cdn enabled put it in cdn as well here
if (Phpfox::getParam('core.allow_cdn') && Phpfox::getParam('core.push_jscss_to_cdn')) {
Phpfox::getLib('cache')->save($sCacheId, '1');
Phpfox::getLib('cdn')->put($sFilePath);
$sUrl = Phpfox::getLib('cdn')->getUrl($sUrl);
}
}
return $sUrl . $sVersion;
}