[TASK] Group excludefields by table
authorJohannes Feustel <s@feustel.eu>
Sun, 19 Feb 2012 16:14:44 +0000 (17:14 +0100)
committerSteffen Ritter <info@rs-websystems.de>
Sun, 14 Oct 2012 08:38:02 +0000 (10:38 +0200)
Do not display table name redundantly for each item but group items like
it is done for other fields like page types.

* Add header for each table of items in excludefields array and remove
table from item label
* Add possibility to set icon for headers
* Unset icon for page type headers
* Remove unused variable $descr

Change-Id: I4201c64a50ee63c9d9e3415e0e8245614db7af07
Resolves: #34098
Releases: 4.7,4.6,4.5
Reviewed-on: http://review.typo3.org/13916
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
t3lib/class.t3lib_tceforms.php

index 85c086b..619dd71 100644 (file)
@@ -1681,9 +1681,13 @@ class t3lib_TCEforms {
                        foreach ($selItems as $p) {
                                        // Non-selectable element:
                                if (!strcmp($p[1], '--div--')) {
+                                       $selIcon = '';
+                                       if (isset($p[2]) && $p[2] != 'empty-emtpy') {
+                                               $selIcon = $this->getIconHtml($p[2]) ;
+                                       }
                                        $tRows[] = '
                                                <tr class="c-header">
-                                                       <td colspan="3">' . htmlspecialchars($p[0]) . '</td>
+                                                       <td colspan="3">' . $selIcon . htmlspecialchars($p[0]) . '</td>
                                                </tr>';
                                } else {
                                                // Selected or not by default:
@@ -1698,7 +1702,7 @@ class t3lib_TCEforms {
                                                $selIcon = $p[2];
                                        } else {
                                                $selIcon = t3lib_iconWorks::getSpriteIcon('empty-empty');
-                                       }
+                                       }
 
                                                // Compile row:
                                        $rowId = uniqid('select_checkbox_row_');
@@ -4551,7 +4555,6 @@ class t3lib_TCEforms {
                        switch ($fieldValue['config']['special']) {
                                case 'tables':
                                        $temp_tc = array_keys($GLOBALS['TCA']);
-                                       $descr = '';
 
                                        foreach ($temp_tc as $theTableNames) {
                                                if (!$GLOBALS['TCA'][$theTableNames]['ctrl']['adminOnly']) {
@@ -4581,8 +4584,15 @@ class t3lib_TCEforms {
                                        $theTypes = $GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'];
 
                                        foreach ($theTypes as $theTypeArrays) {
+
                                                        // Icon:
-                                               $icon = t3lib_iconWorks::mapRecordTypeToSpriteIconName('pages', array('doktype' => $theTypeArrays[1]));
+                                               $icon = 'empty-emtpy';
+                                               if ($theTypeArrays[1] != '--div--') {
+                                                       $icon = t3lib_iconWorks::mapRecordTypeToSpriteIconName(
+                                                               'pages',
+                                                               array('doktype' => $theTypeArrays[1])
+                                                       );
+                                               }
 
                                                        // Item configuration:
                                                $items[] = array(
@@ -4594,7 +4604,6 @@ class t3lib_TCEforms {
                                break;
                                case 'exclude':
                                        $theTypes = t3lib_BEfunc::getExcludeFields();
-                                       $descr = '';
 
                                        foreach ($theTypes as $theTypeArrays) {
                                                list($theTable, $theFullField) = explode(':', $theTypeArrays[1]);
@@ -4602,6 +4611,16 @@ class t3lib_TCEforms {
                                                $theFieldParts = explode(';', $theFullField);
                                                $theField = array_pop($theFieldParts);
 
+                                                       // Add header if not yet set for table:
+                                               if (!array_key_exists($theTable, $items)){
+                                                       $icon = t3lib_iconWorks::mapRecordTypeToSpriteIconName($theTable, array());
+                                                       $items[$theTable] = array(
+                                                               $this->sL($GLOBALS['TCA'][$theTable]['ctrl']['title']),
+                                                               '--div--',
+                                                               $icon,
+                                                       );
+                                               }
+
                                                        // Add help text
                                                $helpText = array();
                                                $GLOBALS['LANG']->loadSingleTableDescription($theTable);
@@ -4612,7 +4631,8 @@ class t3lib_TCEforms {
 
                                                        // Item configuration:
                                                $items[] = array(
-                                                       rtrim($theTypeArrays[0], ':') . ' (' . $theField . ')',
+                                                       rtrim($GLOBALS['LANG']->sl($GLOBALS['TCA'][$theTable]['columns'][$theField]['label']), ':') .
+                                                                       ' (' . $theField . ')',
                                                        $theTypeArrays[1],
                                                        'empty-empty',
                                                        $helpText
@@ -4699,7 +4719,6 @@ class t3lib_TCEforms {
 
                                        $modList = $fieldValue['config']['special'] == 'modListUser' ? $loadModules->modListUser : $loadModules->modListGroup;
                                        if (is_array($modList)) {
-                                               $descr = '';
 
                                                foreach ($modList as $theMod) {