import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
@ -17,16 +16,14 @@
|
||||
* @package Zend_Validate
|
||||
* @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: Abstract.php 12359 2008-11-07 09:37:50Z thomas $
|
||||
* @version $Id: Abstract.php 14317 2009-03-13 20:39:31Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Validate_Interface
|
||||
*/
|
||||
require_once 'Zend/Validate/Interface.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Validate
|
||||
@ -90,6 +87,12 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface
|
||||
*/
|
||||
protected static $_defaultTranslator;
|
||||
|
||||
/**
|
||||
* Is translation disabled?
|
||||
* @var Boolean
|
||||
*/
|
||||
protected $_translatorDisabled = false;
|
||||
|
||||
/**
|
||||
* Returns array of validation failure messages
|
||||
*
|
||||
@ -110,6 +113,16 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface
|
||||
return array_keys($this->_messageVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the message templates from the validator
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMessageTemplates()
|
||||
{
|
||||
return $this->_messageTemplates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the validation failure message template for a particular key
|
||||
*
|
||||
@ -198,6 +211,16 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface
|
||||
}
|
||||
}
|
||||
|
||||
if (is_object($value)) {
|
||||
if (!in_array('__toString', get_class_methods($value))) {
|
||||
$value = get_class($value) . ' object';
|
||||
} else {
|
||||
$value = $value->__toString();
|
||||
}
|
||||
} else {
|
||||
$value = (string)$value;
|
||||
}
|
||||
|
||||
if ($this->getObscureValue()) {
|
||||
$value = str_repeat('*', strlen($value));
|
||||
}
|
||||
@ -300,6 +323,10 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface
|
||||
*/
|
||||
public function getTranslator()
|
||||
{
|
||||
if ($this->translatorIsDisabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (null === $this->_translator) {
|
||||
return self::getDefaultTranslator();
|
||||
}
|
||||
@ -343,6 +370,29 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self::$_defaultTranslator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate whether or not translation should be disabled
|
||||
*
|
||||
* @param bool $flag
|
||||
* @return Zend_Validate_Abstract
|
||||
*/
|
||||
public function setDisableTranslator($flag)
|
||||
{
|
||||
$this->_translatorDisabled = (bool) $flag;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is translation disabled?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function translatorIsDisabled()
|
||||
{
|
||||
return $this->_translatorDisabled;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user