/** * @param float $percent 0 <= percent <= 100. * @param string $type * @param string $content */ public function __construct($percent, $type = self::TYPE_DEFAULT, $content = null) { if ($percent > 100) { $percent = 100; } if ($percent < 0) { $percent = 0; } $this->addClass('progress'); if (empty($content)) { $content = new GenericTag('span'); $content->addClass('sr-only'); $content->setContent($percent . '%'); } $this->content = new GenericTag('div'); $this->content->addClass('progress-bar'); if (!in_array($type, $this->types)) { $type = self::TYPE_DEFAULT; } if ($type !== self::TYPE_DEFAULT) { $this->content->addClass('progress-bar-' . $type); } $this->content->setAttribute('role', 'progress'); $this->content->setAttribute('aria-valuenow', $percent); $this->content->setAttribute('aria-valuemin', 0); $this->content->setAttribute('aria-valuemax', 100); $this->content->setAttribute('style', 'width="' . $percent . '%"'); parent::__construct('div', $content); }
/** * GenericTab "ul.nav-tabs" with navigation links for all tabs as content. * @return string */ public function getTabsNavAsString() { $list = []; foreach ($this->tabs as $tab) { $a = new GenericTag('a', $tab->getTitle()); $a->setAttribute('href', '#' . $tab->getAttribute('id')); $a->setAttribute('data-toggle', 'tab'); if ($tab->isAjax()) { $a->setAttribute('data-src', implode('', $tab->getContent())); } $li = new GenericTag('li', $a); if ($this->activatedTab === $tab) { $li->addClass('active'); } $list[] = $li; } $tabsNav = clone $this->tabsNav; return (string) $tabsNav->setContent($list); }