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

Changes (15)

View Page History
{zone-data:skeletons}
{composition-setup}
{deck:id=Source}

{code:php} {card:label=Zend_Filter_Minify_Interface}

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


/**
* @category Zend
* @package Zend_Filter
* @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_Css 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_Css_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 = 'RegEx';
}

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

if (Zend_Loader::isReadable('Zend/Filter/Minify/Css/' . ucfirst($adapter). '.php')) {
$adapter = 'Zend_Filter_Minify_Css_' . 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;

{code:php}
interface Zend_Filter_Minify_Interface
{
public function minify($value);
}
{code}


{code:php}
require_once 'Zend/Filter/Minify/Interface.php';

class Zend_Filter_Minify_Css_RegEx implements Zend_Filter_Minify_Interface
{
public function minify($value){
$value = preg_replace('#\s+#', ' ', $value);
$value = preg_replace('#/\*.*?\*/#s', '', $value);
$value = str_replace('; ', ';', $value);
$value = str_replace(': ', ':', $value);
$value = str_replace(' {', '{', $value);
$value = str_replace('{ ', '{', $value);
$value = str_replace(', ', ',', $value);
$value = str_replace('} ', '}', $value);
$value = str_replace(';}', '}', $value);
$value = trim($value);

return $value;
}
}
{code}

{code:php}
require_once 'Zend/Filter/Minify/Exception.php';

class Zend_Filter_Minify_Css_Exception extends Zend_Filter_Minify_Exception
{

}

{code}

/**
* Defined by Zend_Filter_Interface
*
* Returns a string containing the minified css. Accepts a string of css to be minified
*
* @param string $value
* @return string
*/
public function filter($value)
{
return $this->_adapter->minify($value);
}
}
{code}
* Minification interface
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
{code:php}
*/
interface Zend_Filter_Minify_Interface
{
public function minify($value);
}
{code}


{code:php}
require_once 'Zend/Filter/Minify/Exception.php';

class Zend_Filter_Minify_Css_Exception extends Zend_Filter_Minify_Exception
{

}

{code}
{card}

{deck}
{zone-data}