コード例 #1
0
ファイル: StyleSheet.php プロジェクト: ppuschmann/icingaweb2
 public static function send($minified = false)
 {
     self::checkPhp();
     $app = Icinga::app();
     $basedir = $app->getBootstrapDirectory();
     foreach (self::$lessFiles as $file) {
         $lessFiles[] = $basedir . '/' . $file;
     }
     $files = $lessFiles;
     foreach ($app->getModuleManager()->getLoadedModules() as $name => $module) {
         if ($module->hasCss()) {
             foreach ($module->getCssFiles() as $path) {
                 if (file_exists($path)) {
                     $files[] = $path;
                 }
             }
         }
     }
     if ($etag = FileCache::etagMatchesFiles($files)) {
         header("HTTP/1.1 304 Not Modified");
         return;
     } else {
         $etag = FileCache::etagForFiles($files);
     }
     header('Cache-Control: public');
     header('ETag: "' . $etag . '"');
     header('Content-Type: text/css');
     $min = $minified ? '.min' : '';
     $cacheFile = 'icinga-' . $etag . $min . '.css';
     $cache = FileCache::instance();
     if ($cache->has($cacheFile)) {
         $cache->send($cacheFile);
         return;
     }
     $less = new LessCompiler();
     $less->disableExtendedImport();
     foreach ($lessFiles as $file) {
         $less->addFile($file);
     }
     $less->addLoadedModules();
     if ($minified) {
         $less->compress();
     }
     $out = self::fixModuleLayoutCss($less->compile());
     $cache->store($cacheFile, $out);
     echo $out;
 }
コード例 #2
0
 public static function send($minified = false)
 {
     header('Content-Type: text/css');
     $min = $minified ? '.min' : '';
     $cacheFile = '/tmp/cache_icinga' . $min . '.css';
     if (file_exists($cacheFile)) {
         readfile($cacheFile);
         exit;
     }
     $less = new LessCompiler();
     $basedir = Icinga::app()->getBootstrapDirecory();
     foreach (self::$lessFiles as $file) {
         $less->addFile($basedir . '/' . $file);
     }
     $less->addLoadedModules();
     if ($minified) {
         $less->compress();
     }
     $out = $less->compile();
     // Not yet, this is for tests only. Waiting for Icinga\Web\Cache
     // file_put_contents($cacheFile, $out);
     echo $out;
 }