diff --git a/src/News.php b/src/News.php new file mode 100644 index 0000000..162f9b6 --- /dev/null +++ b/src/News.php @@ -0,0 +1,113 @@ + + * @license LGPL + */ + +namespace Jr\FalsBundle; + +/** + * Provide methods regarding news archives + */ +class News extends \Contao\News +{ + + /** + * Add the categories to the template + * @param object + * @param array + */ + public function addImagesToTemplate($objTemplate, $arrData, $news) + { + $multiSRC = deserialize($arrData['multiSRC']); + + // Return if there are no files + if (!is_array($multiSRC) || empty($multiSRC)) + { + return ''; + } + + // Get the file entries from the database + $objFiles = \FilesModel::findMultipleByUuids($multiSRC); + + if ($objFiles === null) + { + if (!\Validator::isUuid($multiSRC[0])) + { + return '
'.$GLOBALS['TL_LANG']['ERR']['version2format'].'
'; + } + return ''; + } + + $objTemplate->addMoreImages = false; + $arrArticle = $arrData; + $objTemplate->pictures = array(); + $arrArticle['multiSRC'] = array(); + if ($news->imgSize != '') + { + $size = deserialize($news->imgSize); + if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) + { + $arrArticle['size'] = $news->imgSize; + } + } + while ($objFiles->next()) + { + if (isset($arrArticle['multiSRC'][$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path) || $objFiles->type != 'file') + { + continue; + } + $objFile = new \File($objFiles->path, true); + if (!$objFile->isImage) { + continue; + } + $arrArticle['multiSRC'][$objFiles->path] = $objFile; + } + if (count($arrArticle['multiSRC']) > 0) + { + $this->addMoreImagesToTemplate($objTemplate, $arrArticle); + } + } + + public function addMoreImagesToTemplate($objTemplate, $arrItem, $intMaxWidth=null, $strLightboxId=null) + { + /** @var \PageModel $objPage */ + global $objPage; + + $pictures = array(); + foreach ($arrItem['multiSRC'] as $path => $objFile) + { + $size = unserialize($arrItem['size']); + $arrMeta = \Frontend::getMetaData($file->meta, $objPage->language); + + $picture = \Picture::create($path, $size)->getTemplateData(); + if (isset($arrMeta['title'])) + { + $picture['title'] = $arrMeta['title']; + } + if (isset($arrMeta['link'])) + { + $picture['link'] = $arrMeta['link']; + } + if (isset($arrMeta['caption'])) + { + $picture['caption'] = $arrMeta['caption']; + } + $picture['href'] = TL_FILES_URL . \System::urlEncode($path); + $pictures[] = $picture; + } + + $objTemplate->morePictures = $pictures; + if (count($pictures) > 0 && $arrItem['addMoreImages'] == "1") + { + $objTemplate->addMoreImages = true; + } + } + +} diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php new file mode 100644 index 0000000..2e0df0d --- /dev/null +++ b/src/Resources/contao/config/config.php @@ -0,0 +1,6 @@ +