: $conf['cachejsparams']['lifetime'];
}
- if ($conf['cachejsparams']['compress'] == 'yui') {
+ switch ($conf['cachejsparams']['compress']) {
+ case 'closure':
+ $jsmin_params = array(
+ 'closure' => $conf['cachejsparams']['closurepath'],
+ 'java' => $conf['cachejsparams']['javapath']
+ );
+ break;
+
+ case 'yui':
$jsmin_params = array(
'java' => $conf['cachejsparams']['javapath'],
'yui' => $conf['cachejsparams']['yuipath']
);
- } else {
+ break;
+
+ default:
$jsmin_params = array();
+ break;
}
/* Output prototype.js separately from the other files. */
* @var array
*/
protected $_params = array(
+ 'closure' => null,
'java' => null,
'yui' => null
);
*/
public function postProcess($text)
{
- /* Are we using the YUI Compressor? */
- if (!empty($this->_params['yui']) &&
- !empty($this->_params['java'])) {
- return $this->_runYuiCompressor($text);
+ if (!empty($this->_params['java'])) {
+ /* Are we using the YUI Compressor? */
+ if (!empty($this->_params['yui'])) {
+ return $this->_runCompressor($text, $this->_params['yui'], ' --type js');
+ }
+
+ /* Are we using the Google Closure Compiler? */
+ if (!empty($this->_params['closure'])) {
+ return $this->_runCompressor($text, $this->_params['closure']);
+ }
}
/* Use PHP-based minifier. */
}
/**
- * Passes javascript through YUI Compressor.
+ * Passes javascript through a java compressor (YUI or Closure).
*
* @param string $text The javascript text.
+ * @param string $jar The JAR location.
+ * @param string $args Additional command line arguments.
*
* @return string The modified text.
*/
- protected function _runYuiCompressor($text)
+ protected function _runCompressor($jar, $args = '')
{
if (!is_executable($this->_params['java']) ||
- !file_exists($this->_params['yui'])) {
+ !file_exists($jar)) {
return $text;
}
2 => array('pipe', 'w')
);
- $process = proc_open(escapeshellcmd($this->_params['java']) . ' -jar ' . escapeshellarg($this->_params['yui']) . ' --type js', $descspec, $pipes);
+ $process = proc_open(escapeshellcmd($this->_params['java']) . ' -jar ' . escapeshellarg($jar) . $args, $descspec, $pipes);
fwrite($pipes[0], $text);
fclose($pipes[0]);
<api>beta</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Fix dimming signatures when mixed with quoted text (Bug #4299).
+ <notes>* Add support for Google Closure Compiler in javascript minfiy filter.
+ * Fix dimming signatures when mixed with quoted text (Bug #4299).
* Added javscript minify filter.
* Add support for using the tidy extension when filtering HTML data.
* Initial Horde 4 package.