/**
  * Configures YUI compressor. 
  * @param array $conf typoscript options
  */
 private function configureYUI($conf)
 {
     if ($conf['jarpath.']['isrelative'] && $conf['jarpath.']['isrelative'] == 1) {
         $conf['jarpath'] = $_SERVER['DOCUMENT_ROOT'] . $conf['jarpath'];
     }
     Minify_YUICompressor::$jarFile = $conf['jarpath'];
     Minify_YUICompressor::$tempDir = $conf['tmpdir'];
     //sys_get_temp_dir();
     Minify_YUICompressor::$javaExecutable = $conf['javapath'];
 }
Example #2
0
    $fp = fopen($fn, "r") or die("Failed: Cannot open {$fn}");
    $contents = "";
    while (!feof($fp)) {
        $contents .= fgets($fp);
    }
    $contents = substr($contents, strpos($contents, "*/") + 2);
    fwrite($fpOut, $contents);
    fclose($fp);
}
echo "Finished building {$OUTPUT_DIR}{$OUTPUT_FILE} (" . filesize($OUTPUT_DIR . $OUTPUT_FILE) . " bytes): Took " . (microtime_float() - $time_start) . "s\n\n";
fclose($fpOut);
echo "Building Compressed File: {$OUTPUT_DIR}{$OUTPUT_FILE_COMPRESSED}\n\r";
$time_start = microtime_float();
Minify_YUICompressor::$jarFile = $YUI_COMPRESSOR_JAR;
Minify_YUICompressor::$tempDir = $TMP_DIR;
Minify_YUICompressor::$javaExecutable = $JDK_HOME . "/bin/java";
$fp = fopen($OUTPUT_DIR . $OUTPUT_FILE, "r");
$uncompressed = "";
while (!feof($fp)) {
    $uncompressed .= fgets($fp);
}
fclose($fp);
$compressed = Minify_YUICompressor::minifyJs($uncompressed, array());
$fp = fopen($OUTPUT_DIR . $OUTPUT_FILE_COMPRESSED, "w");
fwrite($fp, $compressed);
fclose($fp);
echo "Finished building {$OUTPUT_DIR}{$OUTPUT_FILE_COMPRESSED} (" . filesize($OUTPUT_DIR . $OUTPUT_FILE_COMPRESSED) . " bytes): Took " . (microtime_float() - $time_start) . "s\n";
echo "\nCopying Resources to {$OUTPUT_DIR}{$OUTPUT_RESOURCES}\n";
if (!is_dir($OUTPUT_DIR . $OUTPUT_RESOURCES)) {
    mkdir($OUTPUT_DIR . 'resources');
}
Example #3
0
$baseVersionFile = $pathToAssets + "/script.ver";
//$pathToCss = $pathToAssets . '/stylesheets/sitewide.css';
$getScripts = "http://127.0.0.1/v5/servlet/getScripts";
$pathToCore = $pathToAssets . '/core';
if (!file_exists($pathToTmp)) {
    if (!mkdir($pathToTmp)) {
        die('unable to create tmp folder');
    }
}
// Set up Minify
require "{$pathToLib}/Minify/Loader.php";
Minify_Loader::register();
//$javaExecPath = 'java'; // dev2
$javaExecPath = '/opt/java/jdk1.6.0_35/jre/bin/java';
// testing.foretees.com
Minify_YUICompressor::$javaExecutable = $javaExecPath;
Minify_ClosureCompiler::$javaExecutable = $javaExecPath;
Minify_ClosureStylesheets::$javaExecutable = $javaExecPath;
Minify_YUICompressor::$jarFile = $pathToYui;
Minify_YUICompressor::$tempDir = $pathToTmp;
Minify_ClosureCompiler::$jarFile = $pathToClosureCompiler;
Minify_ClosureCompiler::$tempDir = $pathToTmp;
Minify_ClosureStylesheets::$jarFile = $pathToClosureStylesheets;
Minify_ClosureStylesheets::$tempDir = $pathToTmp;
// Set up CSSTidy
define('ABSPATH', $pathToCssTidy);
require $pathToCssTidy . '/class.csstidy.php';
require $pathToCssTidy . '/lang.inc.php';
/*
$css->settings['optimise_shorthands'] = true;
$css->settings['template'] = 'highest';
 /**
  * Test minifier action
  *
  * @return void
  */
 function w3tc_test_minifier()
 {
     $engine = Util_Request::get_string('engine');
     $path_java = Util_Request::get_string('path_java');
     $path_jar = Util_Request::get_string('path_jar');
     $result = false;
     $error = '';
     if ($engine != 'googleccjs') {
         if (!$path_java) {
             $error = __('Empty JAVA executable path.', 'w3-total-cache');
         } elseif (!$path_jar) {
             $error = __('Empty JAR file path.', 'w3-total-cache');
         }
     }
     if (empty($error)) {
         switch ($engine) {
             case 'yuijs':
                 Minify_YUICompressor::$tempDir = Util_File::create_tmp_dir();
                 Minify_YUICompressor::$javaExecutable = $path_java;
                 Minify_YUICompressor::$jarFile = $path_jar;
                 $result = Minify_YUICompressor::testJs($error);
                 break;
             case 'yuicss':
                 Minify_YUICompressor::$tempDir = Util_File::create_tmp_dir();
                 Minify_YUICompressor::$javaExecutable = $path_java;
                 Minify_YUICompressor::$jarFile = $path_jar;
                 $result = Minify_YUICompressor::testCss($error);
                 break;
             case 'ccjs':
                 Minify_ClosureCompiler::$tempDir = Util_File::create_tmp_dir();
                 Minify_ClosureCompiler::$javaExecutable = $path_java;
                 Minify_ClosureCompiler::$jarFile = $path_jar;
                 $result = Minify_ClosureCompiler::test($error);
                 break;
             case 'googleccjs':
                 $result = Minify_JS_ClosureCompiler::test($error);
                 break;
             default:
                 $error = __('Invalid engine.', 'w3-total-cache');
                 break;
         }
     }
     $response = array('result' => $result, 'error' => $error);
     echo json_encode($response);
 }
 /**
  * Initializes minifier
  *
  * @param string  $engine
  * @return void
  */
 function init($engine)
 {
     switch ($engine) {
         case 'yuijs':
             Minify_YUICompressor::$tempDir = Util_File::create_tmp_dir();
             Minify_YUICompressor::$javaExecutable = $this->_config->get_string('minify.yuijs.path.java');
             Minify_YUICompressor::$jarFile = $this->_config->get_string('minify.yuijs.path.jar');
             break;
         case 'yuicss':
             Minify_YUICompressor::$tempDir = Util_File::create_tmp_dir();
             Minify_YUICompressor::$javaExecutable = $this->_config->get_string('minify.yuicss.path.java');
             Minify_YUICompressor::$jarFile = $this->_config->get_string('minify.yuicss.path.jar');
             break;
         case 'ccjs':
             Minify_ClosureCompiler::$tempDir = Util_File::create_tmp_dir();
             Minify_ClosureCompiler::$javaExecutable = $this->_config->get_string('minify.ccjs.path.java');
             Minify_ClosureCompiler::$jarFile = $this->_config->get_string('minify.ccjs.path.jar');
             break;
     }
 }