[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>
Tue, 21 Feb 2012 06:39:17 +0000 (07:39 +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: I2115f154ee61c00dbe5af0fc45391bae9170ce16
Resolves: #34098
Releases: 4.7,4.6,4.5
Reviewed-on: http://review.typo3.org/9108
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
Reviewed-by: Soren Malling
Tested-by: Soren Malling
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
t3lib/class.t3lib_tceforms.php

index d511459..3f8a08f 100644 (file)
@@ -1707,9 +1707,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:
@@ -1724,7 +1728,7 @@ class t3lib_TCEforms {
                                                $selIcon = $p[2];
                                        } else {
                                                $selIcon = t3lib_iconWorks::getSpriteIcon('empty-empty');
-                                       }
+                                       }
 
                                                // Compile row:
                                        $rowId = uniqid('select_checkbox_row_');
@@ -4668,7 +4672,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']) {
@@ -4698,8 +4701,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(
@@ -4711,7 +4721,6 @@ class t3lib_TCEforms {
                                break;
                                case 'exclude':
                                        $theTypes = t3lib_BEfunc::getExcludeFields();
-                                       $descr = '';
 
                                        foreach ($theTypes as $theTypeArrays) {
                                                list($theTable, $theFullField) = explode(':', $theTypeArrays[1]);
@@ -4719,6 +4728,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);
@@ -4729,7 +4748,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
@@ -4816,7 +4836,6 @@ class t3lib_TCEforms {
 
                                        $modList = $fieldValue['config']['special'] == 'modListUser' ? $loadModules->modListUser : $loadModules->modListGroup;
                                        if (is_array($modList)) {
-                                               $descr = '';
 
                                                foreach ($modList as $theMod) {