protected function _applyId(HtmlTag $tag) { if ($this->_hasId()) { $tag->setId($this->_getId()); } return $tag; }
protected function _applyDataAttributes(HtmlTag $tag) { if ($this->_dataAttributes) { foreach ($this->_dataAttributes as $k => $v) { $tag->setAttribute('data-' . $k, $v); } } return $tag; }
/** * @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; }
/** * Add singular action to PanelHeading * * @param HtmlTag $action * * @return $this */ public function addAction(HtmlTag $action) { $this->_actions[] = $action->addClass(Ui::MARGIN_MEDIUM_LEFT); return $this; }
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'); }
/** * @group Basic Query Builder */ public final function queryBuilder() { $div = Div::create([QueryBuilder::create('/querybuilder/definition', '/querybuilder/policy'), HtmlTag::create()->setTag('pre')->setId('values')])->addClass(Ui::BG_INFO, Ui::PADDING_LARGE); AssetManager::sourceType()->requireInlineJs("\n \$('.query-builder').QueryBuilder();\n \$(document).on('change.querybuilder', function(e, data) {\n \$('#values').text(\n JSON.stringify(data, null, 2)\n );\n });\n "); return $div; }
public function testToStringException() { $tag = HtmlTag::createTag('a', ['href' => 'javascript:alert(\'Hi\');']); $this->assertContains('Attempting to render a tag with an', (string) $tag); }