compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (2)

View Page History

{zone-data:skeletons}
{code:php}

/**
* @see Zend_Filter_Interface
*/
require_once 'Zend/Filter/Interface.php';


/**
* Based on JSMin by Ryan Grove and Steve Clay (in turn based on JsMin.c by Douglas Crockford
* Copyright (c) 2002 Douglas Crockford (www.crockford.com)
*
* Copyright (c) 2008 Ryan Grove <ryan@wonko.com>
* Copyright (c) 2008 Steve Clay <steve@mrclay.org>
* All rights reserved.
*
* @category Zend
* @package Zend_Filter_Minify
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Minify_Javascript implements Zend_Filter_Interface
{
/**
* Minification adapter
*/
protected $_adapter;

/**
* Store options
*/
protected $_options;

/**
* Class constructor
*
* @param string|array $options (Optional) Options to set, if no adapter set, RegEx is used
*/
public function __construct($options = null)
{
$this->setOptions($options);

$this->setAdapter($options);
}

/**
* Returns the adapter instance
*
* @return Zend_Filter_Minify_Interface
*/
public function getAdapter()
{
return $this->_adapter;
}

/**
* Sets minification adapter
*
* @param string|array $options (Optional) Minification options
* @return Zend_Filter_Minify_Css
*/
public function setAdapter($options = null)
{
if (is_string($options)) {
$adapter = $options;
} else if (isset($options['adapter'])) {
$adapter = $options['adapter'];
unset($options['adapter']);
} else {
$adapter = 'JsMin';
}

if (!is_array($options)) {
$options = array();
}

if (Zend_Loader::isReadable('Zend/Filter/Minify/Javascript/' . ucfirst($adapter). '.php')) {
$adapter = 'Zend_Filter_Minify_Javascript_' . ucfirst($adapter);
}

if (!class_exists($adapter)) {
Zend_Loader::loadClass($adapter);
}

$this->_adapter = new $adapter($options);

if (!$this->_adapter instanceof Zend_Filter_Minify_Interface) {
require_once 'Zend/Filter/Minify/Exception.php';
throw new Zend_Filter_Minify_Exception("Minification adapter '" . $adapter . "' does not implement Zend_Filter_Minify_Interface");
}

return $this;
}

public function getOptions()
{
return $this->_options;
}

public function setOptions($options)
{
$this->_options = $options;

return $this;
}

/**
* Defined by Zend_Filter_Interface
*
* Returns a string containing the minified javascript. Accepts a string of javascript to be minified
*
* @param string $value
* @return string
*/
public function filter($value)
{
return $this->_adapter->minify($value);
}
}

{code}



{code:php}

<?php