示例#1
0
文件: css.php 项目: sangikumar/IP
 function generateCSS($group = null, $serve = true)
 {
     if (!$group && class_exists('NextendFontsGoogle', false)) {
         $fonts = NextendFontsGoogle::getInstance();
         $fonts->generateFonts();
     }
     $cssfiles = !$group ? $this->_cssFiles : (isset($this->_cssFilesGroup[$group]) ? $this->_cssFilesGroup[$group] : null);
     if (!$cssfiles) {
         return '';
     }
     $cache = !$group ? $this->_cache : $this->_cacheGroup[$group];
     $lesscache = !$group ? $this->_lesscache : $this->_lesscacheGroup[$group];
     if (count($cssfiles)) {
         foreach ($cssfiles as $file) {
             if (is_array($file)) {
                 // LESS
                 $lesscache->addContext($file[1], $file[2]);
             } else {
                 if (substr($file, 0, 4) == 'http') {
                     $this->serveCSSFile($file);
                 } else {
                     if (NextendFilesystem::safefileexists($file)) {
                         if ($this->_cacheenabled) {
                             $cache->addFile($file);
                         } else {
                             $url = NextendFilesystem::pathToAbsoluteURL($file);
                             $this->serveCSSFile($url);
                         }
                     } else {
                         if ($this->_cacheenabled) {
                             $cache->addText($file);
                         } else {
                             $this->addCss($file, $group);
                         }
                     }
                 }
             }
         }
     }
     $filename = null;
     if ($this->_cacheenabled) {
         if ($lesscache) {
             $filename = $lesscache->getCache();
             if ($filename) {
                 $cache->addFile(NextendFilesystem::absoluteURLToPath($filename));
             }
         }
         $filename = $cache->getCache();
         if ($serve && $filename) {
             $this->serveCSSFile($filename);
         }
     } else {
         if ($lesscache) {
             $filename = $lesscache->getCache();
             if ($serve && $filename) {
                 $this->serveCSSFile($filename);
             }
         }
     }
     $this->serveCSS(true, $group);
     return $filename;
 }