[TASK] Category fields are not added to TCA interface section 61/37861/2
authorOliver Hader <oliver@typo3.org>
Thu, 22 May 2014 13:41:37 +0000 (15:41 +0200)
committerMarkus Klein <klein.t3@reelworx.at>
Sun, 15 Mar 2015 18:14:56 +0000 (19:14 +0100)
$TCA[<table>]['interface']['showRecordFieldList'] contains a list
of fields that is used for visualizing
* accordant element details (record info)
* differences in the workspaces detail view

Fields that are treated as category should appear automatically.
If using CategoryRegistry::add() in extensions, the option
property "interface" can be used to disable this automated
handling in the interface section - in that case it needs
to be FALSE.

Resolves: #59042
Releases: master, 6.2
Change-Id: Id51aaf5d057a70cb9b8c230da3f9335f74c9850a
Reviewed-on: http://review.typo3.org/37861
Reviewed-by: Benjamin Mack <benni@typo3.org>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/core/Classes/Category/CategoryRegistry.php

index e5e04d4..28e088d 100644 (file)
@@ -14,8 +14,11 @@ namespace TYPO3\CMS\Core\Category;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
 
 /**
  * Class to register category configurations.
@@ -23,7 +26,7 @@ use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
  * @author Fabien Udriot <fabien.udriot@typo3.org>
  * @author Oliver Hader <oliver.hader@typo3.org>
  */
-class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface {
+class CategoryRegistry implements SingletonInterface {
 
        /**
         * @var array
@@ -48,10 +51,10 @@ class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface {
        /**
         * Returns a class instance
         *
-        * @return \TYPO3\CMS\Core\Category\CategoryRegistry
+        * @return CategoryRegistry
         */
        static public function getInstance() {
-               return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(__CLASS__);
+               return GeneralUtility::makeInstance(__CLASS__);
        }
 
        /**
@@ -140,11 +143,10 @@ class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface {
         * in tt_content table (called as itemsProcFunc).
         *
         * @param array $configuration Current field configuration
-        * @param \TYPO3\CMS\Backend\Form\FormEngine $formObject Back-reference to the calling object
         * @throws \UnexpectedValueException
         * @return void
         */
-       public function getCategoryFieldsForTable(array &$configuration, \TYPO3\CMS\Backend\Form\FormEngine $formObject) {
+       public function getCategoryFieldsForTable(array &$configuration) {
                $table = '';
                // Define the table being looked up from the type of menu
                if ($configuration['row']['menu_type'] == 'categorized_pages') {
@@ -160,7 +162,7 @@ class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface {
                foreach ($this->registry as $tableName => $fields) {
                        if ($tableName === $table) {
                                foreach ($fields as $fieldName => $options) {
-                                       $fieldLabel = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
+                                       $fieldLabel = $this->getLanguageService()->sL($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
                                        $configuration['items'][] = array($fieldLabel, $fieldName);
                                }
                        }
@@ -250,7 +252,7 @@ class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface {
         * @return void
         */
        protected function registerDefaultCategorizedTables() {
-               $defaultCategorizedTables = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(
+               $defaultCategorizedTables = GeneralUtility::trimExplode(
                        ',',
                        $GLOBALS['TYPO3_CONF_VARS']['SYS']['defaultCategorizedTables'],
                        TRUE
@@ -326,6 +328,7 @@ class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface {
         * @param array $options Additional configuration options
         *              + fieldConfiguration: TCA field config array to override defaults
         *              + label: backend label of the categories field
+        *              + interface: boolean if the category should be included in the "interface" section of the TCA table
         * @return void
         */
        protected function addTcaColumn($tableName, $fieldName, array $options) {
@@ -353,6 +356,7 @@ class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface {
                                ),
                        );
 
+                       // Register opposite references for the foreign side of a relation
                        if (empty($GLOBALS['TCA']['sys_category']['columns']['items']['config']['MM_oppositeUsage'][$tableName])) {
                                $GLOBALS['TCA']['sys_category']['columns']['items']['config']['MM_oppositeUsage'][$tableName] = array();
                        }
@@ -360,6 +364,15 @@ class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface {
                                $GLOBALS['TCA']['sys_category']['columns']['items']['config']['MM_oppositeUsage'][$tableName][] = $fieldName;
                        }
 
+                       // Add field to interface list per default (unless the 'interface' property is FALSE)
+                       if (
+                               (!isset($options['interface']) || $options['interface'])
+                               && !empty($GLOBALS['TCA'][$tableName]['interface']['showRecordFieldList'])
+                               && !GeneralUtility::inList($GLOBALS['TCA'][$tableName]['interface']['showRecordFieldList'], $fieldName)
+                       ) {
+                               $GLOBALS['TCA'][$tableName]['interface']['showRecordFieldList'] .= ',' . $fieldName;
+                       }
+
                        // Adding fields to an existing table definition
                        ExtensionManagementUtility::addTCAcolumns($tableName, $columns);
                }
@@ -438,4 +451,11 @@ class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface {
                $sqlString[] = $this->getDatabaseTableDefinition($extensionKey);
                return array('sqlString' => $sqlString, 'extensionKey' => $extensionKey);
        }
+
+       /**
+        * @return LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
 }