48 public function render($conf = array()) {
49 if (!empty($conf[
'if.']) && !$this->cObj->checkIf($conf[
'if.'])) {
53 $fileObjects = array();
55 if ($conf[
'references'] || $conf[
'references.']) {
65 $referencesUid = $this->cObj->stdWrapValue(
'references', $conf);
67 foreach ($referencesUidArray as $referenceUid) {
76 $logger->warning(
'The file-reference with uid "' . $referenceUid .
'" could not be found and won\'t be included in frontend output');
82 if ($conf[
'files'] || $conf[
'files.']) {
90 foreach ($fileUids as $fileUid) {
96 $logger->warning(
'The file with uid "' . $fileUid .
'" could not be found and won\'t be included in frontend output');
100 if ($conf[
'collections'] || $conf[
'collections.']) {
102 foreach ($collectionUids as $collectionUid) {
105 if ($fileCollection instanceof \
TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection) {
106 $fileCollection->loadContents();
107 $this->
addToArray($fileCollection->getItems(), $fileObjects);
112 $logger->warning(
'The file-collection with uid "' . $collectionUid .
'" could not be found or contents could not be loaded and won\'t be included in frontend output');
116 if ($conf[
'folders'] || $conf[
'folders.']) {
118 foreach ($folderIdentifiers as $folderIdentifier) {
119 if ($folderIdentifier) {
121 $folder = $this->
getFileFactory()->getFolderObjectFromCombinedIdentifier($folderIdentifier);
122 if ($folder instanceof \
TYPO3\CMS\Core\Resource\Folder) {
123 $this->
addToArray(array_values($folder->getFiles()), $fileObjects);
128 $logger->warning(
'The folder with identifier "' . $folderIdentifier .
'" could not be found and won\'t be included in frontend output');
136 $splitConf =
$GLOBALS[
'TSFE']->tmpl->splitConfArray($conf, count($fileObjects));
139 $sortingProperty =
'';
140 if ($conf[
'sorting'] || $conf[
'sorting.']) {
141 $sortingProperty = $this->cObj->stdWrapValue(
'sorting', $conf);
143 if ($sortingProperty !==
'' && count($fileObjects) > 1) {
144 @usort($fileObjects,
function(\
TYPO3\CMS\Core\Resource\FileInterface $a, \
TYPO3\CMS\Core\Resource\FileInterface $b) use($sortingProperty) {
145 if ($a->hasProperty($sortingProperty) && $b->hasProperty($sortingProperty)) {
146 return strnatcasecmp($a->getProperty($sortingProperty), $b->getProperty($sortingProperty));
151 $sortingDirection = isset($conf[
'sorting.'][
'direction']) ? $conf[
'sorting.'][
'direction'] :
'';
152 if (isset($conf[
'sorting.'][
'direction.'])) {
153 $sortingDirection = $this->cObj->stdWrap($sortingDirection, $conf[
'sorting.'][
'direction.']);
155 if (strtolower($sortingDirection) ===
'desc') {
156 $fileObjects = array_reverse($fileObjects);
160 $availableFileObjectCount = count($fileObjects);
163 if (!empty($conf[
'begin'])) {
164 $start = (int)$conf[
'begin'];
166 if (!empty($conf[
'begin.'])) {
167 $start = (int)$this->cObj->stdWrap($start, $conf[
'begin.']);
171 $limit = $availableFileObjectCount;
172 if (!empty($conf[
'maxItems'])) {
173 $limit = (int)$conf[
'maxItems'];
175 if (!empty($conf[
'maxItems.'])) {
176 $limit = (int)$this->cObj->stdWrap($limit, $conf[
'maxItems.']);
181 $GLOBALS[
'TSFE']->register[
'FILES_COUNT'] = min($limit, $availableFileObjectCount);
182 $fileObjectCounter = 0;
183 $keys = array_keys($fileObjects);
184 for ($i = $start; $i < $end; $i++) {
186 $fileObject = $fileObjects[$key];
188 $GLOBALS[
'TSFE']->register[
'FILE_NUM_CURRENT'] = $fileObjectCounter;
189 $this->cObj->setCurrentFile($fileObject);
190 $content .= $this->cObj->cObjGetSingle($splitConf[$key][
'renderObj'], $splitConf[$key][
'renderObj.']);
191 $fileObjectCounter++;
193 $content = $this->cObj->stdWrap($content, $conf[
'stdWrap.']);
213 if ($this->fileFactory === NULL) {
236 if ($this->fileRepository === NULL) {
259 if ($this->collectionRepository === NULL) {
275 if (empty($configuration[
'references.'])) {
280 $referencesFieldName = $this->cObj->stdWrapValue(
'fieldName', $configuration[
'references.']);
283 if (empty($referencesFieldName)) {
287 $currentId = !empty($element[
'uid']) ? $element[
'uid'] : 0;
288 $tableName = $this->cObj->getCurrentTable();
291 $referencesForeignTable = $this->cObj->stdWrapValue(
'table', $configuration[
'references.'], $tableName);
292 $referencesForeignUid = $this->cObj->stdWrapValue(
'uid', $configuration[
'references.'], $currentId);
296 if ($referencesForeignTable !== $tableName || $referencesForeignUid !== $currentId) {
297 $element = $pageRepository->getRawRecord(
298 $referencesForeignTable,
299 $referencesForeignUid,
304 $pageRepository->versionOL($referencesForeignTable, $element, TRUE);
305 if ($referencesForeignTable ===
'pages') {
306 $element = $pageRepository->getPageOverlay($element);
308 $element = $pageRepository->getRecordOverlay(
309 $referencesForeignTable,
311 $GLOBALS[
'TSFE']->sys_language_content,
312 $GLOBALS[
'TSFE']->sys_language_contentOL
317 if (is_array($element)) {
318 $references = $pageRepository->getFileReferences(
319 $referencesForeignTable,
320 $referencesFieldName,
334 if (is_array($newItems)) {
335 $theArray = array_merge($theArray, $newItems);
336 } elseif (is_object($newItems)) {
337 $theArray[] = $newItems;
350 protected function stdWrapValue($key, array $config, $defaultValue =
'') {
351 return $this->cObj->stdWrapValue($key, $config, $defaultValue);
setCollectionRepository($collectionRepository)
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
stdWrapValue($key, array $config, $defaultValue='')
setFileRepository($fileRepository)
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
getCollectionRepository()
static makeInstance($className)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
setFileFactory($fileFactory)
addToArray($newItems, array &$theArray)
handleFileReferences(array $configuration, array $element, array &$fileObjects)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]