/** * Replace insert tags. * * @param ReplaceInsertTagsEvent $event Replace insert tags event. * * @return void */ public function replaceIconInsertTag(ReplaceInsertTagsEvent $event) { if ($event->getTag() == 'icon' || $event->getTag() == 'i') { $icon = Bootstrap::generateIcon($event->getParam(0), $event->getParam(1)); $event->setHtml($icon); $event->stopPropagation(); } }
/** * compile button element, inspired by ContentHyperlink */ protected function compile() { if ($this->linkTitle == '') { $this->linkTitle = $this->url; } $attributes = new Attributes(); $attributes->addClass('btn'); // @See: #6258 if (TL_MODE != 'BE') { $attributes->setAttribute('title', $this->titleText ?: $this->linkTitle); } if (substr($this->url, 0, 7) == 'mailto:') { $attributes->setAttribute('href', \String::encodeEmail($this->url)); } else { $attributes->setAttribute('href', ampersand($this->url)); } if (strncmp($this->rel, 'lightbox', 8) !== 0) { $attributes->setAttribute('rel', $this->rel); } else { $attributes->setAttribute('data-lightbox', substr($this->rel, 9, -1)); } // Override the link target if ($this->target) { $attributes->setAttribute('target', '_blank'); } if ($this->cssID[1] == '') { $attributes->addClass('btn-default'); } else { $attributes->addClass($this->cssID[1]); } if ($this->icon) { $this->Template->icon = Bootstrap::generateIcon($this->bootstrap_icon); } // add data attributes $this->bootstrap_dataAttributes = deserialize($this->bootstrap_dataAttributes, true); if (!empty($this->bootstrap_dataAttributes)) { foreach ($this->bootstrap_dataAttributes as $attribute) { if (trim($attribute['value']) != '' && $attribute['name'] != '') { $attributes->setAttribute('data-' . $attribute['name'], $attribute['value']); } } } $this->Template->attributes = $attributes; $this->Template->link = $this->linkTitle; }
/** * Compile button element, inspired by ContentHyperlink. * * @return void */ protected function compile() { $attributes = new Attributes(); $this->setLinkTitle($attributes); $this->setHref($attributes); $this->setCssClass($attributes); $this->enableLightbox($attributes); $this->setDataAttributes($attributes); // Override the link target if ($this->target) { $attributes->setAttribute('target', '_blank'); } if ($this->bootstrap_icon) { $this->Template->icon = Bootstrap::generateIcon($this->bootstrap_icon); } $this->Template->attributes = $attributes; $this->Template->link = $this->linkTitle; }
/** * Generate the widget and return it as string. * * @return string */ public function generate() { $buttonClass = $this->strClass ? $this->strClass : Bootstrap::getConfigVar('form.default-submit-btn'); $button = Element::create('button', $this->arrAttributes)->setId('ctrl_' . $this->strId)->addAttributes(array('type' => 'submit', 'class' => array('submit', 'btn', $buttonClass), 'title' => specialchars($this->slabel))); if ($this->imageSubmit) { $model = \FilesModel::findByPk($this->singleSRC); if ($model !== null && is_file(TL_ROOT . '/' . $model->path)) { $button->addChild(\Image::getHtml($model->path, $this->slabel)); return $button; } } $label = specialchars($this->slabel); if ($this->bootstrap_addIcon) { $icon = Bootstrap::generateIcon($this->bootstrap_icon); if ($this->bootstrap_iconPosition == 'right') { $button->addChild($label)->addChild(' ' . $icon); } else { $button->addChild($icon . ' ')->addChild($label); } } else { $button->addChild($label); } return $button; }
/** * Handle submit buttons added to a field. * * @param ContextualConfig|Config $config The bootstrap config. * @param Container $container Form element container. * @param \Widget $widget The form widget. * @param InputGroup $inputGroup The input group. * * @return void */ private function adjustSubmitButton($config, Container $container, \Widget $widget, InputGroup $inputGroup) { if ($container->hasChild('submit')) { /** @var Node $submit */ $submit = $container->removeChild('submit'); // recreate as button if ($submit->getTag() != 'button') { $submit = Element::create('button'); $submit->setAttribute('type', 'submit'); $submit->addChild($widget->slabel); } $submit->addClass('btn'); if ($widget->bootstrap_addSubmitClass) { $submit->addClass($widget->bootstrap_addSubmitClass); } else { $submit->addClass($config->get('form.default-submit-btn')); } if ($widget->bootstrap_addSubmitIcon) { $icon = Bootstrap::generateIcon($widget->bootstrap_addSubmitIcon); $position = null; if ($widget->bootstrap_addSubmitIconPosition == 'left') { $position = Node::POSITION_FIRST; $icon .= ' '; } else { $icon = ' ' . $icon; } $submit->addChild(new StaticHtml($icon), $position); } $inputGroup->setRight($submit, $inputGroup::BUTTON); } }