Fixed bug #17215: TCEFORM.tt_content.colPos.removeItems not working correctly on...
authorErnesto Baschny <ernst@cron-it.de>
Mon, 24 Jan 2011 21:58:20 +0000 (21:58 +0000)
committerErnesto Baschny <ernst@cron-it.de>
Mon, 24 Jan 2011 21:58:20 +0000 (21:58 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@10287 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/classes/class.tx_cms_backendlayout.php

index 3996f15..55257d2 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-01-24  Ernesto Baschny  <ernst@cron-it.de>
+
+       * Fixed bug #17215: TCEFORM.tt_content.colPos.removeItems not working correctly on colPos with new backend layouts (Thanks to Jo Hasenau)
+
 2011-01-24  Steffen Kamper  <steffen@typo3.org>
 
        * Fixed bug #17275: Pagetree preloads huge amount of pages with initial load / refresh
index 59d54d5..2693142 100644 (file)
@@ -34,7 +34,16 @@ class tx_cms_BackendLayout {
         * @return void
         */
        public function colPosListItemProcFunc(&$params) {
-               $params['items'] = $this->addColPosListLayoutItems($params['row']['pid'], $params['items']);
+               if ($params['row']['pid'] > 0) {
+                       $params['items'] = $this->addColPosListLayoutItems($params['row']['pid'], $params['items']);
+               } else {
+                       // negative uid_pid values indicate that the element has been inserted after an existing element
+                       // so there is no pid to get the backendLayout for and we have to get that first
+                       $existingElement = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('pid', 'tt_content', 'uid=' . -(intval($params['row']['pid'])));
+                       if ($existingElement['pid'] > 0) {
+                               $params['items'] = $this->addColPosListLayoutItems($existingElement['pid'], $params['items']);
+                       }
+               }
        }
 
        /**
@@ -74,7 +83,11 @@ class tx_cms_BackendLayout {
                }
 
                foreach (t3lib_div::trimExplode(',', $tsConfig['properties']['removeItems'], 1) as $removeId) {
-                       unset($tcaItems[$removeId]);
+                       foreach ($tcaItems as $key => $item) {
+                               if ($item[1] == $removeId) {
+                                       unset($tcaItems[$key]);
+                               }
+                       }
                }
 
                return $tcaItems;
@@ -96,15 +109,21 @@ class tx_cms_BackendLayout {
                                'pages',
                                'uid=' . intval($rootline[$i]['uid'])
                        );
-
-                       if (intval($page['backend_layout_next_level']) > 0 && $page['uid'] != $id) {
-                               $backendLayoutUid = intval($page['backend_layout_next_level']);
-                               break;
-                       } else {
-                               if (intval($page['backend_layout']) > 0) {
-                                       $backendLayoutUid = intval($page['backend_layout']);
-                                       break;
+                       $selectedBackendLayout = intval($page['backend_layout']);
+                       $selectedBackendLayoutNextLevel = intval($page['backend_layout_next_level']);
+                       if ($selectedBackendLayout != 0 && $page['uid'] == $id) {
+                               if ($selectedBackendLayout > 0) {
+                                               // Backend layout for current page is set
+                                       $backendLayoutUid = $selectedBackendLayout;
                                }
+                               break;
+                       } else if ($selectedBackendLayoutNextLevel == -1 && $page['uid'] != $id) {
+                                       // Some previous page in our rootline sets layout_next to "None"
+                               break;
+                       } else if ($selectedBackendLayoutNextLevel > 0 && $page['uid'] != $id) {
+                                       // Some previous page in our rootline sets some backend_layout, use it
+                               $backendLayoutUid = $selectedBackendLayoutNextLevel;
+                               break;
                        }
                }