public function testConstructor() { $tag = new GenericTag('foo', 'bar'); $this->assertEquals('<foo>bar</foo>', $tag->getHTML()); $tag = new GenericTag('foo', ['bar', 'baz', 'bax']); $this->assertEquals('<foo>barbazbax</foo>', $tag->getHTML()); }
/** * @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); }
/** * @param string $content */ public function __construct($content) { $this->addClass('well'); parent::__construct('div', $content); }
/** * @param string $content * @param string $type Const Label::TYPE_. */ public function __construct($content, $type = self::TYPE_DEFAULT) { $this->addClass('label'); $this->changeType($type); parent::__construct('span', $content); }
/** * @param string $content */ public function __construct($content = null) { $this->addClass('badge'); parent::__construct('span', $content); }
/** * {@inheritdoc} */ public function getContentAsString() { if ($this->isAjax()) { return $this->loadingText; } return parent::getContentAsString(); }