Ejemplo n.º 1
0
 /**
  * @param ElementInterface $element
  * @param boolean          $block
  *
  * @return null|string
  */
 public function __invoke(ElementInterface $element, $block = false)
 {
     $messages = $element->getMessages();
     if (empty($messages)) {
         return null;
     }
     $errors = array();
     foreach ($messages as $message) {
         $error = new HtmlElement('span');
         $error->addClass($block ? 'help-block' : 'help-inline');
         $error->setContent($this->translate((string) $message));
         $errors[] = $error;
     }
     return implode(PHP_EOL, $errors);
 }
Ejemplo n.º 2
0
 /**
  * Set the content of the element
  *
  * @param string $content
  *
  * @return $this
  */
 public function setContent($content)
 {
     $this->element->setContent($content);
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * @param \Zend\Paginator\Paginator $paginator
  *
  * @return Pagination
  */
 public function __invoke(Paginator $paginator)
 {
     $paginationElement = new HtmlElement();
     $paginationElement->addClass('pagination');
     $this->setPaginator($paginator);
     $this->setElement($paginationElement);
     return clone $this;
 }
Ejemplo n.º 4
0
 /**
  * Returns close button
  *
  * @return string
  */
 protected function renderCloseButton()
 {
     $button = new HtmlElement('button');
     return $button->addAttributes(array('type' => 'button', 'data-dismiss' => 'modal', 'aria-hidden' => 'true'))->addClass('close')->setContent('×')->render();
 }
Ejemplo n.º 5
0
 /**
  * @expectedException \SxCore\Html\Exception\InvalidArgumentException
  */
 public function testRenderChildrenFails()
 {
     $htmlElement = new HtmlElement();
     $childElements = array(new HtmlElement('bacon'), new HtmlElement('foo'), new HtmlElement('bar'));
     $htmlElement->setChildren($childElements);
     $this->assertSame('', $htmlElement->renderChildren(''));
     $htmlElement->renderChildren('abc');
 }
Ejemplo n.º 6
0
 /**
  * Invoke Tooltip
  *
  * @param string $title
  * @param string $content
  * @param string $href
  *
  * @return \SxBootstrap\View\Helper\Bootstrap\Label
  */
 public function __invoke($title = null, $content = null, $href = null)
 {
     $element = new HtmlElement('a');
     $element->addAttributes(array('data-toggle' => 'tooltip', 'rel' => 'tooltip'));
     $this->setElement($element);
     if (!is_null($title)) {
         $this->setTitle($title);
     }
     if (!is_null($content)) {
         $this->setContent($content);
     }
     if (!is_null($href)) {
         $this->setHref($href);
     }
     return clone $this;
 }
Ejemplo n.º 7
0
 /**
  * @param Fieldset $fieldset
  * @param boolean  $groupActions
  *
  * @return HtmlElement
  */
 protected function renderFieldset(Fieldset $fieldset, $groupActions = false)
 {
     $fieldsetElement = new HtmlElement('fieldset');
     $id = $fieldset->getAttribute('id') ?: $fieldset->getName();
     $parent = $this->getElement();
     $fieldsetElement->addAttribute('id', $id);
     /**
      * This changes the scope of the current element,
      * so that the child elements (the ones that are about to be rendered),
      * will be set on the fieldset.
      * Then change it back again so that the fieldset will be added to the form.
      */
     $this->setElement($fieldsetElement)->renderElements($fieldset, $groupActions)->setElement($parent);
     return $fieldsetElement;
 }