public function render() { if (!empty($this->_items)) { $indicators = new Lists(Lists::LIST_UNSTYLED); $indicators->set_tag('ol'); $indicators->add_class('carousel-indicators'); foreach ($this->_items as $key => $item) { if ($key == 0) { $indicators->add_item('', Lists::ITEM_ACTIVE, array('data-target' => '#' . $this->_attributes['id'], 'data-slide-to' => $key)); $slides[$key] = new Tag('div', $item, ['class' => 'item active']); } else { $indicators->add_item('', array('data-target' => '#' . $this->_attributes['id'], 'data-slide-to' => $key)); $slides[$key] = new Tag('div', $item, ['class' => 'item']); } } $slide = new Tag('div', implode(PHP_EOL, $slides), ['class' => 'carousel-inner', 'role' => 'listbox']); $controls['left'] = new Link(implode(PHP_EOL, array(new Tag('span', ['class' => 'glyphicon glyphicon-chevron-left', 'aria-hidden' => TRUE]), new Tag('span', 'Previous', ['class' => 'sr-only']))), ['class' => 'left carousel-control', 'href' => '#' . $this->_attributes['id'], 'role' => 'button', 'data-slide' => 'prev']); $controls['right'] = new Link(implode(PHP_EOL, array(new Tag('span', ['class' => 'glyphicon glyphicon-chevron-right', 'aria-hidden' => TRUE]), new Tag('span', 'Next', ['class' => 'sr-only']))), ['class' => 'right carousel-control', 'href' => '#' . $this->_attributes['id'], 'role' => 'button', 'data-slide' => 'next']); return (new Tag($this->_tag, implode(PHP_EOL, array($indicators, $slide)), $this->_attributes))->render(); } return ''; }
/** * Builder * * @return object */ public function build() { @(list($content, $type, $attr) = func_get_args()); $this->set_contextual_class_prefix('alert'); if (is_array($content)) { $lists = new Lists(Lists::LIST_UNSTYLED); $lists->add_class('alert-list'); foreach ($content as $list) { $lists->add_item($list); } $this->_content[] = $lists; } elseif (is_string($content)) { if (in_array($content, $this->_contextual_classes) and !in_array($content, ['default', 'primary'])) { $this->{'is_' . $content}(); } else { $this->_content[] = $content; } } if (isset($type)) { if (is_array($type)) { $this->add_attributes($type); } elseif (is_string($type)) { if (in_array($type, $this->_contextual_classes) and !in_array($type, ['default', 'primary'])) { $this->{'is_' . $type}(); } } } if (isset($attr)) { if (is_array($attr)) { $this->add_attributes($attr); } elseif (is_string($attr)) { if (in_array($attr, $this->_contextual_classes) and !in_array($attr, ['default', 'primary'])) { $this->{'is_' . $attr}(); } } } return $this; }