コード例 #1
0
ファイル: views.php プロジェクト: gzachos/elgg_ellak
/**
 * Minifies simplecache CSS and JS views by handling the "simplecache:generate" hook
 *
 * @param string $hook    The name of the hook
 * @param string $type    View type (css, js, or unknown)
 * @param string $content Content of the view
 * @param array  $params  Array of parameters
 *
 * @return string|null View content minified (if css/js type)
 * @access private
 */
function _elgg_views_minify($hook, $type, $content, $params)
{
    static $autoload_registered;
    if (!$autoload_registered) {
        $path = elgg_get_root_path() . 'vendors/minify/lib';
        elgg_get_class_loader()->addFallback($path);
        $autoload_registered = true;
    }
    if (preg_match('~[\\.-]min\\.~', $params['view'])) {
        // bypass minification
        return;
    }
    if ($type == 'js') {
        if (elgg_get_config('simplecache_minify_js')) {
            return JSMin::minify($content);
        }
    } elseif ($type == 'css') {
        if (elgg_get_config('simplecache_minify_css')) {
            $cssmin = new CSSMin();
            return $cssmin->run($content);
        }
    }
}
コード例 #2
0
ファイル: router.php プロジェクト: kalle0045/BigTree-CMS
                 }
             }
             $data .= $style . "\n";
         }
     }
     // Should only loop once, not with every file
     if (is_array($bigtree["config"]["css"]["vars"])) {
         foreach ($bigtree["config"]["css"]["vars"] as $key => $val) {
             $data = str_replace('$' . $key, $val, $data);
         }
     }
     // Replace roots
     $data = str_replace(array('$www_root', 'www_root/', '$static_root', 'static_root/', '$admin_root/', 'admin_root/'), array(WWW_ROOT, WWW_ROOT, STATIC_ROOT, STATIC_ROOT, ADMIN_ROOT, ADMIN_ROOT), $data);
     if ($bigtree["config"]["css"]["minify"]) {
         $minifier = new CSSMin();
         $data = $minifier->run($data);
     }
     BigTree::putFile($cfile, $data);
     header("Content-type: text/css");
     die($data);
 } else {
     // Added a line to .htaccess to hopefully give us IF_MODIFIED_SINCE when running as CGI
     if (function_exists("apache_request_headers")) {
         $headers = apache_request_headers();
         $ims = $headers["If-Modified-Since"];
     } else {
         $ims = $_SERVER["HTTP_IF_MODIFIED_SINCE"];
     }
     if (!$ims || strtotime($ims) != $last_modified) {
         header("Content-type: text/css");
         header("Last-Modified: " . gmdate("D, d M Y H:i:s", $last_modified) . ' GMT', true, 200);
コード例 #3
0
ファイル: CSSmin.php プロジェクト: Dirichi/Ushahidi_Web
 /**
  * Minify CSS
  *
  * @uses __construct()
  * @uses min()
  * @param string $js Javascript to be minified
  * @return string
  */
 public static function go($css)
 {
     $cssmin = new CSSMin();
     return $cssmin->run($css);
 }
コード例 #4
0
    if ($sapi_name == 'cgi' or $sapi_name == 'cgi-fcgi') {
        header('Status: 304 Not Modified');
    } else {
        header('HTTP/1.1 304 Not Modified');
    }
    // remove the content-type and X-Powered headers to emulate a 304 Not Modified response as close as possible
    header('Content-Type:');
    header('X-Powered-By:');
    exit;
}
$cssfiles = array();
$cssfiles = explode(",", $_REQUEST['file']);
$output = '';
if ($cssfiles) {
    foreach ($cssfiles as $cssfile) {
        if (file_exists("css/{$cssfile}")) {
            $output .= file_get_contents("css/{$cssfile}") . "\r\n";
        }
    }
    include 'CSSMin.php';
    $CSSMin = new CSSMin();
    $returntext = $CSSMin->run($output);
    $output = $returntext;
}
header('Content-Type: text/css');
header('Cache-control: max-age=31536000, private');
header('Expires: ' . gmdate("D, d M Y H:i:s", time() + 31536000) . ' GMT');
header('Pragma:');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $style['dateline']) . ' GMT');
header('Content-Length: ' . strlen($output));
echo $output;