[BUGFIX] Movements pollute colPos value of content elements 92/31492/2
authorNicole Cordes <typo3@cordes.co>
Tue, 8 Jul 2014 07:53:33 +0000 (09:53 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Tue, 8 Jul 2014 09:15:56 +0000 (11:15 +0200)
Due to commit I148ca1b023226f2f99417b3baf238b72346e721f the information
concerning previous and next content elements in one row is messed up.
This patch helps to build information which depends on colPos again and
prevents records being moved to another column.

Resolves: #48939
Resolves: #49055
Releases: 6.2, 6.1, 6.0, 4.7, 4.5
Change-Id: I3a15321ee11a1f7d96b58b8b7a5ab14098664b22
Reviewed-on: https://review.typo3.org/31492
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/backend/Classes/View/PageLayoutView.php

index 2a1e602..5d49fc8 100644 (file)
@@ -472,6 +472,7 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                                        ';
                                        $editUidList = '';
                                        $rowArr = $contentRecordsPerColumn[$key];
                                        ';
                                        $editUidList = '';
                                        $rowArr = $contentRecordsPerColumn[$key];
+                                       $this->generateTtContentDataArray($rowArr);
                                        foreach ((array) $rowArr as $rKey => $row) {
                                                if ($this->tt_contentConfig['languageMode']) {
                                                        $languageColumn[$key][$lP] = $head[$key] . $content[$key];
                                        foreach ((array) $rowArr as $rKey => $row) {
                                                if ($this->tt_contentConfig['languageMode']) {
                                                        $languageColumn[$key][$lP] = $head[$key] . $content[$key];
@@ -751,6 +752,7 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                                foreach ($cList as $counter => $key) {
                                        $c = 0;
                                        $rowArr = $contentRecordsPerColumn[$key];
                                foreach ($cList as $counter => $key) {
                                        $c = 0;
                                        $rowArr = $contentRecordsPerColumn[$key];
+                                       $this->generateTtContentDataArray($rowArr);
                                        $numberOfContentElementsInColumn = count($rowArr);
                                        $rowOut = '';
                                        // If it turns out that there are not content elements in the column, then display a big button which links directly to the wizard script:
                                        $numberOfContentElementsInColumn = count($rowArr);
                                        $rowOut = '';
                                        // If it turns out that there are not content elements in the column, then display a big button which links directly to the wizard script:
@@ -1809,10 +1811,6 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
         * @todo Define visibility
         */
        public function getResult($result, $table = 'tt_content') {
         * @todo Define visibility
         */
        public function getResult($result, $table = 'tt_content') {
-               // Initialize:
-               $recs = array();
-               $nextTree = $this->nextThree;
-               $c = 0;
                $output = array();
                // Traverse the result:
                while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
                $output = array();
                // Traverse the result:
                while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
@@ -1820,27 +1818,9 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                        if ($row) {
                                // Add the row to the array:
                                $output[] = $row;
                        if ($row) {
                                // Add the row to the array:
                                $output[] = $row;
-                               // Set an internal register:
-                               $recs[$c] = $row['uid'];
-                               // Create the list of the next three ids (for editing links...)
-                               for ($a = 0; $a < $nextTree; $a++) {
-                                       $inList = GeneralUtility::inList($this->tt_contentData['nextThree'][$recs[$c - $a]], $row['uid']);
-                                       if (isset($recs[$c - $a]) && !$inList) {
-                                               $this->tt_contentData['nextThree'][$recs[$c - $a]] .= $row['uid'] . ',';
-                                       }
-                               }
-                               // Set next/previous ids:
-                               if (isset($recs[$c - 1])) {
-                                       if (isset($recs[$c - 2])) {
-                                               $this->tt_contentData['prev'][$row['uid']] = -$recs[($c - 2)];
-                                       } else {
-                                               $this->tt_contentData['prev'][$row['uid']] = $row['pid'];
-                                       }
-                                       $this->tt_contentData['next'][$recs[$c - 1]] = -$row['uid'];
-                               }
-                               $c++;
                        }
                }
                        }
                }
+               $this->generateTtContentDataArray($output);
                // Return selected records
                return $output;
        }
                // Return selected records
                return $output;
        }
@@ -1878,6 +1858,40 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
        }
 
        /**
        }
 
        /**
+        * Generates the data for previous and next elements which is needed for movements.
+        *
+        * @param array $rowArray
+        * @return void
+        */
+       protected function generateTtContentDataArray(array $rowArray) {
+               $this->tt_contentData = array(
+                       'nextThree' => array(),
+                       'next' => array(),
+                       'prev' => array(),
+               );
+               foreach ($rowArray as $key => $value) {
+                       // Create the list of the next three ids (for editing links...)
+                       for ($i = 0; $i < $this->nextThree; $i++) {
+                               if (isset($rowArray[$key - $i])
+                                       && !GeneralUtility::inList($this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']], $value['uid'])
+                               ) {
+                                       $this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']] .= $value['uid'] . ',';
+                               }
+                       }
+
+                       // Create information for next and previous content elements
+                       if (isset($rowArray[$key - 1])) {
+                               if (isset($rowArray[$key - 2])) {
+                                       $this->tt_contentData['prev'][$value['uid']] = -$rowArray[$key - 2]['uid'];
+                               } else {
+                                       $this->tt_contentData['prev'][$value['uid']] = $value['pid'];
+                               }
+                               $this->tt_contentData['next'][$rowArray[$key - 1]['uid']] = -$value['uid'];
+                       }
+               }
+       }
+
+       /**
         * Counts and returns the number of records on the page with $pid
         *
         * @param string $table Table name
         * Counts and returns the number of records on the page with $pid
         *
         * @param string $table Table name