Example #1
0
 /**
  * 
  * @param string $label
  * @param array $items
  * @return string
  */
 protected function renderOptGroup($label, array $items)
 {
     $optgroup = new Tag('optgroup', '', ['label' => $label]);
     foreach ($items as $key => $value) {
         $optgroup->append($this->renderItem($key, $value));
     }
     return $optgroup->render();
 }
Example #2
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 #3
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;
 }