Index: typo3/db_new.php
===================================================================
--- typo3/db_new.php	(revision 2786)
+++ typo3/db_new.php	(working copy)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2007 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -33,6 +33,7 @@
  * $Id$
  * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
  * XHTML compliant
+ * Clean up by 2007-12-03 by Malte Jansen
  *
  * @author	Kasper Skaarhoj <kasperYYYY@typo3.com>
  */
@@ -96,7 +97,7 @@
 	 * @param	array		Item row
 	 * @return	string		Wrapping icon image.
 	 */
-	function wrapIcon($icon,$row)	{
+	public function wrapIcon($icon,$row)	{
 		return $this->addTagAttributes($icon,' title="id='.htmlspecialchars($row['uid']).'"');
 	}
 
@@ -107,7 +108,7 @@
 	 * @param	integer		The ID (page id) of the element
 	 * @return	boolean		Returns true if the IDs matches
 	 */
-	function expandNext($id)	{
+	public function expandNext($id)	{
 		return $id==$GLOBALS['SOBE']->id ? 1 : 0;
 	}
 }
@@ -126,25 +127,32 @@
  * @subpackage core
  */
 class SC_db_new {
-	var $pageinfo;
-	var $pidInfo;
-	var $newPagesInto;
-	var $newContentInto;
-	var $newPagesAfter;
-	var $web_list_modTSconfig;
-	var $allowedNewTables;
-	var $web_list_modTSconfig_pid;
-	var $allowedNewTables_pid;
-	var $code;
-	var $R_URI;
+	protected $pageinfo;
+	protected $pidInfo;
+	protected $newPagesInto;
+	protected $newContentInto;
+	protected $newPagesAfter;
+	
+	protected $web_list_modTSconfig;
+	protected $allowedNewTables;
+	protected $tableTSconfigOverTCA = array(); //TSconfig which overwrites TCA-Settings
+	
+	protected $web_list_modTSconfig_pid;
+	protected $allowedNewTables_pid;
+	protected $tableTSconfigOverTCA_pid = array(); //TSconfig which overwrites TCA-Settings
+
+	protected $code;
+	protected $R_URI;
+	
+	protected $entries = array();	// see generateNewEntries()
 
 		// Internal, static: GPvar
-	var $id;			// see init()
-	var $returnUrl;		// Return url.
-	var $pagesOnly;		// pagesOnly flag.
+	public $id;			// see init()
+	public $returnUrl;		// Return url.
+	public $pagesOnly;		// pagesOnly flag.
 
 		// Internal
-	var $perms_clause;	// see init()
+	protected $perms_clause;	// see init()
 
 	/**
 	 * Document template object
@@ -151,8 +159,8 @@
 	 *
 	 * @var mediumDoc
 	 */
-	var $doc;
-	var $content;		// Accumulated HTML output
+	protected $doc;
+	protected $content;		// Accumulated HTML output
 
 
 	/**
@@ -160,7 +168,7 @@
 	 *
 	 * @return	void
 	 */
-	function init()	{
+	public function init()	{
 		global $BE_USER,$LANG,$BACK_PATH;
 
 			// page-selection permission clause (reading)
@@ -227,7 +235,7 @@
 	 *
 	 * @return	void
 	 */
-	function main()	{
+	public function main()	{
 		global $BE_USER,$LANG;
 
 			// If there was a page - or if the user is admin (admins has access to the root) we proceed:
@@ -235,10 +243,18 @@
 				// Acquiring TSconfig for this module/current page:
 			$this->web_list_modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
 			$this->allowedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['allowedNewTables'],1);
-
+			$this->tableTSconfigOverTCA = $this->web_list_modTSconfig['properties']['table.'];
+			if (!is_array($this->tableTSconfigOverTCA)) {
+				$this->tableTSconfigOverTCA = array();
+			}
+			
 				// Acquiring TSconfig for this module/parent page:
 			$this->web_list_modTSconfig_pid = t3lib_BEfunc::getModTSconfig($this->pageinfo['pid'],'mod.web_list');
 			$this->allowedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['allowedNewTables'],1);
+			$this->tableTSconfigOverTCA_pid = $this->web_list_modTSconfig_pid['properties']['table.'];
+			if (!is_array($this->tableTSconfigOverTCA)) {
+				$this->tableTSconfigOverTCA_pid = array();
+			}
 
 				// More init:
 			if (!$this->showNewRecLink('pages'))	{
@@ -256,9 +272,9 @@
 
 				// GENERATE the HTML-output depending on mode (pagesOnly is the page wizard)
 			if (!$this->pagesOnly)	{	// Regular new element:
-				$this->regularNew();
+				self::regularNew();
 			} elseif ($this->showNewRecLink('pages')) {	// Pages only wizard
-				$this->pagesOnly();
+				self::pagesOnly();
 			}
 
 				// Create go-back link.
@@ -279,7 +295,7 @@
 	 *
 	 * @return	void
 	 */
-	function pagesOnly()	{
+	protected function pagesOnly()	{
 		global $LANG;
 
 		$posMap = t3lib_div::makeInstance('t3lib_positionMap');
@@ -297,144 +313,19 @@
 	 *
 	 * @return	void
 	 */
-	function regularNew()	{
-		global $BE_USER,$LANG,$BACK_PATH,$TCA;
+	protected function regularNew()	{
 
 		$doNotShowFullDescr = FALSE;
 
-			// Slight spacer from header:
-		$this->code.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" /><br />';
-
-			// Initialize array for accumulating table rows:
-		$tRows = array();
-
-			// New pages INSIDE this pages
-		if ($this->newPagesInto
-			&& $this->isTableAllowedForThisPage($this->pageinfo, 'pages')
-			&& $BE_USER->check('tables_modify','pages')
-			&& $BE_USER->workspaceCreateNewRecord($this->pageinfo['_ORIG_uid']?$this->pageinfo['_ORIG_uid']:$this->id, 'pages')
-			)	{
-
-				// Create link to new page inside:
-			$t = 'pages';
-			$v = $TCA[$t];
-			$rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
-					$this->linkWrap(
-						'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/'.($v['ctrl']['iconfile'] ? $v['ctrl']['iconfile'] : $t.'.gif'),'width="18" height="16"').' alt="" />'.
-							$LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.inside',1).')',
-						$t,
-						$this->id).'<br/>';
-
-				// Link to page-wizard:
-			$rowContent.= '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/line.gif','width="18" height="16"').' alt="" /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/joinbottom.gif','width="18" height="16"').' alt="" />'.
-				'<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly'=>1))).'">'.
-				'<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_page.gif','width="13" height="12"').' alt="" /> '.
-				htmlspecialchars($LANG->getLL('clickForWizard')).
-				'</a>';
-				// Half-line:
-			$rowContent.= '<br /><img'.t3lib_iconWorks::skinImg('','gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
-
-				// Compile table row:
-			$tRows[]='
-				<tr>
-					<td nowrap="nowrap">'.$rowContent.'</td>
-					<td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
-				</tr>
-			';
-		}
-
-			// New tables (but not pages) INSIDE this pages
-		if ($this->newContentInto)	{
-			if (is_array($TCA))	{
-				foreach($TCA as $t => $v)	{
-					if ($t!='pages'
-							&& $this->showNewRecLink($t)
-							&& $this->isTableAllowedForThisPage($this->pageinfo, $t)
-							&& $BE_USER->check('tables_modify',$t)
-							&& (($v['ctrl']['rootLevel'] xor $this->id) || $v['ctrl']['rootLevel']==-1)
-							&& $BE_USER->workspaceCreateNewRecord($this->pageinfo['_ORIG_uid']?$this->pageinfo['_ORIG_uid']:$this->id, $t)
-							)	{
-
-							// Create new link for record:
-						$rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
-								$this->linkWrap(
-								t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
-								$LANG->sL($v['ctrl']['title'],1)
-							,$t
-							,$this->id);
-
-							// If the table is 'tt_content' (from "cms" extension), create link to wizard
-						if ($t=='tt_content')	{
-
-								// If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's wizard instead:
-							$overrideExt = $this->web_list_modTSconfig['properties']['newContentWiz.']['overrideWithExtension'];
-							$pathToWizard = (t3lib_extMgm::isLoaded($overrideExt)) ? (t3lib_extMgm::extRelPath($overrideExt).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
-
-							$href = $pathToWizard.'?id='.$this->id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
-							$rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
-										'<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/joinbottom.gif','width="18" height="16"').' alt="" />'.
-										'<a href="'.htmlspecialchars($href).'"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_record.gif','width="16" height="12"').' alt="" /> '.
-										htmlspecialchars($LANG->getLL('clickForWizard')).
-										'</a>';
-
-								// Half-line added:
-							$rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
-						}
-
-
-							// Compile table row:
-						$tRows[] = '
-				<tr>
-					<td nowrap="nowrap">'.$rowContent.'</td>
-					<td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
-				</tr>
-			';
-
-					}
-				}
-			}
-		}
-
-			// New pages AFTER this pages
-		if ($this->newPagesAfter
-			&& $this->isTableAllowedForThisPage($this->pidInfo,'pages')
-			&& $BE_USER->check('tables_modify','pages')
-			&& $BE_USER->workspaceCreateNewRecord($this->pidInfo['uid'], 'pages')
-			)	{
-
-				// Create link to new page after
-			$t = 'pages';
-			$v = $TCA[$t];
-			$rowContent = $this->linkWrap(
-					t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
-						$LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.after',1).')',
-					'pages',
-					-$this->id
-				);
-
-				// Compile table row:
-			$tRows[] = '
-				<tr>
-					<td nowrap="nowrap">'.$rowContent.'</td>
-					<td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
-				</tr>
-			';
-		} else {
-				// Compile table row:
-			$tRows[]='
-				<tr>
-					<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/stopper.gif','width="18" height="16"').' alt="" /></td>
-					<td></td>
-				</tr>
-			';
-		}
-
-			// Make table:
+			// Loading entries
+		self::initEntryArray();
+		
+			// CODE
+			// Generating the List
 		$this->code.='
-			<table border="0" cellpadding="0" cellspacing="0" id="typo3-newRecord">
-			'.implode('',$tRows).'
-			</table>
-		';
+			<div id="typo3-newRecord">
+				'.self::getEntryList($this->entries).'
+			</div>';
 
 			// Create a link to the new-pages wizard.
 		if ($this->showNewRecLink('pages'))	{
@@ -439,19 +330,11 @@
 			// Create a link to the new-pages wizard.
 		if ($this->showNewRecLink('pages'))	{
 			$this->code.='
-
-				<!--
-					Link; create new page:
-				-->
 				<div id="typo3-newPageLink">
-					<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly'=>'1'))).'">'.
-					'<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_page.gif','width="13" height="12"').' alt="" />'.
-					htmlspecialchars($LANG->getLL('createNewPage')).
-					'</a>
-				</div>
-				';
+					'.self::getLinkEntry(0, array('type' => 'wizard', 'label' => 'LLL:EXT:lang/locallang_misc.xml:createNewPage', 'path' => 'self', 'icon' => 'gfx/new_page.gif', 'parameter' => array('pagesOnly' => '1'))).'
+				</div>';
 		}
-
+		
 			// Add CSH:
 		$this->code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_regular', $GLOBALS['BACK_PATH'],'<br/>');
 	}
@@ -461,7 +344,7 @@
 	 *
 	 * @return	void
 	 */
-	function printContent()	{
+	public function printContent()	{
 		$this->content.= $this->doc->endPage();
 		$this->content = $this->doc->insertStylesAndJS($this->content);
 		echo $this->content;
@@ -476,7 +359,7 @@
 	 * @param	boolean		If $addContentTable is set, then a new contentTable record is created together with pages
 	 * @return	string		The link.
 	 */
-	function linkWrap($code,$table,$pid,$addContentTable=0)	{
+	protected function linkWrap($code,$table,$pid,$addContentTable=0)	{
 		$params = '&edit['.$table.']['.$pid.']=new'.
 			($table=='pages'
 				&& $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']
@@ -496,14 +379,10 @@
 	 * @param	string		Table name to check
 	 * @return	boolean		Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row
 	 */
-	function isTableAllowedForThisPage($pid_row, $checkTable)	{
+	protected function isTableAllowedForThisPage($pid_row, $checkTable)	{
 		global $TCA, $PAGES_TYPES;
 		if (!is_array($pid_row))	{
-			if ($GLOBALS['BE_USER']->user['admin'])	{
-				return true;
-			} else {
-				return false;
-			}
+			return ($GLOBALS['BE_USER']->user['admin']);
 		}
 			// be_users and be_groups may not be created anywhere but in the root.
 		if ($checkTable=='be_users' || $checkTable=='be_groups')	{
@@ -526,10 +405,322 @@
 	 * @param	array		Array of new tables that are allowed.
 	 * @return	boolean		Returns true if the $table tablename is found in $allowedNewTables (or if $allowedNewTables is empty)
 	 */
-	function showNewRecLink($table,$allowedNewTables='')	{
+	protected function showNewRecLink($table,$allowedNewTables='')	{
 		$allowedNewTables = is_array($allowedNewTables) ? $allowedNewTables : $this->allowedNewTables;
 		return !count($allowedNewTables) || in_array($table,$allowedNewTables);
 	}
+
+	/**
+	 * Returns true if a new-link for a $table should not be displayed.
+	 * For the 'pageafter' there is some special treatment
+	 *
+	 * @param string $table: Table to check
+	 * @param boolean $wizard: is table added by a wizard
+	 * @param boolean $pageafter: is table added by a wizard
+	 * @return boolean
+	 */
+	protected function hideEntry($table, $wizard = false, $pageafter = false) {
+		global $BE_USER, $TCA;
+
+		// Common checks
+		if (	// readOnly tables should be edited, so there are hidden
+				$TCA[$table]['ctrl']['readOnly'] == 1
+				// Static tables should always be hidden
+			||	$TCA[$table]['ctrl']['is_static'] == 1
+				// If a Table is not allowed for the Page (rootpage,normal page), the table should be hidden 
+			||	!self::isTableAllowedForThisPage($this->pageinfo, $table)
+				// If user is not allowed to modify table, so the entry should be hidden
+			||	!$BE_USER->check('tables_modify',$table)	
+				// workspaceCheck	
+			||	(!$pageafter && !$BE_USER->workspaceCreateNewRecord($this->pageinfo['_ORIG_uid']?$this->pageinfo['_ORIG_uid']:$this->id, $table))
+			||	($pageafter && !$BE_USER->workspaceCreateNewRecord($this->pidInfo['uid'], $table))
+			) return true;
+
+		$tableTSconfigOverTCA = $this->tableTSconfigOverTCA;
+		if ($pageafter) {
+			$tableTSconfigOverTCA = $this->tableTSconfigOverTCA_pid;
+		}
+
+		// TS-Config/TCA-ctrl checks	
+		if (	// hideNewTable
+				(	self::checkTSconfigOverTCActrl($table,'hideNewTable',1,$tableTSconfigOverTCA)
+				 && !$wizard)
+				// hideTable, except hideNewTable is explitly set to false
+			||	(	self::checkTSconfigOverTCActrl($table,'hideTable',1,$tableTSconfigOverTCA)
+			 	 &&	!self::checkTSconfigOverTCActrl($table,'hideNewTable',0,$this->$tableTSconfigOverTCA))
+			 	// TS-config mod.web_list.hideTables = ...
+			||	!self::showNewRecLink($table)
+			) return true;
+		
+		// special treatment for PAGES-table
+		// permission to created new subpage
+		if ($table == 'pages') { 
+			return (	// create page as subpage
+						(!$pageafter && !$this->newPagesInto)
+						// create page after this page
+					||	($pageafter && !$this->newPagesAfter)
+					);
+		}
+
+		// treatment of content-tables
+		if (	// permission to created new content on this page
+				!$this->newContentInto
+				// is table allowed on root page or normal page
+			||	!(($TCA[$table]['ctrl']['rootLevel'] xor $this->id) || $TCA[$table]['ctrl']['rootLevel']==-1)
+			) return true;	
+		
+		return false;
+	}
+	
+	/**
+	 * Checks for a $table, if a TCA-ctrl is true and if it is not overwritten.
+	 * Overwise the the TSconfig value is used.
+	 *
+	 * @param string $table Tablename
+	 * @param string $key of the TSConfig/TCA-ctrl
+	 * @param mixed $value Any value, which should be compared
+	 * @param array $tableTSconfig Property of mod.web_list.table.
+	 * @return Boolean
+	 */
+	protected function checkTSconfigOverTCActrl($table, $key, $value, $tableTSconfig) {
+		global $TCA;
+		return (	($TCA[$table]['ctrl'][$key] == $value && !isset($tableTSconfig[$table.'.'][$key]))
+				||	($tableTSconfig[$table.'.'][$key] == $value)
+				);
+	}
+
+	/**
+	 * Generates a array, which contains all entries for the db_new-list.
+	 * The function also checks, wheather a table is allowed or any otherrestrictions are set.
+	 * 
+	 * entry[0]: Current Page (level 0)
+	 * entry[0][sub][$i]: One entry foreach table (level 1)
+	 * entry[0][sub][$i][sub][]: One entry foreach wizard of a table (level 2)
+	 * entry[]: New After Page (level 0)
+	 * entry[]: Any other wizard, which should be displayed at the end. (level 0)  
+	 * 
+	 * @return array
+	 */
+	protected function initEntryArray() {
+		global $TCA;
+
+		// Loading entries
+		$this->entries[0]['type'] = 'none';	// display none on level 0
+		$i = 0;
+		if (is_array($TCA))	{
+			reset($TCA);
+			while (list($table) = each($TCA)) {
+				// Check all the access and visibility
+				if (self::hideEntry($table)) {
+					continue;
+				}
+				$tableEntryExists = false;
+				if ($TCA[$table]['ctrl']['disableNewTable'] != 1) {
+					// Common New-Entry (for one table)
+					$this->entries[0]['sub'][$i] = array(
+								'type' => 'table',
+								'table' => $table,
+								'path' => $this->id,
+								);
+					$tableEntryExists = true;
+				}
+				
+				t3lib_div::loadTCA($table);
+				
+				// Checking for wizards
+				if (	is_array($TCA[$table]['newWizards'])
+					&&	!self::checkTSconfigOverTCActrl($table,'hideNewWizards',1,$this->tableTSconfigOverTCA)
+					) {
+					foreach ($TCA[$table]['newWizards'] AS $wizard) {
+						if (!is_array($wizard)) {
+							continue;
+						}
+						
+						//Wizard-Entry
+						if (empty($wizard['type'])) {
+							$wizard['type'] = 'wizard';
+						}
+						if (empty($wizard['table']) || isset($TCA[$wizard['table']])) {
+							$wizard['table'] = $table;
+						}
+
+						// Setting default for wizard level
+						if (!isset($wizard['level'])) {
+							$wizard['level'] = 2;
+						}
+
+						//special handling for pageafter
+						$pageafter = false;
+						if ($wizard['type'] == 'pageafter') {
+								$wizard['table'] = 'pages';
+								$wizard['type'] = 'table';
+								$pageafter = true;
+						}
+
+						//special handling for table
+						if ($wizard['type'] == 'table') {
+							if (!is_array($TCA[$wizard['table']])) {
+								continue;
+							}elseif (self::hideEntry($wizard['table'],true,$pageafter)) {
+								continue;
+							}
+							$wizard['path'] = ($pageafter ? -$this->id : $this->id);
+						}
+						if ($wizard['type'] == 'disabled') {
+							$wizard['level'] = 1;
+						}						
+
+						// Adding the wizard to the correct position in the entry-array
+						switch ($wizard['level']) {
+							case 0:
+								if ($tableEntryExists) {
+									$this->entries[] = $wizard;
+								}
+								break;
+							case 1:
+								// Wizard as Common New-Entry (level 1)
+								$i++;
+								$this->entries[0]['sub'][$i] = $wizard;
+								$tableEntryExists = true;
+								break;
+							case 2:
+								if ($tableEntryExists) {
+									// Wizard (level 2)
+									$this->entries[0]['sub'][$i]['sub'][] = $wizard;
+								}
+						}
+					}
+				}
+				$i++;
+			}
+		}
+	}
+
+	/**
+	 * Generate the HTML for each entries
+	 *
+	 * @param array $entries
+	 * @param int $level
+	 * @param array $lastEntry
+	 * @return array
+	 */
+	protected function getEntryList(Array $entries, $level = 0,$parentLastEntry = false) {
+		$list = '';
+		$countEntries = count($entries);
+		foreach ($entries AS $index => $entry) {
+			$lastEntry = ($index+1 == $countEntries);
+			$item = '';
+			// CSH
+			if ($entry['type'] == 'table') { 
+				$item.= '<span class="help">'.t3lib_BEfunc::cshItem($entry['table'],'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</span>';
+			}
+						
+			$item.= self::getLinkEntry($level, $entry, $lastEntry);
+			
+			if (count($entry['sub'])) {
+				$item.= self::getEntryList($entry['sub'],$level+1,$lastEntry);
+			}
+			$list.= '<li'.($level == 0 ? '' : '').'>'.$item.'</li>';
+		}
+		$style = ' style="background: transparent url('.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/line.gif','',1).') repeat-y scroll left top;"';
+		return (!empty($list) ? '<ul'.($level > 1 ? ' class="sub"' : '').(!$parentLastEntry && $level > 0 ? $style : '' ).'>'.$list.'</ul>' : '');
+	}
+	
+	
+
+	/**
+	 * Returns a HTML-String with the Link (with icon, title) for one entry. 
+	 * In front of a link the path-image (join or joinbottom)  is added
+	 * 
+	 * @param integer $level: Llevel of the entry.
+	 * @param array $entry: Array of one entry. 
+	 * @param boolean $lastEntry: Is it the last Entry?
+	 * @return string
+	 */
+	protected function getLinkEntry($level, array $entry, $lastEntry = false) {
+		global $BACK_PATH,$LANG,$TCA;
+		
+		$string = '';
+		// PathImage
+		if ($level > 0) {
+			$string.= ($lastEntry ? self::getPathImage('joinbottom') : self::getPathImage('join'));
+		}
+		//Icon
+		if (!empty($entry['icon'])) {
+			$entry['icon'] = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,$entry['icon'],'width="18" height="16"').' alt="" /> ';
+		}elseif(!empty($entry['table'])) {
+			$entry['icon'] = t3lib_iconWorks::getIconImage($entry['table'],array(),$BACK_PATH,'');
+		}else {
+			$entry['icon'] = '';
+		}
+		//Label
+		if (!empty($entry['label'])) {
+			$entry['label'] = $LANG->sL($entry['label'],1);
+		}else {
+			$entry['label'] = $LANG->sL($TCA[$entry['table']]['ctrl']['title'],1);
+		}
+		
+		// Link (with icon, title )
+		switch ($entry['type']) {
+			// Common new Entry
+			case 'disabled':
+				$string.= $entry['icon'].$entry['label'];
+				break;
+			// Common new Entry
+			case 'table':
+				$string.= $this->linkWrap(
+								 $entry['icon'].$entry['label']
+								,$entry['table']
+								,$entry['path']
+								);
+				break;
+			// Common Wizard
+			case 'wizard':
+				// Path
+				if ($entry['path'] = 'self') {
+					$entry['path'] = t3lib_div::linkThisScript();
+				}
+				if ($entry['table'] == 'tt_content') {
+					// If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's wizard instead:
+					$overrideExt = $this->web_list_modTSconfig['properties']['newContentWiz.']['overrideWithExtension'];
+					$entry['path'] = (t3lib_extMgm::isLoaded($overrideExt)) ? (t3lib_extMgm::extRelPath($overrideExt).'mod1/db_new_content_el.php') : $entry['path'];					
+				}
+				// Parameter
+				if (!is_array($entry['parameter'])) {
+					$entry['parameter'] = array();
+				}
+				$entry['parameter']['id'] = $this->id;
+				$entry['parameter']['returnUrl'] = rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
+				// Final Path
+				
+				$entry['path'] = t3lib_div::linkThisUrl($entry['path'], $entry['parameter']);
+				
+				// String
+				$string.= '<a href="'.htmlspecialchars($entry['path']).'">'.
+							$entry['icon'].$LANG->sL($entry['label']).
+						 '</a>';
+				break;
+			case 'none':
+				// needed for displaying in ie 
+				$string.= self::getPathImage('line');
+				break;
+			default: 
+				return '';			
+		}
+		return $string;
+	}
+	
+	/**
+	 * Returns the HTML-string of the path-image.
+	 * 
+	 * @param
+	 * @return string
+	 */
+	protected function getPathImage($type) {
+		$height = ($type=='halfline' ? '8' : '16');
+		return '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/'.$type.'.gif','width="18" height="'.$height.'"').' alt="" />';
+	}
+
 }
 
 // Include extension?
Index: typo3/stylesheet.css
===================================================================
--- typo3/stylesheet.css	(revision 2786)
+++ typo3/stylesheet.css	(working copy)
@@ -497,7 +497,11 @@
 BODY#typo3-db-new-php A { text-decoration: none; }
 BODY#typo3-db-new-php IMG.c-helpImg { margin-left: 20px; text-align: right; }
 BODY#typo3-db-new-php DIV#typo3-newPageLink { margin-top: 20px; }
-BODY#typo3-db-new-php  TABLE#typo3-newRecord TR TD { padding-right: 20px; }
+BODY#typo3-db-new-php DIV#typo3-newRecord UL { background: transparent; text-decoration: none; margin: 0pt; padding: 0 0 6px 0; }
+BODY#typo3-db-new-php DIV#typo3-newRecord UL.sub { padding: 0 0 6px 18px; }
+BODY#typo3-db-new-php DIV#typo3-newRecord UL LI { list-style-image: none; list-style-position: outside; list-style-type: none; margin: 0pt; padding: 0pt; white-space: nowrap;}
+BODY#typo3-db-new-php DIV#typo3-newRecord UL LI.after { padding: 20px 0 0px 20px; }
+BODY#typo3-db-new-php DIV#typo3-newRecord SPAN.help { float: right; }
 
 /* Extension Manager */
 BODY#typo3-mod-tools-em-index-php .em-listbg1 { background-color: #d9d5c9; }
Index: typo3/sysext/cms/ext_tables.php
===================================================================
--- typo3/sysext/cms/ext_tables.php	(revision 2786)
+++ typo3/sysext/cms/ext_tables.php	(working copy)
@@ -103,7 +103,27 @@
 	// Adding default value columns:
 	$TCA['pages']['ctrl']['useColumnsForDefaultValues'].=',fe_group,hidden';
 	$TCA['pages']['ctrl']['transForeignTable'] = 'pages_language_overlay';
-
+	$TCA['pages']['newWizards'] = array(
+		0 => array(
+				'type' => 'wizard',
+				'label' => 'LLL:EXT:lang/locallang_misc.xml:clickForWizard',
+				'icon' => 'gfx/new_page.gif',
+				'path' => 'self',
+				'parameter' => array(
+					'pagesOnly' => '1'
+				),
+		),
+		1 => array(
+				'type' => 'pageafter',
+				'label' => 'LLL:EXT:lang/locallang_misc.xml:createNewPageAfter',
+				'icon' => 'gfx/new_page.gif',
+				'parameter' => array(
+					'pagesOnly' => '1'
+				),
+				'level' => 0,
+		),
+	);
+	
 	// Adding new columns:
 	$TCA['pages']['columns'] = array_merge($TCA['pages']['columns'],array(
 		'hidden' => array (
@@ -642,8 +662,16 @@
 		'mainpalette' => '1,15',
 		'thumbnail' => 'image',
 		'requestUpdate' => 'list_type,rte_enabled',
-		'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tbl_tt_content.php'
-	)
+		'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tbl_tt_content.php',
+	),
+	'newWizards' => array(
+		0 => array(
+				'type' => 'wizard',
+				'label' => 'LLL:EXT:lang/locallang_misc.xml:clickForWizard',
+				'icon' => 'gfx/new_record.gif',
+				'path' => t3lib_extMgm::extRelPath($_EXTKEY).'layout/db_new_content_el.php',
+		),
+	),
 );
 
 // ******************************************************************
Index: typo3/sysext/cms/tbl_tt_content.php
===================================================================
--- typo3/sysext/cms/tbl_tt_content.php	(revision 2786)
+++ typo3/sysext/cms/tbl_tt_content.php	(working copy)
@@ -37,6 +37,7 @@
 
 $TCA['tt_content'] = Array (
 	'ctrl' => $TCA['tt_content']['ctrl'],
+	'newWizards' => $TCA['tt_content']['newWizards'],
 	'interface' => Array (
 		'always_description' => 0,
 		'showRecordFieldList' => 'CType,header,header_link,bodytext,image,imagewidth,imageorient,media,records,colPos,starttime,endtime,fe_group'
Index: typo3/sysext/lang/locallang_misc.xml
===================================================================
--- typo3/sysext/lang/locallang_misc.xml	(revision 2786)
+++ typo3/sysext/lang/locallang_misc.xml	(working copy)
@@ -33,6 +33,7 @@
 			<label index="selectPosition">Select a position for the new page</label>
 			<label index="goBack">Go back</label>
 			<label index="createNewPage">Create a new page</label>
+			<label index="createNewPageAfter">Page (after)</label>
 			<label index="clickForWizard">Click here for wizard!</label>
 			<label index="insertNewPageHere">Insert the new page here</label>
 			<label index="insertNewRecordHere">Insert new record here</label>
