Want more features on Pastebin? Sign Up, it's FREE!
Guest

getMergedCssUrl

By: a guest on Feb 24th, 2012  |  syntax: PHP  |  size: 1.04 KB  |  views: 65  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.      public function getMergedCssUrl($files) {
  2.      
  3.         $tstamp = $this->getYoungestFile($files);
  4.        
  5.         // secure or unsecure
  6.         $isSecure = Mage::app()->getRequest()->isSecure();
  7.         $mergerDir = $isSecure ? 'css_secure' : 'css';
  8.         $targetDir = $this->_initMergerDir($mergerDir);
  9.         if (!$targetDir) {
  10.             return '';
  11.         }
  12.  
  13.         // base hostname & port
  14.         $baseMediaUrl = Mage::getBaseUrl('media', $isSecure);
  15.         $hostname = parse_url($baseMediaUrl, PHP_URL_HOST);
  16.         $port = parse_url($baseMediaUrl, PHP_URL_PORT);
  17.         if (false === $port) {
  18.             $port = $isSecure ? 443 : 80;
  19.         }
  20.  
  21.         // merge into target file
  22.         $targetFilename = md5(implode(',', $files) . "|{$hostname}|{$port}") . '.' . $tstamp . '.css';
  23.         if ($this->_mergeFiles($files, $targetDir . DS . $targetFilename, false, array($this, 'beforeMergeCss'), 'css')) {
  24.             return $baseMediaUrl . $mergerDir . '/' . $targetFilename;
  25.         }
  26.         return '';
  27.      }
clone this paste RAW Paste Data