[BUGFIX] Enable translation of file references
authorHelmut Hummel <helmut.hummel@typo3.org>
Tue, 4 Sep 2012 13:44:00 +0000 (15:44 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Wed, 10 Oct 2012 10:22:59 +0000 (12:22 +0200)
Currently the file references are missing a localisation
possibility.

This change only adds the respective fields and TCA configuration.
Other needed changes to get the right languages for
frontend rendering will follow.

Also add some minor cleanups on the go.

Fixes: #40608
Releases: 6.0

Change-Id: Ia4454c1652eb3718a138a162319e9c95db6dd012
Reviewed-on: http://review.typo3.org/14335
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
t3lib/stddb/tables.php
t3lib/stddb/tables.sql
t3lib/stddb/tca_sys_file_reference.php
typo3/sysext/cms/tbl_tt_content.php
typo3/sysext/core/Classes/Database/DatabaseConnection.php
typo3/sysext/core/Classes/Extension/ExtensionManager.php
typo3/sysext/core/Classes/Resource/AbstractRepository.php
typo3/sysext/core/Classes/Resource/FileInterface.php
typo3/sysext/core/Classes/Resource/Service/FrontendContentAdapterService.php

index 19555f4..ddac32d 100644 (file)
@@ -438,6 +438,9 @@ $TCA['sys_file_reference'] = array(
                'sortby' => 'sorting',
                'delete' => 'deleted',
                'versioningWS' => TRUE,
+               'languageField' => 'sys_language_uid',
+               'transOrigPointerField' => 'l10n_parent',
+               'transOrigDiffSourceField' => 'l10n_diffsource',
                // records can and should be edited in workspaces
                'shadowColumnsForNewPlaceholders' => 'tablenames,fieldname,uid_local,uid_foreign',
                'enablecolumns' => array(
index 8c1c651..821bc81 100644 (file)
@@ -283,6 +283,9 @@ CREATE TABLE sys_file (
        tstamp int(11) DEFAULT '0' NOT NULL,
        crdate int(11) DEFAULT '0' NOT NULL,
        cruser_id int(11) DEFAULT '0' NOT NULL,
+       deleted tinyint(4) DEFAULT '0' NOT NULL,
+
+       # Versioning fields
        t3ver_oid int(11) DEFAULT '0' NOT NULL,
        t3ver_id int(11) DEFAULT '0' NOT NULL,
        t3ver_wsid int(11) DEFAULT '0' NOT NULL,
@@ -293,7 +296,6 @@ CREATE TABLE sys_file (
        t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
        t3ver_move_id int(11) DEFAULT '0' NOT NULL,
        t3_origuid int(11) DEFAULT '0' NOT NULL,
-       deleted tinyint(4) DEFAULT '0' NOT NULL,
 
        type varchar(10) DEFAULT '' NOT NULL,
        storage int(11) DEFAULT '0' NOT NULL,
@@ -374,6 +376,11 @@ CREATE TABLE sys_file_reference (
        t3ver_move_id int(11) DEFAULT '0' NOT NULL,
        t3_origuid 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,
+
        # Reference fields (basically same as MM table)
        uid_local int(11) DEFAULT '0' NOT NULL,
        uid_foreign int(11) DEFAULT '0' NOT NULL,
index b8f2bf6..bc5a06c 100644 (file)
@@ -9,6 +9,45 @@ $TCA['sys_file_reference'] = array(
        ),
        'feInterface' => $TCA['sys_file_reference']['feInterface'],
        'columns' => array(
+               't3ver_label' => array(
+                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.versionLabel',
+                       'config' => array(
+                               'type' => 'input',
+                               'size' => '30',
+                               'max' => '30'
+                       )
+               ),
+               'sys_language_uid' => array(
+                       'exclude' => 1,
+                       'label' => 'LLL:EXT:lang/locallang_general.php: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.php:LGL.allLanguages', -1),
+                                       array('LLL:EXT:lang/locallang_general.php:LGL.default_value', 0)
+                               )
+                       )
+               ),
+               'l10n_parent' => array(
+                       'displayCond' => 'FIELD:sys_language_uid:>:0',
+                       'exclude' => 1,
+                       'label' => 'LLL:EXT:lang/locallang_general.php: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(
+                       'config' => array(
+                               'type' => 'passthrough'
+                       )
+               ),
                'hidden' => array(
                        'exclude' => 1,
                        'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
@@ -87,6 +126,7 @@ $TCA['sys_file_reference'] = array(
                        )
                ),
                'title' => array(
+                       'l10n_mode' => 'mergeIfNotBlank',
                        'exclude' => 0,
                        'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.title',
                        'config' => array(
@@ -96,6 +136,7 @@ $TCA['sys_file_reference'] = array(
                        )
                ),
                'link' => array(
+                       'l10n_mode' => 'mergeIfNotBlank',
                        'exclude' => 1,
                        'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.link',
                        'config' => array(
@@ -115,6 +156,7 @@ $TCA['sys_file_reference'] = array(
                ),
                'description' => array(
                        // This is used for captions in the frontend
+                       'l10n_mode' => 'mergeIfNotBlank',
                        'exclude' => 0,
                        'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.description',
                        'config' => array(
@@ -124,14 +166,15 @@ $TCA['sys_file_reference'] = array(
                        )
                ),
                'alternative' => array(
+                       'l10n_mode' => 'mergeIfNotBlank',
                        'exclude' => 0,
                        'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.alternative',
                        'config' => array(
                                'type' => 'input',
                                'size' => '22',
-                               'placeholder' => '__row|uid_local|name'
-                       )
-               )
+                               'placeholder' => '__row|uid_local|alternative'
+                       ),
+               ),
        ),
        'types' => array(
                // Note that at the moment we define the same fields for every media type.
@@ -183,7 +226,7 @@ $TCA['sys_file_reference'] = array(
                ),
                // file palette, hidden but needs to be included all the time
                'filePalette' => array(
-                       'showitem' => 'uid_local,hidden',
+                       'showitem' => 'uid_local, hidden, sys_language_uid, l10n_parent',
                        'isHiddenPalette' => TRUE
                )
        )
index f5ed589..58fcc00 100755 (executable)
@@ -665,7 +665,6 @@ $TCA['tt_content'] = array(
                        )
                ),
                'image' => array(
-                       'l10n_mode' => 'mergeIfNotBlank',
                        'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.images',
                        'config' => \TYPO3\CMS\Core\Extension\ExtensionManager::getFileFieldTCAConfig('image', array(
                                'appearance' => array(
@@ -1440,10 +1439,12 @@ $TCA['tt_content'] = array(
                        'config' => array(
                                'type' => 'group',
                                'internal_type' => 'db',
+                               'localizeReferencesAtParentLocalization' => TRUE,
                                'allowed' => 'sys_file_collection',
+                               'foreign_table' => 'sys_file_collection',
                                'maxitems' => 999,
                                'minitems' => 0,
-                               'size' => 5
+                               'size' => 5,
                        )
                ),
                'multimedia' => array(
index 0ab10e7..ade8e0d 100644 (file)
@@ -208,7 +208,7 @@ class DatabaseConnection {
         * @param string $groupBy Optional GROUP BY field(s), if none, supply blank string.
         * @param string $orderBy Optional ORDER BY field(s), if none, supply blank string.
         * @param string $limit Optional LIMIT value ([begin,]max), if none, supply blank string.
-        * @return pointer MySQL result pointer / DBAL object
+        * @return resource MySQL result pointer / DBAL object
         * @todo Define visibility
         */
        public function exec_SELECTquery($select_fields, $from_table, $where_clause, $groupBy = '', $orderBy = '', $limit = '') {
@@ -237,7 +237,7 @@ class DatabaseConnection {
         * @param string $groupBy Optional GROUP BY field(s), if none, supply blank string.
         * @param string $orderBy Optional ORDER BY field(s), if none, supply blank string.
         * @param string $limit Optional LIMIT value ([begin,]max), if none, supply blank string.
-        * @return pointer MySQL result pointer / DBAL object
+        * @return resource MySQL result pointer / DBAL object
         * @see exec_SELECTquery()
         * @todo Define visibility
         */
@@ -259,7 +259,7 @@ class DatabaseConnection {
         * Executes a select based on input query parts array
         *
         * @param array $queryParts Query parts array
-        * @return pointer MySQL select result pointer / DBAL object
+        * @return resource MySQL select result pointer / DBAL object
         * @see exec_SELECTquery()
         * @todo Define visibility
         */
index 82e47c3..9688fbd 100644 (file)
@@ -482,15 +482,24 @@ class ExtensionManager {
                        'appearance' => array(
                                'useSortable' => TRUE,
                                'headerThumbnail' => 'uid_local',
+                               'showPossibleLocalizationRecords' => TRUE,
+                               'showRemovedLocalizationRecords' => TRUE,
+                               'showSynchronizationLink' => TRUE,
+
                                'enabledControls' => array(
                                        'info' => FALSE,
                                        'new' => FALSE,
                                        'dragdrop' => TRUE,
                                        'sort' => FALSE,
                                        'hide' => TRUE,
-                                       'delete' => TRUE
-                               )
-                       )
+                                       'delete' => TRUE,
+                                       'localize' => TRUE,
+                               ),
+                       ),
+                       'behaviour' => array(
+                               'localizationMode' => 'select',
+                               'localizeChildrenAtParentLocalization' => TRUE,
+                       ),
                );
                return \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($fileFieldTCAConfig, $customSettingOverride);
        }
index f576649..e034955 100644 (file)
@@ -185,8 +185,8 @@ abstract class AbstractRepository implements \TYPO3\CMS\Extbase\Persistence\Repo
         * @api
         */
        public function findByUid($uid) {
-               if (!is_numeric($uid)) {
-                       throw new \InvalidArgumentException('uid has to be numeric.', 1316779798);
+               if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($uid)) {
+                       throw new \InvalidArgumentException('uid has to be integer.', 1316779798);
                }
                $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', $this->table, 'uid=' . intval($uid) . ' AND deleted=0');
                if (count($row) === 0) {
index 8c92932..90cf5e4 100644 (file)
@@ -33,8 +33,7 @@ namespace TYPO3\CMS\Core\Resource;
  * @package TYPO3
  * @subpackage t3lib
  */
-interface FileInterface extends \TYPO3\CMS\Core\Resource\ResourceInterface
-{
+interface FileInterface extends \TYPO3\CMS\Core\Resource\ResourceInterface {
        /*******************************
         * VARIOUS FILE PROPERTY GETTERS
         *******************************/
index 474db2e..691c9be 100644 (file)
@@ -65,9 +65,10 @@ class FrontendContentAdapterService {
         *
         * This method is called by the render() method of tslib_content_Content.
         *
-        * @param $row typically an array, but can also be null (in extensions or e.g. FLUID viewhelpers)
-        * @param $table the database table where the record is from
-        * @return      void
+        * @param array $row typically an array, but can also be null (in extensions or e.g. FLUID viewhelpers)
+        * @param string $table the database table where the record is from
+        * @throws \RuntimeException
+        * @return void
         */
        static public function modifyDBRow(&$row, $table) {
                if (array_key_exists($table, static::$migrateFields)) {
@@ -115,4 +116,4 @@ class FrontendContentAdapterService {
 }
 
 
-?>
+?>
\ No newline at end of file