[BUGFIX] TYPO3 prompts to select position when there are no pages
[Packages/TYPO3.CMS.git] / typo3 / db_new.php
index 399b276..6289aff 100644 (file)
@@ -326,12 +326,23 @@ class SC_db_new {
         * @return      void
         */
        function pagesOnly() {
-               /** @var $posMap t3lib_positionMap */
-               $posMap = t3lib_div::makeInstance('t3lib_positionMap');
-               $this->code.='
-                       <h3>' . htmlspecialchars($GLOBALS['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) {
+                       $this->code.='
+                               <h3>' . htmlspecialchars($GLOBALS['LANG']->getLL('selectPosition')) . ':</h3>
+                       ';
+                       $positionMap = t3lib_div::makeInstance('t3lib_positionMap');
+                       /** @var t3lib_positionMap $positionMap */
+                       $this->code .= $positionMap->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);
+               }
        }
 
        /**