diff --git a/Module.php b/Module.php index a11ef45..2bffc23 100755 --- a/Module.php +++ b/Module.php @@ -7,7 +7,6 @@ class Module implements AutoloaderProviderInterface, ConfigProviderInterface { - public function getAutoloaderConfig() { return array( @@ -26,5 +25,4 @@ public function getConfig() { return include __DIR__ . '/config/module.config.php'; } - -} \ No newline at end of file +} diff --git a/autoload_classmap.php b/autoload_classmap.php index dad330e..bd25a40 100755 --- a/autoload_classmap.php +++ b/autoload_classmap.php @@ -1,2 +1,21 @@ __DIR__ . '/Module.php', + 'AgvBootstrap\Form\View\Helper\Form' => __DIR__ . '/src/AgvBootstrap/Form/View/Helper/Form.php', + 'AgvBootstrap\Form\View\Helper\FormActions' => __DIR__ . '/src/AgvBootstrap/Form/View/Helper/FormActions.php', + 'AgvBootstrap\Form\View\Helper\FormButton' => __DIR__ . '/src/AgvBootstrap/Form/View/Helper/FormButton.php', + 'AgvBootstrap\Form\View\Helper\FormCollection' => __DIR__ . '/src/AgvBootstrap/Form/View/Helper/FormCollection.php', + 'AgvBootstrap\Form\View\Helper\FormDate' => __DIR__ . '/src/AgvBootstrap/Form/View/Helper/FormDate.php', + 'AgvBootstrap\Form\View\Helper\FormElementErrors' => __DIR__ . '/src/AgvBootstrap/Form/View/Helper/FormElementErrors.php', + 'AgvBootstrap\Form\View\Helper\FormInput' => __DIR__ . '/src/AgvBootstrap/Form/View/Helper/FormInput.php', + 'AgvBootstrap\Form\View\Helper\FormRadio' => __DIR__ . '/src/AgvBootstrap/Form/View/Helper/FormRadio.php', + 'AgvBootstrap\Form\View\Helper\FormRow' => __DIR__ . '/src/AgvBootstrap/Form/View/Helper/FormRow.php', + 'AgvBootstrap\Form\View\Helper\FormSelect' => __DIR__ . '/src/AgvBootstrap/Form/View/Helper/FormSelect.php', + 'AgvBootstrap\Form\View\Helper\FormSubmit' => __DIR__ . '/src/AgvBootstrap/Form/View/Helper/FormSubmit.php', + 'AgvBootstrap\Form\View\Helper\FormTextarea' => __DIR__ . '/src/AgvBootstrap/Form/View/Helper/FormTextarea.php', + 'AgvBootstrap\View\Helper\Alert' => __DIR__ . '/src/AgvBootstrap/View/Helper/Alert.php', + 'AgvBootstrap\View\Helper\Navigation\AbstractHelper' => __DIR__ . '/src/AgvBootstrap/View/Helper/Navigation/AbstractHelper.php', + 'AgvBootstrap\View\Helper\Navigation\AbstractNavigationHelper' => __DIR__ . '/src/AgvBootstrap/View/Helper/Navigation/AbstractNavigationHelper.php', + 'AgvBootstrap\View\Helper\Navigation\Navbar' => __DIR__ . '/src/AgvBootstrap/View/Helper/Navigation/Navbar.php', +); diff --git a/config/module.config.php b/config/module.config.php index 63376b4..69525ad 100755 --- a/config/module.config.php +++ b/config/module.config.php @@ -19,6 +19,7 @@ 'alert' => 'AgvBootstrap\View\Helper\Alert', 'formSelect' => 'AgvBootstrap\Form\View\Helper\FormSelect', 'formElementErrors' => 'AgvBootstrap\Form\View\Helper\FormElementErrors', + 'formDate' => 'AgvBootstrap\Form\View\Helper\FormDate', ), ), -); \ No newline at end of file +); diff --git a/src/AgvBootstrap/Form/View/Helper/Form.php b/src/AgvBootstrap/Form/View/Helper/Form.php index fe78221..18f466f 100755 --- a/src/AgvBootstrap/Form/View/Helper/Form.php +++ b/src/AgvBootstrap/Form/View/Helper/Form.php @@ -57,7 +57,7 @@ class Form extends ZendForm /** * Generate an opening form tag * - * @param FormInterface $form + * @param FormInterface $form * @return string */ public function openTag(FormInterface $form = null) @@ -66,7 +66,7 @@ public function openTag(FormInterface $form = null) 'action' => '', 'method' => 'get', 'role' => 'form', - 'class' => '' + 'class' => '', ); if ($form instanceof FormInterface) { @@ -77,9 +77,8 @@ public function openTag(FormInterface $form = null) } $attributes = array_merge($attributes, $formAttributes); } - + if (!empty($this->type) && !empty($this->validTypes[$this->type])) { - if (isset($attributes['class'])) { $attributes['class'] = $attributes['class'] . ' '; } @@ -99,8 +98,7 @@ public function openTag(FormInterface $form = null) public function setType($type) { $this->type = $type; - + return $this; } - -} \ No newline at end of file +} diff --git a/src/AgvBootstrap/Form/View/Helper/FormActions.php b/src/AgvBootstrap/Form/View/Helper/FormActions.php index d08d064..7b8663a 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormActions.php +++ b/src/AgvBootstrap/Form/View/Helper/FormActions.php @@ -6,10 +6,9 @@ class FormActions extends AbstractHelper { - /** * Renders the form-actions div tag - * @param array $content Either a string or an array of elements + * @param array $content Either a string or an array of elements * @return string */ public function render($content) @@ -23,13 +22,14 @@ public function render($content) } $html .= PHP_EOL . $this->closeTag(); + return $html; } /** * Returns the form-renderActions open tag - * @param null|string $formType - * @param array $displayOptions + * @param null|string $formType + * @param array $displayOptions * @return string */ public function openTag() @@ -39,7 +39,7 @@ public function openTag() /** * Returns the control group closing tag - * @param null|string $formType + * @param null|string $formType * @return string */ public function closeTag() @@ -50,9 +50,9 @@ public function closeTag() /** * Invoke helper as function * Proxies to {@link render()}. - * @param string|array|null $content Either a string or an array of elements - * @param null|string $formType - * @param array $displayOptions + * @param string|array|null $content Either a string or an array of elements + * @param null|string $formType + * @param array $displayOptions * @return string|FormActionsTwb */ public function __invoke($content = array()) @@ -60,7 +60,7 @@ public function __invoke($content = array()) if (!$content) { return $this; } + return $this->render($content); } - } diff --git a/src/AgvBootstrap/Form/View/Helper/FormButton.php b/src/AgvBootstrap/Form/View/Helper/FormButton.php index f3a91de..843ebaf 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormButton.php +++ b/src/AgvBootstrap/Form/View/Helper/FormButton.php @@ -8,6 +8,8 @@ class FormButton extends ZendFormButton { + const HTML_CLASS_ATTRIBUTE = 'btn btn-default'; + const HTML_SUBMIT_CLASS_ATTRIBUTE = ' btn btn-primary '; /** * Invoke helper as functor @@ -18,7 +20,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; @@ -31,8 +34,8 @@ public function __invoke(ElementInterface $element = null, $buttonContent = null * Render a form '; - 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; @@ -26,7 +24,7 @@ class FormCollection extends ZendFormCollection "; public function __invoke(ElementInterface $element = null, - $allowRemove = false) + $allowRemove = false) { if (!$element) { return $this; @@ -39,7 +37,6 @@ public function render(ElementInterface $element, $allowRemove = false) { $renderer = $this->getView(); if (!method_exists($renderer, 'plugin')) { - // Bail early if renderer is not pluggable return ''; } @@ -53,11 +50,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,40 +67,39 @@ 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); } $label = $element->getLabel(); if (!empty($label)) { - 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 +115,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) ); } @@ -137,5 +133,4 @@ protected function getElementHelper() { return parent::getElementHelper(); } - -} \ No newline at end of file +} diff --git a/src/AgvBootstrap/Form/View/Helper/FormDate.php b/src/AgvBootstrap/Form/View/Helper/FormDate.php new file mode 100644 index 0000000..2996afd --- /dev/null +++ b/src/AgvBootstrap/Form/View/Helper/FormDate.php @@ -0,0 +1,56 @@ + element from the provided $element + * + * @param ElementInterface $element + * @throws Exception\DomainException + * @return string + */ + public function render(ElementInterface $element) + { + $name = $element->getName(); + if ($name === null || $name === '') { + throw new Exception\DomainException(sprintf( + '%s requires that the element has an assigned name; none discovered', + __METHOD__ + )); + } + + $attributes = $element->getAttributes(); + $attributes['name'] = $name; + $attributes['type'] = $this->getType($element); + $attributes['value'] = $element->getValue(); + $attributes['id'] = str_replace(']', '', (str_replace('[', '-',$attributes['id']))); + + return sprintf( + //col-lg-%s col-md-%s col-sm-%s + '
+ ', self::BOOTSTRAP_COLUMN, //, $size, $size, $size, + $this->createAttributesString($attributes), + $this->getInlineClosingBracket() + ); + } + + /** + * Determine input type to use + * + * @param ElementInterface $element + * @return string + */ + protected function getType(ElementInterface $element) + { + return 'text'; + } +} 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/FormElementErrors.php b/src/AgvBootstrap/Form/View/Helper/FormElementErrors.php index 2dbcc95..f209073 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormElementErrors.php +++ b/src/AgvBootstrap/Form/View/Helper/FormElementErrors.php @@ -2,7 +2,7 @@ namespace AgvBootstrap\Form\View\Helper; -use Zend\Form\View\Helper\FormElementErrors as ZendFormElementErrors; +use Zend\Form\View\Helper\FormElementErrors as ZendFormElementErrors; use Zend\Form\ElementInterface; /** @@ -20,14 +20,13 @@ class FormElementErrors extends ZendFormElementErrors protected $messageSeparatorString = '
  • '; /**@-*/ - /** * Invoke helper as functor * * Proxies to {@link render()} if an element is passed. * - * @param ElementInterface $element - * @param array $attributes + * @param ElementInterface $element + * @param array $attributes * @return string|FormElementErrors */ public function __invoke(ElementInterface $element = null, array $attributes = array()) @@ -42,8 +41,8 @@ public function __invoke(ElementInterface $element = null, array $attributes = a /** * Render validation errors for the provided $element * - * @param ElementInterface $element - * @param array $attributes + * @param ElementInterface $element + * @param array $attributes * @throws Exception\DomainException * @return string */ @@ -60,9 +59,8 @@ public function render(ElementInterface $element, array $attributes = array()) (is_object($messages) ? get_class($messages) : gettype($messages)) )); } - + $attributes['class'] = 'errors'; - // Prepare attributes for opening tag $attributes = array_merge($this->attributes, $attributes); @@ -93,4 +91,4 @@ public function render(ElementInterface $element, array $attributes = array()) return $markup; } -} \ No newline at end of file +} diff --git a/src/AgvBootstrap/Form/View/Helper/FormInput.php b/src/AgvBootstrap/Form/View/Helper/FormInput.php index 02ffb59..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 * @@ -51,12 +50,26 @@ class FormInput extends ZendFormInput 'value' => true, 'width' => true, 'gridSize' => true, + 'help_text' => true, ); + private $helpText; + + public function getHelpText() + { + return $this->helpText; + } + + public function setHelpText($helpText) + { + $this->helpText = $helpText; + + return $this; + } /** * Render a form element from the provided $element * - * @param ElementInterface $element + * @param ElementInterface $element * @throws Exception\DomainException * @return string */ @@ -75,22 +88,33 @@ public function render(ElementInterface $element) $attributes['type'] = $this->getType($element); $attributes['value'] = $element->getValue(); + $helpText = $element->getAttribute('help_text'); + $helpTextTag = ''; + if (!empty($helpText)) { + $helpTextTag = sprintf( + '%s', $helpText + ); + + unset($attributes['help_text']); + } + $size = $element->getAttribute('size'); if (empty($size)) { return sprintf( - 'createAttributesString($attributes), - $this->getInlineClosingBracket() + 'createAttributesString($attributes), + $this->getInlineClosingBracket(), $helpTextTag ); } return sprintf( - //col-lg-%s col-md-%s col-sm-%s + //col-lg-%s col-md-%s col-sm-%s '
    ', $size, //, $size, $size, $size, +
    + %s', $size, //, $size, $size, $size, $this->createAttributesString($attributes), - $this->getInlineClosingBracket() + $this->getInlineClosingBracket(), + $helpTextTag ); } - } 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 @@ - element from the provided $element * - * @param ElementInterface $element + * @param ElementInterface $element * @throws Exception\InvalidArgumentException * @throws Exception\DomainException * @return string @@ -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); } - -} \ No newline at end of file +} diff --git a/src/AgvBootstrap/Form/View/Helper/FormRow.php b/src/AgvBootstrap/Form/View/Helper/FormRow.php index 402fa97..275444f 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormRow.php +++ b/src/AgvBootstrap/Form/View/Helper/FormRow.php @@ -8,15 +8,15 @@ use Zend\Form\Element\File; use Zend\Form\Element\MultiCheckbox; use Zend\Form\Element\Radio; -use Zend\Form\Element\Submit; use Zend\Form\Element\Hidden; use Zend\Form\Element\Select; +use Zend\Form\Element\Date; +use Zend\Form\Element\Submit; use Zend\Form\ElementInterface; use AgvBootstrap\Form\View\Helper\Form as AgvBootstrapForm; class FormRow extends ZendFormRow { - /** * The class that is added to element that have errors * @var string @@ -31,13 +31,13 @@ class FormRow extends ZendFormRow /** * Row class - * @var string + * @var string */ protected $rowClass = 'form-group'; - + /** * Element class - * @var string + * @var string */ protected $elementClass = 'form-control'; @@ -64,7 +64,7 @@ public function __invoke(ElementInterface $element = null, $formType = null, /** * Utility form helper that renders a label (if it exists), an element and errors * - * @param ElementInterface $element + * @param ElementInterface $element * @throws \Zend\Form\Exception\DomainException * @return string */ @@ -110,7 +110,7 @@ public function render(ElementInterface $element) if (isset($label) && '' !== $label) { $label = $escapeHtmlHelper($label); } - + if ($element instanceof Radio) { $rowClass = $this->rowClass; @@ -118,11 +118,19 @@ public function render(ElementInterface $element) '
    %s%s
    ', $label, $elementHelper->render($element) ); - + $markup = $this->getDivRadioCheckboxHorizontal($markup); } elseif ($element instanceof MultiCheckbox) { + + $labelAttributes = $element->getLabelAttributes(); + + $labelAttributesClass = ''; + if(isset($labelAttributes['class'])) { + $labelAttributesClass = $labelAttributes['class']; + } + $rowClass = $this->rowClass; - $element->setLabelAttributes(array('class' => 'checkbox')); + $element->setLabelAttributes(array('class' => 'checkbox ' . $labelAttributesClass)); $markup = sprintf( '
    %s%s
    ', $label, @@ -137,15 +145,15 @@ public function render(ElementInterface $element) . $elementHelper->render($element) . $label . $labelHelper->closeTag(); - } elseif ($element instanceof \Zend\Form\Element\File) { + } elseif ($element instanceof File) { $rowClass = $this->rowClass; $label = $labelHelper->openTag($this->getLabelAttributesByElement($element)) . $label . $labelHelper->closeTag(); $markup = $label . $elementHelper->render($element); - } else if ($element instanceof Hidden) { + } elseif ($element instanceof Hidden) { return $elementHelper->render($element); - } else if ($element instanceof Select) { + } elseif ($element instanceof Select) { $rowClass = $this->rowClass; $element->setAttribute('class', $this->elementClass); @@ -158,6 +166,41 @@ public function render(ElementInterface $element) } $markup = $label . $elementHelper->render($element); + } elseif ($element instanceof Date) { + $rowClass = $this->rowClass; + + $element->setAttribute('class', $this->elementClass); + + $label = $labelHelper->openTag($this->getLabelAttributesByElement($element)) + . $label + . $labelHelper->closeTag(); + + $markup = $label . $elementHelper->render($element); + } elseif ($element instanceof Button) { + $rowClass = $this->rowClass; + + $elementClass = $element->getAttribute('class'); + if (!empty($elementClass)) { + $elementClass .= ' '; + } + $elementClass .= $this->elementClass; + $element->setAttribute('class', $elementClass); + + $markup = $elementHelper->render($element); + } elseif ($element instanceof Submit) { + $rowClass = $this->rowClass; + + $elementClass = $element->getAttribute('class'); + if (!empty($elementClass)) { + $elementClass .= ' '; + } + + if($this->formType == AgvBootstrapForm::FORM_TYPE_HORIZONTAL) { + $elementClass .= $this->elementClass; + $element->setAttribute('class', $elementClass); + } + + $markup = $elementHelper->render($element); } else { $rowClass = $this->rowClass; @@ -191,7 +234,7 @@ public function render(ElementInterface $element) /** * Return label element - * @param ElementInterface $element + * @param ElementInterface $element * @return string */ protected function getLabelAttributesByElement($element) @@ -232,7 +275,7 @@ protected function getLabelAttributesByElement($element) /** * Return div element for checkbox and radio in horizontal layout - * @param string $markup + * @param string $markup * @return string */ protected function getDivRadioCheckboxHorizontal($markup) @@ -246,5 +289,4 @@ protected function getDivRadioCheckboxHorizontal($markup) return $markup; } - } diff --git a/src/AgvBootstrap/Form/View/Helper/FormSelect.php b/src/AgvBootstrap/Form/View/Helper/FormSelect.php index 4182769..d6582c8 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormSelect.php +++ b/src/AgvBootstrap/Form/View/Helper/FormSelect.php @@ -6,14 +6,13 @@ use Zend\Form\ElementInterface; use Zend\Form\Element\Select as SelectElement; use Zend\Form\Exception; -use Zend\Stdlib\ArrayUtils; class FormSelect extends ZendFormSelect { /** * Render a form %s @@ -73,4 +72,4 @@ public function render(ElementInterface $element) $this->renderOptions($options, $value) ); } -} \ No newline at end of file +} diff --git a/src/AgvBootstrap/Form/View/Helper/FormSubmit.php b/src/AgvBootstrap/Form/View/Helper/FormSubmit.php index d97061d..56b87b8 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 * @@ -26,6 +25,12 @@ public function __invoke(ElementInterface $element = null) return $this->render($element); } + /** + * Render + * @param ElementInterface $element + * @return string + * @throws Exception\DomainException + */ public function render(ElementInterface $element) { $name = $element->getName(); @@ -40,12 +45,17 @@ public function render(ElementInterface $element) $attributes['name'] = $name; $attributes['type'] = $this->getType($element); $attributes['value'] = $element->getValue(); - + + $cssClass = ''; + if(isset($attributes['class'])) { + $cssClass = $attributes['class']; + } + return sprintf( - 'createAttributesString($attributes), $this->getInlineClosingBracket() ); } - -} \ No newline at end of file +} diff --git a/src/AgvBootstrap/Form/View/Helper/FormTextarea.php b/src/AgvBootstrap/Form/View/Helper/FormTextarea.php index 789d1d0..9b48bb7 100755 --- a/src/AgvBootstrap/Form/View/Helper/FormTextarea.php +++ b/src/AgvBootstrap/Form/View/Helper/FormTextarea.php @@ -28,7 +28,7 @@ public function __invoke(ElementInterface $element = null) /** * Render a form @@ -63,4 +63,4 @@ public function render(ElementInterface $element) $this->createAttributesString($attributes), $escapeHtml($content) ); } -} \ No newline at end of file +} diff --git a/src/AgvBootstrap/View/Helper/Alert.php b/src/AgvBootstrap/View/Helper/Alert.php index 9790215..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', @@ -34,7 +33,7 @@ public function __invoke($alerts) } } } - + return $html; } @@ -42,5 +41,4 @@ private function getClass($namespace) { return $this->class[$namespace]; } - -} \ No newline at end of file +} diff --git a/src/AgvBootstrap/View/Helper/Navigation/AbstractHelper.php b/src/AgvBootstrap/View/Helper/Navigation/AbstractHelper.php index ead2313..d736ce9 100755 --- a/src/AgvBootstrap/View/Helper/Navigation/AbstractHelper.php +++ b/src/AgvBootstrap/View/Helper/Navigation/AbstractHelper.php @@ -8,12 +8,11 @@ abstract class AbstractHelper extends ZendAbstractHelper { - /** * View helper entry point: * Retrieves helper and optionally sets container to operate on * @param \Zend\Navigation\Navigation $container [optional] container to operate on - * @return TwbNavbar fluent interface, returns self + * @return TwbNavbar fluent interface, returns self */ public function __invoke(Navigation $container = null) { @@ -36,8 +35,8 @@ protected function translate($text) /** * Render the container - * @param \Zend\Navigation\Navigation $container - * @param array $options + * @param \Zend\Navigation\Navigation $container + * @param array $options * @return string */ protected function renderContainer(Navigation $container, @@ -59,8 +58,8 @@ protected function renderContainer(Navigation $container, /** * Decorate the dropdown link - * @param \Zend\Navigation\Navigation $content - * @param \Zend\Navigation\Page\AbstractPage $page + * @param \Zend\Navigation\Navigation $content + * @param \Zend\Navigation\Page\AbstractPage $page * @return string */ protected function decorateDropdownLink($content, AbstractPage $page) @@ -75,24 +74,26 @@ protected function decorateDropdownLink($content, AbstractPage $page) /** * Render a menu item - * @param \Zend\Navigation\Page\AbstractPage $page - * @param boolean $renderInDropdown + * @param \Zend\Navigation\Page\AbstractPage $page + * @param boolean $renderInDropdown * @return string */ protected function renderItem(AbstractPage $page, $renderInDropdown = false) { if ($renderInDropdown) { $itemHtml = $this->renderDropdownLinks($page); + return $this->decorateDropdownLink($itemHtml, $page); } $itemHtml = $this->renderLink($page); + return $this->decorateLink($itemHtml, $page); } /** * Render a link with tag a - * @param \Zend\Navigation\Page\AbstractPage $page + * @param \Zend\Navigation\Page\AbstractPage $page * @return string */ protected function renderLink(AbstractPage $page) @@ -102,7 +103,7 @@ protected function renderLink(AbstractPage $page) /** * Render a dropdown - * @param \Zend\Navigation\Page\AbstractPage $page + * @param \Zend\Navigation\Page\AbstractPage $page * @return string */ protected function renderDropdown(AbstractPage $page) @@ -140,7 +141,7 @@ protected function renderDropdown(AbstractPage $page) /** * Render the HTML for a nav-text on right - * @param string $text + * @param string $text * @return string */ protected function renderNavTextRight($text) @@ -157,9 +158,9 @@ abstract protected function decorateDropdown($content, AbstractPage $page); /** * Returns an HTML string containing an 'a' element for the given page - * @param \Zend\Navigation\Page\AbstractPage $page - * @param bool $renderIcons - * @param bool $activeIconInverse + * @param \Zend\Navigation\Page\AbstractPage $page + * @param bool $renderIcons + * @param bool $activeIconInverse * @return string */ public function htmlTagA(AbstractPage $page) @@ -174,7 +175,7 @@ public function htmlTagA(AbstractPage $page) 'title' => $title, 'class' => $page->getClass(), 'href' => $page->getHref(), - 'target' => $page->getTarget() + 'target' => $page->getTarget(), ); return sprintf( @@ -184,7 +185,7 @@ public function htmlTagA(AbstractPage $page) /** * Render the HTML for dropdown links - * @param \Zend\Navigation\Page\AbstractPage $page + * @param \Zend\Navigation\Page\AbstractPage $page * @return string */ protected function renderDropdownLinks(AbstractPage $page) @@ -212,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 5bf44d2..dc9ec35 100755 --- a/src/AgvBootstrap/View/Helper/Navigation/AbstractNavigationHelper.php +++ b/src/AgvBootstrap/View/Helper/Navigation/AbstractNavigationHelper.php @@ -2,7 +2,6 @@ namespace AgvBootstrap\View\Helper\Navigation; -use AgvBootstrap\View\Helper\Navigation\AbstractHelper; use Zend\Navigation\Page\AbstractPage; /** @@ -12,13 +11,12 @@ */ abstract class AbstractNavigationHelper extends AbstractHelper { - const ALIGN_RIGHT = 'right'; const ALIGN_LEFT = 'left'; - + /** * Render the brand header - * @param Zend\Navigation\Page\AbstractPage $brand + * @param Zend\Navigation\Page\AbstractPage $brand * @return string */ protected function renderNavHeader(AbstractPage $brand = null) @@ -44,8 +42,8 @@ protected function renderNavHeader(AbstractPage $brand = null) /** * Decorate container - * @param string $content - * @param array $options + * @param string $content + * @param array $options * @return string */ protected function decorateContainer($content, array $options = array()) @@ -70,13 +68,14 @@ protected function decorateContainer($content, array $options = array()) $html = "'; + return $html; } /** * Decorante link - * @param string $content - * @param \Zend\Navigation\Page\AbstractPage $page + * @param string $content + * @param \Zend\Navigation\Page\AbstractPage $page * @return string */ protected function decorateLink($content, AbstractPage $page) @@ -86,8 +85,8 @@ protected function decorateLink($content, AbstractPage $page) /** * Decorate dropdown - * @param string $content - * @param \Zend\Navigation\Page\AbstractPage $page + * @param string $content + * @param \Zend\Navigation\Page\AbstractPage $page * @return string */ protected function decorateDropdown($content, AbstractPage $page) @@ -100,7 +99,7 @@ protected function decorateDropdown($content, AbstractPage $page) $html = PHP_EOL . '
  • htmlAttribs($attribs) . ' >' . PHP_EOL . $content . PHP_EOL . '
  • '; + return $html; } - -} \ No newline at end of file +} diff --git a/src/AgvBootstrap/View/Helper/Navigation/Navbar.php b/src/AgvBootstrap/View/Helper/Navigation/Navbar.php index d825265..a8c3af4 100755 --- a/src/AgvBootstrap/View/Helper/Navigation/Navbar.php +++ b/src/AgvBootstrap/View/Helper/Navigation/Navbar.php @@ -2,7 +2,6 @@ namespace AgvBootstrap\View\Helper\Navigation; -use AgvBootstrap\View\Helper\Navigation\AbstractNavigationHelper; use Zend\Navigation\Page\AbstractPage; /** @@ -12,14 +11,13 @@ */ class Navbar extends AbstractNavigationHelper { - /** * Render the navbar HTML - * @param Zend\Navigation\Navigation|string|null $container - * @param boolean $staticTop - * @param boolean $fixedTop - * @param \Zend\Navigation\Page\AbstractPage $brand - * @param string $textRight + * @param Zend\Navigation\Navigation|string|null $container + * @param boolean $staticTop + * @param boolean $fixedTop + * @param \Zend\Navigation\Page\AbstractPage $brand + * @param string $textRight * @return string */ public function render($container = null, $staticTop = false, @@ -45,6 +43,7 @@ public function render($container = null, $staticTop = false, if (is_null($container)) { $html .= PHP_EOL . '
    '; $html .= PHP_EOL . ''; + return $html; } @@ -64,11 +63,9 @@ public function render($container = null, $staticTop = false, $html .= PHP_EOL . ''; - $html .= PHP_EOL . ''; $html .= PHP_EOL . ''; return $html; } - -} \ No newline at end of file +}