equal
deleted
inserted
replaced
12 * obtain it through the world-wide-web, please send an email |
12 * obtain it through the world-wide-web, please send an email |
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Validate |
16 * @package Zend_Validate |
17 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @version $Id: Abstract.php 25105 2012-11-07 20:33:22Z rob $ |
19 * @version $Id$ |
20 */ |
20 */ |
21 |
21 |
22 /** |
22 /** |
23 * @see Zend_Validate_Interface |
23 * @see Zend_Validate_Interface |
24 */ |
24 */ |
25 require_once 'Zend/Validate/Interface.php'; |
25 require_once 'Zend/Validate/Interface.php'; |
26 |
26 |
27 /** |
27 /** |
28 * @category Zend |
28 * @category Zend |
29 * @package Zend_Validate |
29 * @package Zend_Validate |
30 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
30 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
31 * @license http://framework.zend.com/license/new-bsd New BSD License |
31 * @license http://framework.zend.com/license/new-bsd New BSD License |
32 */ |
32 */ |
33 abstract class Zend_Validate_Abstract implements Zend_Validate_Interface |
33 abstract class Zend_Validate_Abstract implements Zend_Validate_Interface |
34 { |
34 { |
35 /** |
35 /** |
227 if (!in_array('__toString', get_class_methods($value))) { |
227 if (!in_array('__toString', get_class_methods($value))) { |
228 $value = get_class($value) . ' object'; |
228 $value = get_class($value) . ' object'; |
229 } else { |
229 } else { |
230 $value = $value->__toString(); |
230 $value = $value->__toString(); |
231 } |
231 } |
|
232 } elseif (is_array($value)) { |
|
233 $value = $this->_implodeRecursive($value); |
232 } else { |
234 } else { |
233 $value = implode((array) $value); |
235 $value = implode((array) $value); |
234 } |
236 } |
235 |
237 |
236 if ($this->getObscureValue()) { |
238 if ($this->getObscureValue()) { |
253 |
255 |
254 return $message; |
256 return $message; |
255 } |
257 } |
256 |
258 |
257 /** |
259 /** |
|
260 * Joins elements of a multidimensional array |
|
261 * |
|
262 * @param array $pieces |
|
263 * @return string |
|
264 */ |
|
265 protected function _implodeRecursive(array $pieces) |
|
266 { |
|
267 $values = array(); |
|
268 foreach ($pieces as $item) { |
|
269 if (is_array($item)) { |
|
270 $values[] = $this->_implodeRecursive($item); |
|
271 } else { |
|
272 $values[] = $item; |
|
273 } |
|
274 } |
|
275 |
|
276 return implode(', ', $values); |
|
277 } |
|
278 |
|
279 /** |
258 * @param string $messageKey |
280 * @param string $messageKey |
259 * @param string $value OPTIONAL |
281 * @param string $value OPTIONAL |
260 * @return void |
282 * @return void |
261 */ |
283 */ |
262 protected function _error($messageKey, $value = null) |
284 protected function _error($messageKey, $value = null) |
321 |
343 |
322 /** |
344 /** |
323 * Set translation object |
345 * Set translation object |
324 * |
346 * |
325 * @param Zend_Translate|Zend_Translate_Adapter|null $translator |
347 * @param Zend_Translate|Zend_Translate_Adapter|null $translator |
|
348 * @throws Zend_Validate_Exception |
326 * @return Zend_Validate_Abstract |
349 * @return Zend_Validate_Abstract |
327 */ |
350 */ |
328 public function setTranslator($translator = null) |
351 public function setTranslator($translator = null) |
329 { |
352 { |
330 if ((null === $translator) || ($translator instanceof Zend_Translate_Adapter)) { |
353 if ((null === $translator) || ($translator instanceof Zend_Translate_Adapter)) { |
368 |
391 |
369 /** |
392 /** |
370 * Set default translation object for all validate objects |
393 * Set default translation object for all validate objects |
371 * |
394 * |
372 * @param Zend_Translate|Zend_Translate_Adapter|null $translator |
395 * @param Zend_Translate|Zend_Translate_Adapter|null $translator |
373 * @return void |
396 * @throws Zend_Validate_Exception |
374 */ |
397 */ |
375 public static function setDefaultTranslator($translator = null) |
398 public static function setDefaultTranslator($translator = null) |
376 { |
399 { |
377 if ((null === $translator) || ($translator instanceof Zend_Translate_Adapter)) { |
400 if ((null === $translator) || ($translator instanceof Zend_Translate_Adapter)) { |
378 self::$_defaultTranslator = $translator; |
401 self::$_defaultTranslator = $translator; |