Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 /**
  * 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;
 }
Esempio n. 3
0
 /**
  * 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);
             }
         }
     }
 }
Esempio n. 4
0
 /**
  * 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']);
         }
     }
 }