Project

General

Profile

Actions

Bug #52851

closed

Find a way to set the type of File Metadata

Added by Fabien Udriot over 10 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
Start date:
2013-10-15
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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?

Actions #1

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'

See https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Configuration/TCA/sys_file_reference.php

Actions #2

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!

Actions #3

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

Actions #4

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';
            }
Actions #5

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.

Actions #6

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.

Actions #7

Updated by Mathias Brodala over 10 years ago

Frans Saris wrote:

See https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Configuration/TCA/sys_file_reference.php

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.

Fixed: https://github.com/TYPO3/TYPO3.CMS/blob/a220c80ab0/typo3/sysext/core/Configuration/TCA/sys_file_reference.php#L16

Actions #8

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

Actions #9

Updated by Ernesto Baschny over 10 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #10

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF