From de184bcf486d8c5b502c6880038b263b07f5cab5 Mon Sep 17 00:00:00 2001 From: Nick Sagona Date: Fri, 17 Jun 2016 17:22:24 -0500 Subject: [PATCH] Add exclude functionality to addFilter() method --- src/AbstractForm.php | 148 ++++++++++++++++++++++++++-- src/Element/AbstractElement.php | 2 +- src/Element/Button.php | 2 +- src/Element/CheckboxSet.php | 2 +- src/Element/ElementInterface.php | 2 +- src/Element/Exception.php | 2 +- src/Element/Input.php | 2 +- src/Element/Input/Button.php | 2 +- src/Element/Input/Captcha.php | 2 +- src/Element/Input/Checkbox.php | 2 +- src/Element/Input/Color.php | 2 +- src/Element/Input/Csrf.php | 2 +- src/Element/Input/Datalist.php | 2 +- src/Element/Input/Date.php | 2 +- src/Element/Input/DateTime.php | 2 +- src/Element/Input/DateTimeLocal.php | 2 +- src/Element/Input/Email.php | 2 +- src/Element/Input/Exception.php | 2 +- src/Element/Input/File.php | 2 +- src/Element/Input/Hidden.php | 2 +- src/Element/Input/Month.php | 2 +- src/Element/Input/Number.php | 2 +- src/Element/Input/Password.php | 2 +- src/Element/Input/Radio.php | 2 +- src/Element/Input/Range.php | 2 +- src/Element/Input/Reset.php | 2 +- src/Element/Input/Search.php | 2 +- src/Element/Input/Submit.php | 2 +- src/Element/Input/Tel.php | 2 +- src/Element/Input/Text.php | 2 +- src/Element/Input/Time.php | 2 +- src/Element/Input/Url.php | 2 +- src/Element/Input/Week.php | 2 +- src/Element/RadioSet.php | 2 +- src/Element/Select.php | 2 +- src/Element/Textarea.php | 2 +- src/Exception.php | 2 +- src/Fields.php | 2 +- src/Form.php | 88 +---------------- src/Template/AbstractTemplate.php | 2 +- src/Template/Exception.php | 2 +- src/Template/File.php | 2 +- src/Template/Stream.php | 2 +- src/Template/TemplateInterface.php | 2 +- 44 files changed, 185 insertions(+), 135 deletions(-) diff --git a/src/AbstractForm.php b/src/AbstractForm.php index 02a7d0f..8cd6996 100644 --- a/src/AbstractForm.php +++ b/src/AbstractForm.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ abstract class AbstractForm extends Child implements \ArrayAccess { @@ -46,6 +46,18 @@ abstract class AbstractForm extends Child implements \ArrayAccess */ protected $filters = []; + /** + * Fields to exclude filtering by type + * @var array + */ + protected $filterExcludeByType = []; + + /** + * Fields to exclude filtering by name + * @var array + */ + protected $filterExcludeByName = []; + /** * Form field groups * @var array @@ -129,14 +141,41 @@ public function setMethod($method) * * @param mixed $call * @param mixed $params + * @param mixed $excludeByType + * @param mixed $excludeByName * @return AbstractForm */ - public function addFilter($call, $params = null) + public function addFilter($call, $params = null, $excludeByType = null, $excludeByName = null) { $this->filters[] = [ 'call' => $call, 'params' => $params ]; + + if (null !== $excludeByType) { + if (!is_array($excludeByType)) { + $excludeByType = [$excludeByType]; + } + foreach ($excludeByType as $type) { + if (!isset($this->filterExcludeByType[$type])) { + $this->filterExcludeByType[$type] = []; + } + $this->filterExcludeByType[$type][] = $call; + } + } + + if (null !== $excludeByName) { + if (!is_array($excludeByName)) { + $excludeByName = [$excludeByName]; + } + foreach ($excludeByName as $name) { + if (!isset($this->filterExcludeByName[$name])) { + $this->filterExcludeByName[$name] = []; + } + $this->filterExcludeByName[$name][] = $call; + } + } + return $this; } @@ -145,16 +184,18 @@ public function addFilter($call, $params = null) * * @param array $filters * @throws Exception + * @param mixed $excludeByType + * @param mixed $excludeByName * @return AbstractForm */ - public function addFilters(array $filters) + public function addFilters(array $filters, $excludeByType = null, $excludeByName = null) { foreach ($filters as $filter) { if (!isset($filter['call'])) { throw new Exception('Error: The \'call\' key must be set.'); } $params = (isset($filter['params'])) ? $filter['params'] : null; - $this->addFilter($filter['call'], $params); + $this->addFilter($filter['call'], $params, $excludeByType, $excludeByName); } return $this; } @@ -220,6 +261,92 @@ public function getFields() return $this->fields; } + /** + * Alias method to getElements()) + * + * @return array + */ + public function elements() + { + return $this->getElements(); + } + + /** + * Get the elements of the form object. + * + * @return array + */ + public function getElements() + { + $children = $this->getChildren(); + $elements = []; + + foreach ($children as $child) { + if ($child instanceof Element\AbstractElement){ + $elements[] = $child; + } + } + + return $elements; + } + + /** + * Alias method to getElement() + * + * @param string $elementName + * @return Element\AbstractElement + */ + public function element($elementName) + { + return $this->getElement($elementName); + } + + /** + * Get an element object of the form by name. + * + * @param string $elementName + * @return Element\AbstractElement + */ + public function getElement($elementName) + { + $i = $this->getElementIndex($elementName); + return (null !== $i) ? $this->getChild($this->getElementIndex($elementName)) : null; + } + + /** + * Get the index of an element object of the form by name. + * + * @param string $elementName + * @return int + */ + public function getElementIndex($elementName) + { + $name = null; + $elem = null; + $index = null; + $elems = $this->getChildren(); + + foreach ($elems as $i => $e) { + if ($e->getNodeName() == 'fieldset') { + $children = $e->getChildren(); + foreach ($children as $c) { + if ($c->getNodeName() == 'input') { + $attribs = $c->getAttributes(); + $name = str_replace('[]', '', $attribs['name']); + } + } + } else { + $attribs = $e->getAttributes(); + $name = $attribs['name']; + } + if ($name == $elementName) { + $index = $i; + } + } + + return $index; + } + /** * Get fieldConfig * @@ -316,8 +443,17 @@ protected function filterValues(array $values = null) protected function applyFilter(&$array, $call, $params = []) { array_walk_recursive($array, function(&$value, $key, $userdata) { - $params = array_merge([$value], $userdata[1]); - $value = call_user_func_array($userdata[0], $params); + $element = $this->getElement($key); + $type = ((null !== $element) && ($element instanceof \Pop\Form\Element\AbstractElement)) ? + $element->getType() : -1; + + if (((!isset($this->filterExcludeByType[$type])) || + (isset($this->filterExcludeByType[$type]) && !in_array($userdata[0], $this->filterExcludeByType[$type]))) && + ((!isset($this->filterExcludeByName[$key])) || + (isset($this->filterExcludeByName[$key]) && !in_array($userdata[0], $this->filterExcludeByName[$key])))) { + $params = array_merge([$value], $userdata[1]); + $value = call_user_func_array($userdata[0], $params); + } }, [$call, $params]); } diff --git a/src/Element/AbstractElement.php b/src/Element/AbstractElement.php index 9386d92..f709c8f 100644 --- a/src/Element/AbstractElement.php +++ b/src/Element/AbstractElement.php @@ -24,7 +24,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ abstract class AbstractElement extends Child implements ElementInterface { diff --git a/src/Element/Button.php b/src/Element/Button.php index d2512f8..6ea70c6 100644 --- a/src/Element/Button.php +++ b/src/Element/Button.php @@ -21,7 +21,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Button extends AbstractElement diff --git a/src/Element/CheckboxSet.php b/src/Element/CheckboxSet.php index 9ebfde4..75830b1 100644 --- a/src/Element/CheckboxSet.php +++ b/src/Element/CheckboxSet.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class CheckboxSet extends AbstractElement diff --git a/src/Element/ElementInterface.php b/src/Element/ElementInterface.php index 5455345..622dc2f 100644 --- a/src/Element/ElementInterface.php +++ b/src/Element/ElementInterface.php @@ -21,7 +21,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ interface ElementInterface { diff --git a/src/Element/Exception.php b/src/Element/Exception.php index 6b4ec25..db8069d 100644 --- a/src/Element/Exception.php +++ b/src/Element/Exception.php @@ -21,6 +21,6 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Exception extends \Exception {} diff --git a/src/Element/Input.php b/src/Element/Input.php index 1d2241e..d360e14 100644 --- a/src/Element/Input.php +++ b/src/Element/Input.php @@ -21,7 +21,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Input extends AbstractElement diff --git a/src/Element/Input/Button.php b/src/Element/Input/Button.php index 0105c64..0ee1843 100644 --- a/src/Element/Input/Button.php +++ b/src/Element/Input/Button.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Button extends Element\Input diff --git a/src/Element/Input/Captcha.php b/src/Element/Input/Captcha.php index e500e76..76e5250 100644 --- a/src/Element/Input/Captcha.php +++ b/src/Element/Input/Captcha.php @@ -21,7 +21,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Captcha extends Text diff --git a/src/Element/Input/Checkbox.php b/src/Element/Input/Checkbox.php index 97d497b..95d1ac3 100644 --- a/src/Element/Input/Checkbox.php +++ b/src/Element/Input/Checkbox.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Checkbox extends Element\Input diff --git a/src/Element/Input/Color.php b/src/Element/Input/Color.php index f92403c..6257ead 100644 --- a/src/Element/Input/Color.php +++ b/src/Element/Input/Color.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Color extends Element\Input diff --git a/src/Element/Input/Csrf.php b/src/Element/Input/Csrf.php index f0a9f38..7139a60 100644 --- a/src/Element/Input/Csrf.php +++ b/src/Element/Input/Csrf.php @@ -21,7 +21,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Csrf extends Hidden diff --git a/src/Element/Input/Datalist.php b/src/Element/Input/Datalist.php index 4d6765f..92961d2 100644 --- a/src/Element/Input/Datalist.php +++ b/src/Element/Input/Datalist.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Datalist extends Text diff --git a/src/Element/Input/Date.php b/src/Element/Input/Date.php index e03fd69..cd985e6 100644 --- a/src/Element/Input/Date.php +++ b/src/Element/Input/Date.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Date extends Element\Input diff --git a/src/Element/Input/DateTime.php b/src/Element/Input/DateTime.php index 8310bc2..4687958 100644 --- a/src/Element/Input/DateTime.php +++ b/src/Element/Input/DateTime.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class DateTime extends Element\Input diff --git a/src/Element/Input/DateTimeLocal.php b/src/Element/Input/DateTimeLocal.php index 38e4d11..066b93e 100644 --- a/src/Element/Input/DateTimeLocal.php +++ b/src/Element/Input/DateTimeLocal.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class DateTimeLocal extends Element\Input diff --git a/src/Element/Input/Email.php b/src/Element/Input/Email.php index 281ebc8..af9bfa4 100644 --- a/src/Element/Input/Email.php +++ b/src/Element/Input/Email.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Email extends Element\Input diff --git a/src/Element/Input/Exception.php b/src/Element/Input/Exception.php index 65d0e1c..48c7189 100644 --- a/src/Element/Input/Exception.php +++ b/src/Element/Input/Exception.php @@ -21,6 +21,6 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Exception extends \Exception {} diff --git a/src/Element/Input/File.php b/src/Element/Input/File.php index b126b26..827eac7 100644 --- a/src/Element/Input/File.php +++ b/src/Element/Input/File.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class File extends Element\Input diff --git a/src/Element/Input/Hidden.php b/src/Element/Input/Hidden.php index 4aeee9c..941149f 100644 --- a/src/Element/Input/Hidden.php +++ b/src/Element/Input/Hidden.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Hidden extends Element\Input diff --git a/src/Element/Input/Month.php b/src/Element/Input/Month.php index 9f72ec7..35db161 100644 --- a/src/Element/Input/Month.php +++ b/src/Element/Input/Month.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Month extends Element\Input diff --git a/src/Element/Input/Number.php b/src/Element/Input/Number.php index 99e4580..9c12f7d 100644 --- a/src/Element/Input/Number.php +++ b/src/Element/Input/Number.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Number extends Element\Input diff --git a/src/Element/Input/Password.php b/src/Element/Input/Password.php index 00e3a4e..5a4d676 100644 --- a/src/Element/Input/Password.php +++ b/src/Element/Input/Password.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Password extends Element\Input diff --git a/src/Element/Input/Radio.php b/src/Element/Input/Radio.php index 973e09f..b258da9 100644 --- a/src/Element/Input/Radio.php +++ b/src/Element/Input/Radio.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Radio extends Element\Input diff --git a/src/Element/Input/Range.php b/src/Element/Input/Range.php index fad9f36..67e1423 100644 --- a/src/Element/Input/Range.php +++ b/src/Element/Input/Range.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Range extends Element\Input diff --git a/src/Element/Input/Reset.php b/src/Element/Input/Reset.php index 1e37f67..1f34e4a 100644 --- a/src/Element/Input/Reset.php +++ b/src/Element/Input/Reset.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Reset extends Element\Input diff --git a/src/Element/Input/Search.php b/src/Element/Input/Search.php index bf2dfbc..b23a4d6 100644 --- a/src/Element/Input/Search.php +++ b/src/Element/Input/Search.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Search extends Element\Input diff --git a/src/Element/Input/Submit.php b/src/Element/Input/Submit.php index 4a57f4f..fa279c7 100644 --- a/src/Element/Input/Submit.php +++ b/src/Element/Input/Submit.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Submit extends Element\Input diff --git a/src/Element/Input/Tel.php b/src/Element/Input/Tel.php index d99c621..744084c 100644 --- a/src/Element/Input/Tel.php +++ b/src/Element/Input/Tel.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Tel extends Element\Input diff --git a/src/Element/Input/Text.php b/src/Element/Input/Text.php index 9262393..d91de61 100644 --- a/src/Element/Input/Text.php +++ b/src/Element/Input/Text.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Text extends Element\Input diff --git a/src/Element/Input/Time.php b/src/Element/Input/Time.php index 186c498..8f76669 100644 --- a/src/Element/Input/Time.php +++ b/src/Element/Input/Time.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Time extends Element\Input diff --git a/src/Element/Input/Url.php b/src/Element/Input/Url.php index 12111c8..3f291c5 100644 --- a/src/Element/Input/Url.php +++ b/src/Element/Input/Url.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Url extends Element\Input diff --git a/src/Element/Input/Week.php b/src/Element/Input/Week.php index 302f4ed..4a7e99e 100644 --- a/src/Element/Input/Week.php +++ b/src/Element/Input/Week.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Week extends Element\Input diff --git a/src/Element/RadioSet.php b/src/Element/RadioSet.php index a5a7268..5a4bace 100644 --- a/src/Element/RadioSet.php +++ b/src/Element/RadioSet.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class RadioSet extends AbstractElement diff --git a/src/Element/Select.php b/src/Element/Select.php index 16caa4b..66b99eb 100644 --- a/src/Element/Select.php +++ b/src/Element/Select.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Select extends AbstractElement diff --git a/src/Element/Textarea.php b/src/Element/Textarea.php index c9605dd..59f480b 100644 --- a/src/Element/Textarea.php +++ b/src/Element/Textarea.php @@ -21,7 +21,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Textarea extends AbstractElement diff --git a/src/Exception.php b/src/Exception.php index d2f0756..f1b306b 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -21,6 +21,6 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Exception extends \Exception {} diff --git a/src/Fields.php b/src/Fields.php index 9998d03..d33a08d 100644 --- a/src/Fields.php +++ b/src/Fields.php @@ -21,7 +21,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Fields implements \ArrayAccess { diff --git a/src/Form.php b/src/Form.php index 35f5124..f0a125d 100644 --- a/src/Form.php +++ b/src/Form.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Form extends AbstractForm { @@ -482,92 +482,6 @@ public function addElements(array $e) return $this; } - /** - * Alias method to getElements()) - * - * @return array - */ - public function elements() - { - return $this->getElements(); - } - - /** - * Get the elements of the form object. - * - * @return array - */ - public function getElements() - { - $children = $this->getChildren(); - $elements = []; - - foreach ($children as $child) { - if ($child instanceof Element\AbstractElement){ - $elements[] = $child; - } - } - - return $elements; - } - - /** - * Alias method to getElement() - * - * @param string $elementName - * @return Element\AbstractElement - */ - public function element($elementName) - { - return $this->getElement($elementName); - } - - /** - * Get an element object of the form by name. - * - * @param string $elementName - * @return Element\AbstractElement - */ - public function getElement($elementName) - { - $i = $this->getElementIndex($elementName); - return (null !== $i) ? $this->getChild($this->getElementIndex($elementName)) : null; - } - - /** - * Get the index of an element object of the form by name. - * - * @param string $elementName - * @return int - */ - public function getElementIndex($elementName) - { - $name = null; - $elem = null; - $index = null; - $elems = $this->getChildren(); - - foreach ($elems as $i => $e) { - if ($e->getNodeName() == 'fieldset') { - $children = $e->getChildren(); - foreach ($children as $c) { - if ($c->getNodeName() == 'input') { - $attribs = $c->getAttributes(); - $name = str_replace('[]', '', $attribs['name']); - } - } - } else { - $attribs = $e->getAttributes(); - $name = $attribs['name']; - } - if ($name == $elementName) { - $index = $i; - } - } - - return $index; - } - /** * Remove a form element * diff --git a/src/Template/AbstractTemplate.php b/src/Template/AbstractTemplate.php index 2dbb425..90b0548 100644 --- a/src/Template/AbstractTemplate.php +++ b/src/Template/AbstractTemplate.php @@ -21,7 +21,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ abstract class AbstractTemplate implements TemplateInterface { diff --git a/src/Template/Exception.php b/src/Template/Exception.php index 8facfb3..d2a75f3 100644 --- a/src/Template/Exception.php +++ b/src/Template/Exception.php @@ -21,6 +21,6 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Exception extends \Exception {} diff --git a/src/Template/File.php b/src/Template/File.php index d30be6e..7cc42bf 100644 --- a/src/Template/File.php +++ b/src/Template/File.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class File extends AbstractTemplate { diff --git a/src/Template/Stream.php b/src/Template/Stream.php index 26cf3c7..22d7e51 100644 --- a/src/Template/Stream.php +++ b/src/Template/Stream.php @@ -23,7 +23,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ class Stream extends AbstractTemplate { diff --git a/src/Template/TemplateInterface.php b/src/Template/TemplateInterface.php index 09fd94e..8127bbc 100644 --- a/src/Template/TemplateInterface.php +++ b/src/Template/TemplateInterface.php @@ -21,7 +21,7 @@ * @author Nick Sagona, III * @copyright Copyright (c) 2009-2016 NOLA Interactive, LLC. (http://www.nolainteractive.com) * @license http://www.popphp.org/license New BSD License - * @version 2.0.1 + * @version 2.0.2 */ interface TemplateInterface {