[TASK] Group excludefields by table
authorJohannes Feustel <s@feustel.eu>
Sun, 19 Feb 2012 16:14:44 +0000 (17:14 +0100)
committerJigal van Hemert <jigal@xs4all.nl>
Sat, 24 Nov 2012 12:48:51 +0000 (13:48 +0100)
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: Ic1abe4ed0032b5e2c0a04814f1371a9d1a84448e
Resolves: #34098
Releases: 4.7,4.6,4.5
Reviewed-on: http://review.typo3.org/13919
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Stefan Neufeind
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
t3lib/class.t3lib_tceforms.php

index 1f7f2d3..9205b91 100644 (file)
@@ -1804,9 +1804,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:
@@ -1821,7 +1825,7 @@ class t3lib_TCEforms {
                                                $selIcon = $p[2];
                                        } else {
                                                $selIcon = t3lib_iconWorks::getSpriteIcon('empty-empty');
-                                       }
+                                       }
 
                                                // Compile row:
                                        $rowId = uniqid('select_checkbox_row_');
@@ -4659,8 +4663,7 @@ class t3lib_TCEforms {
                if ($fieldValue['config']['special']) {
                        switch ($fieldValue['config']['special']) {
                                case 'tables':
-                                       $temp_tc = array_keys($TCA);
-                                       $descr = '';
+                                       $temp_tc = array_keys($GLOBALS['TCA']);
 
                                        foreach ($temp_tc as $theTableNames) {
                                                if (!$TCA[$theTableNames]['ctrl']['adminOnly']) {
@@ -4690,8 +4693,15 @@ class t3lib_TCEforms {
                                        $theTypes = $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(
@@ -4703,7 +4713,6 @@ class t3lib_TCEforms {
                                break;
                                case 'exclude':
                                        $theTypes = t3lib_BEfunc::getExcludeFields();
-                                       $descr = '';
 
                                        foreach ($theTypes as $theTypeArrays) {
                                                list($theTable, $theFullField) = explode(':', $theTypeArrays[1]);
@@ -4711,6 +4720,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);
@@ -4721,7 +4740,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
@@ -4808,7 +4828,6 @@ class t3lib_TCEforms {
 
                                        $modList = $fieldValue['config']['special'] == 'modListUser' ? $loadModules->modListUser : $loadModules->modListGroup;
                                        if (is_array($modList)) {
-                                               $descr = '';
 
                                                foreach ($modList as $theMod) {