/**
  * Method to build the CSS / JavaScript cache
  *
  * @param string $type
  * @param array  $matches
  *
  * @return string
  */
 private function buildCacheUrl($type, $list = array())
 {
     // Check for the cache-path
     $tmp_path = JPATH_SITE . '/cache/plg_scriptmerge/';
     if (@is_dir($tmp_path) == false) {
         jimport('joomla.filesystem.folder');
         JFolder::create($tmp_path);
     }
     if (!empty($list)) {
         $cacheId = $this->getHashFromList($list);
         $cacheFile = $cacheId . '.' . $type;
         $cachePath = $tmp_path . '/' . $cacheFile;
         $cacheExpireFile = $cachePath . '_expire';
         $hasExpired = false;
         if (ScriptMergeHelper::hasExpired($cacheExpireFile, $cachePath)) {
             $hasExpired = true;
         }
         if (file_exists($cachePath)) {
             foreach ($list as $file) {
                 if (file_exists($file['file']) == false) {
                     $hasExpired = true;
                     break;
                 }
                 if (filemtime($file['file'] > filemtime($cachePath))) {
                     $hasExpired = true;
                     break;
                 }
             }
         } else {
             $hasExpired = true;
         }
         // Check the cache
         if ($hasExpired) {
             $buffer = null;
             foreach ($list as $file) {
                 if (isset($file['file'])) {
                     // CSS-code
                     if ($type == 'css') {
                         $buffer .= ScriptMergeHelper::getCssContent($file['file']);
                         // JS-code
                     } else {
                         $buffer .= ScriptMergeHelper::getJsContent($file['file']);
                     }
                 }
             }
             // Clean up CSS-code
             if ($type == 'css') {
                 $buffer = ScriptMergeHelper::cleanCssContent($buffer);
                 // Clean up JS-code
             } else {
                 $buffer = ScriptMergeHelper::cleanJsContent($buffer);
             }
             // Write this buffer to a file
             jimport('joomla.filesystem.file');
             JFile::write($cachePath, $buffer);
             // Create a minified version of this file
             $this->createMinified($type, $cachePath);
             // Set the cache parameter
             $this->createCacheExpireFile($cacheExpireFile);
         }
     }
     // Construct the minified version
     if ($type == 'js') {
         $minifiedFile = preg_replace('/\\.js$/', '.min.js', $cacheFile);
     } else {
         $minifiedFile = preg_replace('/\\.css$/', '.min.css', $cacheFile);
     }
     // Return the minified version if it exists
     if (file_exists(JPATH_SITE . '/cache/plg_scriptmerge/' . $minifiedFile)) {
         $url = JURI::root() . 'cache/plg_scriptmerge/' . $minifiedFile;
         // Return the cache-file itself
     } else {
         $url = JURI::root() . 'cache/plg_scriptmerge/' . $cacheFile;
     }
     // Domainname sharding
     $domain = $type == 'js' ? $this->params->get('js_domain') : $this->params->get('css_domain');
     $url = $this->replaceUrlDomain($url, $domain);
     // Protocol change
     if (JURI::getInstance()->isSSL()) {
         $url = str_replace('http://', 'https://', $url);
     } else {
         $url = str_replace('https://', 'http://', $url);
     }
     return $url;
 }
        if ($type == 'css') {
            if (!preg_match('/\\.css$/', $file)) {
                continue;
            }
            $buffer .= $helper->getCssContent($file);
        } else {
            if (!preg_match('/\\.js$/', $file)) {
                continue;
            }
            $buffer .= $helper->getJsContent($file);
        }
    }
}
// Clean up CSS-code
if ($type == 'css') {
    $buffer = ScriptMergeHelper::cleanCssContent($buffer);
    // Clean up JS-code
} else {
    $buffer = ScriptMergeHelper::cleanJsContent($buffer);
}
// Handle GZIP support
$compression = false;
if (function_exists('gzencode') && ScriptMergeHelper::getParams()->get('force_gzip', 0) == 1) {
    $gzip = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
    $deflate = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate');
    $compression = $gzip ? 'gzip' : ($deflate ? 'deflate' : false);
    $buffer = gzencode($buffer, 9, $gzip ? FORCE_GZIP : FORCE_DEFLATE);
}
// Send HTTP-headers
ScriptMergeHelper::sendHttpHeaders($buffer, $helper->getParams(), $compression);
// Print the buffer