[BUGFIX] List module - backend layout - moving content elements
authorJo Hasenau <info@cybercraft.de>
Fri, 4 Mar 2011 08:42:13 +0000 (09:42 +0100)
committerAndreas Wolf <andreas.wolf@ikt-werk.de>
Wed, 9 Mar 2011 18:17:46 +0000 (19:17 +0100)
When moving a content element in the List module by clicking on
the "Re-position content element" icon, an user is presented with
the old 4 columns instead of columns that would represent the newly
introduced backend layout as it is appearing in the Page module.

Change-Id: Ie8120784b0ccb9036d012437cae966de3484f1e6
Fixes: #M17529
Reviewed-on: http://review.typo3.org/1040
Reviewed-by: Andreas Wolf <andreas.wolf@ikt-werk.de>
Tested-by: Andreas Wolf <andreas.wolf@ikt-werk.de>
t3lib/class.t3lib_positionmap.php
typo3/move_el.php

index c3b7225..66813cc 100644 (file)
@@ -403,18 +403,18 @@ class t3lib_positionMap {
                                '',
                                'sorting'
                        );
-                       $lines[$kk] = array();
-                       $lines[$kk][] = $this->insertPositionIcon('', $vv, $kk, $moveUid, $pid);
+                       $lines[$vv] = array();
+                       $lines[$vv][] = $this->insertPositionIcon('', $vv, $kk, $moveUid, $pid);
                        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                                t3lib_BEfunc::workspaceOL('tt_content', $row);
                                if (is_array($row)) {
-                                       $lines[$kk][] = $this->wrapRecordHeader($this->getRecordHeader($row), $row);
-                                       $lines[$kk][] = $this->insertPositionIcon($row, $vv, $kk, $moveUid, $pid);
+                                       $lines[$vv][] = $this->wrapRecordHeader($this->getRecordHeader($row), $row);
+                                       $lines[$vv][] = $this->insertPositionIcon($row, $vv, $kk, $moveUid, $pid);
                                }
                        }
                        $GLOBALS['TYPO3_DB']->sql_free_result($res);
                }
-               return $this->printRecordMap($lines, $colPosArray);
+               return $this->printRecordMap($lines, $colPosArray, $pid);
        }
 
        /**
@@ -422,35 +422,109 @@ class t3lib_positionMap {
         *
         * @param       array           Array with arrays of lines for each column
         * @param       array           Column position array
+        * @param       integer         The id of the page
         * @return      string          HTML
         */
-       function printRecordMap($lines, $colPosArray) {
+       function printRecordMap($lines, $colPosArray, $pid = 0) {
+
                $row1 = '';
                $row2 = '';
                $count = t3lib_div::intInRange(count($colPosArray), 1);
 
-                       // Traverse the columns here:
-               foreach ($colPosArray as $kk => $vv) {
-                       $row1 .= '<td align="center" width="' . round(100 / $count) . '%"><span class="uppercase"><strong>' .
-                                        $this->wrapColumnHeader($GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content', 'colPos', $vv), 1), $vv) .
-                                        '</strong></span></td>';
-                       $row2 .= '<td valign="top" nowrap="nowrap">' .
-                                        implode('<br />', $lines[$kk]) .
-                                        '</td>';
-               }
+               $backendLayout = t3lib_div::callUserFunction('EXT:cms/classes/class.tx_cms_backendlayout.php:tx_cms_BackendLayout->getSelectedBackendLayout', $pid, $this);
+
+               if (isset($backendLayout['__config']['backend_layout.'])) {
 
-               $table = '
+                       $table = '<div class="t3-gridContainer"><table border="0" cellspacing="1" cellpadding="4" id="typo3-ttContentList">';
+
+                       $colCount = intval($backendLayout['__config']['backend_layout.']['colCount']);
+                       $rowCount = intval($backendLayout['__config']['backend_layout.']['rowCount']);
+
+                       $table .= '<colgroup>';
+                       for ($i = 0; $i < $colCount; $i++) {
+                               $table .= '<col style="width:' . (100 / $colCount) . '%"></col>';
+                       }
+                       $table .= '</colgroup>';
+
+                       $tcaItems = t3lib_div::callUserFunction('EXT:cms/classes/class.tx_cms_backendlayout.php:tx_cms_BackendLayout->getColPosListItemsParsed', $pid, $this);
+
+                       // cycle through rows
+                       for ($row = 1; $row <= $rowCount; $row++) {
+                               $rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.'];
+                               if (!isset($rowConfig)) {
+                                       continue;
+                               }
+
+                               $table .= '<tr>';
+
+                               for ($col = 1; $col <= $colCount; $col++) {
+                                       $columnConfig = $rowConfig['columns.'][$col . '.'];
+                                       if (!isset($columnConfig)) {
+                                               continue;
+                                       }
 
-               <!--
-                       Map of records in columns:
-               -->
-               <table border="0" cellpadding="0" cellspacing="1" id="typo3-ttContentList">
-                       <tr class="bgColor5">' . $row1 . '</tr>
-                       <tr>' . $row2 . '</tr>
-               </table>
+                                       // which tt_content colPos should be displayed inside this cell
+                                       $columnKey = intval($columnConfig['colPos']);
+                                       $head = '';
 
-               ';
+                                       $params = array();
+                                       $params['pid'] = $pid;
 
+                                       foreach ($tcaItems as $item) {
+                                               if ($item[1] == $columnKey) {
+                                                       $head = $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content', 'colPos', $columnKey, $params), 1);
+                                               }
+                                       }
+
+                                       // render the grid cell
+                                       $table .= '<td valign="top"' .
+                                                       (isset($columnConfig['colspan']) ? ' colspan="' . $columnConfig['colspan'] . '"' : '') .
+                                                       (isset($columnConfig['rowspan']) ? ' rowspan="' . $columnConfig['rowspan'] . '"' : '') .
+                                                       ' class="t3-gridCell t3-page-column t3-page-column-' . $columnKey .
+                                                       (!isset($columnConfig['colPos']) ? ' t3-gridCell-unassigned' : '') .
+                                                       ((isset($columnConfig['colPos']) && ! $head) ? ' t3-gridCell-restricted' : '') .
+                                                       (isset($columnConfig['colspan']) ? ' t3-gridCell-width' . $columnConfig['colspan'] : '') .
+                                                       (isset($columnConfig['rowspan']) ? ' t3-gridCell-height' . $columnConfig['rowspan'] : '') . '">';
+
+                                       $table .= '<div class="t3-page-colHeader t3-row-header">';
+
+                                       if (isset($columnConfig['colPos']) && $head) {
+                                               $table .= $this->wrapColumnHeader($head, '', '') . '</div>' . implode('<br />', $lines[$columnKey]);
+                                       } else if ($columnConfig['colPos']) {
+                                               $table .= $this->wrapColumnHeader($GLOBALS['LANG']->getLL('noAccess'), '', '') . '</div>';
+                                       } else if ($columnConfig['name']) {
+                                               $table .= $this->wrapColumnHeader($columnConfig['name'], '', '') . '</div>';
+                                       } else {
+                                               $table .= $this->wrapColumnHeader($GLOBALS['LANG']->getLL('notAssigned'), '', '') . '</div>';
+                                       }
+                                       $table .= '</td>';
+                               }
+                               $table .= '</tr>';
+                       }
+                       $table .= '</table></div>';
+               } else {
+                   // Traverse the columns here:
+                       foreach ($colPosArray as $kk => $vv) {
+                               $row1 .= '<td align="center" width="' . round(100 / $count) . '%"><div class="t3-page-colHeader t3-row-header">' .
+                                               $this->wrapColumnHeader($GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content', 'colPos', $vv, $pid), 1), $vv) .
+                                               '</div></td>';
+                               $row2 .= '<td valign="top" nowrap="nowrap">' .
+                                               implode('<br />', $lines[$vv]) .
+                                               '</td>';
+                       }
+
+                       $table = '
+
+                       <!--
+                               Map of records in columns:
+                       -->
+                       <table border="0" cellpadding="0" cellspacing="1" id="typo3-ttContentList">
+                               <tr>' . $row1 . '</tr>
+                               <tr>' . $row2 . '</tr>
+                       </table>
+
+                       ';
+               }
                return $this->JSimgFunc('2') . $table;
        }
 
@@ -544,4 +618,4 @@ class t3lib_positionMap {
 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_positionmap.php'])) {
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_positionmap.php']);
 }
-?>
\ No newline at end of file
+?>
index 0bd5faa..e4174ee 100644 (file)
@@ -360,38 +360,44 @@ class SC_move_el {
 
                                                // Headerline for the parent page: Icon, record title:
                                        $hline = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageinfo, array('title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($pageinfo, 'pages'))));
-                                       $hline.= t3lib_BEfunc::getRecordTitle('pages',$pageinfo,TRUE);
+                                       $hline .= t3lib_BEfunc::getRecordTitle('pages', $pageinfo, TRUE);
 
                                                // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable:
                                        $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->page_id,'mod.SHARED');                // SHARED page-TSconfig settings.
-                                       $colPosList = strcmp(trim($modTSconfig_SHARED['properties']['colPos_list']),'') ? trim($modTSconfig_SHARED['properties']['colPos_list']) : '1,0,2,3';
-                                       $colPosList = implode(',',array_unique(t3lib_div::intExplode(',',$colPosList)));                // Removing duplicates, if any
-
+                                       $colPosArray = t3lib_div::callUserFunction('EXT:cms/classes/class.tx_cms_backendlayout.php:tx_cms_BackendLayout->getColPosListItemsParsed', $this->page_id, $this);
+                                       foreach ($colPosArray as $colPos) {
+                                               $colPosList .= $colPosList != '' ? ',' . $colPos[1] : $colPos[1];
+                                       }
+                                       $colPosList = implode(',', array_unique(t3lib_div::intExplode(',', $colPosList)));              // Removing duplicates, if any
+                                                 
                                                // Adding parent page-header and the content element columns from position-map:
-                                       $code=$hline.'<br />';
-                                       $code.=$posMap->printContentElementColumns($this->page_id,$this->moveUid,$colPosList,1,$this->R_URI);
+                                       $code = $hline . '<br />';
+                                       $code .= $posMap->printContentElementColumns($this->page_id, $this->moveUid, $colPosList, 1, $this->R_URI);
 
                                                // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
-                                       $code.= '<br />';
-                                       $code.= '<br />';
+                                       $code .= '<br />';
+                                       $code .= '<br />';
                                        if ($pageinfo['pid'])   {
-                                               $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo['pid'],$this->perms_clause);
+                                               $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo['pid'], $this->perms_clause);
                                                if (is_array($pidPageInfo))     {
-                                                       if ($BE_USER->isInWebMount($pidPageInfo['pid'],$this->perms_clause))    {
-                                                               $code.= '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('uid'=>intval($pageinfo['pid']),'moveUid'=>$this->moveUid))).'">'.
-                                                                       t3lib_iconWorks::getSpriteIcon('actions-view-go-up') .
-                                                                       t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE).
-                                                                       '</a><br />';
+                                                       if ($BE_USER->isInWebMount($pidPageInfo['pid'], $this->perms_clause))   {
+                                                               $code .= '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
+                                                                               'uid' => intval($pageinfo['pid']),
+                                                                               'moveUid' => $this->moveUid)
+                                                                       )) . '">'
+                                                                       . t3lib_iconWorks::getSpriteIcon('actions-view-go-up')
+                                                                       . t3lib_BEfunc::getRecordTitle('pages', $pidPageInfo, TRUE)
+                                                                       . '</a><br />';
                                                        } else {
-                                                               $code.= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo).
-                                                                       t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE).
-                                                                       '<br />';
+                                                               $code.= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo)
+                                                                       . t3lib_BEfunc::getRecordTitle('pages', $pidPageInfo, TRUE)
+                                                                       '<br />';
                                                        }
                                                }
                                        }
 
                                                // Create the position tree (for pages):
-                                       $code.= $posMap->positionTree($this->page_id,$pageinfo,$this->perms_clause,$this->R_URI);
+                                       $code.= $posMap->positionTree($this->page_id, $pageinfo, $this->perms_clause, $this->R_URI);
                                }
                        }