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


PHP Phpfox::getCdnPath方法代码示例

本文整理汇总了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 . '\')';
 }
开发者ID:lev1976g,项目名称:core,代码行数:14,代码来源:process.class.php

示例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;
 }
开发者ID:Lovinity,项目名称:EQM,代码行数:78,代码来源:minimize.class.php


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