Exemple #1
0
 /**
  * Resolves @imports in css files, fetching contents of these files and adding them to the aggregated file
  * 
  * @param string $sContent      
  * @return string
  */
 protected function replaceImports($sContent)
 {
     if ($this->params->get('pro_replaceImports', '1')) {
         $oCssParser = $this->oCssParser;
         $u = $oCssParser->u;
         $sImportFileContents = preg_replace_callback("#(?>@?[^@'\"/]*+(?:{$u}|/|\\()?)*?\\K(?:@import url\\((?=[^\\)]+\\.(?:css|php))([^\\)]+)\\)([^;]*);|\\K\$)#", array(__CLASS__, 'getImportFileContents'), $sContent);
         if (is_null($sImportFileContents)) {
             JchOptimizeLogger::log(JchPlatformUtility::translate('Failed getting @import file contents'), $this->params);
             return $sContent;
         }
         $sContent = $sImportFileContents;
     } else {
         $sContent = parent::replaceImports($sContent);
     }
     return $sContent;
 }
Exemple #2
0
 /**
  * Resolves @imports in css files, fetching contents of these files and adding them to the aggregated file
  * 
  * @param string $sContent      
  * @return string
  */
 protected function replaceImports($sContent)
 {
     if ($this->params->get('pro_replaceImports', '1')) {
         $oCssParser = $this->oCssParser;
         $u = $oCssParser->u;
         $sImportFileContents = preg_replace_callback("#(?>@?[^@'\"/]*+(?:{$u}|/|\\()?)*?\\K(?:@import\\s*+(?:url\\()?['\"]?([^\\)'\"]+)['\"]?(?:\\))?\\s*+([^;]*);|\\K\$)#", array(__CLASS__, 'getImportFileContents'), $sContent);
         if (is_null($sImportFileContents)) {
             JchOptimizeLogger::log('The plugin failed to get the contents of the file that was imported into the document by the "@import" rule', $this->params);
             return $sContent;
         }
         $sContent = $sImportFileContents;
     } else {
         $sContent = parent::replaceImports($sContent);
     }
     return $sContent;
 }