From 9d95a6ad8943ebd5dc3619f032e22e187016748f Mon Sep 17 00:00:00 2001 From: Alberto Viana Date: Mon, 3 Mar 2014 10:07:20 -0300 Subject: [PATCH 01/13] Remove unused files --- .../Form/View/Helper/FormElement.php | 85 ------------------- .../Form/View/Helper/FormLabel.php | 17 ---- 2 files changed, 102 deletions(-) delete mode 100755 src/AgvBootstrap/Form/View/Helper/FormElement.php delete mode 100755 src/AgvBootstrap/Form/View/Helper/FormLabel.php diff --git a/src/AgvBootstrap/Form/View/Helper/FormElement.php b/src/AgvBootstrap/Form/View/Helper/FormElement.php deleted file mode 100755 index 4691cdb..0000000 --- a/src/AgvBootstrap/Form/View/Helper/FormElement.php +++ /dev/null @@ -1,85 +0,0 @@ -getView(); - if (!method_exists($renderer, 'plugin')) { - // Bail early if renderer is not pluggable - return ''; - } - - //TODO - captcha -// if ($element instanceof Element\Captcha) { -// $helper = $renderer->plugin('form_captcha'); -// return $helper($element); -// } -// -// //CSRF -// if ($element instanceof Element\Csrf) { -// $helper = $renderer->plugin('form_hidden_twb'); -// return $helper($element, $formType, $displayOptions); -// } - //TODO - collection - if ($element instanceof Element\Collection) { - $helper = $renderer->plugin('form_collection'); - return $helper($element); - } - - $type = $element->getAttribute('type'); - -// //Multi Checkbox -// if ('multi_checkbox' == $type && is_array($element->getValueOptions())) { -// $helper = $renderer->plugin('form_multi_checkbox_twb'); -// return $helper($element, $formType, $displayOptions); -// } - - //Select -// if ('select' == $type && is_array($element->getValueOptions())) { -// $helper = $renderer->plugin('form_select_twb'); -// return $helper($element, $formType, $displayOptions); -// } - - //Textarea -// if ('textarea' == $type) { -// $helper = $renderer->plugin('form_textarea_twb'); -// return $helper($element, $formType, $displayOptions); -// } - - //Input - $helper = $renderer->plugin('form_input'); - return $helper($element); - } - - /** - * Invoke helper as function - * Proxies to {@link render()}. - * @param ElementInterface|null $element - * @param null|string $formType - * @param array $displayOptions - * @return string|FormElementTwb - */ - public function __invoke(ElementInterface $element = null) - { - if (!$element) { - return $this; - } - return $this->render($element); - } - -} \ No newline at end of file diff --git a/src/AgvBootstrap/Form/View/Helper/FormLabel.php b/src/AgvBootstrap/Form/View/Helper/FormLabel.php deleted file mode 100755 index d9359b8..0000000 --- a/src/AgvBootstrap/Form/View/Helper/FormLabel.php +++ /dev/null @@ -1,17 +0,0 @@ - Date: Wed, 9 Jul 2014 19:34:23 -0300 Subject: [PATCH 02/13] Fixing remove button on FormCollection --- .../Form/View/Helper/FormCollection.php | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/AgvBootstrap/Form/View/Helper/FormCollection.php b/src/AgvBootstrap/Form/View/Helper/FormCollection.php index fc5cc59..2f428bc 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormCollection.php +++ b/src/AgvBootstrap/Form/View/Helper/FormCollection.php @@ -26,7 +26,7 @@ class FormCollection extends ZendFormCollection "; public function __invoke(ElementInterface $element = null, - $allowRemove = false) + $allowRemove = false) { if (!$element) { return $this; @@ -53,11 +53,11 @@ public function render(ElementInterface $element, $allowRemove = false) foreach ($element->getIterator() as $elementOrFieldset) { if ($elementOrFieldset instanceof FieldsetInterface) { - if ($fieldsetHelper instanceof $this && $element instanceof Collection) { + if ($fieldsetHelper instanceof $this && $elementOrFieldset instanceof CollectionElement) { $markup .= $fieldsetHelper($elementOrFieldset, - $element->allowRemove()); + $elementOrFieldset->allowRemove()); } else { - $markup .= $fieldsetHelper($elementOrFieldset); + $markup .= $fieldsetHelper($elementOrFieldset, $allowRemove); } } elseif ($elementOrFieldset instanceof ElementInterface) { $markup .= $elementHelper($elementOrFieldset); @@ -70,14 +70,14 @@ public function render(ElementInterface $element, $allowRemove = false) if ($element->allowAdd()) { $addButton = ''; + . str_replace('__placeholder__', + $element->getTemplatePlaceholder(), + $this->addButtonEvent) + . '" type="button" class="close">'; } - } elseif ($element instanceof Fieldset && $allowRemove) { + } elseif ($element instanceof FieldsetInterface && $allowRemove) { $removeButton = sprintf($this->removeButtonMarkup, - $this->removeButtonEvent, $this->removeButtonContent); + $this->removeButtonEvent, $this->removeButtonContent); } $label = $element->getLabel(); @@ -86,24 +86,24 @@ public function render(ElementInterface $element, $allowRemove = false) if (null !== ($translator = $this->getTranslator())) { $label = $translator->translate( - $label, $this->getTranslatorTextDomain() + $label, $this->getTranslatorTextDomain() ); } $label = $escapeHtmlHelper($label); $label = sprintf('%s%s%s', $label, $removeButton, - $addButton); + $addButton); $wrapper = $label; } else { $wrapper = sprintf( - '
%s%s
', $removeButton, - $addButton + '
%s%s
', $removeButton, + $addButton ); } $markup = sprintf( - '
%s%s
', $wrapper, $markup + '
%s%s
', $wrapper, $markup ); return $markup; @@ -119,14 +119,14 @@ public function renderTemplate(CollectionElement $collection) if ($elementOrFieldset instanceof FieldsetInterface) { $templateMarkup .= $this->render($elementOrFieldset, - $collection->allowRemove()); + $collection->allowRemove()); } elseif ($elementOrFieldset instanceof ElementInterface) { $templateMarkup .= $elementHelper($elementOrFieldset); } return sprintf( - '', - $escapeHtmlAttribHelper($templateMarkup) + '', + $escapeHtmlAttribHelper($templateMarkup) ); } @@ -138,4 +138,4 @@ protected function getElementHelper() return parent::getElementHelper(); } -} \ No newline at end of file +} From d55ea7044b6e7a59d25a29ff466214d0a5fa6444 Mon Sep 17 00:00:00 2001 From: Alberto Viana Date: Wed, 9 Jul 2014 21:34:22 -0300 Subject: [PATCH 03/13] Adding class trash on fieldset --- src/AgvBootstrap/Form/View/Helper/FormCollection.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/AgvBootstrap/Form/View/Helper/FormCollection.php b/src/AgvBootstrap/Form/View/Helper/FormCollection.php index 2f428bc..5442e18 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormCollection.php +++ b/src/AgvBootstrap/Form/View/Helper/FormCollection.php @@ -15,8 +15,7 @@ class FormCollection extends ZendFormCollection { - protected $removeButtonMarkup = ''; - protected $removeButtonContent = '×'; + protected $removeButtonMarkup = ''; protected $removeButtonEvent = "this.parentElement.tagName == 'fieldset' ? this.parentElement.remove() : this.parentElement.parentElement.remove()"; protected $addButtonEvent = " var parent = this.parentElement.tagName == 'fieldset' ? this.parentElement : this.parentElement.parentElement; @@ -39,7 +38,6 @@ public function render(ElementInterface $element, $allowRemove = false) { $renderer = $this->getView(); if (!method_exists($renderer, 'plugin')) { - // Bail early if renderer is not pluggable return ''; } @@ -77,7 +75,7 @@ public function render(ElementInterface $element, $allowRemove = false) } } elseif ($element instanceof FieldsetInterface && $allowRemove) { $removeButton = sprintf($this->removeButtonMarkup, - $this->removeButtonEvent, $this->removeButtonContent); + $this->removeButtonEvent); } $label = $element->getLabel(); From ad25ce0212d931412340f7c0f2bf6085080a50e2 Mon Sep 17 00:00:00 2001 From: Alberto Viana Date: Wed, 6 Aug 2014 08:11:46 -0300 Subject: [PATCH 04/13] Update FormButton tag class --- .../Form/View/Helper/FormButton.php | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/AgvBootstrap/Form/View/Helper/FormButton.php b/src/AgvBootstrap/Form/View/Helper/FormButton.php index f3a91de..4ddf4c4 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormButton.php +++ b/src/AgvBootstrap/Form/View/Helper/FormButton.php @@ -8,6 +8,7 @@ class FormButton extends ZendFormButton { + const HTML_CLASS_ATTRIBUTE = 'btn btn-default'; /** * Invoke helper as functor @@ -18,7 +19,8 @@ class FormButton extends ZendFormButton * @param null|string $buttonContent * @return string|FormButton */ - public function __invoke(ElementInterface $element = null, $buttonContent = null) + public function __invoke(ElementInterface $element = null, + $buttonContent = null) { if (!$element) { return $this; @@ -45,7 +47,7 @@ public function render(ElementInterface $element, $buttonContent = null) if (null === $buttonContent) { throw new Exception\DomainException(sprintf( '%s expects either button content as the second argument, ' . - 'or that the element provided has a label value; neither found', + 'or that the element provided has a label value; neither found', __METHOD__ )); } @@ -77,6 +79,7 @@ public function openTag($attributesOrElement = null) } if (is_array($attributesOrElement)) { + $attributesOrElement = $this->classTagExists($attributesOrElement); $attributes = $this->createAttributesString($attributesOrElement); return sprintf(''; protected $removeButtonEvent = "this.parentElement.tagName == 'fieldset' ? this.parentElement.remove() : this.parentElement.parentElement.remove()"; protected $addButtonEvent = " @@ -81,7 +80,6 @@ public function render(ElementInterface $element, $allowRemove = false) $label = $element->getLabel(); if (!empty($label)) { - if (null !== ($translator = $this->getTranslator())) { $label = $translator->translate( $label, $this->getTranslatorTextDomain() @@ -135,5 +133,4 @@ protected function getElementHelper() { return parent::getElementHelper(); } - } diff --git a/src/AgvBootstrap/Form/View/Helper/FormInput.php b/src/AgvBootstrap/Form/View/Helper/FormInput.php index d1a5e12..5a9ebea 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormInput.php +++ b/src/AgvBootstrap/Form/View/Helper/FormInput.php @@ -13,7 +13,6 @@ */ class FormInput extends ZendFormInput { - /** * Attributes valid for the input tag * @@ -118,5 +117,4 @@ public function render(ElementInterface $element) $helpTextTag ); } - } diff --git a/src/AgvBootstrap/Form/View/Helper/FormRadio.php b/src/AgvBootstrap/Form/View/Helper/FormRadio.php index 42d76ae..25f8b74 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormRadio.php +++ b/src/AgvBootstrap/Form/View/Helper/FormRadio.php @@ -14,7 +14,6 @@ */ class FormRadio extends ZendFormRadio { - /** * Invoke helper as functor * @@ -129,7 +128,7 @@ protected function renderOptions(MultiCheckboxElement $element, if (is_scalar($optionSpec)) { $optionSpec = array( 'label' => $optionSpec, - 'value' => $key + 'value' => $key, ); } @@ -200,5 +199,4 @@ protected function renderOptions(MultiCheckboxElement $element, return implode($this->getSeparator(), $combinedMarkup); } - } diff --git a/src/AgvBootstrap/Form/View/Helper/FormRow.php b/src/AgvBootstrap/Form/View/Helper/FormRow.php index 20aa88b..9dd226f 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormRow.php +++ b/src/AgvBootstrap/Form/View/Helper/FormRow.php @@ -16,7 +16,6 @@ class FormRow extends ZendFormRow { - /** * The class that is added to element that have errors * @var string @@ -267,5 +266,4 @@ protected function getDivRadioCheckboxHorizontal($markup) return $markup; } - } diff --git a/src/AgvBootstrap/Form/View/Helper/FormSubmit.php b/src/AgvBootstrap/Form/View/Helper/FormSubmit.php index 740f098..59cdfdf 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormSubmit.php +++ b/src/AgvBootstrap/Form/View/Helper/FormSubmit.php @@ -8,7 +8,6 @@ class FormSubmit extends ZendFormSubmit { - /** * Invoke helper as functor * @@ -47,5 +46,4 @@ public function render(ElementInterface $element) $this->getInlineClosingBracket() ); } - } diff --git a/src/AgvBootstrap/View/Helper/Alert.php b/src/AgvBootstrap/View/Helper/Alert.php index 2f0a996..08799f7 100755 --- a/src/AgvBootstrap/View/Helper/Alert.php +++ b/src/AgvBootstrap/View/Helper/Alert.php @@ -11,7 +11,6 @@ */ class Alert extends AbstractHtmlElement { - private $class = array( 'error' => 'danger', 'info' => 'info', @@ -42,5 +41,4 @@ private function getClass($namespace) { return $this->class[$namespace]; } - } diff --git a/src/AgvBootstrap/View/Helper/Navigation/AbstractHelper.php b/src/AgvBootstrap/View/Helper/Navigation/AbstractHelper.php index b60aec8..d736ce9 100755 --- a/src/AgvBootstrap/View/Helper/Navigation/AbstractHelper.php +++ b/src/AgvBootstrap/View/Helper/Navigation/AbstractHelper.php @@ -8,7 +8,6 @@ abstract class AbstractHelper extends ZendAbstractHelper { - /** * View helper entry point: * Retrieves helper and optionally sets container to operate on @@ -176,7 +175,7 @@ public function htmlTagA(AbstractPage $page) 'title' => $title, 'class' => $page->getClass(), 'href' => $page->getHref(), - 'target' => $page->getTarget() + 'target' => $page->getTarget(), ); return sprintf( @@ -214,5 +213,4 @@ protected function addWord($word, &$text) $text = implode(' ', $words); } } - } diff --git a/src/AgvBootstrap/View/Helper/Navigation/AbstractNavigationHelper.php b/src/AgvBootstrap/View/Helper/Navigation/AbstractNavigationHelper.php index 93f919b..dc9ec35 100755 --- a/src/AgvBootstrap/View/Helper/Navigation/AbstractNavigationHelper.php +++ b/src/AgvBootstrap/View/Helper/Navigation/AbstractNavigationHelper.php @@ -11,7 +11,6 @@ */ abstract class AbstractNavigationHelper extends AbstractHelper { - const ALIGN_RIGHT = 'right'; const ALIGN_LEFT = 'left'; @@ -103,5 +102,4 @@ protected function decorateDropdown($content, AbstractPage $page) return $html; } - } diff --git a/src/AgvBootstrap/View/Helper/Navigation/Navbar.php b/src/AgvBootstrap/View/Helper/Navigation/Navbar.php index 074f6a3..a8c3af4 100755 --- a/src/AgvBootstrap/View/Helper/Navigation/Navbar.php +++ b/src/AgvBootstrap/View/Helper/Navigation/Navbar.php @@ -11,7 +11,6 @@ */ class Navbar extends AbstractNavigationHelper { - /** * Render the navbar HTML * @param Zend\Navigation\Navigation|string|null $container @@ -69,5 +68,4 @@ public function render($container = null, $staticTop = false, return $html; } - } From 919f2c6a4b4c88c039b66d5a3de7aa817086bc41 Mon Sep 17 00:00:00 2001 From: Alberto Viana Date: Sat, 27 Dec 2014 14:32:35 -0200 Subject: [PATCH 10/13] Fixing css class --- src/AgvBootstrap/Form/View/Helper/FormDate.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AgvBootstrap/Form/View/Helper/FormDate.php b/src/AgvBootstrap/Form/View/Helper/FormDate.php index f424cc6..2996afd 100644 --- a/src/AgvBootstrap/Form/View/Helper/FormDate.php +++ b/src/AgvBootstrap/Form/View/Helper/FormDate.php @@ -8,7 +8,7 @@ class FormDate extends ZendFormDate { - const BOOTSTRAP_COLUMN = 2; + const BOOTSTRAP_COLUMN = 4; /** * Render a form element from the provided $element @@ -35,7 +35,7 @@ public function render(ElementInterface $element) return sprintf( //col-lg-%s col-md-%s col-sm-%s - '
+ '
', self::BOOTSTRAP_COLUMN, //, $size, $size, $size, $this->createAttributesString($attributes), From c8bd4fc210ef9f378c3c75db8c34957a983c494a Mon Sep 17 00:00:00 2001 From: Alberto Viana Date: Sat, 27 Dec 2014 22:44:12 -0200 Subject: [PATCH 11/13] Fixing css class --- .../Form/View/Helper/FormButton.php | 19 +++++++++++++++++-- .../Form/View/Helper/FormSubmit.php | 14 +++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/AgvBootstrap/Form/View/Helper/FormButton.php b/src/AgvBootstrap/Form/View/Helper/FormButton.php index 16f4e65..843ebaf 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormButton.php +++ b/src/AgvBootstrap/Form/View/Helper/FormButton.php @@ -9,6 +9,7 @@ class FormButton extends ZendFormButton { const HTML_CLASS_ATTRIBUTE = 'btn btn-default'; + const HTML_SUBMIT_CLASS_ATTRIBUTE = ' btn btn-primary '; /** * Invoke helper as functor @@ -61,7 +62,13 @@ public function render(ElementInterface $element, $buttonContent = null) $escape = $this->getEscapeHtmlHelper(); - return $openTag . $escape($buttonContent) . $this->closeTag(); + $attributes = $element->getAttributes(); + $icon = ''; + if(isset($attributes['icon'])) { + $icon = sprintf(' ', $attributes['icon']); + } + + return $openTag . $icon . $escape($buttonContent) . $this->closeTag(); } /** @@ -82,7 +89,11 @@ public function openTag($attributesOrElement = null) $attributesOrElement = $this->classTagExists($attributesOrElement); $attributes = $this->createAttributesString($attributesOrElement); - return sprintf('