From 9b0b1091e690e645c6ee690c4ee985f503329a94 Mon Sep 17 00:00:00 2001 From: Steffen Ritter <info@rs-websystems.de> Date: Fri, 17 Jul 2015 21:35:52 +0200 Subject: [PATCH] [!!!][TASK] Show folder modification date in file list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Show the modification date of folders in the "Last Modified" column in filelist again, which has been removed with the introduction of FAL. Resolves: #65165 Releases: master Change-Id: Ie8f615eaa1eaed27f2a869e55ca220668ce94663 Reviewed-on: https://review.typo3.org/37017 Reviewed-by: Xavier Perseguers <xavier@typo3.org> Tested-by: Xavier Perseguers <xavier@typo3.org> Reviewed-by: Daniel Goerz <ervaude@gmail.com> Tested-by: Daniel Goerz <ervaude@gmail.com> Reviewed-by: Frank Nägler <frank.naegler@typo3.org> Tested-by: Frank Nägler <frank.naegler@typo3.org> --- .../Classes/Resource/Driver/LocalDriver.php | 3 ++ typo3/sysext/core/Classes/Resource/Folder.php | 20 +++++++++++++ .../core/Classes/Resource/FolderInterface.php | 14 +++++++++ .../Classes/Resource/InaccessibleFolder.php | 16 ++++++++++ .../core/Classes/Resource/ResourceStorage.php | 11 +++++++ ...165-AdditionalMethodsInFolderInterface.rst | 30 +++++++++++++++++++ typo3/sysext/filelist/Classes/FileList.php | 4 +-- 7 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Breaking-65165-AdditionalMethodsInFolderInterface.rst diff --git a/typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php b/typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php index 26ab2f4654e6..b771b1913cd3 100644 --- a/typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php +++ b/typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php @@ -288,9 +288,12 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver 1314516810 ); } + $absolutePath = $this->getAbsolutePath($folderIdentifier); return array( 'identifier' => $folderIdentifier, 'name' => PathUtility::basename($folderIdentifier), + 'mtime' => filemtime($absolutePath), + 'ctime' => filectime($absolutePath), 'storage' => $this->storageUid ); } diff --git a/typo3/sysext/core/Classes/Resource/Folder.php b/typo3/sysext/core/Classes/Resource/Folder.php index a1a7b893b43e..8714c0d58168 100644 --- a/typo3/sysext/core/Classes/Resource/Folder.php +++ b/typo3/sysext/core/Classes/Resource/Folder.php @@ -512,4 +512,24 @@ class Folder implements FolderInterface { return $this->getStorage()->getFolder($this->getStorage()->getFolderIdentifierFromFileIdentifier($this->getIdentifier())); } + + /** + * Returns the modification time of the file as Unix timestamp + * + * @return int + */ + public function getModificationTime() + { + return $this->storage->getFolderInfo($this)['mtime']; + } + + /** + * Returns the creation time of the file as Unix timestamp + * + * @return int + */ + public function getCreationTime() + { + return $this->storage->getFolderInfo($this)['ctime']; + } } diff --git a/typo3/sysext/core/Classes/Resource/FolderInterface.php b/typo3/sysext/core/Classes/Resource/FolderInterface.php index a1e242c385de..547eae263308 100644 --- a/typo3/sysext/core/Classes/Resource/FolderInterface.php +++ b/typo3/sysext/core/Classes/Resource/FolderInterface.php @@ -76,4 +76,18 @@ interface FolderInterface extends ResourceInterface * @return bool TRUE if deletion succeeded */ public function delete(); + + /** + * Returns the modification time of the folder as Unix timestamp + * + * @return int + */ + public function getModificationTime(); + + /** + * Returns the creation time of the folder as Unix timestamp + * + * @return int + */ + public function getCreationTime(); } diff --git a/typo3/sysext/core/Classes/Resource/InaccessibleFolder.php b/typo3/sysext/core/Classes/Resource/InaccessibleFolder.php index cd5b504b5613..4f17ed42d484 100644 --- a/typo3/sysext/core/Classes/Resource/InaccessibleFolder.php +++ b/typo3/sysext/core/Classes/Resource/InaccessibleFolder.php @@ -265,4 +265,20 @@ class InaccessibleFolder extends Folder { $this->throwInaccessibleException(); } + + /** + * @return int + */ + public function getModificationTime() + { + return 0; + } + + /** + * @return int + */ + public function getCreationTime() + { + return 0; + } } diff --git a/typo3/sysext/core/Classes/Resource/ResourceStorage.php b/typo3/sysext/core/Classes/Resource/ResourceStorage.php index 2527c934f2ca..3a5388915565 100644 --- a/typo3/sysext/core/Classes/Resource/ResourceStorage.php +++ b/typo3/sysext/core/Classes/Resource/ResourceStorage.php @@ -2293,6 +2293,17 @@ class ResourceStorage implements ResourceStorageInterface return $newFolder; } + /** + * Retrieves information about a folder + * + * @param Folder $folder + * @return array + */ + public function getFolderInfo(Folder $folder) + { + return $this->driver->getFolderInfoByIdentifier($folder->getIdentifier()); + } + /** * Returns the default folder where new files are stored if no other folder is given. * diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-65165-AdditionalMethodsInFolderInterface.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-65165-AdditionalMethodsInFolderInterface.rst new file mode 100644 index 000000000000..c56366bbe173 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-65165-AdditionalMethodsInFolderInterface.rst @@ -0,0 +1,30 @@ +===================================================== +Breaking: #65165 - AdditionalMethodsInFolderInterface +===================================================== + +Description +=========== + +The interface ``AdditionalMethodsInFolderInterface`` has received two additional methods. Classes that implement +``FolderInterface`` have to implement those methods as well. The new methods are: + +* ``getModificationTime()`` - Returns the modification time of the folder as Unix timestamp. +* ``getCreationTime()`` - Returns the creation time of the folder as Unix timestamp. + + +Impact +====== + +Classes implementing the ``FolderInterface`` no longer fulfill the requirements of the interface. + + +Affected Installations +====================== + +Installations that use custom implementations of the ``FolderInterface``. + + +Migration +========= + +Implement the two new methods in custom implementations of the ``FolderInterface``. diff --git a/typo3/sysext/filelist/Classes/FileList.php b/typo3/sysext/filelist/Classes/FileList.php index bfecd1ce5686..81794f98c387 100644 --- a/typo3/sysext/filelist/Classes/FileList.php +++ b/typo3/sysext/filelist/Classes/FileList.php @@ -503,8 +503,8 @@ class FileList extends AbstractRecordList $theData[$field] = $this->getLanguageService()->getLL('folder', true); break; case 'tstamp': - // @todo: FAL: how to get the mtime info -- $theData[$field] = \TYPO3\CMS\Backend\Utility\BackendUtility::date($theFile['tstamp']); - $theData[$field] = '-'; + $tstamp = $folderObject->getModificationTime(); + $theData[$field] = $tstamp ? BackendUtility::date($tstamp) : '-'; break; case 'file': $theData[$field] = $this->linkWrapDir($displayName, $folderObject); -- GitLab