cvs: pear /HTML_QuickForm2/QuickForm2/Element Select.php /HTML_QuickForm2/tests/QuickForm2/Element SelectTest.php

From: Date: Fri, 20 Oct 2006 09:09:45 +0000
Subject: cvs: pear /HTML_QuickForm2/QuickForm2/Element Select.php /HTML_QuickForm2/tests/QuickForm2/Element SelectTest.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-42675@lists.php.net to get a copy of this message
avb Fri Oct 20 09:09:45 2006 UTC Modified files: /pear/HTML_QuickForm2/QuickForm2/Element Select.php /pear/HTML_QuickForm2/tests/QuickForm2/Element SelectTest.php Log: We won't allow changing added options, therefore little sense for Select to implement IteratorAggregate and Countable http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm2/QuickForm2/Element/Select.php?r1=1.2&r2=1.3&diff_format=u Index: pear/HTML_QuickForm2/QuickForm2/Element/Select.php diff -u pear/HTML_QuickForm2/QuickForm2/Element/Select.php:1.2 pear/HTML_QuickForm2/QuickForm2/Element/Select.php:1.3 --- pear/HTML_QuickForm2/QuickForm2/Element/Select.php:1.2 Thu Oct 19 21:40:29 2006 +++ pear/HTML_QuickForm2/QuickForm2/Element/Select.php Fri Oct 20 09:09:44 2006 @@ -39,7 +39,7 @@ * @author Alexey Borzov <avb@php.net> * @author Bertrand Mansion <golgote@mamasam.com> * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Select.php,v 1.2 2006/10/19 21:40:29 avb Exp $ + * @version CVS: $Id: Select.php,v 1.3 2006/10/20 09:09:44 avb Exp $ * @link http://pear.php.net/package/HTML_QuickForm2 */ @@ -285,9 +285,6 @@ /** * Class representing a <select> element * - * Implementation-wise, this class is a Decorator around - * {@see HTML_QuickForm2_Element_Select_OptionContainer} - * * @category HTML * @package HTML_QuickForm2 * @author Alexey Borzov <avb@php.net> @@ -296,7 +293,6 @@ * @todo Unit tests and better PHPDoc for loadOptions() */ class HTML_QuickForm2_Element_Select extends HTML_QuickForm2_Element - implements IteratorAggregate, Countable { protected $persistent = true; @@ -370,7 +366,7 @@ } $valueHash = is_array($value)? array_flip($value): array($value => true); $options = array(); - foreach ($this->getRecursiveIterator() as $child) { + foreach ($this->optionContainer->getRecursiveIterator() as $child) { if (is_array($child) && isset($valueHash[$child['attr']['value']]) && empty($child['attr']['disabled'])) { @@ -412,8 +408,8 @@ */ public function getValue() { - if (0 == count($this) || !empty($this->attributes['disabled']) || - 0 == count($this->values) || 0 == count($this->possibleValues)) + if (0 == count($this->optionContainer) || 0 == count($this->values) || + 0 == count($this->possibleValues) || !empty($this->attributes['disabled'])) { return null; } @@ -434,7 +430,7 @@ // The <select> is not multiple, but several options are to be // selected. At least IE and Mozilla select the last selected // option in this case, we should do the same - foreach ($this->getRecursiveIterator() as $child) { + foreach ($this->optionContainer->getRecursiveIterator() as $child) { if (is_array($child) && in_array($child['attr']['value'], $values)) { $lastValue = $child['attr']['value']; } @@ -499,10 +495,6 @@ } - // - // The following methods decorate those of OptionContainer - // - /** * Adds a new option * @@ -531,35 +523,5 @@ { return $this->optionContainer->addOptgroup($label, $attributes); } - - /** - * Returns an iterator over contained elements - * - * @return HTML_QuickForm2_Element_Select_OptionIterator - */ - public function getIterator() - { - return $this->optionContainer->getIterator(); - } - - /** - * Returns a recursive iterator over contained elements - * - * @return RecursiveIteratorIterator - */ - public function getRecursiveIterator() - { - return $this->optionContainer->getRecursiveIterator(); - } - - /** - * Returns the number of options in the container - * - * @return int - */ - public function count() - { - return $this->optionContainer->count(); - } } ?> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm2/tests/QuickForm2/Element/SelectTest.php?r1=1.2&r2=1.3&diff_format=u Index: pear/HTML_QuickForm2/tests/QuickForm2/Element/SelectTest.php diff -u pear/HTML_QuickForm2/tests/QuickForm2/Element/SelectTest.php:1.2 pear/HTML_QuickForm2/tests/QuickForm2/Element/SelectTest.php:1.3 --- pear/HTML_QuickForm2/tests/QuickForm2/Element/SelectTest.php:1.2 Thu Oct 19 21:40:29 2006 +++ pear/HTML_QuickForm2/tests/QuickForm2/Element/SelectTest.php Fri Oct 20 09:09:44 2006 @@ -38,7 +38,7 @@ * @package HTML_QuickForm2 * @author Alexey Borzov <avb@php.net> * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: SelectTest.php,v 1.2 2006/10/19 21:40:29 avb Exp $ + * @version CVS: $Id: SelectTest.php,v 1.3 2006/10/20 09:09:44 avb Exp $ * @link http://pear.php.net/package/HTML_QuickForm2 */ @@ -71,7 +71,6 @@ public function testSelectIsEmptyByDefault() { $sel = new HTML_QuickForm2_Element_Select(); - $this->assertEquals(0, count($sel)); $this->assertNull($sel->getValue()); $this->assertRegExp( '!^<select[^>]*>\\s*</select>$!',

« previous php.pear.cvs (#42675) next »