system/modules/pct_revolutionslider/RevolutionSlider/Frontend/ContentRevolutionSliderText.php line 35

Open in your IDE?
  1. <?php
  2. /**
  3.  * Contao Open Source CMS
  4.  *
  5.  * Copyright (C) 2005-2013 Leo Feyer
  6.  *
  7.  * @copyright     Tim Gatzky 2015, Premium Contao Webworks, Premium Contao Themes
  8.  * @author      Tim Gatzky <info@tim-gatzky.de>
  9.  * @package      pct_revolutionslider
  10.  * @link         http://contao.org
  11.  */
  12. /**
  13.  * Namespace
  14.  */
  15. namespace RevolutionSlider\Frontend;
  16. use Contao\StringUtil;
  17. /**
  18.  * Class file
  19.  */
  20. class ContentRevolutionSliderText extends \Contao\ContentElement
  21. {
  22.     /**
  23.      * Template
  24.      * @var
  25.      */
  26.     protected $strTemplate 'ce_revolutionslider_text';
  27.     /**
  28.      * Display wildcard
  29.      */
  30.     public function generate()
  31.     {
  32.         if (TL_MODE == 'BE')
  33.         {
  34.             $this->Template = new \Contao\BackendTemplate('be_wildcard');
  35.             $this->Template->wildcard '### REVOLUTION SLIDER TEXT ###'.($this->text '<p>'.$this->text.'</p>' '');
  36.             $this->Template->title $this->headline;
  37.             
  38.             return $this->Template->parse();
  39.         }
  40.         
  41.         if(strlen($this->customTpl) > && $this->customTpl != $this->strTemplate)
  42.         {
  43.             $this->strTemplate $this->customTpl;
  44.         }
  45.         return parent::generate();
  46.     }
  47.     /**
  48.      * Generate the module
  49.      */
  50.     protected function compile()
  51.     {
  52.         $arrCssID $this->cssID;
  53.         $arrClass explode(' '$arrCssID[1]);
  54.         $arrClass[] = $this->strTemplate;
  55.         $arrClass[] = 'caption';
  56.         $arrClass[] = 'tp-caption';
  57.         if($this->revolutionslider_text_bold)
  58.         {
  59.             $arrClass[] = 'bold';
  60.         }
  61.         if($this->revolutionslider_text_invertcolor)
  62.         {
  63.             $arrClass[] = 'invertcolor';
  64.         }
  65.         if($this->revolutionslider_text_italic)
  66.         {
  67.             $arrClass[] = 'italic';
  68.         }
  69.         // parallax
  70.         if( $this->revolutionslider_parallax )
  71.         {
  72.             $arrClass[] = 'rs-parallaxlevel-'.$this->revolutionslider_parallax;
  73.         }
  74.         
  75.         $arrCssID[1] = trim(implode(' 'array_unique($arrClass)));
  76.         $this->cssID $arrCssID;
  77.         
  78.         // fontsize
  79.         $arrFontSize StringUtil::deserialize($this->revolutionslider_text_fontsize);
  80.         if( !\is_array($arrFontSize) )
  81.         {
  82.             $arrFontSize \explode(',',$arrFontSize);
  83.         }
  84.         $arrStyles = array
  85.         (
  86.             'font-size'    => $arrFontSize[0].'px' ?: 'inherit'
  87.         );
  88.         
  89.         $this->Template->styles $this->prepareStyles($arrStyles);
  90.     }
  91.     
  92.     
  93.     /**
  94.      * Generate the inline style string
  95.      * @param array
  96.      * @return string
  97.      */
  98.     protected function prepareStyles($arrStyles)
  99.     {
  100.         if(empty($arrStyles))
  101.         {
  102.             return '';
  103.         }
  104.         
  105.         $strReturn '';
  106.         foreach($arrStyles as $k => $v)
  107.         {
  108.             $strReturn .= $k.':'.$v.';';
  109.         }
  110.         $strReturn substr($strReturn,0,-1);
  111.         
  112.         return $strReturn;
  113.     }
  114. }