--- a/web/lib/Zend/Form.php Thu May 07 15:10:09 2015 +0200
+++ b/web/lib/Zend/Form.php Thu May 07 15:16:02 2015 +0200
@@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Form
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
@@ -26,9 +26,9 @@
*
* @category Zend
* @package Zend_Form
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Form.php 25223 2013-01-17 14:44:54Z frosch $
+ * @version $Id$
*/
class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
{
@@ -226,7 +226,6 @@
* Registers form view helper as decorator
*
* @param mixed $options
- * @return void
*/
public function __construct($options = null)
{
@@ -263,6 +262,7 @@
$displayGroups = array();
foreach ($this->_displayGroups as $group) {
+ /** @var Zend_Form_DisplayGroup $clone */
$clone = clone $group;
$elements = array();
foreach ($clone->getElements() as $name => $e) {
@@ -281,9 +281,11 @@
*/
public function reset()
{
+ /** @var Zend_Form_Element $element */
foreach ($this->getElements() as $element) {
$element->setValue(null);
}
+ /** @var Zend_Form_SubForm $subForm */
foreach ($this->getSubForms() as $subForm) {
$subForm->reset();
}
@@ -439,6 +441,7 @@
*
* @param string $type
* @return Zend_Loader_PluginLoader_Interface
+ * @throws Zend_Form_Exception
*/
public function getPluginLoader($type = null)
{
@@ -563,10 +566,12 @@
'type' => $type,
);
+ /** @var Zend_Form_Element $element */
foreach ($this->getElements() as $element) {
$element->addPrefixPath($prefix, $path, $type);
}
+ /** @var Zend_Form_SubForm $subForm */
foreach ($this->getSubForms() as $subForm) {
$subForm->addElementPrefixPath($prefix, $path, $type);
}
@@ -584,6 +589,7 @@
{
$this->_elementPrefixPaths = $this->_elementPrefixPaths + $spec;
+ /** @var Zend_Form_Element $element */
foreach ($this->getElements() as $element) {
$element->addPrefixPaths($spec);
}
@@ -605,6 +611,7 @@
'path' => $path,
);
+ /** @var Zend_Form_DisplayGroup $group */
foreach ($this->getDisplayGroups() as $group) {
$group->addPrefixPath($prefix, $path);
}
@@ -855,6 +862,7 @@
*
* @param string $name
* @return Zend_Form
+ * @throws Zend_Form_Exception
*/
public function setName($name)
{
@@ -1074,9 +1082,10 @@
* settings as specified in the form object (including plugin loader
* prefix paths, default decorators, etc.).
*
- * @param string $type
- * @param string $name
+ * @param string $type
+ * @param string $name
* @param array|Zend_Config $options
+ * @throws Zend_Form_Exception
* @return Zend_Form_Element
*/
public function createElement($type, $name, $options = null)
@@ -1234,6 +1243,7 @@
unset($this->_order[$name]);
$this->_orderUpdated = true;
} else {
+ /** @var Zend_Form_DisplayGroup $group */
foreach ($this->_displayGroups as $group) {
if (null !== $group->getElement($name)) {
$group->removeElement($name);
@@ -1279,6 +1289,7 @@
$eBelongTo = $this->getElementsBelongTo();
$defaults = $this->_dissolveArrayValue($defaults, $eBelongTo);
}
+ /** @var Zend_Form_Element $element */
foreach ($this->getElements() as $name => $element) {
$check = $defaults;
if (($belongsTo = $element->getBelongsTo()) !== $eBelongTo) {
@@ -1289,6 +1300,7 @@
$defaults = $this->_dissolveArrayUnsetKey($defaults, $belongsTo, $name);
}
}
+ /** @var Zend_Form_SubForm $form */
foreach ($this->getSubForms() as $name => $form) {
if (!$form->isArray() && array_key_exists($name, $defaults)) {
$form->setDefaults($defaults[$name]);
@@ -1313,6 +1325,7 @@
$element->setValue($value);
} else {
if (is_scalar($value)) {
+ /** @var Zend_Form_SubForm $subForm */
foreach ($this->getSubForms() as $subForm) {
$subForm->setDefault($name, $value);
}
@@ -1339,6 +1352,7 @@
return $subForm->getValues(true);
}
+ /** @var Zend_Form_SubForm $subForm */
foreach ($this->getSubForms() as $subForm) {
if ($name == $subForm->getElementsBelongTo()) {
return $subForm->getValues(true);
@@ -1361,7 +1375,7 @@
if ($this->isArray()) {
$eBelongTo = $this->getElementsBelongTo();
}
-
+ /** @var Zend_Form_Element $element */
foreach ($this->getElements() as $key => $element) {
if (!$element->getIgnore()) {
$merge = array();
@@ -1374,6 +1388,7 @@
$values = $this->_array_replace_recursive($values, $merge);
}
}
+ /** @var Zend_Form_SubForm $subForm */
foreach ($this->getSubForms() as $key => $subForm) {
$merge = array();
if (!$subForm->isArray()) {
@@ -1415,6 +1430,7 @@
$data = $this->_dissolveArrayValue($data, $eBelongTo);
}
$context = $data;
+ /** @var Zend_Form_Element $element */
foreach ($this->getElements() as $key => $element) {
if (!$element->getIgnore()) {
$check = $data;
@@ -1434,6 +1450,7 @@
}
}
}
+ /** @var Zend_Form_SubForm $form */
foreach ($this->getSubForms() as $key => $form) {
$merge = array();
if (isset($data[$key]) && !$form->isArray()) {
@@ -1481,6 +1498,7 @@
public function getUnfilteredValues()
{
$values = array();
+ /** @var Zend_Form_Element $element */
foreach ($this->getElements() as $key => $element) {
$values[$key] = $element->getUnfilteredValue();
}
@@ -1496,6 +1514,7 @@
*/
public function setElementFilters(array $filters)
{
+ /** @var Zend_Form_Element $element */
foreach ($this->getElements() as $element) {
$element->setFilters($filters);
}
@@ -1545,6 +1564,7 @@
}
if (null === $name) {
+ /** @var Zend_Form_Element $element */
foreach ($this->getElements() as $element) {
$element->setBelongsTo($array);
}
@@ -1606,6 +1626,7 @@
public function addSubForm(Zend_Form $form, $name, $order = null)
{
$name = (string) $name;
+ /** @var Zend_Loader_PluginLoader $loader */
foreach ($this->_loaders as $type => $loader) {
$loaderPaths = $loader->getPaths();
foreach ($loaderPaths as $prefix => $paths) {
@@ -1868,7 +1889,8 @@
* Add a display group object (used with cloning)
*
* @param Zend_Form_DisplayGroup $group
- * @param string|null $name
+ * @param string|null $name
+ * @throws Zend_Form_Exception
* @return Zend_Form
*/
protected function _addDisplayGroupObject(Zend_Form_DisplayGroup $group, $name = null)
@@ -2001,6 +2023,7 @@
{
$name = (string) $name;
if (array_key_exists($name, $this->_displayGroups)) {
+ /** @var Zend_Form_Element $element */
foreach ($this->_displayGroups[$name] as $key => $element) {
if (array_key_exists($key, $this->_elements)) {
$this->_order[$key] = $element->getOrder();
@@ -2030,6 +2053,7 @@
if (array_key_exists($key, $this->_order)) {
unset($this->_order[$key]);
}
+ /** @var Zend_Form_Element $element */
foreach ($group as $name => $element) {
if (isset($this->_elements[$name])) {
$this->_order[$name] = $element->getOrder();
@@ -2194,6 +2218,7 @@
array_splice($ordered, $order, 0, array($this->$name));
} else if ($this->$name instanceof Zend_Form_DisplayGroup) {
$subordered = array();
+ /** @var Zend_Form_Element $element */
foreach ($this->$name->getElements() as $element) {
$suborder = $element->getOrder();
$suborder = (null !== $suborder) ? $suborder : count($subordered);
@@ -2211,8 +2236,7 @@
* This is a helper function until php 5.3 is widespreaded
*
* @param array $into
- * @access protected
- * @return void
+ * @return array
*/
protected function _array_replace_recursive(array $into)
{
@@ -2237,7 +2261,8 @@
* Validate the form
*
* @param array $data
- * @return boolean
+ * @throws Zend_Form_Exception
+ * @return bool
*/
public function isValid($data)
{
@@ -2254,6 +2279,7 @@
$data = $this->_dissolveArrayValue($data, $eBelongTo);
}
$context = $data;
+ /** @var Zend_Form_Element $element */
foreach ($this->getElements() as $key => $element) {
if (null !== $translator && $this->hasTranslator()
&& !$element->hasTranslator()) {
@@ -2270,6 +2296,7 @@
$data = $this->_dissolveArrayUnsetKey($data, $belongsTo, $key);
}
}
+ /** @var Zend_Form_SubForm $form */
foreach ($this->getSubForms() as $key => $form) {
if (null !== $translator && $this->hasTranslator()
&& !$form->hasTranslator()) {
@@ -2313,6 +2340,7 @@
$valid = true;
$context = $data;
+ /** @var Zend_Form_Element $element */
foreach ($this->getElements() as $key => $element) {
$check = $data;
if (($belongsTo = $element->getBelongsTo()) !== $eBelongTo) {
@@ -2326,6 +2354,7 @@
$data = $this->_dissolveArrayUnsetKey($data, $belongsTo, $key);
}
}
+ /** @var Zend_Form_SubForm $form */
foreach ($this->getSubForms() as $key => $form) {
if (null !== $translator && !$form->hasTranslator()) {
$form->setTranslator($translator);
@@ -2494,13 +2523,34 @@
*/
public function hasErrors()
{
- return $this->_errorsExist;
+ $errors = $this->_errorsExist;
+
+ if (!$errors) {
+ /** @var Zend_Form_Element $element */
+ foreach ($this->getElements() as $element) {
+ if ($element->hasErrors()) {
+ $errors = true;
+ break;
+ }
+ }
+
+ /** @var Zend_Form_SubForm $subForm */
+ foreach ($this->getSubForms() as $subForm) {
+ if ($subForm->hasErrors()) {
+ $errors = true;
+ break;
+ }
+ }
+ }
+
+ return $errors;
}
/**
* Get error codes for all elements failing validation
*
* @param string $name
+ * @param bool $suppressArrayNotation
* @return array
*/
public function getErrors($name = null, $suppressArrayNotation = false)
@@ -2514,9 +2564,11 @@
}
}
+ /** @var Zend_Form_Element $element */
foreach ($this->_elements as $key => $element) {
$errors[$key] = $element->getErrors();
}
+ /** @var Zend_Form_SubForm $subForm */
foreach ($this->getSubForms() as $key => $subForm) {
$merge = array();
if (!$subForm->isArray()) {
@@ -2552,6 +2604,7 @@
} else if (isset($this->_subForms[$name])) {
return $this->getSubForm($name)->getMessages(null, true);
}
+ /** @var Zend_Form_SubForm $subForm */
foreach ($this->getSubForms() as $key => $subForm) {
if ($subForm->isArray()) {
$belongTo = $subForm->getElementsBelongTo();
@@ -2569,6 +2622,7 @@
$messages = array();
+ /** @var Zend_Form_Element $element */
foreach ($this->getElements() as $name => $element) {
$eMessages = $element->getMessages();
if (!empty($eMessages)) {
@@ -2576,6 +2630,7 @@
}
}
+ /** @var Zend_Form_SubForm $subForm */
foreach ($this->getSubForms() as $key => $subForm) {
$merge = $subForm->getMessages(null, true);
if (!empty($merge)) {
@@ -2665,7 +2720,8 @@
* Add a decorator for rendering the element
*
* @param string|Zend_Form_Decorator_Interface $decorator
- * @param array|Zend_Config $options Options with which to initialize decorator
+ * @param array|Zend_Config $options Options with which to initialize decorator
+ * @throws Zend_Form_Exception
* @return Zend_Form
*/
public function addDecorator($decorator, $options = null)
@@ -2708,6 +2764,7 @@
* Add many decorators at once
*
* @param array $decorators
+ * @throws Zend_Form_Exception
* @return Zend_Form
*/
public function addDecorators(array $decorators)
@@ -2876,6 +2933,7 @@
$elementObjs = $this->getElements();
}
+ /** @var Zend_Form_Element $element */
foreach ($elementObjs as $element) {
$element->setDecorators($decorators);
}
@@ -2893,6 +2951,7 @@
*/
public function setDisplayGroupDecorators(array $decorators)
{
+ /** @var Zend_Form_DisplayGroup $group */
foreach ($this->getDisplayGroups() as $group) {
$group->setDecorators($decorators);
}
@@ -2908,6 +2967,7 @@
*/
public function setSubFormDecorators(array $decorators)
{
+ /** @var Zend_Form_SubForm $form */
foreach ($this->getSubForms() as $form) {
$form->setDecorators($decorators);
}
@@ -2928,6 +2988,7 @@
}
$content = '';
+ /** @var Zend_Form_Decorator_Abstract $decorator */
foreach ($this->getDecorators() as $decorator) {
$decorator->setElement($this);
$content = $decorator->render($content);
@@ -2963,6 +3024,7 @@
* Set translator object
*
* @param Zend_Translate|Zend_Translate_Adapter|null $translator
+ * @throws Zend_Form_Exception
* @return Zend_Form
*/
public function setTranslator($translator = null)
@@ -2985,6 +3047,7 @@
* Set global default translator object
*
* @param Zend_Translate|Zend_Translate_Adapter|null $translator
+ * @throws Zend_Form_Exception
* @return void
*/
public static function setDefaultTranslator($translator = null)
@@ -3206,6 +3269,7 @@
/**
* Current element/subform/display group
*
+ * @throws Zend_Form_Exception
* @return Zend_Form_Element|Zend_Form_DisplayGroup|Zend_Form
*/
public function current()
@@ -3339,6 +3403,7 @@
/**
* Sort items according to their order
*
+ * @throws Zend_Form_Exception
* @return void
*/
protected function _sort()
@@ -3357,6 +3422,13 @@
} else {
$items[$order] = $key;
}
+ } elseif (isset($items[$order]) && $items[$order] !== $key) {
+ throw new Zend_Form_Exception('Form elements ' .
+ $items[$order] . ' and ' . $key .
+ ' have the same order (' .
+ $order . ') - ' .
+ 'this would result in only the last added element to be rendered'
+ );
} else {
$items[$order] = $key;
}