[BUGFIX] Warning in list module
[Packages/TYPO3.CMS.git] / typo3 / db_new.php
index 3bc7d93..e8518ee 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2009 Kasper Skaarhoj (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
  * Includes a wizard mode for visually pointing out the position of new pages
  *
  * $Id$
- * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
+ * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
  * XHTML compliant
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
@@ -73,7 +73,7 @@ $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
 /**
  * Extension for the tree class that generates the tree of pages in the page-wizard mode
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -111,7 +111,7 @@ class localPageTree extends t3lib_pageTree {
 /**
  * Script class for 'db_new'
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -166,7 +166,7 @@ class SC_db_new {
                }
                        // Setting GPvars:
                $this->id = intval(t3lib_div::_GP('id'));       // The page id to operate from
-               $this->returnUrl = t3lib_div::_GP('returnUrl');
+               $this->returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
                $this->pagesOnly = t3lib_div::_GP('pagesOnly');
 
                        // Create instance of template class for output
@@ -327,12 +327,14 @@ class SC_db_new {
                                '</a>';
 
                                // Record list
-                       if ($GLOBALS['BE_USER']->check('modules', 'web_list')) {
-                               $href = $this->backPath . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
-                               $buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', 1) . '">' .
-                                               t3lib_iconWorks::getSpriteIcon('actions-system-list-open') .
-                                       '</a>';
-                       }
+                               // If access to Web>List for user, then link to that module.
+                       $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);
+               }
        }
 
        /**
@@ -381,7 +393,7 @@ class SC_db_new {
                $table = 'pages';
                $v = $GLOBALS['TCA'][$table];
                $pageIcon = t3lib_iconWorks::getSpriteIconForRecord($table,array());
-                                               
+
                $newPageIcon = t3lib_iconWorks::getSpriteIcon('actions-page-new');
                $rowContent = $firstLevel . $newPageIcon . '&nbsp;<strong>' . $GLOBALS['LANG']->getLL('createNewPage') . '</strong>';
 
@@ -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;
@@ -720,8 +732,8 @@ class SC_db_new {
 }
 
 
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_new.php'])       {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_new.php']);
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/db_new.php'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/db_new.php']);
 }