<?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_Validate
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Validate_Interface
*/
require_once 'Zend/Validate/Interface.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate implements Zend_Validate_Interface
{
/**
* Validator chain
*
* @var array
*/
protected $_validators = array();
/**
* Array of validation failure messages
*
* @var array
*/
protected $_messages = array();
/**
* Default Namespaces
*
* @var array
*/
protected static $_defaultNamespaces = array();
/**
* Array of validation failure message codes
*
* @var array
* @deprecated Since 1.5.0
*/
protected $_errors = array();
/**
* Adds a validator to the end of the chain
*
* If $breakChainOnFailure is true, then if the validator fails, the next validator in the chain,
* if one exists, will not be executed.
*
* @param Zend_Validate_Interface $validator
* @param boolean $breakChainOnFailure
* @return Zend_Validate Provides a fluent interface
*/
public function addValidator(Zend_Validate_Interface $validator, $breakChainOnFailure = false)
{
$this->_validators[] = array(
'instance' => $validator,
'breakChainOnFailure' => (boolean) $breakChainOnFailure
);
return $this;
}
/**
* Returns true if and only if $value passes all validations in the chain
*
* Validators are run in the order in which they were added to the chain (FIFO).
*
* @param mixed $value
* @return boolean
*/
public function isValid($value)
{
$this->_messages = array();
$this->_errors = array();
$result = true;
foreach ($this->_validators as $element) {
$validator = $element['instance'];
if ($validator->isValid($value)) {
continue;
}
$result = false;
$messages = $validator->getMessages();
$this->_messages = array_merge($this->_messages, $messages);
$this->_errors = array_merge($this->_errors, array_keys($messages));
if ($element['breakChainOnFailure']) {
break;
}
}
return $result;
}
/**
* Defined by Zend_Validate_Interface
*
* Returns array of validation failure messages
*
* @return array
*/
public function getMessages()
{
return $this->_messages;
}
/**
* Defined by Zend_Validate_Interface
*
* Returns array of validation failure message codes
*
* @return array
* @deprecated Since 1.5.0
*/
public function getErrors()
{
return $this->_errors;
}
/**
* Returns the set default namespaces
*
* @return array
*/
public static function getDefaultNamespaces()
{
return self::$_defaultNamespaces;
}
/**
* Sets new default namespaces
*
* @param array|string $namespace
* @return null
*/
public static function setDefaultNamespaces($namespace)
{
if (!is_array($namespace)) {
$namespace = array((string) $namespace);
}
self::$_defaultNamespaces = $namespace;
}
/**
* Adds a new default namespace
*
* @param array|string $namespace
* @return null
*/
public static function addDefaultNamespaces($namespace)
{
if (!is_array($namespace)) {
$namespace = array((string) $namespace);
}
self::$_defaultNamespaces = array_unique(array_merge(self::$_defaultNamespaces, $namespace));
}
/**
* Returns true when defaultNamespaces are set
*
* @return boolean
*/
public static function hasDefaultNamespaces()
{
return (!empty(self::$_defaultNamespaces));
}
/**
* @param mixed $value
* @param string $classBaseName
* @param array $args OPTIONAL
* @param mixed $namespaces OPTIONAL
* @return boolean
* @throws Zend_Validate_Exception
*/
public static function is($value, $classBaseName, array $args = array(), $namespaces = array())
{
$namespaces = array_merge((array) $namespaces, self::$_defaultNamespaces, array('Zend_Validate'));
$className = ucfirst($classBaseName);
try {
if (!class_exists($className, false)) {
require_once 'Zend/Loader.php';
foreach($namespaces as $namespace) {
$class = $namespace . '_' . $className;
$file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
if (Zend_Loader::isReadable($file)) {
Zend_Loader::loadClass($class);
$className = $class;
break;
}
}
}
$class = new ReflectionClass($className);
if ($class->implementsInterface('Zend_Validate_Interface')) {
if ($class->hasMethod('__construct')) {
$keys = array_keys($args);
$numeric = false;
foreach($keys as $key) {
if (is_numeric($key)) {
$numeric = true;
break;
}
}
if ($numeric) {
$object = $class->newInstanceArgs($args);
} else {
$object = $class->newInstance($args);
}
} else {
$object = $class->newInstance();
}
return $object->isValid($value);
}
} catch (Zend_Validate_Exception $ze) {
// if there is an exception while validating throw it
throw $ze;
} catch (Exception $e) {
// fallthrough and continue for missing validation classes
}
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("Validate class not found from basename '$classBaseName'");
}
/**
* Returns the maximum allowed message length
*
* @return integer
*/
public static function getMessageLength()
{
require_once 'Zend/Validate/Abstract.php';
return Zend_Validate_Abstract::getMessageLength();
}
/**
* Sets the maximum allowed message length
*
* @param integer $length
*/
public static function setMessageLength($length = -1)
{
require_once 'Zend/Validate/Abstract.php';
Zend_Validate_Abstract::setMessageLength($length);
}
/**
* Returns the default translation object
*
* @return Zend_Translate_Adapter|null
*/
public static function getDefaultTranslator($translator = null)
{
require_once 'Zend/Validate/Abstract.php';
return Zend_Validate_Abstract::getDefaultTranslator();
}
/**
* Sets a default translation object for all validation objects
*
* @param Zend_Translate|Zend_Translate_Adapter|null $translator
*/
public static function setDefaultTranslator($translator = null)
{
require_once 'Zend/Validate/Abstract.php';
Zend_Validate_Abstract::setDefaultTranslator($translator);
}
}
| nama | waktu | ukuran | owner | perm | aksi |
|---|---|---|---|---|---|
| .. | |||||
| Acl/ | 2016-11-07 16:01 | 18.18 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Auth/ | 2016-11-07 16:01 | 110.51 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Cache/ | 2016-11-07 16:01 | 301.58 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Config/ | 2016-11-07 16:01 | 67.48 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Controller/ | 2016-11-07 16:01 | 433.7 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Crypt/ | 2016-11-07 16:01 | 58.94 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Currency/ | 2016-11-07 15:59 | 2.25 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Date/ | 2016-11-07 15:59 | 63.91 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Db/ | 2016-11-07 16:01 | 522.98 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Dom/ | 2016-11-07 16:01 | 18.5 KB | 76129f60960:kunden | dxwrx-rx-r | |
| File/ | 2016-11-07 16:01 | 74.13 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Filter/ | 2016-11-07 16:01 | 248.23 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Form/ | 2016-11-07 16:01 | 256.39 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Http/ | 2016-11-07 16:01 | 292.14 KB | 76129f60960:kunden | dxwrx-rx-r | |
| InfoCard/ | 2016-11-07 16:01 | 110.37 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Json/ | 2016-11-07 15:59 | 40.19 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Layout/ | 2016-11-07 16:03 | 9.91 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Ldap/ | 2016-11-07 16:03 | 210.38 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Loader/ | 2016-11-07 16:01 | 79 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Locale/ | 2016-11-07 16:01 | 9.04 MB | 76129f60960:kunden | dxwrx-rx-r | |
| Log/ | 2016-11-07 16:01 | 68.07 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Mail/ | 2016-11-07 16:01 | 267.86 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Mime/ | 2016-11-07 15:59 | 24.28 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Navigation/ | 2016-11-07 16:01 | 81.02 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Oauth/ | 2016-11-07 16:01 | 92.36 KB | 76129f60960:kunden | dxwrx-rx-r | |
| OpenId/ | 2016-11-07 16:01 | 114.52 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Paginator/ | 2016-11-07 16:01 | 34.29 KB | 76129f60960:kunden | dxwrx-rx-r | |
| ProgressBar/ | 2016-11-07 16:01 | 26.92 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Rest/ | 2016-11-07 16:01 | 53.33 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Server/ | 2016-11-07 16:01 | 86.45 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Service/ | 2016-11-07 15:59 | 2.8 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Session/ | 2016-11-07 16:01 | 50.38 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Soap/ | 2016-11-07 16:01 | 134.06 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Stdlib/ | 2016-11-07 16:01 | 32.44 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Text/ | 2016-11-07 16:01 | 90.27 KB | 76129f60960:kunden | dxwrx-rx-r | |
| TimeSync/ | 2016-11-07 15:59 | 22.15 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Translate/ | 2016-11-07 16:01 | 86.71 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Uri/ | 2016-11-07 15:59 | 24.51 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Validate/ | 2016-11-07 16:01 | 818.28 KB | 76129f60960:kunden | dxwrx-rx-r | |
| View/ | 2016-11-07 16:01 | 428.19 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Wildfire/ | 2016-11-07 16:01 | 57.02 KB | 76129f60960:kunden | dxwrx-rx-r | |
| XmlRpc/ | 2016-11-07 16:02 | 139.14 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Acl.php | 2016-11-07 15:58 | 46.16 KB | 76129f60960:kunden | -xw-x----- | |
| Auth.php | 2016-11-07 15:58 | 3.95 KB | 76129f60960:kunden | -xw-x----- | |
| Cache.php | 2016-11-07 15:58 | 9.44 KB | 76129f60960:kunden | -xw-x----- | |
| Config.php | 2016-11-07 15:58 | 12.61 KB | 76129f60960:kunden | -xw-x----- | |
| Crypt.php | 2016-11-07 15:58 | 4.36 KB | 76129f60960:kunden | -xw-x----- | |
| Currency.php | 2016-11-07 15:58 | 28.97 KB | 76129f60960:kunden | -xw-x----- | |
| Date.php | 2016-11-07 15:58 | 193.33 KB | 76129f60960:kunden | -xw-x----- | |
| Db.php | 2016-11-07 15:58 | 9.85 KB | 76129f60960:kunden | -xw-x----- | |
| Debug.php | 2016-11-07 15:58 | 3.11 KB | 76129f60960:kunden | -xw-x----- | |
| Exception.php | 2016-11-07 15:58 | 2.45 KB | 76129f60960:kunden | -xw-x----- | |
| Filter.php | 2016-11-07 15:58 | 7 KB | 76129f60960:kunden | -xw-x----- | |
| Form.php | 2016-11-07 15:58 | 93.43 KB | 76129f60960:kunden | -xw-x----- | |
| InfoCard.php | 2016-11-07 15:58 | 17.23 KB | 76129f60960:kunden | -xw-x----- | |
| Json.php | 2016-11-07 15:58 | 16.7 KB | 76129f60960:kunden | -xw-x----- | |
| Layout.php | 2016-11-07 15:58 | 18.49 KB | 76129f60960:kunden | -xw-x----- | |
| Ldap.php | 2016-11-07 15:58 | 51.21 KB | 76129f60960:kunden | -xw-x----- | |
| Loader.php | 2016-11-07 15:58 | 11.29 KB | 76129f60960:kunden | -xw-x----- | |
| Locale.php | 2016-11-07 15:58 | 41.5 KB | 76129f60960:kunden | -xw-x----- | |
| Log.php | 2016-11-07 15:58 | 19.53 KB | 76129f60960:kunden | -xw-x----- | |
| Mail.php | 2016-11-07 15:58 | 31.56 KB | 76129f60960:kunden | -xw-x----- | |
| Mime.php | 2016-11-07 15:58 | 12.6 KB | 76129f60960:kunden | -xw-x----- | |
| Navigation.php | 2016-11-07 15:58 | 1.74 KB | 76129f60960:kunden | -xw-x----- | |
| Oauth.php | 2016-11-07 15:58 | 2.67 KB | 76129f60960:kunden | -xw-x----- | |
| OpenId.php | 2016-11-07 15:58 | 26.2 KB | 76129f60960:kunden | -xw-x----- | |
| Paginator.php | 2016-11-07 15:58 | 30.12 KB | 76129f60960:kunden | -xw-x----- | |
| ProgressBar.php | 2016-11-07 15:58 | 5.71 KB | 76129f60960:kunden | -xw-x----- | |
| Registry.php | 2016-11-07 15:58 | 5.91 KB | 76129f60960:kunden | -xw-x----- | |
| Session.php | 2016-11-07 15:58 | 29.51 KB | 76129f60960:kunden | -xw-x----- | |
| TimeSync.php | 2016-11-07 15:58 | 8.93 KB | 76129f60960:kunden | -xw-x----- | |
| Translate.php | 2016-11-07 15:58 | 5.97 KB | 76129f60960:kunden | -xw-x----- | |
| Uri.php | 2016-11-07 15:58 | 6.29 KB | 76129f60960:kunden | -xw-x----- | |
| Validate.php | 2016-11-07 15:58 | 8.16 KB | 76129f60960:kunden | -xw-x----- | |
| Version.php | 2016-11-07 15:58 | 2.45 KB | 76129f60960:kunden | -xw-x----- | |
| View.php | 2016-11-07 15:58 | 2.92 KB | 76129f60960:kunden | -xw-x----- | |