/** * @param FontIcon[] ...$icons * * @return HtmlTag */ public static function stack(...$icons) { foreach ($icons as $k => $icon) { $icon->addClass('fa-stack-' . ($k == 0 ? 1 : 2) . 'x'); } return HtmlTag::createTag('i', ['class' => ['fa-stack', 'fa']], $icons); }
/** * @return HtmlTag */ protected function _produceHtml() { $icon = HtmlTag::createTag('i'); $icon->addClass($this->_icon); foreach ($this->_classes as $class) { $icon->addClass($class); } if ($this->_color) { $icon->setAttribute('style', 'color:' . $this->_color); } return $icon; }
public static function leaderboard() { $script = HtmlTag::createTag('script'); $script->setAttribute('async', 'async'); $script->setAttribute('src', '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'); $ins = HtmlTag::createTag('ins'); $ins->addClass('adsbygoogle'); $ins->setAttribute('style', 'display:inline-block;width:728px;height:90px;'); $ins->setAttribute('data-ad-client', 'ca-pub-3044096786339784'); $ins->setAttribute('data-ad-slot', '4802576340'); $function = HtmlTag::createTag('script'); $function->setContent('(adsbygoogle = window.adsbygoogle || []).push({})'); return [$script, $ins, $function]; }
/** * @return ISafeHtmlProducer */ public function render() { $output = new Div(); $groups = $this->getMethods(); foreach ($groups as $group => $methods) { $output->appendContent(Div::create(new HeadingOne(Strings::titleize($group)))->addClass('content-container')); foreach ($methods as $method) { $reflect = new \ReflectionMethod($this, $method); $parsed = DocBlockParser::fromMethod($this, $method); $code = $this->_getCode($reflect); $id = Strings::randomString(4); $toggledCode = new Div(); $toggledCode->appendContent(new HeadingFour((new Link('#', Strings::titleize($method)))->setAttribute('onclick', '$(\'#code-' . $id . '\')' . '.toggleClass(\'' . Ui::HIDE . '\');' . 'return false;'))); $code = new SafeHtml(str_replace('<span style="color: #0000BB"><?php </span>', '', highlight_string('<?php ' . $code, true))); $toggledCode->appendContent(Div::create()->appendContent(HtmlTag::createTag('pre', [], $code))->addClass(Ui::HIDE)->setId('code-' . $id)); $methRow = Div::create()->addClass('content-container'); $methRow->appendContent($toggledCode); $methRow->appendContent(new Paragraph($parsed->getSummary())); $methRow->appendContent($this->{$method}()); $output->appendContent($methRow); } } return $output; }
protected function _arrayBuilder(array $values = []) { $arrayBuilder = Div::create()->addClass('arrayBuilder'); $arrayBuilderValues = HtmlTag::createTag('input', ['type' => 'text', 'class' => 'arrayBuilder-values', 'value' => json_encode($values, JSON_FORCE_OBJECT)]); return Div::create($arrayBuilder->appendContent($arrayBuilderValues))->addClass('col-xs-6'); }
public function testToStringException() { $tag = HtmlTag::createTag('a', ['href' => 'javascript:alert(\'Hi\');']); $this->assertContains('Attempting to render a tag with an', (string) $tag); }