Bug #52851
closedFind a way to set the type of File Metadata
100%
Description
In #52719, I had to add a field "type" at the level of sys_file_metadata too. This enable to load different set of metadata according to a file type. The field "sys_file_metadata.type" must be kept in sync with "sys_file.type" in some way. Upon indexation?
Updated by Frans Saris over 10 years ago
Can't we just use the same solution as sys_file_reference?
In the TCA say 'type' => 'file:type'
Updated by Ernesto Baschny over 10 years ago
- Status changed from New to Accepted
- Priority changed from Should have to Must have
Yes, Frans, this works perfectly well!
Updated by Gerrit Code Review over 10 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/25035
Updated by Frans Saris over 10 years ago
Currently IconUtility::mapRecordTypeToSpriteIconName() doesn't support the multi level type
This code snippet makes it respect the "generated" type value as possible value.
748 $column = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column']; 749 if ($column === 'type') { 750 $recordType[1] = \TYPO3\CMS\Backend\Utility\BackendUtility::getTCAtypeValue($table, $row); 751 } elseif (isset($row[$column])) { 752 $recordType[1] = $row[$column]; 753 } else { 754 $recordType[1] = 'default'; 755 }
So then the TCA would need to be:
'type' => 'file:type', 'typeicon_column' => 'type', 'typeicon_classes' => array( '1' => 'mimetypes-text-text', '2' => 'mimetypes-media-image', '3' => 'mimetypes-media-audio', '4' => 'mimetypes-media-video', '5' => 'mimetypes-application', 'default' => 'mimetypes-other-other' ),
A second solution could be is to leave the 'typeicon_column' out of the TCA and then when 'typeicon_classes' is set use the 'type' value to find the icon class.
if (is_array($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])) { $type = \TYPO3\CMS\Backend\Utility\BackendUtility::getTCAtypeValue($table, $row) if (array_key_exists($type, $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])) { $recordType[0] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'][$type]; } else { $recordType[0] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['default']; } } else { $recordType[0] = 'tcarecords-' . $table . '-default'; }
Updated by Frans Saris over 10 years ago
\TYPO3\CMS\Backend\Utility\BackendUtility::getTCAtypeValue($table, $row) doesn't handle the file:type value correctly. Will have a look at it again later today to find another place in code where the type is processed.
Updated by Frans Saris over 10 years ago
When https://review.typo3.org/#/c/24537/ gets in to the core we can use TYPO3\CMS\Backend\Form\FormDataTraverser::getTraversedFieldValue() for this.
Updated by Mathias Brodala over 10 years ago
Frans Saris wrote:
Please always refer to VCS files including a specific commit. The content may always change otherwise and future visitors will not know what you refer to.
Updated by Gerrit Code Review over 10 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25035
Updated by Ernesto Baschny over 10 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset e66afd9ce319a1e66fea34edfe25050f84f51b85.
Updated by Riccardo De Contardi over 6 years ago
- Status changed from Resolved to Closed