[TASK] Make sys_file_metadata translatable 51/24751/10
authorSteffen Ritter <info@rs-websystems.de>
Mon, 14 Oct 2013 19:47:56 +0000 (21:47 +0200)
committerErnesto Baschny <ernst@cron-it.de>
Tue, 15 Oct 2013 12:19:49 +0000 (14:19 +0200)
This patch adds SQL and TCA to sys_file_metadata
allowing the table to be localized. In addition
IRRE for sys_file_references is slightly reconfigured
and the - already prepared - repository is adapted to
only return live records in default language.

Resolves: #52816
Releases: 6.2
Change-Id: Ia5fbb1423f7ab2f73f58d9671a50a3c379e9e1f3
Reviewed-on: https://review.typo3.org/24751
Reviewed-by: Fabien Udriot
Tested-by: Fabien Udriot
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny
typo3/sysext/core/Classes/Resource/Index/MetaDataRepository.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Configuration/TCA/sys_file_metadata.php
typo3/sysext/core/ext_tables.sql

index bf9c24f..2197eac 100644 (file)
@@ -31,7 +31,6 @@ namespace TYPO3\CMS\Core\Resource\Index;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\SingletonInterface;
 
-
 /**
  * Repository Class as an abstraction layer to sys_file_metadata
  *
@@ -76,7 +75,7 @@ class MetaDataRepository implements SingletonInterface {
                if ($uid <= 0) {
                        throw new \RuntimeException('Metadata can only be retrieved for indexed files.', 1381590731);
                }
-               $record = $this->getDatabase()->exec_SELECTgetSingleRow('*', $this->tableName, 'file = ' . $uid);
+               $record = $this->getDatabase()->exec_SELECTgetSingleRow('*', $this->tableName, 'file = ' . $uid . $this->getGeneralWhereClause());
 
                if ($record === FALSE) {
                        $record = $this->createMetaDataRecord($uid);
@@ -91,8 +90,9 @@ class MetaDataRepository implements SingletonInterface {
         * @return string
         */
        protected function getGeneralWhereClause() {
-               return ' AND 1=1';
+               return ' AND sys_language_uid IN (0,-1) AND pid=0';
        }
+
        /**
         * Create empty
         *
index 3be617e..f0a0ed3 100644 (file)
@@ -477,9 +477,10 @@ class ExtensionManagementUtility {
                                        'width' => '64',
                                        'height' => '64',
                                ),
-                               'showPossibleLocalizationRecords' => TRUE,
-                               'showRemovedLocalizationRecords' => TRUE,
-                               'showSynchronizationLink' => TRUE,
+                               'showPossibleLocalizationRecords' => FALSE,
+                               'showRemovedLocalizationRecords' => FALSE,
+                               'showSynchronizationLink' => FALSE,
+                               'showAllLocalizationLink' => FALSE,
 
                                'enabledControls' => array(
                                        'info' => FALSE,
index edd66a2..d5b5524 100644 (file)
@@ -9,17 +9,14 @@ return array(
                'type' => 'type',
                'hideTable' => TRUE,
                'rootLevel' => TRUE,
+               'languageField' => 'sys_language_uid',
+               'transOrigPointerField' => 'l10n_parent',
+               'transOrigDiffSourceField' => 'l10n_diffsource',
                'versioningWS' => TRUE,
                'origUid' => 't3_origuid',
                'default_sortby' => 'ORDER BY crdate DESC',
                'dividers2tabs' => TRUE,
-               'typeicon_column' => '__row|file|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'
                ),
                'security' => array(
@@ -31,6 +28,38 @@ return array(
                'showRecordFieldList' => 'file, title, description, alternative'
        ),
        'columns' => array(
+               'sys_language_uid' => array(
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language',
+                       'config' => array(
+                               'type' => 'select',
+                               'foreign_table' => 'sys_language',
+                               'foreign_table_where' => 'ORDER BY sys_language.title',
+                               'items' => array(
+                                       array('LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1),
+                                       array('LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0)
+                               )
+                       )
+               ),
+               'l10n_parent' => array(
+                       'displayCond' => 'FIELD:sys_language_uid:>:0',
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent',
+                       'config' => array(
+                               'type' => 'select',
+                               'items' => array(
+                                       array('', 0)
+                               ),
+                               'foreign_table' => 'sys_file_reference',
+                               'foreign_table_where' => 'AND sys_file_reference.uid=###REC_FIELD_l10n_parent### AND sys_file_reference.sys_language_uid IN (-1,0)'
+                       )
+               ),
+               'l10n_diffsource' => array(
+                       'exclude' => 0,
+                       'config' => array(
+                               'type' => 'passthrough'
+                       )
+               ),
                't3ver_label' => array(
                        'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.versionLabel',
                        'config' => array(
@@ -46,6 +75,7 @@ return array(
                        )
                ),
                'file' => array(
+                       'displayCond' => 'FIELD:sys_language_uid:=:0',
                        'exclude' => 0,
                        'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file',
                        'config' => array(
@@ -60,6 +90,7 @@ return array(
                'title' => array(
                        'exclude' => 1,
                        'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file.title',
+                       'l10n_mode' => 'prefixLangTitle',
                        'config' => array(
                                'type' => 'input',
                                'size' => '30',
@@ -69,6 +100,7 @@ return array(
                'description' => array(
                        'exclude' => 0,
                        'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file.description',
+                       'l10n_mode' => 'prefixLangTitle',
                        'config' => array(
                                'type' => 'text',
                                'cols' => '40',
@@ -84,6 +116,14 @@ return array(
                                'rows' => '3'
                        )
                ),
+               'width' => array(
+                       'exclude' => 0,
+                       'l10n_mode' => 'exclude'
+               ),
+               'height' => array(
+                       'exclude' => 0,
+                       'l10n_mode' => 'exclude'
+               )
        ),
        'types' => array(
                '1' => array('showitem' => 'fileinfo, title, description, alternative')
index 83ac34f..c2340f9 100644 (file)
@@ -316,6 +316,11 @@ CREATE TABLE sys_file_metadata (
        crdate int(11) DEFAULT '0' NOT NULL,
        cruser_id int(11) DEFAULT '0' NOT NULL,
 
+       # Language fields
+       sys_language_uid int(11) DEFAULT '0' NOT NULL,
+       l10n_parent int(11) DEFAULT '0' NOT NULL,
+       l10n_diffsource mediumblob NOT NULL,
+
        # Versioning fields
        t3ver_oid int(11) DEFAULT '0' NOT NULL,
        t3ver_id int(11) DEFAULT '0' NOT NULL,