/** * 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; }
/** * Construct. * * @param array $item Current navigation item. * @param \FrontendTemplate $template Parent template. * @param array $attributes Additional attributes. */ public function __construct(array $item, \FrontendTemplate $template, $attributes = array()) { $this->item = $item; $this->template = $template; parent::__construct($attributes); $this->initialize(); }
/** * Generate the options element. * * @return string|void */ public function generate() { $template = new \FrontendTemplate($this->template); $template->options = $this->options; $template->element = $this; $template->tag = $this->getTag(); $template->attributes = (array) $this->childAttributes->getAttributes(); return $template->parse(); }
/** * @param \Template $template * @return $this */ public function render(\Template $template) { $template->attributes = parent::generate(); $template->closeButton = $this->closeButton; $template->title = $this->title; $template->content = $this->content; $template->footer = $this->footer; $template->size = $this->size ? ' ' . $this->size : ''; return $this; }
/** * Generate the divider. * * @return string */ public function generate() { return sprintf('<li %s></li>', parent::generate()); }
/** * @return string */ public function generate() { return sprintf('<li %s>%s%s</li>', parent::generate(), PHP_EOL, $this->getButton()->generate()); }
/** * Generate the attributes. * * @return string */ protected function generateAttributes() { return parent::generate(); }
/** * Apply attributes. * * @param Attributes $node Attrbiutes alement. * @param array $attributes Html attributes which being applied. * @param bool $fromFieldset Set true if attributes comes from fieldset definitions have to be transformed. * * @return void */ protected static function applyAttributes(Attributes $node, array $attributes, $fromFieldset = false) { if (empty($attributes)) { return; } if ($fromFieldset) { foreach ($attributes as $attribute) { if ($attribute['name']) { if ($attribute['name'] == 'class') { if (!$attribute['value']) { return; } $attribute['value'] = explode(' ', $attribute['value']); } $node->setAttribute($attribute['name'], $attribute['value']); } } } else { foreach ($attributes as $name => $value) { if ($name) { $node->setAttribute($name, $value); } } } }
/** * Generate the button. * * @return string */ public function generate() { return sprintf('<%s %s>%s</%s>%s', $this->tag, parent::generate(), $this->label, $this->tag, PHP_EOL); }
/** * @return string */ public function generateAttributes() { return parent::generate(); }
/** * 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; }
/** * @return string */ public function generate() { return sprintf('<li %s>%s</li>', parent::generate(), $this->label); }
/** * Set data attributes. * * @param Attributes $attributes Link attributes. * * @return void */ protected function setDataAttributes(Attributes $attributes) { // add data attributes $this->bootstrap_dataAttributes = deserialize($this->bootstrap_dataAttributes, true); if (empty($this->bootstrap_dataAttributes)) { return; } foreach ($this->bootstrap_dataAttributes as $attribute) { if (trim($attribute['value']) != '' && $attribute['name'] != '') { $attributes->setAttribute('data-' . $attribute['name'], $attribute['value']); } } }
/** * 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; }