[BUGFIX] Warning in list module
[Packages/TYPO3.CMS.git] / typo3 / db_new.php
index 93c5e42..e8518ee 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
+*  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -328,10 +328,12 @@ class SC_db_new {
 
                                // Record list
                                // If access to Web>List for user, then link to that module.
-                       $buttons['record_list'] = t3lib_extMgm::createListViewLink(
-                               $this->pageinfo['uid'],
-                               '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')),
-                               $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', TRUE)
+                       $buttons['record_list'] = t3lib_BEfunc::getListViewLink(
+                               array(
+                                       'id' => $this->pageinfo['uid'],
+                                       'returnUrl' => t3lib_div::getIndpEnv('REQUEST_URI'),
+                               ),
+                               $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList')
                        );
                }
 
@@ -347,12 +349,22 @@ class SC_db_new {
         */
        function pagesOnly()    {
                global $LANG;
-
-               $posMap = t3lib_div::makeInstance('t3lib_positionMap');
-               $this->code.='
-                       <h3>'.htmlspecialchars($LANG->getLL('selectPosition')).':</h3>
-               ';
-               $this->code.= $posMap->positionTree($this->id,$this->pageinfo,$this->perms_clause,$this->R_URI);
+               $numberOfPages = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'pages', '1=1' . t3lib_BEfunc::deleteClause('pages'));
+               if ($numberOfPages > 0) {
+                       $posMap = t3lib_div::makeInstance('t3lib_positionMap');
+                       $this->code.='
+                               <h3>'.htmlspecialchars($LANG->getLL('selectPosition')).':</h3>
+                       ';
+                       $this->code.= $posMap->positionTree($this->id,$this->pageinfo,$this->perms_clause,$this->R_URI);
+               } else {
+                       // No pages yet, no need to prompt for position, redirect to page creation.
+                       $javascript = t3lib_BEfunc::editOnClick('returnUrl=%2Ftypo3%2Fdb_new.php%3Fid%3D0%26pagesOnly%3D1&edit[pages][0]=new&returnNewPageId=1');
+                       $startPos = strpos($javascript, 'href=\'') + 6;
+                       $endPos = strpos($javascript, '\';');
+                       $url = substr($javascript, $startPos, $endPos - $startPos);
+                       @ob_end_clean();
+                       t3lib_utility_Http::redirect($url);
+               }
        }
 
        /**
@@ -434,7 +446,7 @@ class SC_db_new {
                        $startRows[] = '
                                <tr>
                                        <td nowrap="nowrap">' . $rowContent . '</td>
-                                       <td>' . t3lib_BEfunc::cshItem($table, '', $this->doc->backPath, '', $doNotShowFullDescr) . '</td>
+                                       <td>' . t3lib_BEfunc::wrapInHelp($table, '') . '</td>
                                </tr>
                        ';
                }
@@ -538,7 +550,7 @@ class SC_db_new {
                                                        $startRows[] = '
                                                                <tr>
                                                                        <td nowrap="nowrap">' . $rowContent . '</td>
-                                                                       <td>' . t3lib_BEfunc::cshItem($table, '', $this->doc->backPath, '', $doNotShowFullDescr) . '</td>
+                                                                       <td>' . t3lib_BEfunc::wrapInHelp($table, '') . '</td>
                                                                </tr>';
                                                } else {
                                                        $this->tRows[$groupName]['title'] = $thisTitle;
@@ -564,14 +576,14 @@ class SC_db_new {
                        $row = '<tr>
                                                <td nowrap="nowrap">' . $halfLine . '<br />' .
                                                $firstLevel . '' . $iconFile[$key] . '&nbsp;<strong>' . $value['title'] . '</strong>' .
-                                               '</td><td>'.t3lib_BEfunc::cshItem($t,'',$this->doc->backPath,'',$doNotShowFullDescr).'</td>
+                                               '</td><td>&nbsp;<br />' . t3lib_BEfunc::wrapInHelp($key, '') . '</td>
                                                </tr>';
                        $count = count($value['html']) - 1;
                        foreach ($value['html'] as $recordKey => $record) {
                                $row .= '
                                        <tr>
                                                <td nowrap="nowrap">' . ($recordKey < $count ? $secondLevel : $secondLevelLast) . $record . '</td>
-                                               <td>'.t3lib_BEfunc::cshItem($value['table'][$recordKey], '', $this->doc->backPath, '', $doNotShowFullDescr) . '</td>
+                                               <td>' . t3lib_BEfunc::wrapInHelp($value['table'][$recordKey], '') . '</td>
                                        </tr>';
                        }
                        $finalRows[] = $row;