[BUGFIX] Display Info of File in popup instead of File Metadata 94/33294/5
authorFabien Udriot <fabien.udriot@ecodev.ch>
Mon, 13 Oct 2014 15:20:20 +0000 (17:20 +0200)
committerFrans Saris <franssaris@gmail.com>
Fri, 30 Jan 2015 23:08:31 +0000 (00:08 +0100)
To stay inline with the File List, the popup from the list
should display info of a File and not of the File Metadata. Otherwise,
it will display misleading information for the End User such
as different creation / modification date.

Change-Id: I84ac293dc63d222d1111dd35bd1474709449bafa
Releases: master, 6.2
Resolves: #56655
Reviewed-on: http://review.typo3.org/33294
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Fabien Udriot <fabien.udriot@ecodev.ch>
Tested-by: Fabien Udriot <fabien.udriot@ecodev.ch>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
typo3/sysext/lang/locallang_mod_file_list.xlf

index e94e9ac..8c738e4 100644 (file)
@@ -16,7 +16,9 @@ namespace TYPO3\CMS\Backend\Controller\ContentElement;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Resource\Folder;
 use TYPO3\CMS\Core\Resource\ProcessedFile;
+use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -90,7 +92,7 @@ class ElementInformationController {
        protected $fileObject;
 
        /**
-        * @var \TYPO3\CMS\Core\Resource\Folder
+        * @var Folder
         */
        protected $folderObject;
 
@@ -161,10 +163,9 @@ class ElementInformationController {
         * Init file/folder parameters
         */
        protected function initFileOrFolderRecord() {
-               $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->
-                               retrieveFileOrFolderObject($this->uid);
+               $fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->uid);
 
-               if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
+               if ($fileOrFolderObject instanceof Folder) {
                        $this->folderObject = $fileOrFolderObject;
                        $this->access = $this->folderObject->checkActionPermission('read');
                        $this->type = 'folder';
@@ -172,11 +173,10 @@ class ElementInformationController {
                        $this->fileObject = $fileOrFolderObject;
                        $this->access = $this->fileObject->checkActionPermission('read');
                        $this->type = 'file';
-                       $this->table = 'sys_file_metadata';
+                       $this->table = 'sys_file';
 
                        try {
-                               $metaData = $fileOrFolderObject->_getMetaData();
-                               $this->row = BackendUtility::getRecordWSOL($this->table, $metaData['uid']);
+                               $this->row = BackendUtility::getRecordWSOL($this->table, $fileOrFolderObject->getUid());
                        } catch (\Exception $e) {
                                $this->row = array();
                        }
@@ -317,21 +317,33 @@ class ElementInformationController {
                $tableRows = array();
                $extraFields = array();
 
-               if ($this->type !== 'folder') {
-                       $extraFields = array(
-                               'crdate' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE),
-                               'cruser_id' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', TRUE),
-                               'tstamp' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE)
-                       );
-               }
-
                if (in_array($this->type, array('folder', 'file'), TRUE)) {
+                       if ($this->type === 'file') {
+                               $extraFields['creation_date'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
+                               $extraFields['modification_date'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
+                       }
                        $extraFields['storage'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xlf:sys_file.storage', TRUE);
                        $extraFields['folder'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:folder', TRUE);
+               } else {
+                       $extraFields['crdate'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
+                       $extraFields['cruser_id'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', TRUE);
+                       $extraFields['tstamp'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
                }
 
                foreach ($extraFields as $name => $value) {
-                       $rowValue = BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
+                       $rowValue = '';
+                       if (!isset($this->row[$name])) {
+                               $resourceObject = $this->fileObject ?: $this->folderObject;
+                               if ($name === 'storage') {
+                                       $rowValue = $resourceObject->getStorage()->getName();
+                               } elseif ($name === 'folder') {
+                                       $rowValue = $resourceObject->getParentFolder()->getIdentifier();
+                               }
+                       } elseif (in_array($name, array('creation_date', 'modification_date'), TRUE)) {
+                               $rowValue = BackendUtility::datetime($this->row[$name]);
+                       } else {
+                               $rowValue = BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
+                       }
                        if ($name === 'cruser_id' && $rowValue) {
                                $userTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('username, realName', 'be_users', 'uid = ' . (int)$rowValue);
                                if ($userTemp[0]['username'] !== '') {
@@ -340,13 +352,6 @@ class ElementInformationController {
                                                $rowValue .= ' - ' . $userTemp[0]['realName'];
                                        }
                                }
-                       } elseif ($rowValue === NULL) {
-                               $resourceObject = $this->fileObject ?: $this->folderObject;
-                               if ($name === 'storage') {
-                                       $rowValue = $resourceObject->getStorage()->getName();
-                               } elseif ($name === 'folder') {
-                                       $rowValue = $resourceObject->getParentFolder()->getIdentifier();
-                               }
                        }
                        $tableRows[] = '
                                <tr>
@@ -365,6 +370,11 @@ class ElementInformationController {
                                continue;
                        }
 
+                       // Storage is already handled above
+                       if ($this->type === 'file' && $name === 'storage') {
+                               continue;
+                       }
+
                        $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
                        if ($isExcluded) {
                                continue;
index ec0f958..e4ea115 100644 (file)
@@ -31,7 +31,7 @@
                                <source>Display thumbnails</source>
                        </trans-unit>
                        <trans-unit id="c_file" xml:space="preserve">
-                               <source>Filename</source>
+                               <source>File Name</source>
                        </trans-unit>
                        <trans-unit id="c_size" xml:space="preserve">
                                <source>Size</source>
@@ -40,7 +40,7 @@
                                <source>Type</source>
                        </trans-unit>
                        <trans-unit id="c_tstamp" xml:space="preserve">
-                               <source>Date</source>
+                               <source>Last Modified</source>
                        </trans-unit>
                        <trans-unit id="c_rw" xml:space="preserve">
                                <source>RW</source>