[BUGFIX] Fix the display of references in filelist 33/18333/2
authorHelmut Hummel <helmut.hummel@typo3.org>
Sat, 16 Feb 2013 20:53:31 +0000 (21:53 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sun, 17 Feb 2013 14:50:43 +0000 (15:50 +0100)
Currently references are not displayed
in the filelist module when trying to delete a file
which has been referenced.

Fixes: #45538
Releases: 6.0, 6.1
Change-Id: Id88bc954ab0002585ec6bb75dabba901784ddab5
Reviewed-on: https://review.typo3.org/18333
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php

index afa76cb..6bca1ae 100644 (file)
@@ -391,12 +391,12 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
                        // check if the file still has references
                        if (count($refIndexRecords) > 0) {
                                $shortcutContent = array();
-                               foreach ($refIndexRecords as $row) {
-                                       $shortcutRecord = NULL;
-                                       $shortcutRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($row['tablename'], $row['recuid']);
-                                       if (is_array($shortcutRecord) && $row['tablename'] !== 'sys_file_reference') {
+                               foreach ($refIndexRecords as $fileReferenceRow) {
+                                       if ($fileReferenceRow['tablename'] === 'sys_file_reference') {
+                                               $row = $this->transformFileReferenceToRecordReference($fileReferenceRow);
+                                               $shortcutRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($row['tablename'], $row['recuid']);
                                                $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($row['tablename'], $shortcutRecord);
-                                               $onClick = 'showClickmenu("' . $row['tablename'] . '", "' . $row['recuid'] . '", "1", "+info,history,edit,delete", "|", "");return false;';
+                                               $onClick = 'showClickmenu("' . $row['tablename'] . '", "' . $row['recuid'] . '", "1", "+info,history,edit", "|", "");return false;';
                                                $shortcutContent[] = '<a href="#" oncontextmenu="' . htmlspecialchars($onClick) . '" onclick="' . htmlspecialchars($onClick) . '">' . $icon . '</a>' . htmlspecialchars((\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($row['tablename'], $shortcutRecord) . '  [' . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordPath($shortcutRecord['pid'], '', 80) . ']'));
                                        }
                                }
@@ -435,6 +435,25 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
        }
 
        /**
+        * Maps results from the fal file reference table on the
+        * structure of  the normal reference index table.
+        *
+        * @param array $referenceRecord
+        * @return array
+        */
+       protected function transformFileReferenceToRecordReference(array $referenceRecord) {
+               $fileReference = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_file_reference', 'uid=' . (int)$referenceRecord['recuid']);
+               return array(
+                       'recuid' => $fileReference['uid_foreign'],
+                       'tablename' => $fileReference['tablenames'],
+                       'field' => $fileReference['fieldname'],
+                       'flexpointer' => '',
+                       'softref_key' => '',
+                       'sorting' => $fileReference['sorting_foreign']
+               );
+       }
+
+       /**
         * Gets a File or a Folder object from an identifier [storage]:[fileId]
         *
         * @param string $identifier