Skip to content

Commit

Permalink
Revert "[mms] Support UglifyJS for compressing javascript."
Browse files Browse the repository at this point in the history
This reverts commit 7513dbe.
  • Loading branch information
slusarz committed Jan 22, 2014
1 parent 672d367 commit cde6241
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 51 deletions.
48 changes: 2 additions & 46 deletions framework/Text_Filter/lib/Horde/Text/Filter/JavascriptMinify.php
Expand Up @@ -23,8 +23,6 @@ class Horde_Text_Filter_JavascriptMinify extends Horde_Text_Filter_Base
protected $_params = array(
'closure' => null,
'java' => null,
'uglifyjs' => null,
'uglifyjscmdline' => '',
'yui' => null
);

Expand All @@ -49,11 +47,6 @@ public function postProcess($text)
}
}

/* Are we using UglifyJS? @since 2.3.0 */
if (!empty($this->_params['uglifyjs'])) {
return $this->_runUglifyjs($text, $this->_params['uglifyjs'], $this->_params['uglifyjscmdline']);
}

/* Use PHP-based minifier. */
if (class_exists('Horde_Text_Filter_Jsmin')) {
$jsmin = new Horde_Text_Filter_Jsmin($text);
Expand All @@ -74,57 +67,20 @@ public function postProcess($text)
*
* @return string The modified text.
*/
protected function _runCompressor($text, $jar, $args = '')
protected function _runCompressor($jar, $args = '')
{
if (!is_executable($this->_params['java']) ||
!file_exists($jar)) {
return $text;
}

return $this->_compressJs(
$text,
escapeshellcmd($this->_params['java']) . ' -jar ' . escapeshellarg($jar) . $args
);
}

/**
* Passes javascript through the UglifyJS compressor.
*
* @param string $text The javascript text.
* @param string $uglifyjs The binary location.
* @param string $args Additional command line arguments.
*
* @return string The modified text.
*/
protected function _runUglifyjs($text, $uglifyjs, $args = '')
{
if (!file_exists($uglifyjs)) {
return $text;
}

return $this->_compressJs(
$text,
escapeshellcmd($uglifyjs) . ' - ' . $args
);
}

/**
* Runs the compression command and returns the output.
*
* @param string $text The javascript text.
* @param string $cmd Command.
*
* @return string The compressed javascript.
*/
protected function _compressJs($text, $cmd)
{
$descspec = array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('pipe', 'w')
);

$process = proc_open($cmd, $descspec, $pipes);
$process = proc_open(escapeshellcmd($this->_params['java']) . ' -jar ' . escapeshellarg($jar) . $args, $descspec, $pipes);

fwrite($pipes[0], $text);
fclose($pipes[0]);
Expand Down
10 changes: 5 additions & 5 deletions framework/Text_Filter/package.xml
Expand Up @@ -24,7 +24,7 @@
</developer>
<date>2013-11-19</date>
<version>
<release>2.3.0</release>
<release>2.2.1</release>
<api>2.2.0</api>
</version>
<stability>
Expand All @@ -33,7 +33,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Support UglifyJS for compressing javascript.
*
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -999,15 +999,15 @@ Initial release as a PEAR package
</release>
<release>
<version>
<release>2.3.0</release>
<api>2.3.0</api></version>
<release>2.2.1</release>
<api>2.2.0</api></version>
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2013-11-19</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Support UglifyJS for compressing javascript.
*
</notes>
</release>
</changelog>
Expand Down

0 comments on commit cde6241

Please sign in to comment.