Exemplo n.º 1
0
 /**
  * Renders the CSS
  *
  * @param $output What to display
  * @return void
  */
 public static function render($output, $level = false)
 {
     if ($level and ini_get('output_handler') !== 'ob_gzhandler' and (int) ini_get('zlib.output_compression') === 0) {
         if ($level < 1 or $level > 9) {
             # Normalize the level to be an integer between 1 and 9. This
             # step must be done to prevent gzencode from triggering an error
             $level = max(1, min($level, 9));
         }
         if (stripos(@$_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) {
             $compress = 'gzip';
         } elseif (stripos(@$_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== FALSE) {
             $compress = 'deflate';
         }
     }
     if (isset($compress) and $level > 0) {
         switch ($compress) {
             case 'gzip':
                 # Compress output using gzip
                 $output = gzencode($output, $level);
                 break;
             case 'deflate':
                 # Compress output using zlib (HTTP deflate)
                 $output = gzdeflate($output, $level);
                 break;
         }
         # This header must be sent with compressed content to prevent browser caches from breaking
         Scaffold::header('Vary', 'Accept-Encoding');
         # Send the content encoding header
         Scaffold::header('Content-Encoding', $compress);
     }
     # Send the headers
     Scaffold::send_headers();
     echo $output;
     exit;
 }