/**
  * 
  * @param mixed $content
  * @param mixed $options
  * @return \PhpBootstrap\Bootstrap\Component
  */
 public function createItem($content, $options = null)
 {
     if (is_array($content)) {
         $options = $content;
         $content = isset($options['content']) ? $options['content'] : '';
     }
     $href = isset($options['href']) ? $options['href'] : '#';
     unset($options['href']);
     $active = isset($options['active']) && $options['active'];
     unset($options['active']);
     $link = $active ? $content : new Link($content, $href);
     $li = new Tag('li', $link, $options);
     if ($active) {
         $li->addClass('active');
     }
     return $li;
 }
Example #2
0
 public function header($content = '', $titleTag = 'h4', $dismissible = true)
 {
     if ($titleTag) {
         $title = new Tag($titleTag, $content, ['class' => 'modal-title']);
         if ($this->getAttrib('id')) {
             $titleLabel = $this->getAttrib('id') . 'Label';
             $title->setAttrib('id', $titleLabel);
             $this->aria('labelledby', $titleLabel);
         }
         $content = $title->render();
     }
     $this->modalHeader->setContent($content);
     if ($dismissible) {
         $closeLabel = is_string($dismissible) ? ' aria-label="' . $dismissible . '"' : '';
         $this->modalHeader->prepend('<button type="button" class="close" ' . 'data-dismiss="modal"' . $closeLabel . '>' . '<span aria-hidden="true">&times;</span></button>');
     }
     return $this;
 }
Example #3
0
 public function render()
 {
     if ($this->items) {
         foreach ($this->items as $item) {
             $this->append($item->render());
         }
     }
     return parent::render();
 }
 public function render()
 {
     if ($this->pages) {
         $this->addPreviewsPage();
         $this->addAllPages();
         $this->addNextPage();
     }
     $this->nav->setContent($this->tag->render());
     return $this->nav->render();
 }
Example #5
0
 public function renderPartial()
 {
     $content = $this->getContent() ? $this->getContent() : $this->element->renderPartial();
     $this->setContent('');
     switch ($this->placement) {
         case self::PLACEMENT_AFTER:
             return $content . parent::render();
         case self::PLACEMENT_WRAP:
             $this->setContent($content);
             return parent::render();
         case self::PLACEMENT_BEFORE:
         default:
             return parent::render() . $content;
     }
 }
Example #6
0
 public function addItem($item, $description = null, $title = null, $active = false)
 {
     if (is_array($item)) {
         if (isset($item['description'])) {
             $description = $item['description'];
         }
         if (isset($item['title'])) {
             $title = $item['title'];
         }
         if (isset($item['active']) && $item['active']) {
             $active = true;
         }
         if (isset($item['img'])) {
             $item = $item['img'];
         }
     }
     if ($item instanceof Img) {
         $img = $item;
     } elseif (is_string($item)) {
         $img = new Img($item);
     }
     $div = new Tag('div', $img, ['class' => 'item']);
     if ($active) {
         $div->addClass('active');
     }
     if ($title || $description) {
         $caption = new Tag('div', '', ['class' => 'carousel-caption']);
         if ($title) {
             $caption->append(new Tag('h3', $title));
         }
         if ($description) {
             $caption->append(new Tag('p', $description));
         }
         $div->append($caption);
     }
     $this->inner->append($div);
     $indicatorOptions = $active ? ['class' => 'active'] : null;
     $this->indicators->addItem('', $indicatorOptions);
     return $this;
 }
Example #7
0
 /**
  * 
  * @return string
  */
 public function render()
 {
     foreach ($this->getElements() as $name => $element) {
         if ($element instanceof FormElement\Group) {
             $this->addElementsToGroup($element);
         }
         if (!$this->isElementInGroup($element)) {
             $this->append($element->render());
         }
     }
     return parent::render();
 }
Example #8
0
 /**
  * render without decorators
  * 
  * @return string
  */
 public function renderPartial()
 {
     return parent::render();
 }
Example #9
0
 public function setHeader($brand = null, $href = null, $srOnly = 'Toggle navigation')
 {
     $buttonContent = '';
     if ($srOnly) {
         $screenReader = new Tag('span', $srOnly, ['class' => 'sr-only']);
         $buttonContent .= $screenReader->render();
     }
     $iconBar = new Tag('span', '', ['class' => 'icon-bar']);
     $buttonContent .= $iconBar->render() . $iconBar->render() . $iconBar->render();
     $button = new Button('toggle_navigation', ['label' => $buttonContent]);
     $button->addClass('navbar-toggle collapsed');
     $button->data('toggle', 'collapse');
     $button->removeAttrib('id');
     $button->removeAttrib('name');
     $button->removeClass('btn');
     if ($this->navbarCollapse->getAttrib('id')) {
         $button->data('target', '#' . $this->navbarCollapse->getAttrib('id'));
     }
     $this->navbarHeader->prepend($button);
     if ($brand) {
         $this->navbarHeader->append(new Link($brand, ['href' => $href ? $href : '#', 'class' => 'navbar-brand']));
     }
     return $this;
 }
Example #10
0
 public function testSetSrOnly()
 {
     $tag = new Tag('div', 'text');
     $tag->srOnly(true);
     $this->assertTrue($tag->hasClass('sr-only'));
     $this->assertTrue($tag->hasClass('sr-only-focusable'));
 }
Example #11
0
 public function render()
 {
     foreach ($this->items as $item) {
         $this->append($item['dt']);
         $this->append($item['dd']);
     }
     return parent::render();
 }
Example #12
0
 /**
  * 
  * @param string $icon
  * @param mixed  $options
  */
 public function __construct($icon, $options = null)
 {
     parent::__construct('span', '', $options);
     $this->addClass('glyphicon');
     $this->setIcon($icon);
 }
Example #13
0
 /**
  * 
  * @param string $value
  * @param string $label
  * @return string
  */
 protected function renderItem($value, $label)
 {
     $options = ['value' => $value, 'selected' => in_array($value, (array) $this->getValue())];
     $item = new Tag('option', $label, $options);
     return $item->render();
 }
 public function render()
 {
     $this->addClass('progress-bar');
     $wrapper = new Tag('div', parent::render(), ['class' => 'progress']);
     return $wrapper->render();
 }
Example #15
0
 public function render()
 {
     return $this->tag->render();
 }
Example #16
0
 public function render()
 {
     if ($this->rows) {
         $parts = ['thead', 'tbody', 'tfoot'];
         foreach ($parts as $part) {
             if ($this->rows[$part]) {
                 $partTag = new Tag($part, '');
                 foreach ($this->rows[$part] as $tr) {
                     $partTag->append($tr->render());
                 }
                 $this->append($partTag->render());
             }
         }
     }
     $html = '';
     if ($this->responsive) {
         $table = new Tag('div', parent::render(), ['class' => 'table-responsive']);
         $html = $table->render();
     } else {
         $html = parent::render();
     }
     return $html;
 }
Example #17
0
 public function render()
 {
     $this->addClass('label');
     return parent::render();
 }