|
Key
This line was removed.
This word was removed. This word was added.
This line was added.
|
Changes (5)
View Page History<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}
{zone-data:component-name}
{zone-data:skeletons}
{code:php}
/**
* @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;
}
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 css. Accepts a string of css to be minified
*
* @param string $value
* @return string
*/
public function filter($value)
{
return $this->_adapter->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/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}
/**
* Minification interface
* Minification interface
{zone-data}
{zone-template-instance}
{zone-template-instance}]]></ac:plain-text-body></ac:macro>