Current File : /home/k/a/r/karenpetzb/www/items/category/Filter.tar |
Word/SeparatorToDash.php 0000604 00000002636 15071177223 0011243 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CamelCaseToUnderscore.php 6779 2007-11-08 15:10:41Z matthew $
*/
/**
* @see Zend_Filter_SeperatorToSeparator
*/
require_once 'Zend/Filter/Word/SeparatorToSeparator.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Word_SeparatorToDash extends Zend_Filter_Word_SeparatorToSeparator
{
/**
* Constructor
*
* @param string $searchSeparator Seperator to search for change
* @return void
*/
public function __construct($searchSeparator = ' ')
{
parent::__construct($searchSeparator, '-');
}
} Word/SeparatorToCamelCase.php 0000604 00000003476 15071177223 0012204 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CamelCaseToSeparator.php 6779 2007-11-08 15:10:41Z matthew $
*/
/**
* @see Zend_Filter_PregReplace
*/
require_once 'Zend/Filter/Word/Separator/Abstract.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Word_SeparatorToCamelCase extends Zend_Filter_Word_Separator_Abstract
{
public function filter($value)
{
// a unicode safe way of converting characters to \x00\x00 notation
$pregQuotedSeparator = preg_quote($this->_separator, '#');
if (self::isUnicodeSupportEnabled()) {
parent::setMatchPattern(array('#('.$pregQuotedSeparator.')(\p{L}{1})#e','#(^\p{Ll}{1})#e'));
parent::setReplacement(array("strtoupper('\\2')","strtoupper('\\1')"));
} else {
parent::setMatchPattern(array('#('.$pregQuotedSeparator.')([A-Z]{1})#e','#(^[a-z]{1})#e'));
parent::setReplacement(array("strtoupper('\\2')","strtoupper('\\1')"));
}
return parent::filter($value);
}
}
Word/DashToUnderscore.php 0000604 00000002530 15071177223 0011405 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CamelCaseToSeparator.php 6779 2007-11-08 15:10:41Z matthew $
*/
/**
* @see Zend_Filter_PregReplace
*/
require_once 'Zend/Filter/Word/SeparatorToSeparator.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Word_DashToUnderscore extends Zend_Filter_Word_SeparatorToSeparator
{
/**
* Constructor
*
* @param string $separator Space by default
* @return void
*/
public function __construct()
{
parent::__construct('-', '_');
}
} Word/Separator/Abstract.php 0000604 00000003775 15071177223 0011710 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CamelCaseToUnderscore.php 6779 2007-11-08 15:10:41Z matthew $
*/
/**
* @see Zend_Filter_PregReplace
*/
require_once 'Zend/Filter/PregReplace.php';
/**
* @category Zend
* @package Zend_Filter
* @uses Zend_Filter_PregReplace
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Filter_Word_Separator_Abstract extends Zend_Filter_PregReplace
{
protected $_separator = null;
/**
* Constructor
*
* @param string $separator Space by default
* @return void
*/
public function __construct($separator = ' ')
{
$this->setSeparator($separator);
}
/**
* Sets a new seperator
*
* @param string $separator Seperator
* @return $this
*/
public function setSeparator($separator)
{
if ($separator == null) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception('"' . $separator . '" is not a valid separator.');
}
$this->_separator = $separator;
return $this;
}
/**
* Returns the actual set seperator
*
* @return string
*/
public function getSeparator()
{
return $this->_separator;
}
} Word/DashToSeparator.php 0000604 00000002475 15071177223 0011244 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CamelCaseToSeparator.php 6779 2007-11-08 15:10:41Z matthew $
*/
/**
* @see Zend_Filter_PregReplace
*/
require_once 'Zend/Filter/Word/Separator/Abstract.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Word_DashToSeparator extends Zend_Filter_Word_Separator_Abstract
{
public function filter($value)
{
$this->setMatchPattern('#-#');
$this->setReplacement($this->_separator);
return parent::filter($value);
}
}
Word/CamelCaseToSeparator.php 0000604 00000003334 15071177223 0012175 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CamelCaseToSeparator.php 6779 2007-11-08 15:10:41Z matthew $
*/
/**
* @see Zend_Filter_PregReplace
*/
require_once 'Zend/Filter/Word/Separator/Abstract.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Word_CamelCaseToSeparator extends Zend_Filter_Word_Separator_Abstract
{
public function filter($value)
{
if (self::isUnicodeSupportEnabled()) {
parent::setMatchPattern(array('#(?<=(?:\p{Lu}))(\p{Lu}\p{Ll})#','#(?<=(?:\p{Ll}))(\p{Lu})#'));
parent::setReplacement(array($this->_separator . '\1', $this->_separator . '\1'));
} else {
parent::setMatchPattern(array('#(?<=(?:[A-Z]))([A-Z]+)([A-Z][A-z])#', '#(?<=(?:[a-z]))([A-Z])#'));
parent::setReplacement(array('\1' . $this->_separator . '\2', $this->_separator . '\1'));
}
return parent::filter($value);
}
}
Word/CamelCaseToUnderscore.php 0000604 00000002460 15071177223 0012345 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CamelCaseToUnderscore.php 6779 2007-11-08 15:10:41Z matthew $
*/
/**
* @see Zend_Filter_CamelCaseToSeparator
*/
require_once 'Zend/Filter/Word/CamelCaseToSeparator.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Word_CamelCaseToUnderscore extends Zend_Filter_Word_CamelCaseToSeparator
{
/**
* Constructor
*
* @return void
*/
public function __construct()
{
parent::__construct('_');
}
}
Word/UnderscoreToSeparator.php 0000604 00000002617 15071177223 0012474 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: UnderscoreToPathSeparator.php 6793 2007-11-09 18:10:06Z matthew $
*/
/**
* @see Zend_Filter_PregReplace
*/
require_once 'Zend/Filter/Word/SeparatorToSeparator.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Word_UnderscoreToSeparator extends Zend_Filter_Word_SeparatorToSeparator
{
/**
* Constructor
*
* @param string $separator Space by default
* @return void
*/
public function __construct($replacementSeparator = ' ')
{
parent::__construct('_', $replacementSeparator);
}
}
Word/SeparatorToSeparator.php 0000604 00000007134 15071177223 0012322 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CamelCaseToUnderscore.php 6779 2007-11-08 15:10:41Z matthew $
*/
/**
* @see Zend_Filter_PregReplace
*/
require_once 'Zend/Filter/PregReplace.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Word_SeparatorToSeparator extends Zend_Filter_PregReplace
{
protected $_searchSeparator = null;
protected $_replacementSeparator = null;
/**
* Constructor
*
* @param string $searchSeparator Seperator to search for
* @param string $replacementSeperator Seperator to replace with
* @return void
*/
public function __construct($searchSeparator = ' ', $replacementSeparator = '-')
{
$this->setSearchSeparator($searchSeparator);
$this->setReplacementSeparator($replacementSeparator);
}
/**
* Sets a new seperator to search for
*
* @param string $separator Seperator to search for
* @return $this
*/
public function setSearchSeparator($separator)
{
$this->_searchSeparator = $separator;
return $this;
}
/**
* Returns the actual set seperator to search for
*
* @return string
*/
public function getSearchSeparator()
{
return $this->_searchSeparator;
}
/**
* Sets a new seperator which replaces the searched one
*
* @param string $separator Seperator which replaces the searched one
* @return $this
*/
public function setReplacementSeparator($separator)
{
$this->_replacementSeparator = $separator;
return $this;
}
/**
* Returns the actual set seperator which replaces the searched one
*
* @return string
*/
public function getReplacementSeparator()
{
return $this->_replacementSeparator;
}
/**
* Defined by Zend_Filter_Interface
*
* Returns the string $value, replacing the searched seperators with the defined ones
*
* @param string $value
* @return string
*/
public function filter($value)
{
return $this->_separatorToSeparatorFilter($value);
}
/**
* Do the real work, replaces the seperator to search for with the replacement seperator
*
* Returns the replaced string
*
* @param string $value
* @return string
*/
protected function _separatorToSeparatorFilter($value)
{
if ($this->_searchSeparator == null) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception('You must provide a search separator for this filter to work.');
}
$this->setMatchPattern('#' . preg_quote($this->_searchSeparator, '#') . '#');
$this->setReplacement($this->_replacementSeparator);
return parent::filter($value);
}
} Word/CamelCaseToDash.php 0000604 00000002431 15071177223 0011111 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CamelCaseToDash.php 6779 2007-11-08 15:10:41Z matthew $
*/
/**
* @see Zend_Filter_Interface
*/
require_once 'Zend/Filter/Word/CamelCaseToSeparator.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Word_CamelCaseToDash extends Zend_Filter_Word_CamelCaseToSeparator
{
/**
* Constructor
*
* @return void
*/
public function __construct()
{
parent::__construct('-');
}
}
Word/UnderscoreToCamelCase.php 0000604 00000002437 15071177223 0012351 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CamelCaseToDash.php 6779 2007-11-08 15:10:41Z matthew $
*/
/**
* @see Zend_Filter_Interface
*/
require_once 'Zend/Filter/Word/SeparatorToCamelCase.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Word_UnderscoreToCamelCase extends Zend_Filter_Word_SeparatorToCamelCase
{
/**
* Constructor
*
* @return void
*/
public function __construct()
{
parent::__construct('_');
}
}
Word/UnderscoreToDash.php 0000604 00000002527 15071177223 0011413 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CamelCaseToSeparator.php 6779 2007-11-08 15:10:41Z matthew $
*/
/**
* @see Zend_Filter_PregReplace
*/
require_once 'Zend/Filter/Word/SeparatorToSeparator.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Word_UnderscoreToDash extends Zend_Filter_Word_SeparatorToSeparator
{
/**
* Constructor
*
* @param string $separator Space by default
* @return void
*/
public function __construct()
{
parent::__construct('_', '-');
}
} Word/DashToCamelCase.php 0000604 00000002431 15071177223 0011111 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CamelCaseToDash.php 6779 2007-11-08 15:10:41Z matthew $
*/
/**
* @see Zend_Filter_Interface
*/
require_once 'Zend/Filter/Word/SeparatorToCamelCase.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Word_DashToCamelCase extends Zend_Filter_Word_SeparatorToCamelCase
{
/**
* Constructor
*
* @return void
*/
public function __construct()
{
parent::__construct('-');
}
}
RealPath.php 0000604 00000002516 15071177223 0006762 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: RealPath.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @see Zend_Filter_Interface
*/
require_once 'Zend/Filter/Interface.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_RealPath implements Zend_Filter_Interface
{
/**
* Defined by Zend_Filter_Interface
*
* Returns realpath($value)
*
* @param string $value
* @return string
*/
public function filter($value)
{
return realpath((string) $value);
}
}
StripTags.php 0000604 00000022755 15071177223 0007211 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: StripTags.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @see Zend_Filter_Interface
*/
require_once 'Zend/Filter/Interface.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_StripTags implements Zend_Filter_Interface
{
/**
* Unique ID prefix used for allowing comments
*/
const UNIQUE_ID_PREFIX = '__Zend_Filter_StripTags__';
/**
* Whether comments are allowed
*
* If false (the default), then comments are removed from the input string.
*
* @var boolean
*/
public $commentsAllowed;
/**
* Array of allowed tags and allowed attributes for each allowed tag
*
* Tags are stored in the array keys, and the array values are themselves
* arrays of the attributes allowed for the corresponding tag.
*
* @var array
*/
protected $_tagsAllowed = array();
/**
* Array of allowed attributes for all allowed tags
*
* Attributes stored here are allowed for all of the allowed tags.
*
* @var array
*/
protected $_attributesAllowed = array();
/**
* Sets the filter options
*
* @param array|string $tagsAllowed
* @param array|string $attributesAllowed
* @param boolean $allowComments
* @return void
*/
public function __construct($tagsAllowed = null, $attributesAllowed = null, $commentsAllowed = false)
{
$this->setTagsAllowed($tagsAllowed);
$this->setAttributesAllowed($attributesAllowed);
$this->commentsAllowed = (boolean) $commentsAllowed;
}
/**
* Returns the tagsAllowed option
*
* @return array
*/
public function getTagsAllowed()
{
return $this->_tagsAllowed;
}
/**
* Sets the tagsAllowed option
*
* @param array|string $tagsAllowed
* @return Zend_Filter_StripTags Provides a fluent interface
*/
public function setTagsAllowed($tagsAllowed)
{
if (!is_array($tagsAllowed)) {
$tagsAllowed = array($tagsAllowed);
}
foreach ($tagsAllowed as $index => $element) {
// If the tag was provided without attributes
if (is_int($index) && is_string($element)) {
// Canonicalize the tag name
$tagName = strtolower($element);
// Store the tag as allowed with no attributes
$this->_tagsAllowed[$tagName] = array();
}
// Otherwise, if a tag was provided with attributes
else if (is_string($index) && (is_array($element) || is_string($element))) {
// Canonicalize the tag name
$tagName = strtolower($index);
// Canonicalize the attributes
if (is_string($element)) {
$element = array($element);
}
// Store the tag as allowed with the provided attributes
$this->_tagsAllowed[$tagName] = array();
foreach ($element as $attribute) {
if (is_string($attribute)) {
// Canonicalize the attribute name
$attributeName = strtolower($attribute);
$this->_tagsAllowed[$tagName][$attributeName] = null;
}
}
}
}
return $this;
}
/**
* Returns the attributesAllowed option
*
* @return array
*/
public function getAttributesAllowed()
{
return $this->_attributesAllowed;
}
/**
* Sets the attributesAllowed option
*
* @param array|string $attributesAllowed
* @return Zend_Filter_StripTags Provides a fluent interface
*/
public function setAttributesAllowed($attributesAllowed)
{
if (!is_array($attributesAllowed)) {
$attributesAllowed = array($attributesAllowed);
}
// Store each attribute as allowed
foreach ($attributesAllowed as $attribute) {
if (is_string($attribute)) {
// Canonicalize the attribute name
$attributeName = strtolower($attribute);
$this->_attributesAllowed[$attributeName] = null;
}
}
return $this;
}
/**
* Defined by Zend_Filter_Interface
*
* @todo improve docblock descriptions
*
* @param string $value
* @return string
*/
public function filter($value)
{
$valueCopy = (string) $value;
// If comments are allowed, then replace them with unique identifiers
if ($this->commentsAllowed) {
preg_match_all('/<\!--.*?--\s*>/s' , (string) $valueCopy, $matches);
$comments = array_unique($matches[0]);
foreach ($comments as $k => $v) {
$valueCopy = str_replace($v, self::UNIQUE_ID_PREFIX . $k, $valueCopy);
}
}
// Initialize accumulator for filtered data
$dataFiltered = '';
// Parse the input data iteratively as regular pre-tag text followed by a
// tag; either may be empty strings
preg_match_all('/([^<]*)(<?[^>]*>?)/', (string) $valueCopy, $matches);
// Iterate over each set of matches
foreach ($matches[1] as $index => $preTag) {
// If the pre-tag text is non-empty, strip any ">" characters from it
if (strlen($preTag)) {
$preTag = str_replace('>', '', $preTag);
}
// If a tag exists in this match, then filter the tag
$tag = $matches[2][$index];
if (strlen($tag)) {
$tagFiltered = $this->_filterTag($tag);
} else {
$tagFiltered = '';
}
// Add the filtered pre-tag text and filtered tag to the data buffer
$dataFiltered .= $preTag . $tagFiltered;
}
// If comments are allowed, then replace the unique identifiers with the corresponding comments
if ($this->commentsAllowed) {
foreach ($comments as $k => $v) {
$dataFiltered = str_replace(self::UNIQUE_ID_PREFIX . $k, $v, $dataFiltered);
}
}
// Return the filtered data
return $dataFiltered;
}
/**
* Filters a single tag against the current option settings
*
* @param string $tag
* @return string
*/
protected function _filterTag($tag)
{
// Parse the tag into:
// 1. a starting delimiter (mandatory)
// 2. a tag name (if available)
// 3. a string of attributes (if available)
// 4. an ending delimiter (if available)
$isMatch = preg_match('~(</?)(\w*)((/(?!>)|[^/>])*)(/?>)~', $tag, $matches);
// If the tag does not match, then strip the tag entirely
if (!$isMatch) {
return '';
}
// Save the matches to more meaningfully named variables
$tagStart = $matches[1];
$tagName = strtolower($matches[2]);
$tagAttributes = $matches[3];
$tagEnd = $matches[5];
// If the tag is not an allowed tag, then remove the tag entirely
if (!isset($this->_tagsAllowed[$tagName])) {
return '';
}
// Trim the attribute string of whitespace at the ends
$tagAttributes = trim($tagAttributes);
// If there are non-whitespace characters in the attribute string
if (strlen($tagAttributes)) {
// Parse iteratively for well-formed attributes
preg_match_all('/(\w+)=([\'"])((.(?!=\2))+)\2/s', $tagAttributes, $matches);
// Initialize valid attribute accumulator
$tagAttributes = '';
// Iterate over each matched attribute
foreach ($matches[1] as $index => $attributeName) {
$attributeName = strtolower($attributeName);
$attributeDelimiter = $matches[2][$index];
$attributeValue = $matches[3][$index];
// If the attribute is not allowed, then remove it entirely
if (!array_key_exists($attributeName, $this->_tagsAllowed[$tagName])
&& !array_key_exists($attributeName, $this->_attributesAllowed)) {
continue;
}
// Add the attribute to the accumulator
$tagAttributes .= " $attributeName=" . $attributeDelimiter
. $attributeValue . $attributeDelimiter;
}
}
// Reconstruct tags ending with "/>" as backwards-compatible XHTML tag
if (strpos($tagEnd, '/') !== false) {
$tagEnd = " $tagEnd";
}
// Return the filtered tag
return $tagStart . $tagName . $tagAttributes . $tagEnd;
}
}
StringToLower.php 0000604 00000004050 15071177223 0010037 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: StringToLower.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @see Zend_Filter_Interface
*/
require_once 'Zend/Filter/Interface.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_StringToLower implements Zend_Filter_Interface
{
/**
* Encoding for the input string
*
* @var string
*/
protected $_encoding = null;
/**
* Set the input encoding for the given string
*
* @param string $encoding
* @throws Zend_Filter_Exception
*/
public function setEncoding($encoding = null)
{
if (!function_exists('mb_strtolower')) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception('mbstring is required for this feature');
}
$this->_encoding = $encoding;
}
/**
* Defined by Zend_Filter_Interface
*
* Returns the string $value, converting characters to lowercase as necessary
*
* @param string $value
* @return string
*/
public function filter($value)
{
if ($this->_encoding) {
return mb_strtolower((string) $value, $this->_encoding);
}
return strtolower((string) $value);
}
}
StringToUpper.php 0000604 00000004050 15071177223 0010042 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: StringToUpper.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @see Zend_Filter_Interface
*/
require_once 'Zend/Filter/Interface.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_StringToUpper implements Zend_Filter_Interface
{
/**
* Encoding for the input string
*
* @var string
*/
protected $_encoding = null;
/**
* Set the input encoding for the given string
*
* @param string $encoding
* @throws Zend_Filter_Exception
*/
public function setEncoding($encoding = null)
{
if (!function_exists('mb_strtoupper')) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception('mbstring is required for this feature');
}
$this->_encoding = $encoding;
}
/**
* Defined by Zend_Filter_Interface
*
* Returns the string $value, converting characters to uppercase as necessary
*
* @param string $value
* @return string
*/
public function filter($value)
{
if ($this->_encoding) {
return mb_strtoupper((string) $value, $this->_encoding);
}
return strtoupper((string) $value);
}
}
File/LowerCase.php 0000604 00000004712 15071177223 0010025 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
*/
/**
* @see Zend_Filter_StringToLower
*/
require_once 'Zend/Filter/StringToLower.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_File_LowerCase extends Zend_Filter_StringToLower
{
/**
* Adds options to the filter at initiation
*
* @param string $options
*/
public function __construct($options = null)
{
if (!empty($options)) {
$this->setEncoding($options);
}
}
/**
* Defined by Zend_Filter_Interface
*
* Does a lowercase on the content of the given file
*
* @param string $value Full path of file to change
* @return string The given $value
* @throws Zend_Filter_Exception
*/
public function filter($value)
{
if (!file_exists($value)) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("File '$value' not found");
}
if (!is_writable($value)) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("File '$value' is not writable");
}
$content = file_get_contents($value);
if (!$content) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("Problem while reading file '$value'");
}
$content = parent::filter($content);
$result = file_put_contents($value, $content);
if (!$result) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("Problem while writing file '$value'");
}
return $value;
}
}
File/UpperCase.php 0000604 00000004712 15071177223 0010030 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
*/
/**
* @see Zend_Filter_StringToUpper
*/
require_once 'Zend/Filter/StringToUpper.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_File_UpperCase extends Zend_Filter_StringToUpper
{
/**
* Adds options to the filter at initiation
*
* @param string $options
*/
public function __construct($options = null)
{
if (!empty($options)) {
$this->setEncoding($options);
}
}
/**
* Defined by Zend_Filter_Interface
*
* Does a lowercase on the content of the given file
*
* @param string $value Full path of file to change
* @return string The given $value
* @throws Zend_Filter_Exception
*/
public function filter($value)
{
if (!file_exists($value)) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("File '$value' not found");
}
if (!is_writable($value)) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("File '$value' is not writable");
}
$content = file_get_contents($value);
if (!$content) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("Problem while reading file '$value'");
}
$content = parent::filter($content);
$result = file_put_contents($value, $content);
if (!$result) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("Problem while writing file '$value'");
}
return $value;
}
}
File/Rename.php 0000604 00000020670 15071177223 0007351 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
*/
/**
* @see Zend_Filter_Interface
*/
require_once 'Zend/Filter/Interface.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_File_Rename implements Zend_Filter_Interface
{
/**
* Internal array of array(source, target, overwrite)
*/
protected $_files = array();
/**
* Class constructor
*
* Options argument may be either a string, a Zend_Config object, or an array.
* If an array or Zend_Config object, it accepts the following keys:
* 'source' => Source filename or directory which will be renamed
* 'target' => Target filename or directory, the new name of the sourcefile
* 'overwrite' => Shall existing files be overwritten ?
*
* @param string|array $options Target file or directory to be renamed
* @param string $target Source filename or directory (deprecated)
* @param bool $overwrite Should existing files be overwritten (deprecated)
* @return void
*/
public function __construct($options)
{
if ($options instanceof Zend_Config) {
$options = $options->toArray();
} elseif (is_string($options)) {
$options = array('target' => $options);
} elseif (!is_array($options)) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception('Invalid options argument provided to filter');
}
if (1 < func_num_args()) {
trigger_error('Support for multiple arguments is deprecated in favor of a single options array', E_USER_NOTICE);
$argv = func_get_args();
array_shift($argv);
$source = array_shift($argv);
$overwrite = false;
if (!empty($argv)) {
$overwrite = array_shift($argv);
}
$options['source'] = $source;
$options['overwrite'] = $overwrite;
}
$this->setFile($options);
}
/**
* Returns the files to rename and their new name and location
*
* @return array
*/
public function getFile()
{
return $this->_files;
}
/**
* Sets a new file or directory as target, deleting existing ones
*
* Array accepts the following keys:
* 'source' => Source filename or directory which will be renamed
* 'target' => Target filename or directory, the new name of the sourcefile
* 'overwrite' => Shall existing files be overwritten ?
*
* @param string|array $options Old file or directory to be rewritten
* @return Zend_Filter_File_Rename
*/
public function setFile($options)
{
$this->_files = array();
$this->addFile($options);
return $this;
}
/**
* Adds a new file or directory as target to the existing ones
*
* Array accepts the following keys:
* 'source' => Source filename or directory which will be renamed
* 'target' => Target filename or directory, the new name of the sourcefile
* 'overwrite' => Shall existing files be overwritten ?
*
* @param string|array $options Old file or directory to be rewritten
* @return Zend_Filter_File_Rename
*/
public function addFile($options)
{
if (is_string($options)) {
$options = array('target' => $options);
} elseif (!is_array($options)) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception ('Invalid options to rename filter provided');
}
$this->_convertOptions($options);
return $this;
}
/**
* Defined by Zend_Filter_Interface
*
* Renames the file $value to the new name set before
* Returns the file $value, removing all but digit characters
*
* @param string $value Full path of file to change
* @return string The new filename which has been set, or false when there were errors
*/
public function filter($value)
{
$file = $this->_getFileName($value);
if ($file['source'] == $file['target']) {
return $value;
}
if (!file_exists($file['source'])) {
return $value;
}
if (($file['overwrite'] == true) and (file_exists($file['target']))) {
unlink($file['target']);
}
if (file_exists($file['target'])) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception(sprintf("File '%s' could not be renamed. It already exists.", $value));
}
$result = rename($file['source'], $file['target']);
if ($result === true) {
return $file['target'];
}
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception(sprintf("File '%s' could not be renamed. An error occured while processing the file.", $value));
}
/**
* Internal method for creating the file array
* Supports single and nested arrays
*
* @param array $options
* @return array
*/
protected function _convertOptions($options) {
$files = array();
foreach ($options as $key => $value) {
if (is_array($value)) {
$this->_convertOptions($value);
continue;
}
switch ($key) {
case "source":
$files['source'] = (string) $value;
break;
case 'target' :
$files['target'] = (string) $value;
break;
case 'overwrite' :
$files['overwrite'] = (boolean) $value;
break;
default:
break;
}
}
if (empty($files)) {
return $this;
}
if (empty($files['source'])) {
$files['source'] = '*';
}
if (empty($files['target'])) {
$files['target'] = '*';
}
if (empty($files['overwrite'])) {
$files['overwrite'] = false;
}
$found = false;
foreach ($this->_files as $key => $value) {
if ($value['source'] == $files['source']) {
$this->_files[$key] = $files;
$found = true;
}
}
if (!$found) {
$count = count($this->_files);
$this->_files[$count] = $files;
}
return $this;
}
/**
* Internal method to resolve the requested source
* and return all other related parameters
*
* @param string $file Filename to get the informations for
* @return array
*/
protected function _getFileName($file)
{
$rename = array();
foreach ($this->_files as $value) {
if ($value['source'] == '*') {
if (!isset($rename['source'])) {
$rename = $value;
$rename['source'] = $file;
}
}
if ($value['source'] == $file) {
$rename = $value;
}
}
if (!isset($rename['source'])) {
return $file;
}
if (!isset($rename['target']) or ($rename['target'] == '*')) {
$rename['target'] = $rename['source'];
}
if (is_dir($rename['target'])) {
$name = basename($rename['source']);
$last = $rename['target'][strlen($rename['target']) - 1];
if (($last != '/') and ($last != '\\')) {
$rename['target'] .= DIRECTORY_SEPARATOR;
}
$rename['target'] .= $name;
}
return $rename;
}
}
Int.php 0000604 00000002477 15071177223 0006022 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Int.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @see Zend_Filter_Interface
*/
require_once 'Zend/Filter/Interface.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Filter_Int implements Zend_Filter_Interface
{
/**
* Defined by Zend_Filter_Interface
*
* Returns (int) $value
*
* @param string $value
* @return integer
*/
public function filter($value)
{
return (int) ((string) $value);
}
}
CustomAccent.php 0000604 00000001232 15071177223 0007644 0 ustar 00 <?php
require_once 'Zend/Filter/Interface.php';
class Zend_Filter_CustomAccent implements Zend_Filter_Interface
{
public function filter($valeur)
{
$accents = array('�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�',
'�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�');
$sans = array('A','A','A','A','A','A','C','E','E','E','E','I','I','I','I','O','O','O','O','O',
'U','U','U','U','Y','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i','o','o','o','o','o','o','u','u','u','u','y','y');
return str_replace($accents, $sans, $valeur);
}
}
?>