public function __construct(\Model\Collection $objCss, $arrReturn = array(), $blnCache)
 {
     parent::__construct();
     $this->start = microtime(true);
     $this->cache = $blnCache;
     $this->loadDataContainer('tl_extcss');
     while ($objCss->next()) {
         $this->arrData[] = $objCss->row();
     }
     $this->variablesSrc = 'variables-' . $this->title . '.less';
     $this->mode = $this->cache ? 'none' : 'static';
     $this->arrReturn = $arrReturn;
     $this->objUserCssFile = new \File($this->getSrc($this->title . '.css'));
     // rewrite if group css is empty or created/updated recently
     if ($this->objUserCssFile->size == 0 || $this->lastUpdate > $this->objUserCssFile->mtime) {
         $this->rewrite = true;
         $this->rewriteBootstrap = true;
         $this->cache = false;
     }
     $this->uriRoot = (TL_ASSETS_URL ? TL_ASSETS_URL : \Environment::get('url')) . '/assets/css/';
     $this->arrLessOptions = array('compress' => !\Config::get('bypassCache'), 'cache_dir' => TL_ROOT . '/assets/css/lesscache');
     if (!$this->cache) {
         $this->objLess = new \Less_Parser($this->arrLessOptions);
         $this->addBootstrapVariables();
         $this->addFontAwesomeVariables();
         $this->addFontAwesomeCore();
         $this->addFontAwesomeMixins();
         $this->addFontAwesome();
         $this->addBootstrapMixins();
         $this->addBootstrapAlerts();
         $this->addBootstrap();
         $this->addBootstrapUtilities();
         $this->addBootstrapType();
         if ($this->addElegantIcons) {
             $this->addElegantIconsVariables();
             $this->addElegantIcons();
         }
         // HOOK: add custom assets
         if (isset($GLOBALS['TL_HOOKS']['addCustomAssets']) && is_array($GLOBALS['TL_HOOKS']['addCustomAssets'])) {
             foreach ($GLOBALS['TL_HOOKS']['addCustomAssets'] as $callback) {
                 $this->import($callback[0]);
                 $this->{$callback}[0]->{$callback}[1]($this->objLess, $this->arrData, $this);
             }
         }
         $this->addCustomLessFiles();
         $this->addCssFiles();
     } else {
         // remove custom less files as long as we can not provide mixins and variables in cache mode
         unset($GLOBALS['TL_USER_CSS']);
         // always add bootstrap
         $this->addBootstrap();
     }
 }
Example #2
0
 protected function buildOptions(\Model\Collection $collection)
 {
     while ($collection->next()) {
         $theme = \ThemeModel::findByPk($collection->pid);
         switch ($collection->type) {
             case 'code':
                 $label = $collection->code_snippet_title;
                 break;
             case 'url':
                 $label = preg_replace('#/([^/]+)$#', '/<strong>$1</strong>', $collection->url);
                 break;
             case 'file':
                 if ($collection->filesource == $GLOBALS['TL_CONFIG']['uploadPath'] && version_compare(VERSION, '3', '>=')) {
                     $file = version_compare(VERSION, '3.2', '>=') ? \FilesModel::findByUuid($collection->file) : \FilesModel::findByPk($collection->file);
                     if ($file) {
                         $label = preg_replace('#/([^/]+)$#', '/<strong>$1</strong>', $file->path);
                         break;
                     }
                 } else {
                     $label = preg_replace('#/([^/]+)$#', '/<strong>$1</strong>', $collection->file);
                     break;
                 }
                 // no break
             // no break
             default:
                 $label = '?';
         }
         if (strlen($collection->cc)) {
             $label .= ' <span style="padding-left: 3px; color: #B3B3B3;">[' . $collection->cc . ']</span>';
         }
         $filterRules = File::renderFilterRules($collection->row());
         if ($filterRules) {
             $label .= ' <span style="padding-left: 3px; color: #B3B3B3;">' . $filterRules . '</span>';
         }
         $image = 'assets/theme-plus/images/' . $collection->type . '.png';
         $options[$theme->name][$collection->id] = ($image ? $this->generateImage($image, $label, 'style="vertical-align:-3px"') . ' ' : '') . $label;
     }
     return $options;
 }
Example #3
0
    /**
     * Parse slides
     *
     * @param  \Model\Collection $objSlides slides retrieved from the database
     * @return array                        parsed slides
     */
    protected function parseSlides($objSlides)
    {
        global $objPage;
        $slides = array();
        $pids = array();
        $idIndexes = array();
        if (!$objSlides) {
            return $slides;
        }
        while ($objSlides->next()) {
            $slide = $objSlides->row();
            $slide['text'] = '';
            $pids[] = $slide['id'];
            $idIndexes[(int) $slide['id']] = count($slides);
            if (trim($slide['singleSRC']) && ($file = version_compare(VERSION, '3.2', '<') ? \FilesModel::findByPk($slide['singleSRC']) : \FilesModel::findByUuid($slide['singleSRC'])) && ($fileObject = new \File($file->path, true)) && ($fileObject->isGdImage || $fileObject->isImage)) {
                $meta = $this->getMetaData($file->meta, $objPage->language);
                $slide['image'] = new \stdClass();
                $this->addImageToTemplate($slide['image'], array('id' => $file->id, 'name' => $fileObject->basename, 'singleSRC' => $file->path, 'alt' => $meta['title'], 'imageUrl' => $meta['link'], 'caption' => $meta['caption'], 'size' => isset($this->imgSize) ? $this->imgSize : $this->size));
            }
            if ($slide['videoURL'] && empty($slide['image'])) {
                $slide['image'] = new \stdClass();
                if (preg_match('(^
						https?://  # http or https
						(?:
							www\\.youtube\\.com/(?:watch\\?v=|v/|embed/)  # Different URL formats
							| youtu\\.be/  # Short YouTube domain
						)
						([0-9a-z_\\-]{11})  # YouTube ID
						(?:$|&|/)  # End or separator
					)ix', html_entity_decode($slide['videoURL']), $matches)) {
                    $video = $matches[1];
                    $slide['image']->src = '//img.youtube.com/vi/' . $video . '/0.jpg';
                } else {
                    // Grey dummy image
                    $slide['image']->src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAJCAMAAAAM9FwAAAAAA1BMVEXGxsbd/8BlAAAAFUlEQVR42s3BAQEAAACAkP6vdiO6AgCZAAG/wrlvAAAAAElFTkSuQmCC';
                }
                $slide['image']->imgSize = '';
                $slide['image']->alt = '';
                if (version_compare(VERSION, '3.4', '>=')) {
                    $slide['image']->picture = array('img' => array('src' => $slide['image']->src, 'srcset' => $slide['image']->src), 'sources' => array());
                }
            }
            if ($slide['videos']) {
                $videoFiles = deserialize($slide['videos'], true);
                if (version_compare(VERSION, '3.2', '<')) {
                    $videoFiles = \FilesModel::findMultipleByIds($videoFiles);
                } else {
                    $videoFiles = \FilesModel::findMultipleByUuids($videoFiles);
                }
                $videos = array();
                foreach ($videoFiles as $file) {
                    $videos[] = $file;
                }
                $slide['videos'] = $videos;
            }
            if (trim($slide['backgroundImage']) && ($file = version_compare(VERSION, '3.2', '<') ? \FilesModel::findByPk($slide['backgroundImage']) : \FilesModel::findByUuid($slide['backgroundImage'])) && ($fileObject = new \File($file->path, true)) && ($fileObject->isGdImage || $fileObject->isImage)) {
                $meta = $this->getMetaData($file->meta, $objPage->language);
                $slide['backgroundImage'] = new \stdClass();
                $this->addImageToTemplate($slide['backgroundImage'], array('id' => $file->id, 'name' => $fileObject->basename, 'singleSRC' => $file->path, 'alt' => $meta['title'], 'imageUrl' => $meta['link'], 'caption' => $meta['caption'], 'size' => $slide['backgroundImageSize']));
            } else {
                $slide['backgroundImage'] = null;
            }
            if ($slide['backgroundVideos']) {
                $videoFiles = deserialize($slide['backgroundVideos'], true);
                if (version_compare(VERSION, '3.2', '<')) {
                    $videoFiles = \FilesModel::findMultipleByIds($videoFiles);
                } else {
                    $videoFiles = \FilesModel::findMultipleByUuids($videoFiles);
                }
                $videos = array();
                foreach ($videoFiles as $file) {
                    $videos[] = $file;
                }
                $slide['backgroundVideos'] = $videos;
            }
            if ($this->rsts_navType === 'thumbs') {
                $slide['thumb'] = new \stdClass();
                if (trim($slide['thumbImage']) && ($file = version_compare(VERSION, '3.2', '<') ? \FilesModel::findByPk($slide['thumbImage']) : \FilesModel::findByUuid($slide['thumbImage'])) && ($fileObject = new \File($file->path, true)) && ($fileObject->isGdImage || $fileObject->isImage)) {
                    $this->addImageToTemplate($slide['thumb'], array('id' => $file->id, 'name' => $fileObject->basename, 'singleSRC' => $file->path, 'size' => $this->rsts_thumbs_imgSize));
                } elseif (trim($slide['singleSRC']) && ($file = version_compare(VERSION, '3.2', '<') ? \FilesModel::findByPk($slide['singleSRC']) : \FilesModel::findByUuid($slide['singleSRC'])) && ($fileObject = new \File($file->path, true)) && ($fileObject->isGdImage || $fileObject->isImage)) {
                    $this->addImageToTemplate($slide['thumb'], array('id' => $file->id, 'name' => $fileObject->basename, 'singleSRC' => $file->path, 'size' => $this->rsts_thumbs_imgSize));
                } elseif (!empty($slide['image']->src)) {
                    $slide['thumb'] = clone $slide['image'];
                } elseif (!empty($slide['backgroundImage']->src)) {
                    $slide['thumb'] = clone $slide['backgroundImage'];
                }
            }
            $slides[] = $slide;
        }
        $slideContents = ContentModel::findPublishedByPidsAndTable($pids, SlideModel::getTable());
        if ($slideContents) {
            while ($slideContents->next()) {
                $slides[$idIndexes[(int) $slideContents->pid]]['text'] .= $this->getContentElement($slideContents->current());
            }
        }
        return $slides;
    }