public function generate() { if (TL_MODE == 'BE') { $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['newslist'][0]) . ' ###'; $objTemplate->title = $this->headline; $objTemplate->id = $this->id; $objTemplate->link = $this->name; $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; return $objTemplate->parse(); } parent::generate(); OwlConfig::createConfigJs($this->objModel); $this->Template->class .= ' ' . OwlConfig::getCssClassFromModel($this->objModel) . ' owl-carousel'; return $this->Template->parse(); }
public function generate() { if (TL_MODE == 'BE') { $this->strTemplate = 'be_wildcard'; $this->Template = new \BackendTemplate($this->strTemplate); $this->Template->title = $this->headline; } parent::generate(); $objConfig = OwlConfigModel::findByPk($this->owlConfig); if ($objConfig === null) { return; } OwlConfig::createConfigJs($objConfig); $this->Template->class .= ' ' . OwlConfig::getCssClassFromModel($objConfig) . ' owl-carousel ' . OwlConfig::getCssClassForContent($this->id); $this->Template->syncid = OwlConfig::getCssClassForContent($this->id); return $this->Template->parse(); }
public function getImages() { global $objPage; $images = array(); $auxDate = array(); $objFiles = $this->objFiles; // Get all images while ($objFiles->next()) { // Continue if the files has been processed or does not exist if (isset($images[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) { continue; } // Single files if ($objFiles->type == 'file') { $objFile = new \File($objFiles->path, true); if (!$objFile->isGdImage) { continue; } $arrMeta = $this->getMetaData($objFiles->meta, $objPage->language); // Use the file name as title if none is given if ($arrMeta['title'] == '') { $arrMeta['title'] = specialchars($objFile->basename); } // Add the image $images[$objFiles->path] = array('id' => $objFiles->id, 'uuid' => $objFiles->uuid, 'name' => $objFile->basename, 'singleSRC' => $objFiles->path, 'alt' => $arrMeta['title'], 'imageUrl' => $arrMeta['link'], 'caption' => $arrMeta['caption']); $auxDate[] = $objFile->mtime; } else { $objSubfiles = \FilesModel::findByPid($objFiles->uuid); if ($objSubfiles === null) { continue; } while ($objSubfiles->next()) { // Skip subfolders if ($objSubfiles->type == 'folder') { continue; } $objFile = new \File($objSubfiles->path, true); if (!$objFile->isGdImage) { continue; } $arrMeta = $this->getMetaData($objSubfiles->meta, $objPage->language); // Use the file name as title if none is given if ($arrMeta['title'] == '') { $arrMeta['title'] = specialchars($objFile->basename); } // Add the image $images[$objSubfiles->path] = array('id' => $objSubfiles->id, 'uuid' => $objSubfiles->uuid, 'name' => $objFile->basename, 'singleSRC' => $objSubfiles->path, 'alt' => $arrMeta['title'], 'imageUrl' => $arrMeta['link'], 'caption' => $arrMeta['caption']); $auxDate[] = $objFile->mtime; } } } // Sort array switch ($this->owlSortBy) { default: case 'name_asc': uksort($images, 'basename_natcasecmp'); break; case 'name_desc': uksort($images, 'basename_natcasercmp'); break; case 'date_asc': array_multisort($images, SORT_NUMERIC, $auxDate, SORT_ASC); break; case 'date_desc': array_multisort($images, SORT_NUMERIC, $auxDate, SORT_DESC); break; case 'meta': // Backwards compatibility // Backwards compatibility case 'custom': if ($this->owlOrderSRC != '') { $tmp = deserialize($this->owlOrderSRC); if (!empty($tmp) && is_array($tmp)) { // Remove all values $arrOrder = array_map(function () { }, array_flip($tmp)); // Move the matching elements to their position in $arrOrder foreach ($images as $k => $v) { if (array_key_exists($v['uuid'], $arrOrder)) { $arrOrder[$v['uuid']] = $v; unset($images[$k]); } } // Append the left-over images at the end if (!empty($images)) { $arrOrder = array_merge($arrOrder, array_values($images)); } // Remove empty (unreplaced) entries $images = array_values(array_filter($arrOrder)); unset($arrOrder); } } break; case 'random': shuffle($images); break; } $images = array_values($images); // Limit the total number of items (see #2652) if ($this->owlNumberOfItems > 0) { $images = array_slice($images, 0, $this->owlNumberOfItems); } $offset = 0; $total = count($images); $limit = $total; $intMaxWidth = TL_MODE == 'BE' ? floor(640 / $total) : floor(\Config::get('maxImageWidth') / $total); $strLightboxId = 'lightbox[lb' . $this->id . ']'; $body = array(); $strTemplate = 'owl_carousel_default'; // Use a custom template if (TL_MODE == 'FE' && $this->owlGalleryTpl != '') { $strTemplate = $this->owlGalleryTpl; } OwlConfig::createConfigJs($this->objSettings, true); $objTemplate = new \FrontendTemplate($strTemplate); $objTemplate->setData($this->arrData); $this->Template->setData($this->arrData); $this->Template->class .= ' ' . OwlConfig::getCssClassFromModel($this->objSettings) . ' owl-carousel'; for ($i = $offset; $i < $limit; $i++) { $objImage = new \stdClass(); $images[$i]['size'] = $this->owlSize; $images[$i]['fullsize'] = $this->owlFullsize; $this->addImageToTemplate($objImage, $images[$i], $intMaxWidth, $strLightboxId); $body[$i] = $objImage; } $objTemplate->body = $body; $objTemplate->headline = $this->headline; // see #1603 return $objTemplate->parse(); }