public function append_content($content)
 {
     if (is_array($content)) {
         $lists = new Lists();
         foreach ($content as $list) {
             $lists->add_item($list);
         }
         $content = $lists;
     }
     $this->_content[] = $content;
     return $this;
 }
Example #2
0
 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 '';
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 public function add_item($item, $describe = NULL, $attr = array())
 {
     if ($item instanceof Link) {
         $attr['role'] = 'presentation';
         if (class_exists('O2System', FALSE)) {
             if ($item->get_attribute('href') === current_url()) {
                 $describe = Lists::ITEM_ACTIVE;
             }
         }
         parent::add_item($item, $describe, $attr);
     } elseif ($item instanceof Dropdown) {
         $dropdown = clone $item;
         $dropdown->set_tag('li');
         if (isset($dropdown->button)) {
             $dropdown->button->set_tag('a')->set_class('dropdown-toggle')->add_attribute('href', '#');
         }
         $dropdown->add_attribute('role', 'presentation');
         $this->_items[] = $dropdown;
     } elseif (is_string($item)) {
         $item = new Link($item, '#');
         parent::add_item($item, $describe, $attr);
     }
     return $this;
 }
Example #5
0
 public function render()
 {
     if (isset($this->previous) and isset($this->next)) {
         return (new Tag('nav', parent::render()))->render();
     }
     return '';
 }