Пример #1
0
 /**
  * Test minifier action
  *
  * @return void
  */
 function action_test_minifier()
 {
     w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
     $engine = W3_Request::get_string('engine');
     $path_java = W3_Request::get_string('path_java');
     $path_jar = W3_Request::get_string('path_jar');
     $result = false;
     $error = '';
     if (!$path_java) {
         $error = __('Empty JAVA executable path.', 'w3-total-cache');
     } elseif (!$path_jar) {
         $error = __('Empty JAR file path.', 'w3-total-cache');
     } else {
         switch ($engine) {
             case 'yuijs':
                 w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/YUICompressor.php');
                 Minify_YUICompressor::setPathJava($path_java);
                 Minify_YUICompressor::setPathJar($path_jar);
                 $result = Minify_YUICompressor::testJs($error);
                 break;
             case 'yuicss':
                 w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/YUICompressor.php');
                 Minify_YUICompressor::setPathJava($path_java);
                 Minify_YUICompressor::setPathJar($path_jar);
                 $result = Minify_YUICompressor::testCss($error);
                 break;
             case 'ccjs':
                 w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/ClosureCompiler.php');
                 Minify_ClosureCompiler::setPathJava($path_java);
                 Minify_ClosureCompiler::setPathJar($path_jar);
                 $result = Minify_ClosureCompiler::test($error);
                 break;
             default:
                 $error = __('Invalid engine.', 'w3-total-cache');
                 break;
         }
     }
     $response = array('result' => $result, 'error' => $error);
     echo json_encode($response);
 }
Пример #2
0
 /**
  * Initializes minifier
  *
  * @param string $engine
  * @return void
  */
 function init($engine)
 {
     switch ($engine) {
         case 'js':
             w3_require_once(W3TC_LIB_MINIFY_DIR . '/JSMin.php');
             break;
         case 'css':
             w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/CSS.php');
             break;
         case 'yuijs':
             w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/YUICompressor.php');
             Minify_YUICompressor::setPathJava($this->_config->get_string('minify.yuijs.path.java'));
             Minify_YUICompressor::setPathJar($this->_config->get_string('minify.yuijs.path.jar'));
             break;
         case 'yuicss':
             w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/YUICompressor.php');
             Minify_YUICompressor::setPathJava($this->_config->get_string('minify.yuicss.path.java'));
             Minify_YUICompressor::setPathJar($this->_config->get_string('minify.yuicss.path.jar'));
             break;
         case 'ccjs':
             w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/ClosureCompiler.php');
             Minify_ClosureCompiler::setPathJava($this->_config->get_string('minify.ccjs.path.java'));
             Minify_ClosureCompiler::setPathJar($this->_config->get_string('minify.ccjs.path.jar'));
             break;
         case 'csstidy':
             w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/CSSTidy.php');
             break;
         case 'html':
         case 'htmlxml':
             w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/HTML.php');
             break;
         case 'htmltidy':
         case 'htmltidyxml':
             w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/HTMLTidy.php');
             break;
     }
 }