[TASK] Improve Layout of CType Menu in page module 53/35953/13
authorMathias Schreiber <mathias.schreiber@wmdb.de>
Tue, 13 Jan 2015 12:01:40 +0000 (13:01 +0100)
committerPhilipp Gampe <philipp.gampe@typo3.org>
Sat, 17 Jan 2015 18:56:16 +0000 (19:56 +0100)
CType menu will now display the selected menu_type and a headline.

Fixes: #39646
Releases: master
Change-Id: I69bf3900c791950487e57621579599437a4cc6e5
Reviewed-on: http://review.typo3.org/35953
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Philipp Gampe <philipp.gampe@typo3.org>
Tested-by: Philipp Gampe <philipp.gampe@typo3.org>
typo3/sysext/backend/Classes/View/PageLayoutView.php

index c6eb658..7bd3696 100644 (file)
@@ -1521,8 +1521,16 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                                        }
                                        break;
                                case 'menu':
-                                       if ($row['pages']) {
-                                               $out .= $this->linkEditContent($row['pages'], $row) . '<br />';
+                                       $contentType = $this->CType_labels[$row['CType']];
+                                       $out .= '<strong>' . htmlspecialchars($contentType) . '</strong><br />';
+                                       // Add Menu Type
+                                       $menuTypeLabel = $this->getLanguageService()->sL(
+                                               BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'menu_type', $row['menu_type'])
+                                       );
+                                       $out .= $menuTypeLabel !== '' ? $menuTypeLabel : 'invalid menu type';
+                                       if ($row['menu_type'] !== '2' && ($row['pages'] || $row['selected_categories'])) {
+                                               // Show pages if menu type is not "Sitemap"
+                                               $out .= ':' . $this->linkEditContent($this->generateListForCTypeMenu($row), $row) . '<br />';
                                        }
                                        break;
                                case 'shortcut':
@@ -1633,6 +1641,33 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
        }
 
        /**
+        * Generates a list of selected pages or categories for the CType menu
+        *
+        * @param array $row row from pages
+        * @return string
+        */
+       protected function generateListForCTypeMenu(array $row) {
+               $table = 'pages';
+               $field = 'pages';
+               // get categories instead of pages
+               if (strpos($row['menu_type'], 'categorized_') !== FALSE) {
+                       $table = 'sys_category';
+                       $field = 'selected_categories';
+               }
+               if (trim($row[$field]) === '') {
+                       return '';
+               }
+               $content = '';
+               $uidList = explode(',', $row[$field]);
+               foreach ($uidList as $uid) {
+                       $uid = (int)$uid;
+                       $record = BackendUtility::getRecord($table, $uid, 'title');
+                       $content .= '<br>' . $record['title'] . ' (' .$uid. ')';
+               }
+               return $content;
+       }
+
+       /**
         * Filters out all tt_content uids which are already translated so only non-translated uids is left.
         * Selects across columns, but within in the same PID. Columns are expect to be the same
         * for translations and original but this may be a conceptual error (?)