/**
  * 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);
 }
Esempio n. 2
0
//$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';
//$css->settings['css_level'] = 'CSS3.1';
 /**
  * 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;
     }
 }