From 04d458723b65bc632b26eb6dbaa52ae5036b83ec Mon Sep 17 00:00:00 2001 From: Garvin Hicking <gh@faktor-e.de> Date: Mon, 8 Jul 2024 22:16:35 +0200 Subject: [PATCH] [BUGFIX] Add missing sortable folder timestamps to filelist view With the introduction of the new filelist functionality, the list view of folders no longer showed their last modification timestamps. Without this information, the list view could no longer sort the whole item list by date. With this patch, the information is now fetched not only for files, but also for folders. Folders and files are sorted on their own, so no file will be sorted in between a list of folders (and vice versa). (Note that for filesystem folders there is only one timestamp, so "last modified" and "created at" will use the same timestamps. Remote folders with their distinct drivers may provide distinguishable information.) Resolves: #100520 Releases: main, 12.4 Change-Id: I4e9ceb597946cc7532b76ec2ee4bec3d52d17fdc Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85193 Tested-by: core-ci <typo3@b13.com> Reviewed-by: Oliver Bartsch <bo@cedev.de> Tested-by: Oliver Bartsch <bo@cedev.de> --- typo3/sysext/filelist/Classes/FileList.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/filelist/Classes/FileList.php b/typo3/sysext/filelist/Classes/FileList.php index b700ea1c6a0d..7faba5d4896b 100644 --- a/typo3/sysext/filelist/Classes/FileList.php +++ b/typo3/sysext/filelist/Classes/FileList.php @@ -687,7 +687,14 @@ class FileList */ protected function renderCreationTime(ResourceView $resourceView): string { - $timestamp = ($resourceView->resource instanceof File) ? $resourceView->getCreatedAt() : null; + if ($resourceView->resource instanceof File) { + $timestamp = $resourceView->getCreatedAt(); + } elseif ($resourceView->resource instanceof Folder) { + $timestamp = $resourceView->resource->getCreationTime(); + } else { + $timestamp = null; + } + return $timestamp ? BackendUtility::datetime($timestamp) : ''; } @@ -696,7 +703,14 @@ class FileList */ protected function renderModificationTime(ResourceView $resourceView): string { - $timestamp = ($resourceView->resource instanceof File) ? $resourceView->getUpdatedAt() : null; + if ($resourceView->resource instanceof File) { + $timestamp = $resourceView->getUpdatedAt(); + } elseif ($resourceView->resource instanceof Folder) { + $timestamp = $resourceView->resource->getModificationTime(); + } else { + $timestamp = null; + } + return $timestamp ? BackendUtility::datetime($timestamp) : ''; } @@ -1647,6 +1661,10 @@ class FileList . ($resource->checkActionPermission('write') ? 'W' : ''); case 'name': return $resource->getName(); + case 'tstamp': + return $resource->getModificationTime() . 't'; + case 'crdate': + return $resource->getCreationTime() . 'c'; default: return ''; } -- GitLab