/** * Set css classes. * * @param Attributes $attributes Link attributes. * * @return void */ protected function setCssClass(Attributes $attributes) { $attributes->addClass('btn'); if ($this->cssID[1] == '') { $attributes->addClass('btn-default'); } else { $attributes->addClass($this->cssID[1]); } }
/** * compile wrapper element */ protected function compile() { if ($this->wrapper->isTypeOf(Wrapper\Helper::TYPE_START)) { $cssID = $this->cssID; if ($cssID[0] == '') { $cssID[0] = sprintf($this->identifier, $this->id); $this->cssID = $cssID; } $attributes = new Attributes(); $attributes->addClass('carousel')->addClass('slide')->setAttribute('id', $cssID[0]); if ($this->bootstrap_autostart) { $attributes->setAttribute('data-ride', 'carousel'); } if ($this->bootstrap_interval > 0) { $attributes->setAttribute('data-interval', $this->bootstrap_interval); } $this->Template->attributes = $attributes; $this->Template->count = $this->wrapper->countRelatedElements(); } else { $start = \ContentModel::findByPk($this->bootstrap_parentId); if ($start !== null) { $start->cssID = deserialize($start->cssID, true); $this->Template->start = $start; if ($start->cssID[0] == '') { $cssID = $start->cssID; $cssID[0] = sprintf($this->identifier, $start->id); $this->cssID = $cssID; } else { $this->cssID = $start->cssID; } } } $this->Template->identifier = $this->cssID[0]; $this->Template->wrapper = $this->wrapper; }
/** * 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; }
/** * Get attributes for a specific section. * * @param string $sectionId The section id. * @param bool $inside If true the inside class is added. Otherwhise $sectionId is set as id attribute. * * @return Attributes */ public function getAttributes($sectionId, $inside = false) { $layout = static::getPageLayout(); $attributes = new Attributes(); if ($inside) { $attributes->addClass('inside'); } else { $attributes->setId($sectionId); } if (in_array($sectionId, array(static::FOOTER, static::HEADER))) { $key = sprintf('bootstrap_%sClass', $sectionId); if ($layout->{$key}) { $attributes->addClass($layout->{$key}); } } elseif (in_array($sectionId, array(static::CONTAINER, static::WRAPPER))) { $class = $layout->bootstrap_containerClass; if ($class && $layout->bootstrap_containerElement === $sectionId) { $attributes->addClass($class); } } elseif (static::isGridActive()) { $key = sprintf('%sClass', $sectionId); if ($this->{$key}) { $attributes->addClass($this->{$key}); } } return $attributes; }