]> git.joonet.de Git - adminer.git/commitdiff
Compress JS
authorJakub Vrana <jakub@vrana.cz>
Fri, 7 Sep 2012 05:23:27 +0000 (22:23 -0700)
committerJakub Vrana <jakub@vrana.cz>
Fri, 7 Sep 2012 15:38:11 +0000 (08:38 -0700)
adminer/file.inc.php
compile.php

index 5d3332cdd3512068a15c2adc2fd41bbb219d9bfa..53d765a27650d49e58007cc78789bd038730ade5 100644 (file)
@@ -9,7 +9,7 @@ if ($_GET["file"] == "favicon.ico") {
        echo lzw_decompress("compile_file('../adminer/static/default.css', 'minify_css');");
 } elseif ($_GET["file"] == "functions.js") {
        header("Content-Type: text/javascript; charset=utf-8");
-       ?>compile_file('../adminer/static/functions.js', 'jsShrink');compile_file('static/editing.js', 'jsShrink');<?php
+       echo lzw_decompress("compile_file('../adminer/static/functions.js;static/editing.js', 'minify_js');");
 } else {
        header("Content-Type: image/gif");
        switch ($_GET["file"]) {
index 2f2bf08197a2b741d2543e446f731db8d27ee15b..2d11e9d064c01f860c332721ae32a809ce766320 100755 (executable)
@@ -4,12 +4,6 @@ error_reporting(6135); // errors and warnings
 include dirname(__FILE__) . "/adminer/include/version.inc.php";
 include dirname(__FILE__) . "/externals/JsShrink/jsShrink.php";
 
-if (!function_exists('jsShrink')) {
-       function jsShrink($code) {
-               return $code;
-       }
-}
-
 function add_apo_slashes($s) {
        return addcslashes($s, "\\'");
 }
@@ -257,9 +251,20 @@ function minify_css($file) {
        return add_quo_slashes(lzw_compress(preg_replace('~\\s*([:;{},])\\s*~', '\\1', preg_replace('~/\\*.*\\*/~sU', '', $file))));
 }
 
+function minify_js($file) {
+       if (function_exists('jsShrink')) {
+               $file = jsShrink($file);
+       }
+       return add_quo_slashes(lzw_compress($file));
+}
+
 function compile_file($match) {
        global $project;
-       return call_user_func($match[2], file_get_contents(dirname(__FILE__) . "/$project/$match[1]"));
+       $file = "";
+       foreach (explode(";", $match[1]) as $filename) {
+               $file .= file_get_contents(dirname(__FILE__) . "/$project/$filename");
+       }
+       return call_user_func($match[2], $file);
 }
 
 $driver = "";