Index: typo3/alt_doc.php
===================================================================
--- typo3/alt_doc.php	(revision 2980)
+++ typo3/alt_doc.php	(working copy)
@@ -139,6 +139,7 @@
 	 * @var mediumDoc
 	 */
 	var $doc;
+	var $template;			// a static HTML template, usually in templates/alt_doc.html
 	var $content;			// Content accumulation
 
 	var $retUrl;			// Return URL script, processed. This contains the script (if any) that we should RETURN TO from the alt_doc.php script IF we press the close button. Thus this variable is normally passed along from the calling script so we can properly return if needed.
@@ -251,9 +252,8 @@
 	 *
 	 * @return	boolean		True, then save the document (data submitted)
 	 */
-	function doProcessData()	{
-		$out = $this->doSave || isset($_POST['_savedok_x']) || isset($_POST['_saveandclosedok_x']) || isset($_POST['_savedokview_x']) || isset($_POST['_savedoknew_x']);
-		return $out;
+	function doProcessData() {
+		return ($this->doSave || isset($_POST['_savedok_x']) || isset($_POST['_saveandclosedok_x']) || isset($_POST['_savedokview_x']) || isset($_POST['_savedoknew_x']));
 	}
 
 
@@ -443,6 +443,7 @@
 
 			// Create an instance of the document template object
 		$this->doc = t3lib_div::makeInstance('template');
+		$this->template = $this->doc->getHtmlTemplate('templates/alt_doc.html');
 		$this->doc->divClass = 'typo3-fullDoc';
 		$this->doc->backPath = $BACK_PATH;
 		$this->doc->docType = 'xhtml_trans';
@@ -515,8 +516,7 @@
 		global $BE_USER,$LANG;
 
 			// Starting content accumulation:
-		$this->content='';
-		$this->content.=$this->doc->startPage('TYPO3 Edit Document');
+		$this->content = $this->doc->startPage('TYPO3 Edit Document');
 
 			// Begin edit:
 		if (is_array($this->editconf))	{
@@ -546,6 +546,8 @@
 				// Creating the editing form, wrap it with buttons, document selector etc.
 			$editForm = $this->makeEditForm();
 
+
+
 			if ($editForm)	{
 				$this->firstEl = reset($this->elementsData);
 
@@ -556,7 +558,6 @@
 					$this->tceforms->printNeededJSFunctions_top().
 					$this->compileHeader().'
 	<div id="typo3-docbody">'.
-					$this->extraFormHeaders.
 					$this->compileForm($editForm).
 					$this->tceforms->printNeededJSFunctions().
 					$this->functionMenus().
@@ -817,7 +818,7 @@
 	 */
 	function getButtons()	{
 		global $TCA,$LANG;
-		$buttons = array();
+		$buttons = array('save' => '', 'save_view' => '', 'save_new' => '', 'save_close' => '', 'close' => '', 'delete' => '', 'undo' => '', 'history' => '', 'columns_only' => '');
 
 			// Render SAVE type buttons:
 			// The action of each button is decided by its name attribute. (See doProcessData())
@@ -882,6 +883,7 @@
 			}
 		}
 		$buttons['shortcut'] = $this->shortCutLink();
+		$buttons['open_in_new_window'] = $this->openInNewWindowLink();
 		return $buttons;
 	}
 
@@ -893,7 +895,7 @@
 	 * @return	string		HTML <select> element  (if applicable)
 	 */
 	function makeDocSel()	{
-		global $BE_USER,$LANG;
+		global $BE_USER, $LANG;
 
 		$docSel = '';
 			// Render the selector ONLY if it has not been disabled:
@@ -949,7 +951,8 @@
 
 
 	/**
-	 * Put together the various elements for the header
+	 * Put together the various elements for the header using a static HTML
+	 * template
 	 *
 	 * @return	string		Composite HTML
 	 */
@@ -957,37 +960,63 @@
 		global $LANG;
 
 		$btns = $this->getButtons();
-		$docSel = $this->makeDocSel();
-		$cMenu = $this->makeCmenu();
+		$content = t3lib_parsehtml::getSubpart($this->template, '###DOCHEADER###');
 
-		$content = '
-	<!-- Page header with buttons for saving & closing and path details -->
-	<div id="typo3-docheader">
-		<div id="typo3-docheader-row1">
-			<div class="buttonsleft">'.$btns['save'].$btns['save_view'].$btns['save_close'].$btns['save_new'].'</div>
-			<div class="buttonsright">'.$docSel.$cMenu.$btns['delete'].$btns['shortcut'].$btns['history'].$buttons['columns_only'].$btns['undo'].$btns['close'].'</div>
-		</div>
-		';
+		$markerArray = array();
+		$markerArray['DOCUMENT_SELECTOR'] = $this->makeDocSel();
+		$markerArray['CACHE_MENU'] = $this->makeCmenu();
+		$markerArray['PAGEPATH'] = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.htmlspecialchars($this->generalPathOfForm);
 
-		if (is_array($this->tceforms->extraFormHeaders))	{
-			$this->extraFormHeaders = '<div id="typo3-docheader-rowextra">'.implode(chr(10), $this->tceforms->extraFormHeaders).'</div>';
+
+			// -- compiling buttons --
+			// get button template, then loop through the buttons and replace them in the template
+		$btnTmpl = t3lib_parsehtml::getSubpart($this->template, '###BUTTON_GROUPS###');
+		$btnTmpl = t3lib_parsehtml::substituteMarkerArray($btnTmpl, $btns, '###|###', true);
+
+			// getting the wrap for each group
+		$btnWrap = t3lib_parsehtml::getSubpart($this->template, '###BUTTON_GROUP_WRAP###');
+
+			// looping through the groups (max 6) and remove the empty groups
+		$grpId = 1;
+		for ($grpNum = 1; $grpNum < 6; $grpNum++) {
+			$btnMarker = '###BUTTON_GROUP'.$grpNum.'###';
+			$btnGroup = t3lib_parsehtml::getSubpart($btnTmpl, $btnMarker);
+			if (trim($btnGroup)) {
+				if ($btnWrap) {
+					$btnGroup = t3lib_parsehtml::substituteMarker($btnWrap, '###BUTTONS###', $btnGroup);
+				}
+				$btnTmpl = t3lib_parsehtml::substituteSubpart($btnTmpl, $btnMarker, trim($btnGroup));
+			}
 		}
 
+			// replace the marker with the template and remove all line breaks (for IE compat)
+		$markerArray['BUTTONLIST'] = str_replace("\n", '', $btnTmpl);
+			// -- end compiling buttons
 
-			// language switch/selector for editing
-			// show only when a single record is edited - multiple records are too confusing
+
+			// language switch/selector for editing, show only when a single record is edited
+			// - multiple records are too confusing
 		if (count($this->elementsData) == 1) {
-			$langSelector = '<div class="langselector">'.$this->languageSwitch($this->firstEl['table'], $this->firstEl['uid'], $this->firstEl['pid']).'</div>';
+			$langSelector = $this->languageSwitch($this->firstEl['table'], $this->firstEl['uid'], $this->firstEl['pid']);
 		}
+		if ($langSelector) {
+			$langTmpl = t3lib_parsehtml::getSubpart($this->template, '###DOCHEADER_LANGSELECTOR###');
+			$langTmpl = t3lib_parsehtml::substituteMarker($langTmpl, '###LANGSELECTOR###', $langSelector);
+			$markerArray['LANGSELECTOR'] = $langTmpl;
+		} else {
+			$markerArray['LANGSELECTOR'] = '';
+		}
 
-		
-		$content.='
-		<div id="typo3-docheader-row2">
-			<div class="pagepath">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.htmlspecialchars($this->generalPathOfForm).'</div>
-			<div class="infooptions">'.$langSelector.'</div>
-		</div>
-	</div>';
-		return $content;
+		if (is_array($this->tceforms->extraFormHeaders)) {
+			$extraTmpl = t3lib_parsehtml::getSubpart($this->template, '###DOCHEADER_EXTRAHEADER###');
+			$extraTmpl = t3lib_parsehtml::substituteMarker($extraTmpl, '###EXTRAHEADER###', implode(chr(10), $this->tceforms->extraFormHeaders));
+			$markerArray['EXTRAHEADER'] = $extraTmpl;
+		} else {
+			$markerArray['EXTRAHEADER'] = '';
+		}
+
+			// replacing all markers with the finished markers and return the HTML content
+		return t3lib_parsehtml::substituteMarkerArray($content, $markerArray, '###|###');
 	}
 
 
@@ -1059,11 +1088,11 @@
 	 * @return	string
 	 */
 	function openInNewWindowLink()	{
-		global $BE_USER,$LANG;
+		global $BE_USER, $LANG;
 		if ($this->returnUrl == 'close.html') {
 			return '';
 		}
-		$aOnClick = 'vHWin=window.open(\''.t3lib_div::linkThisScript(array('returnUrl'=>'close.html')).'\',\''.md5($this->R_URI).'\',\''.($BE_USER->uc['edit_wideDocument']?'width=670,height=500':'width=600,height=400').',status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;';
+		$aOnClick = 'vHWin=window.open(\''.t3lib_div::linkThisScript(array('returnUrl'=>'close.html')).'\',\''.md5($this->R_URI).'\',\'width=670,height=500,status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;';
 		return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
 				'<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/open_in_new_window.gif','width="19" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.openInNewWindow',1).'" alt="" /></a>';
 	}
Index: typo3/class.db_list_extra.inc
===================================================================
--- typo3/class.db_list_extra.inc	(revision 2980)
+++ typo3/class.db_list_extra.inc	(working copy)
@@ -117,184 +117,190 @@
 	var $CBnames=array();					// Tracking names of elements (for clipboard use)
 	var $duplicateStack=array();			// Used to track which elements has duplicates and how many
 
-
 	/**
-	 * Writes the top of the full listing
+	 * Create the panel of buttons for submitting the form or otherwise perform operations.
 	 *
-	 * @param	array		Current page record
-	 * @return	void		(Adds content to internal variable, $this->HTMLcode)
+	 * @return	array	all available buttons as an assoc. array
 	 */
-	function writeTop($row)	{
-		global $LANG;
+	function getButtons()	{
+		global $LANG;	
+		
+		$buttons = array(
+			'csh' => '', 
+			'view' => '', 
+			'edit' => '', 
+			'hide_unhide' => '', 
+			'move' => '', 
+			'new_record' => '',
+			'paste' => '',
+			'level_up' => '', 
+			'cache' => '', 
+			'reload' => '', 
+			'shortcut' => '',
+			'back' => '',
+			'csv' => '',
+			'export' => ''
+		);
 
-			// Makes the code for the pageicon in the top
-		$this->pageRow = $row;
-		$this->counter++;
-		$alttext = t3lib_BEfunc::getRecordIconAltText($row,'pages');
-		$iconImg = t3lib_iconWorks::getIconImage('pages',$row,$this->backPath,'class="absmiddle" title="'.htmlspecialchars($alttext).'"');
-		$titleCol = 'test';	// pseudo title column name
-		$this->fieldArray = Array($titleCol,'up');		// Setting the fields to display in the list (this is of course "pseudo fields" since this is the top!)
-
-
-			// Filling in the pseudo data array:
-		$theData = Array();
-		$theData[$titleCol] = $this->widthGif;
-
-			// Get users permissions for this row:
-		$localCalcPerms = $GLOBALS['BE_USER']->calcPerms($row);
-
-		$theData['up']=array();
-
-			// Initialize control panel for currect page ($this->id):
-			// Some of the controls are added only if $this->id is set - since they make sense only on a real page, not root level.
-		$theCtrlPanel =array();
-
-			// "View page" icon is added:
-		$theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id,$this->backPath,t3lib_BEfunc::BEgetRootLine($this->id))).'">'.
-						'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom.gif','width="12" height="12"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'" alt="" />'.
-						'</a>';
-
-			// If edit permissions are set (see class.t3lib_userauthgroup.php)
-		if ($localCalcPerms&2)	{
-
-				// Adding "Edit page" icon:
-			if ($this->id)	{
-				$params='&edit[pages]['.$row['uid'].']=edit';
-				$theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
-								'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('editPage',1).'" alt="" />'.
+			// Get users permissions for this page record:
+		$localCalcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageRow);
+	
+			// CSH
+		if (!strlen($this->id))	{
+			$buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module_noId', $GLOBALS['BACK_PATH']);
+		} elseif(!$this->id) {
+			$buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module_root', $GLOBALS['BACK_PATH']);
+		} else {
+			$buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module', $GLOBALS['BACK_PATH']);
+		}
+		
+		if (isset($this->id)) {
+				// View
+			$buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id, $this->backPath, t3lib_BEfunc::BEgetRootLine($this->id))) . '">' .
+							'<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/zoom.gif', 'width="12" height="12"') . ' title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '" alt="" />' .
+							'</a>';
+			
+				// New record
+			if (!$GLOBALS['SOBE']->modTSconfig['properties']['noCreateRecordsLink']) {
+				$buttons['new_record'] = '<a href="#" onclick="' . htmlspecialchars('return jumpExt(\'' . $this->backPath . 'db_new.php?id=' . $this->id . '\');') . '">' .
+								'<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/new_el.gif', 'width="11" height="12"') . ' title="' . $LANG->getLL('newRecordGeneral', 1) . '" alt="" />' .
 								'</a>';
 			}
-
-				// Adding "New record" icon:
-			if (!$GLOBALS['SOBE']->modTSconfig['properties']['noCreateRecordsLink']) 	{
-				$theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'db_new.php?id='.$this->id.'\');').'">'.
-								'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_el.gif','width="11" height="12"').' title="'.$LANG->getLL('newRecordGeneral',1).'" alt="" />'.
+						
+				// If edit permissions are set (see class.t3lib_userauthgroup.php)
+			if ($localCalcPerms&2 && !empty($this->id))	{		
+			
+					// Edit
+				$params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
+				$buttons['edit'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath, -1)) . '">' .
+								'<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/edit2.gif', 'width="11" height="12"') . ' title="' . $LANG->getLL('editPage', 1) . '" alt="" />' .
 								'</a>';
-			}
-
-				// Adding "Hide/Unhide" icon:
-			if ($this->id)	{
-				if ($row['hidden'])	{
-					$params='&data[pages]['.$row['uid'].'][hidden]=0';
-					$theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$GLOBALS['SOBE']->doc->issueCommand($params,-1).'\');').'">'.
-									'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$LANG->getLL('unHidePage',1).'" alt="" />'.
+					// Unhide		
+				if ($this->pageRow['hidden'])	{
+					$params = '&data[pages][' . $this->pageRow['uid'] . '][hidden]=0';
+					$buttons['hide_unhide'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '">' .
+									'<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/button_unhide.gif', 'width="11" height="10"') . ' title="' . $LANG->getLL('unHidePage', 1) . '" alt="" />' .
 									'</a>';
+					// Hide
 				} else {
-					$params='&data[pages]['.$row['uid'].'][hidden]=1';
-					$theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$GLOBALS['SOBE']->doc->issueCommand($params,-1).'\');').'">'.
-									'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$LANG->getLL('hidePage',1).'" alt="" />'.
+					$params = '&data[pages][' . $this->pageRow['uid'] . '][hidden]=1';
+					$buttons['hide_unhide'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '">'.
+									'<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/button_hide.gif', 'width="11" height="10"') . ' title="' . $LANG->getLL('hidePage', 1) . '" alt="" />' .
 									'</a>';
 				}
+				
+					// Move
+				$buttons['move'] = '<a href="#" onclick="' . htmlspecialchars('return jumpExt(\'' . $this->backPath . 'move_el.php?table=pages&uid=' . $this->pageRow['uid'] . '\');') . '">' .
+								'<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/move_' . ($this->table == 'tt_content' ? 'record' : 'page') . '.gif', 'width="11" height="12"') . ' title="' . $LANG->getLL('move_page', 1) . '" alt="" />' .
+								'</a>';
+								
+					// Up one level
+				$buttons['level_up'] = '<a href="' . htmlspecialchars($this->listURL($this->pageRow['pid'])) . '" onclick="setHighlight(' . $this->pageRow['pid'] . ')">' .
+							'<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/i/pages_up.gif', 'width="18" height="16"') . ' title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel', 1) . '" alt="" />' .
+							'</a>';
+
 			}
-
-				// Adding "move page" button:
-			if ($this->id)	{
-				$theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'move_el.php?table=pages&uid='.$row['uid'].'\');').'">'.
-								'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/move_'.($this->table=='tt_content'?'record':'page').'.gif','width="11" height="12"').' title="'.$LANG->getLL('move_page',1).'" alt="" />'.
+				
+			
+				// Paste
+			if (($localCalcPerms&8) || ($localCalcPerms&16)) {
+				$elFromTable = $this->clipObj->elFromTable('');
+				if (count($elFromTable)) {
+					$buttons['paste'] = '<a href="' . htmlspecialchars($this->clipObj->pasteUrl('', $this->id)) . '" onclick="' . htmlspecialchars('return ' . $this->clipObj->confirmMsg('pages', $this->pageRow, 'into', $elFromTable)) . '">' .
+									'<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/clip_pasteafter.gif', 'width="12" height="12"') . ' title="' . $LANG->getLL('clip_paste', 1) . '" alt="" />' .
+									'</a>';
+				}
+			}
+	
+				// Cache
+			$buttons['cache'] = '<a href="' . htmlspecialchars($this->listURL() . '&clear_cache=1') . '">' .
+							'<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/clear_cache.gif', 'width="14" height="14"') . ' title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.clear_cache', 1) . '" alt="" />' .
+							'</a>';
+	
+			if ($this->table) {
+				
+					// CSV
+				$buttons['csv'] = '<a href="' . htmlspecialchars($this->listURL() . '&csv=1') . '">' .
+								'<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/csv.gif', 'width="27" height="14"') . ' title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.csv', 1) . '" alt="" />' .
 								'</a>';
+								
+					// Export
+				if (t3lib_extMgm::isLoaded('impexp')) {
+					$buttons['export'] = '<a href="' . htmlspecialchars($this->backPath. 'mod.php?M=xMOD_tximpexp&tx_impexp[action]=export&tx_impexp[list][]=' . rawurlencode($this->table . ':' . $this->id)) . '">' .
+									'<img' . t3lib_iconWorks::skinImg($this->backPath, t3lib_extMgm::extRelPath('impexp') . 'export.gif', ' width="18" height="16"') . ' title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.export', 1) . '" alt="" />' .
+									'</a>';
+				}
+				
 			}
-		}
-
-			// "Paste into page" link:
-		if (($localCalcPerms&8) || ($localCalcPerms&16))	{
-			$elFromTable = $this->clipObj->elFromTable('');
-			if (count($elFromTable))	{
-				$theCtrlPanel[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('',$this->id)).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg('pages',$this->pageRow,'into',$elFromTable)).'">'.
-								'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_paste',1).'" alt="" />'.
+	
+				// Reload
+			$buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '">' .
+							'<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/refresh_n.gif', 'width="14" height="14"') . ' title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.reload', 1) . '" alt="" />' .
+							'</a>';
+							
+				// Shortcut
+			if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
+				$buttons['shortcut'] = $GLOBALS['TBE_TEMPLATE']->makeShortcutIcon('id, imagemode, pointer, table, search_field, search_levels, showLimit, sortField, sortRev', implode(',', array_keys($this->MOD_MENU)), 'web_list');
+			}
+			
+				// Back
+			if ($this->returnUrl) {
+				$buttons['back'] = '<a href="' . htmlspecialchars(t3lib_div::linkThisUrl($this->returnUrl, array('id' => $this->id))) . '" class="typo3-goBack">' .
+								'<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/goback.gif', 'width="14" height="14"') . ' title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.goBack', 1) . '" alt="" />' .
 								'</a>';
 			}
 		}
 
-			// Finally, compile all elements of the control panel into table cells:
-		if (count($theCtrlPanel))	{
-			$theData['up'][]='
+		return $buttons;
+	}
+	
+	/**
+	 * Generate the page path for docheader
+	 *
+	 * @return	string	Page path
+	 */
+	function getPagePath() {
+		global $LANG;
+		
+		if ($this->id)	{	// If there IS a real page...:
 
-				<!--
-					Control panel for page
-				-->
-				<table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-ctrltop">
-					<tr>
-						<td>'.implode('</td>
-						<td>',$theCtrlPanel).'</td>
-					</tr>
-				</table>';
+				// Setting the path of the page
+			$pagePath = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path', 1) . ': <strong>' . htmlspecialchars(t3lib_div::fixed_lgd_cs($this->pageRow['_thePath'],-$this->fixedL)) . '</strong>';
+			
 		}
-
-
-			// Add "clear-cache" link:
-		$theData['up'][]='<a href="'.htmlspecialchars($this->listURL().'&clear_cache=1').'">'.
-						'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clear_cache.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.clear_cache',1).'" alt="" />'.
-						'</a>';
-
-			// Add "CSV" link, if a specific table is shown:
-		if ($this->table)	{
-			$theData['up'][]='<a href="'.htmlspecialchars($this->listURL().'&csv=1').'">'.
-							'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/csv.gif','width="27" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.csv',1).'" alt="" />'.
-							'</a>';
-		}
-
-			// Add "Export" link, if a specific table is shown:
-		if ($this->table && t3lib_extMgm::isLoaded('impexp'))	{
-			$theData['up'][]='<a href="'.htmlspecialchars($this->backPath.'mod.php?M=xMOD_tximpexp&tx_impexp[action]=export&tx_impexp[list][]='.rawurlencode($this->table.':'.$this->id)).'">'.
-							'<img'.t3lib_iconWorks::skinImg($this->backPath,t3lib_extMgm::extRelPath('impexp').'export.gif',' width="18" height="16"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.export',1).'" alt="" />'.
-							'</a>';
-		}
-
-			// Add "refresh" link:
-		$theData['up'][]='<a href="'.htmlspecialchars($this->listURL()).'">'.
-						'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/refresh_n.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.reload',1).'" alt="" />'.
-						'</a>';
-
-
-			// Add icon with clickmenu, etc:
+		
+		return $pagePath;
+	}
+	
+	/**
+	 * Setting title of page + icon with clickmenu + uid for docheader
+	 *
+	 * @return	string	Page info
+	 */
+	function getPageInfo() {
+		global $LANG;
+		
+		$alttext = t3lib_BEfunc::getRecordIconAltText($this->pageRow, 'pages');
+		$iconImg = t3lib_iconWorks::getIconImage('pages', $this->pageRow, $this->backPath, 'class="absmiddle" title="'. htmlspecialchars($alttext) . '"');
+		
+				// Add icon with clickmenu, etc:
 		if ($this->id)	{	// If there IS a real page...:
-
-				// Setting title of page + the "Go up" link:
-			$theData[$titleCol].='<br /><span title="'.htmlspecialchars($row['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['_thePath'],-$this->fixedL)).'</span>';
-			$theData['up'][]='<a href="'.htmlspecialchars($this->listURL($row['pid'])).'" onclick="setHighlight('.$row['pid'].')">'.
-							'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/pages_up.gif','width="18" height="16"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" alt="" />'.
-							'</a>';
-
 				// Make Icon:
-			$theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,'pages',$this->id) : $iconImg;
+			$theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, 'pages', $this->id) : $iconImg;
+						
+				// Setting title of page + icon with clickmenu + uid
+			$pageInfo = $LANG->getLL('viewRecords',1) . $theIcon . '<strong>' . htmlspecialchars($this->pageRow['title']) . '</strong> <em>[pid: ' . $this->pageRow['uid'] . ']</em>';
+			
+					
 		} else {	// On root-level of page tree:
-
-				// Setting title of root (sitename):
-			$theData[$titleCol].='<br />'.htmlspecialchars(t3lib_div::fixed_lgd_cs($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],-$this->fixedL));
-
 				// Make Icon:
 			$theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' alt="" />';
+			
+				// Setting title of root (sitename):
+			$pageInfo = $LANG->getLL('viewRecords',1) . $theIcon . '<strong>' . htmlspecialchars(t3lib_div::fixed_lgd_cs($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],-$this->fixedL)) . '</strong>';
 		}
-
-			// If there is a returnUrl given, add a back-link:
-		if ($this->returnUrl)	{
-			$theData['up'][]='<a href="'.htmlspecialchars(t3lib_div::linkThisUrl($this->returnUrl,array('id'=>$this->id))).'" class="typo3-goBack">'.
-							'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/goback.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.goBack',1).'" alt="" />'.
-							'</a>';
-		}
-
-			// Finally, the "up" pseudo field is compiled into a table - has been accumulated in an array:
-		$theData['up']='
-			<table border="0" cellpadding="0" cellspacing="0">
-				<tr>
-					<td>'.implode('</td>
-					<td>',$theData['up']).'</td>
-				</tr>
-			</table>';
-
-			// ... and the element row is created:
-		$out.=$this->addelement(1,$theIcon,$theData,'',$this->leftMargin);
-
-			// ... and wrapped into a table and added to the internal ->HTMLcode variable:
-		$this->HTMLcode.='
-
-
-		<!--
-			Page header for db_list:
-		-->
-			<table border="0" cellpadding="0" cellspacing="0" id="typo3-dblist-top">
-				'.$out.'
-			</table>';
+		
+		return $pageInfo;
 	}
 
 	/**
Index: typo3/db_list.php
===================================================================
--- typo3/db_list.php	(revision 2980)
+++ typo3/db_list.php	(working copy)
@@ -66,6 +66,7 @@
 require_once (PATH_t3lib.'class.t3lib_pagetree.php');
 require_once (PATH_t3lib.'class.t3lib_recordlist.php');
 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
+require_once (PATH_t3lib.'class.t3lib_parsehtml.php');
 require_once ($BACK_PATH.'class.db_list.inc');
 require_once ($BACK_PATH.'class.db_list_extra.inc');
 $BE_USER->modAccess($MCONF,1);
@@ -203,8 +204,11 @@
 
 			// Start document template object:
 		$this->doc = t3lib_div::makeInstance('template');
+		$this->template = $this->doc->getHtmlTemplate('templates/db_list.html');
+		$this->doc->divClass = 'typo3-fullDoc';
 		$this->doc->backPath = $BACK_PATH;
 		$this->doc->docType='xhtml_trans';
+		$this->doc->inDocStylesArray[] = 'html { overflow: hidden; }';
 
 			// Loading current page record and checking access:
 		$this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
@@ -227,9 +231,10 @@
 		$dblist->alternateBgColors=$this->modTSconfig['properties']['alternateBgColors']?1:0;
 		$dblist->allowedNewTables = t3lib_div::trimExplode(',',$this->modTSconfig['properties']['allowedNewTables'],1);
 		$dblist->newWizards=$this->modTSconfig['properties']['newWizards']?1:0;
+		$dblist->pageRow = $this->pageinfo;
+		$dblist->counter++;
+		$dblist->MOD_MENU = array('bigControlPanel' => '', 'clipBoard' => '', 'localization' => '');
 
-
-
 			// Clipboard is initialized:
 		$dblist->clipObj = t3lib_div::makeInstance('t3lib_clipboard');		// Start clipboard
 		$dblist->clipObj->initializeClipboard();	// Initialize - reads the clipboard content from the user session
@@ -284,9 +289,6 @@
 			$dblist->start($this->id,$this->table,$this->pointer,$this->search_field,$this->search_levels,$this->showLimit);
 			$dblist->setDispFields();
 
-				// Render the page header:
-			$dblist->writeTop($this->pageinfo);
-
 				// Render versioning selector:
 			$dblist->HTMLcode.= $this->doc->getVersionSelector($this->id);
 
@@ -302,6 +304,14 @@
 					window.location.href = URL;
 					return false;
 				}
+					// workaround since IE6 cannot deal with relative height for scrolling elements
+				function resizeDocBody()	{
+					$("typo3-docbody").style.height = (document.body.offsetHeight - parseInt($("typo3-docheader").getStyle("height")));
+				}
+				if (/MSIE 6/.test(navigator.userAgent)) {
+					Event.observe(window, "resize", resizeDocBody, false);
+					Event.observe(document, "load", resizeDocBody, false);
+				}
 				function jumpExt(URL,anchor)	{	//
 					var anc = anchor?anchor:"";
 					window.location.href = URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc;
@@ -357,26 +367,13 @@
 
 			// Begin to compile the whole page, starting out with page header:
 		$this->content='';
-		$this->content.=$this->doc->startPage('DB list');
+		$this->content.= $this->doc->startPage('DB list');
+		$this->content.= $this->compileHeader($dblist);
+		$this->content.= '<div id="typo3-docbody">';
 		$this->content.= '<form action="'.htmlspecialchars($dblist->listURL()).'" method="post" name="dblistForm">';
-
-			// List Module CSH:
-		if (!strlen($this->id))	{
-			$this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module_noId', $GLOBALS['BACK_PATH'],'<br/>|');
-		} elseif (!$this->id)	{	// zero...:
-			$this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module_root', $GLOBALS['BACK_PATH'],'<br/>|');
-		}
-
-			// Add listing HTML code:
 		$this->content.= $dblist->HTMLcode;
 		$this->content.= '<input type="hidden" name="cmd_table" /><input type="hidden" name="cmd" /></form>';
 
-			// List Module CSH:
-		if ($this->id)	{
-			$this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module', $GLOBALS['BACK_PATH'],'<br/>|');
-		}
-
-
 			// If a listing was produced, create the page footer with search form etc:
 		if ($dblist->HTMLcode)	{
 
@@ -430,14 +427,11 @@
 
 				// Display sys-notes, if any are found:
 			$this->content.=$dblist->showSysNotesForPage();
-
-				// ShortCut:
-			if ($BE_USER->mayMakeShortcut())	{
-				$this->content.='<br/>'.$this->doc->makeShortcutIcon('id,imagemode,pointer,table,search_field,search_levels,showLimit,sortField,sortRev',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']);
-			}
 		}
 
 			// Finally, close off the page:
+			// Close the docbody
+		$this->content .= '</div>';
 		$this->content.= $this->doc->endPage();
 	}
 
@@ -449,6 +443,51 @@
 	function printContent()	{
 		echo $this->content;
 	}
+	
+	/**
+	 * Put together the various elements for the header using a static HTML
+	 * template
+	 *
+	 * @return	string		Composite HTML
+	 */
+	function compileHeader(&$dblist)	{
+		global $LANG;
+
+		$btns = $dblist->getButtons();
+		$content = t3lib_parsehtml::getSubpart($this->template, '###DOCHEADER###');
+
+		$markerArray = array();
+		$markerArray['PAGEPATH'] = $dblist->getPagePath();
+		$markerArray['PAGEINFO'] = $dblist->getPageInfo();
+
+			// -- compiling buttons --
+			// get button template, then loop through the buttons and replace them in the template
+		$btnTmpl = t3lib_parsehtml::getSubpart($this->template, '###BUTTON_GROUPS###');
+		$btnTmpl = t3lib_parsehtml::substituteMarkerArray($btnTmpl, $btns, '###|###', true);
+
+			// getting the wrap for each group
+		$btnWrap = t3lib_parsehtml::getSubpart($this->template, '###BUTTON_GROUP_WRAP###');
+
+			// looping through the groups (max 6) and remove the empty groups
+		$grpId = 1;
+		for ($grpNum = 1; $grpNum < 6; $grpNum++) {
+			$btnMarker = '###BUTTON_GROUP'.$grpNum.'###';
+			$btnGroup = t3lib_parsehtml::getSubpart($btnTmpl, $btnMarker);
+			if (trim($btnGroup)) {
+				if ($btnWrap) {
+					$btnGroup = t3lib_parsehtml::substituteMarker($btnWrap, '###BUTTONS###', $btnGroup);
+				}
+				$btnTmpl = t3lib_parsehtml::substituteSubpart($btnTmpl, $btnMarker, trim($btnGroup));
+			}
+		}
+
+			// replace the marker with the template and remove all line breaks (for IE compat)
+		$markerArray['BUTTONLIST'] = str_replace("\n", '', $btnTmpl);
+			// -- end compiling buttons
+
+			// replacing all markers with the finished markers and return the HTML content
+		return t3lib_parsehtml::substituteMarkerArray($content, $markerArray, '###|###');
+	}
 }
 
 // Include extension?
Index: typo3/stylesheet.css
===================================================================
--- typo3/stylesheet.css	(revision 2980)
+++ typo3/stylesheet.css	(working copy)
@@ -126,10 +126,9 @@
 	background-color: #9BA1A8;
 }
 
-body#typo3-alt-doc-php { padding: 0; margin: 0; overflow: hidden; height: 100%; }
+body#typo3-alt-doc-php, body#typo3-db-list-php, body#ext-cms-layout-db-layout-php, body#ext-tstemplate-ts-index-php { padding: 0; margin: 0; overflow: hidden; height: 100%; }
 
 
-
 /****************************************
  * SPECIFIC WRAPPERS
  *
@@ -372,13 +371,14 @@
 div#typo3-docheader div.buttonsleft  { margin: 0 0 0 3px; line-height: 16px; float: left; }
 div#typo3-docheader div.buttonsright { margin: 0 3px 0 0; line-height: 16px; float: right; }
 div#typo3-docheader img, div#typo3-docheader input { margin: 2px 3px 0; vertical-align: top; }
-div#typo3-docheader img.typo3-csh-icon { margin: 2px 15px 0 2px; }
-div#typo3-docheader select { margin: 2px 0 0; }
+div#typo3-docheader img.typo3-csh-icon { margin: 2px 2px 0 2px; }
+div#typo3-docheader select { margin: 1px 0 0; }
 div#typo3-docheader div.pagepath { margin-left: 6px; float: left; }
 div#typo3-docheader div.infooptions { margin-right: 6px; float: right; }
 div#typo3-docbody { width: 98%; padding: 2% 0% 2% 2%; overflow: auto; top: 49px; bottom: 0; position: absolute; z-index: 2; }
 * html div#typo3-docbody { height: 90%; top: 49px; padding-top: 0; padding-bottom: 0; }
 * html div#typo3-docbody table.typo3-TCEforms { margin-top: 20px; }
+div#typo3-docheader div.buttongroup { height: 20px; float: left; padding-right: 20px; border-right: 1px dashed #ccc; margin-right: 5px; }
 
 /* Login Screen
 
@@ -460,7 +460,7 @@
 TABLE#typo3-page-stdlist TR TD.c-headLine { background-color: #ABBBB4; }
 
 /* Web > List */
-TABLE.typo3-dblist { width: 98%; }
+TABLE.typo3-dblist { width: 93%; }
 TABLE.typo3-dblist IMG { vertical-align: middle; }
 TABLE.typo3-dblist TR TD { padding-left: 1px; padding-right: 6px; }
 TABLE.typo3-dblist TR TD.db_list_alt { background-color: #E3DFD3; }
@@ -476,11 +476,11 @@
 TABLE#typo3-versionSelector { background-color: #ABBBB4; margin-top: 5px; margin-bottom: 5px; }
 TABLE#typo3-versionSelector TD { padding-left: 2px; padding-right: 2px; }
 
-DIV#typo3-newRecordLink, DIV.typo3-newRecordLink { margin: 5px 0px 5px 0px; font-weight: bold; }
+DIV#typo3-newRecordLink, DIV.typo3-newRecordLink { margin: 5px 0px 5px 0px; font-weight: bold; width: 93%; }
 DIV#typo3-newRecordLink IMG, DIV.typo3-newRecordLink IMG { margin-right: 5px; vertical-align: middle; }
 
 INPUT.smallCheckboxes { vertical-align: middle; margin: 0px; padding: 0px; width: 12px; height: 12px; }
-DIV#typo3-listOptions { margin: 10px 0px 10px 0px; }
+DIV#typo3-listOptions { margin: 10px 0px 10px 0px; width: 93%; }
 
 /* File > List */
 TABLE#typo3-filelist IMG { vertical-align: middle; }
@@ -576,8 +576,8 @@
  *********************************************/
 
 /* context menus */
-div#contentMenu0 { z-index: 1; position: absolute; }
-div#contentMenu1 { z-index: 2; position: absolute; }
+div#contentMenu0 { z-index: 10; position: absolute; }
+div#contentMenu1 { z-index: 20; position: absolute; }
 
 /* Dimmed span tag color (disabled) */
 .typo3-dimmed { color: #666; }
@@ -670,3 +670,4 @@
 H2,H3,H4,DIV { border: 1px dotted #666; }
 */
 
+
Index: typo3/sysext/cms/layout/db_layout.php
===================================================================
--- typo3/sysext/cms/layout/db_layout.php	(revision 2980)
+++ typo3/sysext/cms/layout/db_layout.php	(working copy)
@@ -75,6 +75,7 @@
 require_once(PATH_t3lib.'class.t3lib_pagetree.php');
 require_once(PATH_t3lib.'class.t3lib_page.php');
 require_once(PATH_t3lib.'class.t3lib_recordlist.php');
+require_once(PATH_t3lib.'class.t3lib_parsehtml.php');
 require_once(PATH_typo3.'class.db_list.inc');
 require_once('class.tx_cms_layout.php');
 require_once(PATH_t3lib.'class.t3lib_positionmap.php');
@@ -404,8 +405,11 @@
 
 				// Start document template object:
 			$this->doc = t3lib_div::makeInstance('mediumDoc');
+			$this->template = $this->doc->getHtmlTemplate($BACK_PATH . 'templates/db_layout.html');
 			$this->doc->backPath = $BACK_PATH;
 			$this->doc->docType='xhtml_trans';
+			$this->doc->divClass = 'typo3-fullDoc';
+			$this->doc->inDocStylesArray[] = 'html { overflow: hidden; }';
 
 				// JavaScript:
 			$this->doc->JScode = '<script type="text/javascript" src="'.$BACK_PATH.'../t3lib/jsfunc.updateform.js"></script>';
@@ -421,6 +425,15 @@
 						}
 					} else window.location.href = URL;
 				}
+
+					// workaround since IE6 cannot deal with relative height for scrolling elements
+				function resizeDocBody()	{
+					$("typo3-docbody").style.height = (document.body.offsetHeight - parseInt($("typo3-docheader").getStyle("height")));
+				}
+				if (/MSIE 6/.test(navigator.userAgent)) {
+					Event.observe(window, "resize", resizeDocBody, false);
+					Event.observe(document, "load", resizeDocBody, false);
+				}
 			'.($this->popView ? t3lib_BEfunc::viewOnClick($this->id,$BACK_PATH,t3lib_BEfunc::BEgetRootLine($this->id)) : '').'
 
 				function deleteRecord(table,id,url)	{	//
@@ -430,7 +443,81 @@
 					return false;
 				}
 			');
+			$this->doc->JScode.= $this->doc->wrapScriptTags('
+				var DTM_array = new Array();
+				var DTM_origClass = new String();
 
+					// if tabs are used in a popup window the array might not exists
+				if(!top.DTM_currentTabs) {
+					top.DTM_currentTabs = new Array();
+				}
+
+				function DTM_activate(idBase,index,doToogle)	{	//
+						// Hiding all:
+					if (DTM_array[idBase])	{
+						for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++)	{
+							if (DTM_array[idBase][cnt] != idBase+"-"+index)	{
+								document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
+								document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
+							}
+						}
+					}
+
+						// Showing one:
+					if (document.getElementById(idBase+"-"+index+"-DIV"))	{
+						if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block")	{
+							document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
+							if(DTM_origClass=="") {
+								document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
+							} else {
+								DTM_origClass = "tab";
+							}
+							top.DTM_currentTabs[idBase] = -1;
+						} else {
+							document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
+							if(DTM_origClass=="") {
+								document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
+							} else {
+								DTM_origClass = "tabact";
+							}
+							top.DTM_currentTabs[idBase] = index;
+						}
+					}
+				}
+				function DTM_toggle(idBase,index,isInit)	{	//
+						// Showing one:
+					if (document.getElementById(idBase+"-"+index+"-DIV"))	{
+						if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block")	{
+							document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
+							if(isInit) {
+								document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
+							} else {
+								DTM_origClass = "tab";
+							}
+							top.DTM_currentTabs[idBase+"-"+index] = 0;
+						} else {
+							document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
+							if(isInit) {
+								document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
+							} else {
+								DTM_origClass = "tabact";
+							}
+							top.DTM_currentTabs[idBase+"-"+index] = 1;
+						}
+					}
+				}
+
+				function DTM_mouseOver(obj) {	//
+						DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue;
+						obj.attributes.getNamedItem(\'class\').nodeValue += "_over";
+				}
+
+				function DTM_mouseOut(obj) {	//
+						obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass;
+						DTM_origClass = "";
+				}
+			');
+
 				// Setting doc-header
 			$this->doc->form='<form action="'.htmlspecialchars('db_layout.php?id='.$this->id.'&imagemode='.$this->imagemode).'" method="post">';
 
@@ -438,14 +525,6 @@
 			$this->topFuncMenu = t3lib_BEfunc::getFuncMenu($this->id,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function'],'db_layout.php','').
 						(count($this->MOD_MENU['language'])>1 ? '<br />'.t3lib_BEfunc::getFuncMenu($this->id,'SET[language]',$this->current_sys_language,$this->MOD_MENU['language'],'db_layout.php','') : '');
 
-				// Creating the top edit page icon:
-			if ($this->CALC_PERMS&2)	{
-				$params='&edit[pages]['.$this->id.']=edit';
-				$this->editIcon='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$BACK_PATH)).'"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/edit2.gif','width="11" height="12"').' vspace="2" align="top" title="'.$LANG->getLL('editPageProperties',1).'" alt="" /></a>';
-			} else {
-				$this->editIcon='';
-			}
-
 				// Find columns
 			$modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->id,'mod.SHARED');		// SHARED page-TSconfig settings.
 			$this->colPosList = strcmp(trim($this->modTSconfig['properties']['tt_content.']['colPos_list']),'') ? trim($this->modTSconfig['properties']['tt_content.']['colPos_list']) : $modTSconfig_SHARED['properties']['colPos_list'];
@@ -461,20 +540,14 @@
 			}
 
 
-				// ShortCut
-			if ($BE_USER->mayMakeShortcut())	{
-				$this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('id,edit_record,pointer,new_unique_uid,search_field,search_levels,showLimit',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']));
-			}
-
-				// Ending page:
-			$this->content.=$this->doc->spacer(10);
-			$this->content.=$this->doc->endPage();
+			
 		} else {
 
 				// If no access or id value, create empty document:
 			$this->doc = t3lib_div::makeInstance('mediumDoc');
 			$this->doc->docType='xhtml_trans';
 			$this->doc->backPath = $BACK_PATH;
+			
 			$this->doc->JScode = $this->doc->wrapScriptTags('
 				if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
 			');
@@ -611,13 +684,13 @@
 
 
 			// Delete-button flag?
-		$deleteButton = (t3lib_div::testInt($eRParts[1]) && $edit_record && (($eRParts[0]!='pages'&&$this->EDIT_CONTENT) || ($eRParts[0]=='pages'&&($this->CALC_PERMS&4))));
+		$this->deleteButton = (t3lib_div::testInt($eRParts[1]) && $edit_record && (($eRParts[0]!='pages'&&$this->EDIT_CONTENT) || ($eRParts[0]=='pages'&&($this->CALC_PERMS&4))));
 
 			// If undo-button should be rendered (depends on available items in sys_history)
-		$undoButton=0;
+		$this->undoButton=0;
 		$undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($eRParts[0], 'sys_history').' AND recuid='.intval($eRParts[1]), '', 'tstamp DESC', '1');
-		if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes))	{
-			$undoButton=1;
+		if ($this->undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes))	{
+			$this->undoButton=1;
 		}
 
 			// Setting up the Return URL for coming back to THIS script (if links take the user to another script)
@@ -627,87 +700,26 @@
 		unset($R_URL_getvars['popView']);
 		unset($R_URL_getvars['new_unique_uid']);
 		$R_URL_getvars['edit_record']=$edit_record;
-		$R_URI = $R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$R_URL_getvars);
+		$this->R_URI = $R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$R_URL_getvars);
 
 			// Setting close url/return url for exiting this script:
-		$closeUrl = $this->local_linkThisScript(array('SET'=>array('function'=>1)));	// Goes to 'Columns' view if close is pressed (default)
+		$this->closeUrl = $this->local_linkThisScript(array('SET'=>array('function'=>1)));	// Goes to 'Columns' view if close is pressed (default)
 
 		if ($BE_USER->uc['condensedMode'])	{
-			$closeUrl = $BACK_PATH.'alt_db_navframe.php';
+			$this->closeUrl = $BACK_PATH.'alt_db_navframe.php';
 		}
 		if ($this->returnUrl)	{
-			$closeUrl = $this->returnUrl;
+			$this->closeUrl = $this->returnUrl;
 		}
 			// Return-url for JavaScript:
 		$retUrlStr = $this->returnUrl?"+'&returnUrl='+'".rawurlencode($this->returnUrl)."'":'';
 
-			// Drawing tool bar:
-		$toolBar=
-			'<select name="edit_record" onchange="'.htmlspecialchars('jumpToUrl(\'db_layout.php?id='.$this->id.'&edit_record=\'+escape(this.options[this.selectedIndex].value)'.$retUrlStr.',this);').'">'.implode('',$opt).'</select>'.
+			// Drawing the edit record selectbox
+		$this->editSelect = '<select name="edit_record" onchange="' . htmlspecialchars('jumpToUrl(\'db_layout.php?id=' . $this->id . '&edit_record=\'+escape(this.options[this.selectedIndex].value)' . $retUrlStr . ',this);') . '">' . implode('', $opt) . '</select>';
 
-			'<input class="c-inputButton" type="image" name="savedok"'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/savedok.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'" alt="" />'.
-
-			'<a href="#" onclick="'.htmlspecialchars('document.editform.redirect.value+=\'&popView=1\'; TBE_EDITOR.checkAndDoSubmit(1); return false;').'">'.
-				'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/savedokshow.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDocShow',1).'" alt="" />'.
-				'</a>'.
-
-			'<a href="#" onclick="'.htmlspecialchars('jumpToUrl(unescape(\''.rawurlencode($closeUrl).'\')); return false;').'">'.
-				'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/closedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'" alt="" />'.
-				'</a>'.
-
-			($deleteButton ? '<a href="#" onclick="'.htmlspecialchars('return deleteRecord(\''.$eRParts[0].'\',\''.$eRParts[1].'\',\''.t3lib_div::getIndpEnv('SCRIPT_NAME').'?id='.$this->id.'\');').'">'.
-							'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/deletedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->getLL('deleteItem',1).'" alt="" />'.
-							'</a>' : '').
-
-			($undoButton ? '<a href="#" onclick="'.htmlspecialchars('window.location.href=\''.$BACK_PATH.'show_rechis.php?element='.rawurlencode($eRParts[0].':'.$eRParts[1]).'&revert=ALL_FIELDS&sumUp=-1&returnUrl='.rawurlencode($R_URI).'\'; return false;').'">'.
-							'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/undo.gif','width="21" height="16"').' class="c-inputButton" title="'.htmlspecialchars(sprintf($LANG->getLL('undoLastChange'),t3lib_BEfunc::calcAge(time()-$undoButtonR['tstamp'],$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))).'" alt="" />'.
-							'</a>' : '');
-
-		$toolBar.='<img src="clear.gif" width="15" height="1" align="top" alt="" />';
-
-		$toolBar.=$undoButton?'<a href="#" onclick="'.htmlspecialchars('jumpToUrl(\''.$BACK_PATH.'show_rechis.php?element='.rawurlencode($eRParts[0].':'.$eRParts[1]).'&returnUrl='.rawurlencode($R_URI).'#latest\');return false;').'">'.
-					'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/history2.gif','width="13" height="12"').' class="c-inputButton" title="'.$LANG->getLL('recordHistory',1).'" alt="" />'.
-					'</a>':'';
-
-		$toolBar.='<a href="'.htmlspecialchars('db_new_content_el.php?id='.$this->id.'&sys_language_uid='.$this->current_sys_language.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
-					'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/new_record.gif','width="16" height="12"').' class="c-inputButton" title="'.$LANG->getLL('newContentElement',1).'" alt="" />'.
-					'</a>';
-
-		if (t3lib_div::testInt($eRParts[1])) $toolBar.='<a href="'.htmlspecialchars($BACK_PATH.'move_el.php?table='.$eRParts[0].'&uid='.$eRParts[1].'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/move_'.($eRParts[0]=='tt_content'?'record':'page').'.gif','width="11" height="12"').' class="c-inputButton" title="'.$LANG->getLL('move_'.($eRParts[0]=='tt_content'?'record':'page'),1).'" alt="" /></a>';
-
-		$toolBar.='<a href="#" onclick="'.htmlspecialchars('jumpToUrl(\''.$BACK_PATH.'db_new.php?id='.$this->id.'&pagesOnly=1&returnUrl='.rawurlencode($R_URI).'\');return false;').'">'.
-				'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/new_page.gif','width="13" height="12"').' class="c-inputButton" title="'.$LANG->getLL('newPage',1).'" alt="" />'.
-				'</a>';
-
-		$toolBar.='<a href="'.htmlspecialchars($this->local_linkThisScript(array('edit_record'=>'pages:'.$this->id))).'">'.
-				'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/edit2.gif','width="11" height="12"').' class="c-inputButton" title="'.$LANG->getLL('editPageProperties',1).'" alt="" />'.
-				'</a>';
-		$toolBar.='<img src="clear.gif" width="15" height="1" align="top" alt="" />';
-
-			// CSH:
-		$toolBar.= t3lib_BEfunc::cshItem($this->descrTable,'quickEdit',$BACK_PATH,'',FALSE,'margin-top: 0px; margin-bottom: 0px;');
-
-			// Setting page properties:
-		$hS2 = '
-			<table border="0" cellpadding="0" cellspacing="0" width="460">
-				<tr>
-					<td valign="top" width="99%">'.$this->doc->getHeader('pages',$this->pageinfo,$this->pageinfo['_thePath'],0,explode('|','<a href="'.htmlspecialchars($this->local_linkThisScript(array('edit_record'=>'pages:'.$this->id))).'">|</a>')).'</td>
-					<td valign="top" width="1%">'.$this->topFuncMenu.'</td>
-					<td valign="top" width="1%"><img src="clear.gif" width="1" height="3" alt="" /><br />'.$this->editIcon.'</td>
-				</tr>
-				<tr>
-					<td><img src="clear.gif" width="300" height="1" alt="" /></td>
-					<td></td>
-					<td></td>
-				</tr>
-				<tr>
-					<td colspan="3" class="bgColor4">'.$toolBar.'</td>
-				</tr>
-			</table>';
-
 		$content.=$this->doc->startPage($LANG->getLL('title'));
-		$content.=$this->doc->section('',$hS2);
-		$content.=$this->doc->spacer(7);
+		$content.= $this->compileHeader('quickEdit', $eRParts);
+		$content.= '<div id="typo3-docbody">';
 
 			// Creating editing form:
 		if ($BE_USER->check('tables_modify',$eRParts[0]) && $edit_record && (($eRParts[0]!='pages'&&$this->EDIT_CONTENT) || ($eRParts[0]=='pages'&&($this->CALC_PERMS&1))))	{
@@ -784,7 +796,7 @@
 					<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />
 					<input type="hidden" name="_disableRTE" value="'.$tceforms->disableRTE.'" />
 					<input type="hidden" name="edit_record" value="'.$edit_record.'" />
-					<input type="hidden" name="redirect" value="'.htmlspecialchars($uidVal=='new' ? t3lib_extMgm::extRelPath('cms').'layout/db_layout.php?id='.$this->id.'&new_unique_uid='.$new_unique_uid.'&returnUrl='.rawurlencode($this->returnUrl) : $R_URI ).'" />
+					<input type="hidden" name="redirect" value="'.htmlspecialchars($uidVal=='new' ? t3lib_extMgm::extRelPath('cms').'layout/db_layout.php?id='.$this->id.'&new_unique_uid='.$new_unique_uid.'&returnUrl='.rawurlencode($this->returnUrl) : $this->R_URI ).'" />
 					';
 
 					// Add JavaScript as needed around the form:
@@ -852,20 +864,8 @@
 				// CSH:
 			$HTMLcode.= t3lib_BEfunc::cshItem($this->descrTable,'quickEdit_selElement',$BACK_PATH,'|<br/>');
 
-			$HTMLcode.=$posMap->printContentElementColumns($this->id,$eRParts[1],$this->colPosList,$this->MOD_SETTINGS['tt_content_showHidden'],$R_URI);
+			$HTMLcode.=$posMap->printContentElementColumns($this->id,$eRParts[1],$this->colPosList,$this->MOD_SETTINGS['tt_content_showHidden'],$this->R_URI);
 
-			$HTMLcode.='<br /><br />'.
-						'<a href="'.htmlspecialchars($BACK_PATH.'move_el.php?table=tt_content&uid='.$eRParts[1].'&sys_language_uid='.$this->current_sys_language.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/move_record.gif','width="11" height="12"').' vspace="0" hspace="5" align="top" title="'.$LANG->getLL('move_record',1).'" alt="" />'.
-						$LANG->getLL('move_record',1).
-						'</a>';
-
-			$HTMLcode.='<br /><img src="clear.gif" width="1" height="5" alt="" />';
-			$HTMLcode.='<br />'.
-						'<a href="'.htmlspecialchars('db_new_content_el.php?id='.$this->id.'&sys_language_uid='.$this->current_sys_language.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
-						'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/new_record.gif','width="16" height="12"').' vspace="0" hspace="2" align="top" title="'.$LANG->getLL('newContentElement',1).'" alt="" />'.
-						$LANG->getLL('newContentElement',1).
-						'</a>';
-
 			$content.=$this->doc->spacer(20);
 			$content.=$this->doc->section($LANG->getLL('CEonThisPage'),$HTMLcode,0,1);
 			$content.=$this->doc->spacer(20);
@@ -882,6 +882,10 @@
 
 			// Adding content to internal accumulation variable:
 		$this->content.=$content;
+
+			// Ending page:
+		$this->content.=$this->doc->spacer(10);
+		$this->content.=$this->doc->endPage();
 	}
 
 	/**
@@ -1035,71 +1039,13 @@
 		$this->doc->getContextMenuCode();
 
 
-			// Draw the page properties.
-		$headerSection = $this->doc->getHeader('pages',$this->pageinfo,$this->pageinfo['_thePath'],$this->modTSconfig['properties']['disableIconToolbar']?1:0).'<br />'.
-						$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.
-						'<span title="'.htmlspecialchars($this->pageinfo['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'],-50)).'</span>';
 
-		if (!$this->modTSconfig['properties']['disableIconToolbar'])	{
-				// Create icon "toolbar" for common operations like creating/moving elements/pages etc.
-			$toolBar='';
-				// History:
-			$toolBar.='<a href="#" onclick="'.htmlspecialchars('jumpToUrl(\''.$BACK_PATH.'show_rechis.php?element='.rawurlencode('pages:'.$this->id).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'#latest\');return false;').'">'.
-						'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/history2.gif','width="13" height="12"').' vspace="2" hspace="2" align="top" title="'.$LANG->getLL('recordHistory',1).'" alt="" />'.
-						'</a>';
-				// New content element
-			$toolBar.='<a href="'.htmlspecialchars('db_new_content_el.php?id='.$this->id.'&sys_language_uid='.$this->current_sys_language.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
-						'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/new_record.gif','width="16" height="12"').' vspace="2" hspace="1" align="top" title="'.$LANG->getLL('newContentElement',1).'" alt="" />'.
-						'</a>';
-				// Move page:
-			$toolBar.='<a href="'.htmlspecialchars($BACK_PATH.'move_el.php?table=pages&uid='.$this->id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
-						'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/move_page.gif','width="11" height="12"').' vspace="2" hspace="2" align="top" title="'.$LANG->getLL('move_page',1).'" alt="" />'.
-						'</a>';
-				// Create new page (wizard):
-			$toolBar.='<a href="#" onclick="'.htmlspecialchars('jumpToUrl(\''.$BACK_PATH.'db_new.php?id='.$this->id.'&pagesOnly=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'\');return false;').'">'.
-						'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/new_page.gif','width="13" height="12"').' hspace="0" vspace="2" align="top" title="'.$LANG->getLL('newPage',1).'" alt="" />'.
-						'</a>';
-				// Edit page properties:
-			$params='&edit[pages]['.$this->id.']=edit';
-			$toolBar.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$BACK_PATH)).'">'.
-						'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/edit2.gif','width="11" height="12"').' hspace="2" vspace="2" align="top" title="'.$LANG->getLL('editPageProperties',1).'" alt="" />'.
-						'</a>';
 
-				// Add CSH (Context Sensitive Help) icon to tool bar:
-			$toolBar.= t3lib_BEfunc::cshItem($this->descrTable,'columns_'.$this->MOD_SETTINGS['function'],$BACK_PATH,'',FALSE,'margin-top: 0px; margin-bottom: 0px;');
-
-				// Wrap the toolbar into a table:
-			$headerSection.='
-				<table border="0" cellpadding="0" cellspacing="0" class="bgColor4">
-					<tr>
-						<td>'.$toolBar.'</td>
-					</tr>
-				</table>';
-		}
-
-			// Create menu of table-icons for jumping to table-listing anchor points:
-		if ($this->MOD_SETTINGS['function']!=3 && count($tableOutput)>1)	{
-			$goToTable_menu = '<td valign="top" width="1%" nowrap="nowrap">'.$h_menu.'</td>';
-		} else {
-			$goToTable_menu = '';
-		}
-
-			// Compile the whole header section into a table: Toolbar, Table selector, Function menu(s), Page-edit icon:
-		$hS2='
-			<table border="0" cellpadding="0" cellspacing="0" width="100%">
-				<tr>
-					<td valign="top" width="99%">'.$headerSection.'</td>
-					'.$goToTable_menu.'
-					<td valign="top" width="1%">'.$this->topFuncMenu.'</td>
-					<td valign="top" align="right" width="1%"><img src="clear.gif" width="1" height="3" alt="" /><br />'.$this->editIcon.'</td>
-				</tr>
-			</table>';
-
 			// Create page properties:
-		$this->content.=$this->doc->startPage($LANG->getLL('title'));
-		$this->content.=$this->doc->section('',$hS2);
+		$this->content.= $this->doc->startPage($LANG->getLL('title'));
+		$this->content.= $this->compileHeader();
+		$this->content.= '<div id="typo3-docbody">';
 
-
 			// Now, create listing based on which element is selected in the function menu:
 
 		if ($this->MOD_SETTINGS['function']==3) {
@@ -1129,35 +1075,14 @@
 				$this->content.=$this->doc->section($LANG->getLL('internalNotes'),$sysNotes,0,1);
 			}
 
-				// Display advanced options: Clear cache, new record link etc:
-			if (!$this->modTSconfig['properties']['disableAdvanced'])	{
-
-					// Clear cache links:
-				$af_content = $this->doc->clearCacheMenu($this->id);
-
-					// "Create new record" link:
-				if (!$this->modTSconfig['properties']['noCreateRecordsLink']) {
-					$af_content.='
-
-					<!--
-						Link for creating a new record:
-					-->
-					<div id="typo3-newRecordLink">
-							<a href="'.htmlspecialchars($BACK_PATH.'db_new.php?id='.$this->id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
-						'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/new_el.gif','width="11" height="12"').' alt="" />'.
-						$LANG->getLL('newRecordGeneral',1).
-						'</a>
-					</div>';
-				}
-
-					// Add content of the advanced-options section:
-				$this->content.=$this->doc->spacer(10);
-				$this->content.=$this->doc->section($LANG->getLL('advancedFunctions'),$af_content,0,1);
-			}
-
 				// Add spacer in bottom of page:
 			$this->content.=$this->doc->spacer(10);
 		}
+
+			// Ending page:
+		$this->content.=$this->doc->spacer(10);
+		$this->content.= '</div>';
+		$this->content.=$this->doc->endPage();
 	}
 
 	/**
@@ -1169,18 +1094,243 @@
 		echo $this->content;
 	}
 
+	/***************************
+	 *
+	 * Sub-content functions, rendering specific parts of the module content.
+	 *
+	 ***************************/
 
+	/**
+	 * Put together the various elements for the header using a static HTML
+	 * template
+	 *
+	 * @param	string	Identifier for function of module
+	 * @param	array	Edit-record cmd value splitted into table/uid
+	 * @return	string		Composite HTML
+	 */
+	function compileHeader($function = '', $eRParts = array())	{
+		global $LANG;
 
+		$btns = $this->getButtons($function, $eRParts);
+		$content = t3lib_parsehtml::getSubpart($this->template, '###DOCHEADER###');
 
+		$markerArray = array();
+		$markerArray['TOP_FUNCTION_MENU'] = $this->editSelect . $this->topFuncMenu;
+		$markerArray['PAGEPATH'] = $this->getPagePath();
+		$markerArray['PAGEINFO'] = $this->getPageInfo();
 
 
+			// -- compiling buttons --
+			// get button template, then loop through the buttons and replace them in the template
+		$subpart = $function == 'quickEdit' ? '###BUTTON_GROUPS_QUICKEDIT###' : '###BUTTON_GROUPS_DEFAULT###';
+		$btnTmpl = t3lib_parsehtml::getSubpart($this->template, $subpart);
+		$btnTmpl = t3lib_parsehtml::substituteMarkerArray($btnTmpl, $btns, '###|###', true);
 
+			// getting the wrap for each group
+		$btnWrap = t3lib_parsehtml::getSubpart($this->template, '###BUTTON_GROUP_WRAP###');
 
+			// looping through the groups (max 6) and remove the empty groups
+		$grpId = 1;
+		for ($grpNum = 1; $grpNum < 6; $grpNum++) {
+			$btnMarker = '###BUTTON_GROUP'.$grpNum.'###';
+			$btnGroup = t3lib_parsehtml::getSubpart($btnTmpl, $btnMarker);
+			if (trim($btnGroup)) {
+				if ($btnWrap) {
+					$btnGroup = t3lib_parsehtml::substituteMarker($btnWrap, '###BUTTONS###', $btnGroup);
+				}
+				$btnTmpl = t3lib_parsehtml::substituteSubpart($btnTmpl, $btnMarker, trim($btnGroup));
+			}
+		}
 
+			// replace the marker with the template and remove all line breaks (for IE compat)
+		$markerArray['BUTTONLIST'] = str_replace("\n", '', $btnTmpl);
+			// -- end compiling buttons
 
+			// replacing all markers with the finished markers and return the HTML content
+		return t3lib_parsehtml::substituteMarkerArray($content, $markerArray, '###|###');
+	}
+	
+	/**
+	 * Create the panel of buttons for submitting the form or otherwise perform operations.
+	 *
+	 * @param	string	Identifier for function of module
+	 * @param	array	Edit-record cmd value splitted into table/uid
+	 * @return	array	all available buttons as an assoc. array
+	 */
+	function getButtons($function, $eRParts)	{
+		global $TCA, $LANG, $BACK_PATH, $BE_USER;
+		
+		$buttons = array(
+			'view' => '',
+			'history_page' => '', 
+			'new_content' => '', 
+			'move_page' => '',
+			'move_record' => '',
+			'new_page' => '', 
+			'edit_page' => '',
+			'record_list' => '',
+			'csh' => '',
+			'shortcut' => '',
+			'cache' => '',
+			'savedok' => '',
+			'savedokshow' => '',
+			'closedok' => '',
+			'deletedok' => '',
+			'undo' => '',
+			'history_record' => ''
+		);
 
+			// View page
+		$buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->pageinfo['uid'], $BACK_PATH, t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '">' .
+				'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/zoom.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '" hspace="3" alt="" />' .
+				'</a>';
 
+			// Shortcut
+		if ($BE_USER->mayMakeShortcut())	{
+			$buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
+		}
+		
+			// Cache
+		if (!$this->modTSconfig['properties']['disableAdvanced'])	{
+			$buttons['cache'] = '<a href="' . htmlspecialchars('db_layout.php?id=' . $this->pageinfo['uid'] . '&clear_cache=1') . '">' .
+					'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/clear_cache.gif', 'width="14" height="14"') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.clear_cache', 1) . '" alt="" />' .
+					'</a>';
+		}
+		
+			// If access to Web>List for user, then link to that module.
+		if ($BE_USER->check('modules','web_list'))	{
+			$href = $BACK_PATH . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
+			$buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '">' .
+					'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/list.gif', 'width="11" height="11"') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', 1) . '" alt="" />' .
+					'</a>';
+		}
+			
+		if (!$this->modTSconfig['properties']['disableIconToolbar'])	{		
+			
+				// Page history
+			$buttons['history_page'] = '<a href="#" onclick="' . htmlspecialchars('jumpToUrl(\'' . $BACK_PATH . 'show_rechis.php?element=' . rawurlencode('pages:' . $this->id) . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . '#latest\');return false;') . '">' .
+						'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/history2.gif', 'width="13" height="12"') . ' vspace="2" hspace="2" align="top" title="' . $LANG->getLL('recordHistory', 1) . '" alt="" />' .
+						'</a>';
+				// New content element
+			$buttons['new_content'] = '<a href="' . htmlspecialchars('db_new_content_el.php?id=' . $this->id . '&sys_language_uid=' . $this->current_sys_language . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
+						'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/new_record.gif', 'width="16" height="12"') . ' vspace="2" hspace="1" align="top" title="' . $LANG->getLL('newContentElement', 1) . '" alt="" />' .
+						'</a>';
+				// Move page
+			$buttons['move_page'] = '<a href="' . htmlspecialchars($BACK_PATH . 'move_el.php?table=pages&uid=' . $this->id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
+						'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/move_page.gif', 'width="11" height="12"') . ' vspace="2" hspace="2" align="top" title="' . $LANG->getLL('move_page', 1) . '" alt="" />' .
+						'</a>';
+				// Move record
+			if (t3lib_div::testInt($eRParts[1])) {
+				$buttons['move_record'] = '<a href="' . htmlspecialchars($BACK_PATH . 'move_el.php?table=' . $eRParts[0] . '&uid=' . $eRParts[1] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
+						'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/move_' . ($eRParts[0] == 'tt_content' ? 'record' : 'page') . '.gif', 'width="11" height="12"') . ' class="c-inputButton" title="' . $LANG->getLL('move_' . ($eRParts[0] == 'tt_content' ? 'record' : 'page'), 1) . '" alt="" />' .
+						'</a>';
+			}
+				// Create new page (wizard)
+			$buttons['new_page'] = '<a href="#" onclick="' . htmlspecialchars('jumpToUrl(\'' . $BACK_PATH . 'db_new.php?id=' . $this->id . '&pagesOnly=1&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . '\');return false;') . '">' .
+						'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/new_page.gif', 'width="13" height="12"') . ' hspace="0" vspace="2" align="top" title="' . $LANG->getLL('newPage', 1) . '" alt="" />' .
+						'</a>';
+				// Edit page properties
+			if ($this->CALC_PERMS&2)	{
+				$params='&edit[pages][' . $this->id . ']=edit';
+				$buttons['edit_page'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $BACK_PATH)) . '">' .
+							'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/edit2.gif', 'width="11" height="12"') . ' hspace="2" vspace="2" align="top" title="' . $LANG->getLL('editPageProperties', 1) . '" alt="" />' .
+							'</a>';
+			}
 
+				// Add CSH (Context Sensitive Help) icon to tool bar
+			if($function == 'quickEdit') {
+				$buttons['csh'] = t3lib_BEfunc::cshItem($this->descrTable, 'quickEdit', $BACK_PATH, '', FALSE, 'margin-top: 0px; margin-bottom: 0px;');
+			} else {
+				$buttons['csh'] = t3lib_BEfunc::cshItem($this->descrTable, 'columns_' . $this->MOD_SETTINGS['function'], $BACK_PATH, '', FALSE, 'margin-top: 0px; margin-bottom: 0px;');
+			}
+			
+			if($function == 'quickEdit') {
+					// Save record
+				$buttons['savedok'] = '<input class="c-inputButton" type="image" name="savedok"' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/savedok.gif','') . ' title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc', 1) . '" alt="" />';
+	
+					// Save record and show page
+				$buttons['savedokshow'] = '<a href="#" onclick="' . htmlspecialchars('document.editform.redirect.value+=\'&popView=1\'; TBE_EDITOR.checkAndDoSubmit(1); return false;') . '">' .
+					'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/savedokshow.gif', 'width="21" height="16"') . ' class="c-inputButton" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDocShow', 1) . '" alt="" />' .
+					'</a>';
+	
+					// Close record
+				$buttons['closedok'] = '<a href="#" onclick="' . htmlspecialchars('jumpToUrl(unescape(\'' . rawurlencode($this->closeUrl) . '\')); return false;') . '">' .
+					'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/closedok.gif', 'width="21" height="16"') . ' class="c-inputButton" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc', 1) . '" alt="" />' .
+					'</a>';
+	
+					// Delete record
+				if($this->deleteButton) {
+					$buttons['deletedok'] = '<a href="#" onclick="' . htmlspecialchars('return deleteRecord(\'' . $eRParts[0] . '\',\'' . $eRParts[1] . '\',\'' . t3lib_div::getIndpEnv('SCRIPT_NAME') . '?id=' . $this->id . '\');') . '">' .
+						'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/deletedok.gif','width="21" height="16"') . ' class="c-inputButton" title="' . $LANG->getLL('deleteItem', 1) . '" alt="" />' .
+						'</a>';
+				}
+					
+				if($this->undoButton) {		
+						// Undo button
+					$buttons['undo'] = '<a href="#" onclick="' . htmlspecialchars('window.location.href=\'' . $BACK_PATH . 'show_rechis.php?element=' . rawurlencode($eRParts[0] . ':' . $eRParts[1]) . '&revert=ALL_FIELDS&sumUp=-1&returnUrl=' . rawurlencode($this->R_URI) . '\'; return false;') . '">' .
+						'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/undo.gif', 'width="21" height="16"') . ' class="c-inputButton" title="' . htmlspecialchars(sprintf($LANG->getLL('undoLastChange'), t3lib_BEfunc::calcAge(time() - $this->undoButtonR['tstamp'], $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))) . '" alt="" />' .
+						'</a>';
+					
+						// History button
+					$buttons['history_record'] = '<a href="#" onclick="' . htmlspecialchars('jumpToUrl(\'' . $BACK_PATH . 'show_rechis.php?element=' . rawurlencode($eRParts[0] . ':' . $eRParts[1]) . '&returnUrl=' . rawurlencode($this->R_URI) . '#latest\');return false;') . '">' .
+						'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/history2.gif', 'width="13" height="12"') . ' class="c-inputButton" title="' . $LANG->getLL('recordHistory', 1) . '" alt="" />' .
+						'</a>';
+				}
+			}
+		}
+		
+		return $buttons;
+	}
+	
+	/**
+	 * Generate the page path for docheader
+	 *
+	 * @return	string	Page path
+	 */
+	function getPagePath() {
+		global $LANG;
+		
+		if ($this->id)	{	// If there IS a real page...:
+
+				// Setting the path of the page
+			$pagePath = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path', 1) . ': <strong>' . htmlspecialchars(t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'], -50)) . '</strong>';
+			
+		}
+		
+		return $pagePath;
+	}
+	
+	/**
+	 * Setting title of page + icon with clickmenu + uid for docheader
+	 *
+	 * @return	string	Page info
+	 */
+	function getPageInfo() {
+		global $LANG, $BACK_PATH;
+		
+		$alttext = t3lib_BEfunc::getRecordIconAltText($this->pageinfo, 'pages');
+		$iconImg = t3lib_iconWorks::getIconImage('pages', $this->pageinfo, $BACK_PATH, 'class="absmiddle" title="'. htmlspecialchars($alttext) . '"');
+		
+				// Add icon with clickmenu, etc:
+		if ($this->id)	{	// If there IS a real page...:
+				// Make Icon:
+			$theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, 'pages', $this->id);
+						
+				// Setting title of page + icon with clickmenu + uid
+			$pageInfo = $LANG->getLL('viewContent', 1) . $theIcon . '<strong>' . htmlspecialchars($this->pageinfo['title']) . '</strong> <em>[pid: ' . $this->pageinfo['uid'] . ']</em>';
+			
+					
+		} else {	// On root-level of page tree:
+				// Make Icon:
+			$theIcon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/i/_icon_website.gif', 'width="18" height="16"') . ' alt="" />';
+			
+				// Setting title of root (sitename):
+			$pageInfo = $LANG->getLL('viewContent', 1) . $theIcon . '<strong>' . htmlspecialchars(t3lib_div::fixed_lgd_cs($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], -50)) . '</strong>';
+		}
+		
+		return $pageInfo;
+	}
+
 	/*******************************
 	 *
 	 * Other functions
Index: typo3/sysext/cms/layout/locallang.xml
===================================================================
--- typo3/sysext/cms/layout/locallang.xml	(revision 2980)
+++ typo3/sysext/cms/layout/locallang.xml	(working copy)
@@ -48,6 +48,7 @@
 			<label index="noAccess_msg">You do not have access to edit the requested record.</label>
 			<label index="undoLastChange">Undo/Redo last change (%s ago)</label>
 			<label index="recordHistory">View record change history</label>
+			<label index="viewContent">Viewing content of</label>
 			<label index="tt_board_subject">Subject</label>
 			<label index="tt_board_author">Author</label>
 			<label index="tt_board_date">Date</label>
Index: typo3/sysext/lang/locallang_mod_web_list.xml
===================================================================
--- typo3/sysext/lang/locallang_mod_web_list.xml	(revision 2980)
+++ typo3/sysext/lang/locallang_mod_web_list.xml	(working copy)
@@ -50,6 +50,7 @@
 			<label index="defaultLanguage">Default</label>
 			<label index="multipleLanguages">All languages</label>
 			<label index="Localize">Localize to:</label>
+			<label index="viewRecords">Viewing records of</label>
 		</languageKey>
 	</data>
 </T3locallang>
\ No newline at end of file
Index: typo3/sysext/t3skin/stylesheets/typo3-TCEforms.css
===================================================================
--- typo3/sysext/t3skin/stylesheets/typo3-TCEforms.css	(revision 2980)
+++ typo3/sysext/t3skin/stylesheets/typo3-TCEforms.css	(working copy)
@@ -24,7 +24,7 @@
 
 table#typo3-altdoc-header input,
 .c-inputButton {
-	background: #EFEFF4;
+	background: transparent;
 	border: 0;
 }
 
@@ -37,7 +37,7 @@
 
 table.typo3-TCEforms table#typo3-altdoc-header input:hover,
 .c-inputButton:hover {
-	background: #F8F9FA;
+	background: transparent;
 	border: 0;
 }
 
Index: typo3/sysext/tstemplate/ts/index.php
===================================================================
--- typo3/sysext/tstemplate/ts/index.php	(revision 2980)
+++ typo3/sysext/tstemplate/ts/index.php	(working copy)
@@ -40,10 +40,11 @@
 require ("conf.php");
 require ($BACK_PATH."init.php");
 require ($BACK_PATH."template.php");
+$LANG->includeLLFile('EXT:tstemplate/ts/locallang.xml');
 require_once (PATH_t3lib."class.t3lib_page.php");
 require_once (PATH_t3lib."class.t3lib_tstemplate.php");
 require_once (PATH_t3lib."class.t3lib_tsparser_ext.php");
-
+require_once (PATH_t3lib.'class.t3lib_parsehtml.php');
 require_once (PATH_t3lib."class.t3lib_scbase.php");
 
 $BE_USER->modAccess($MCONF,1);
@@ -92,12 +93,15 @@
 
 		// Access check...
 		// The page will show only if there is a valid page and if this page may be viewed by the user
-		$pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
-		$access = is_array($pageinfo) ? 1 : 0;
+		$this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
+		$access = is_array($this->pageinfo) ? 1 : 0;
 
 		if ($this->id && $access)	{
 			$this->doc = t3lib_div::makeInstance("template");
+			$this->template = $this->doc->getHtmlTemplate($BACK_PATH . 'templates/tstemplate.html');
+			$this->doc->divClass = 'typo3-fullDoc';
 			$this->doc->backPath = $BACK_PATH;
+			$this->doc->inDocStylesArray[] = 'html { overflow: hidden; }';
 
 
 				// JavaScript
@@ -107,6 +111,14 @@
 			function jumpToUrl(URL)	{
 				window.location.href = URL;
 			}
+			// workaround since IE6 cannot deal with relative height for scrolling elements
+			function resizeDocBody()	{
+				$("typo3-docbody").style.height = (document.body.offsetHeight - parseInt($("typo3-docheader").getStyle("height")));
+			}
+			if (/MSIE 6/.test(navigator.userAgent)) {
+				Event.observe(window, "resize", resizeDocBody, false);
+				Event.observe(document, "load", resizeDocBody, false);
+			}
 			function uFormUrl(aname)	{
 				document.forms[0].action = "index.php?id='.$this->id.'#"+aname;
 			}
@@ -147,27 +159,22 @@
 			$this->doc->getContextMenuCode();
 
 
-			$headerSection = $this->doc->getHeader("pages",$pageinfo,$pageinfo["_thePath"]).'<br>'.
+			$headerSection = $this->doc->getHeader("pages",$this->pageinfo,$this->pageinfo["_thePath"]).'<br>'.
 				$LANG->sL("LLL:EXT:lang/locallang_core.php:labels.path").': '.
-				'<span title="'.htmlspecialchars($pageinfo['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($pageinfo['_thePath'],-50)).'</span>';
+				'<span title="'.htmlspecialchars($this->pageinfo['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'],-50)).'</span>';
 
 				// Draw the header.
-			$this->doc->form='<form action="index.php?id='.$this->id.'" method="post" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'" name="editForm">';
 			$this->content.=$this->doc->startPage("Template Tools");
+			$this->content.= $this->compileHeader();
+			
+			$this->content.= '<div id="typo3-docbody">';
+			$this->content.= '<form action="index.php?id='.$this->id.'" method="post" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'" name="editForm">';
 			$this->content.=$this->doc->header("Template Tools");
-			$this->content.=$this->doc->spacer(5);
-			$this->content.=$this->doc->section('',$this->doc->funcMenu($headerSection,t3lib_BEfunc::getFuncMenu($this->id,"SET[function]",$this->MOD_SETTINGS["function"],$this->MOD_MENU["function"])));
-
-
 			$this->extObjContent();
 
-
-
-			// ShortCut
-			if ($BE_USER->mayMakeShortcut())	{
-				$this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon("id,e,sObj,template","function,ts_browser_type,constant_editor_cat",$this->MCONF["name"]));
-			}
 			$this->content.=$this->doc->spacer(10);
+			$this->content.='
+						</form>';
 		} else {
 				// If no access or if ID == zero
 
@@ -175,7 +182,7 @@
 			$this->doc->backPath = $BACK_PATH;
 
 			$this->content.=$this->doc->startPage("Template Tools");
-			$this->content.=$this->doc->header("Template Tools");
+			$this->content.=$this->doc->header($LANG->getLL('moduleTitle', 1));
 			$this->content.=$this->doc->spacer(5);
 
 
@@ -215,7 +222,7 @@
 			This is an overview of the pages in the database containing one or more template records. Click a page title to go to the page.
 			<BR><BR>
 			'.$table);
-		//	debug($pArray);
+
 			// ********************************************
 			// RENDER LIST of pages with templates, END
 			// ********************************************
@@ -235,7 +242,133 @@
 		$this->content.=$this->doc->endPage();
 		echo $this->content;
 	}
+	
+	/**
+	 * Put together the various elements for the header using a static HTML
+	 * template
+	 *
+	 * @return	string		Composite HTML
+	 */
+	function compileHeader()	{
+		global $LANG;
 
+		$btns = $this->getButtons();
+		$content = t3lib_parsehtml::getSubpart($this->template, '###DOCHEADER###');
+
+		$markerArray = array();
+		$markerArray['PAGEPATH'] = $this->getPagePath();
+		$markerArray['PAGEINFO'] = $this->getPageInfo();
+		$markerArray['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu($this->id,"SET[function]",$this->MOD_SETTINGS["function"],$this->MOD_MENU["function"]);
+		
+
+			// -- compiling buttons --
+			// get button template, then loop through the buttons and replace them in the template
+		$btnTmpl = t3lib_parsehtml::getSubpart($this->template, '###BUTTON_GROUPS###');
+		$btnTmpl = t3lib_parsehtml::substituteMarkerArray($btnTmpl, $btns, '###|###', true);
+
+			// getting the wrap for each group
+		$btnWrap = t3lib_parsehtml::getSubpart($this->template, '###BUTTON_GROUP_WRAP###');
+
+			// looping through the groups (max 6) and remove the empty groups
+		$grpId = 1;
+		for ($grpNum = 1; $grpNum < 6; $grpNum++) {
+			$btnMarker = '###BUTTON_GROUP'.$grpNum.'###';
+			$btnGroup = t3lib_parsehtml::getSubpart($btnTmpl, $btnMarker);
+			if (trim($btnGroup)) {
+				if ($btnWrap) {
+					$btnGroup = t3lib_parsehtml::substituteMarker($btnWrap, '###BUTTONS###', $btnGroup);
+				}
+				$btnTmpl = t3lib_parsehtml::substituteSubpart($btnTmpl, $btnMarker, trim($btnGroup));
+			}
+		}
+
+			// replace the marker with the template and remove all line breaks (for IE compat)
+		$markerArray['BUTTONLIST'] = str_replace("\n", '', $btnTmpl);
+			// -- end compiling buttons
+
+			// replacing all markers with the finished markers and return the HTML content
+		return t3lib_parsehtml::substituteMarkerArray($content, $markerArray, '###|###');
+	}
+	
+	/**
+	 * Create the panel of buttons for submitting the form or otherwise perform operations.
+	 *
+	 * @param	string	Identifier for function of module
+	 * @param	array	Edit-record cmd value splitted into table/uid
+	 * @return	array	all available buttons as an assoc. array
+	 */
+	function getButtons()	{
+		global $TCA, $LANG, $BACK_PATH, $BE_USER;
+		
+		$buttons = array(
+			'view' => '',
+			'record_list' => '',
+			'shortcut' => '',
+		);
+
+			// View page
+		$buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->pageinfo['uid'], $BACK_PATH, t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '">' .
+				'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/zoom.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '" hspace="3" alt="" />' .
+				'</a>';
+
+			// Shortcut
+		if ($BE_USER->mayMakeShortcut())	{
+			$buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
+		}
+		
+			// If access to Web>List for user, then link to that module.
+		if ($BE_USER->check('modules','web_list'))	{
+			$href = $BACK_PATH . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
+			$buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '">' .
+					'<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/list.gif', 'width="11" height="11"') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', 1) . '" alt="" />' .
+					'</a>';
+		}
+		
+		return $buttons;
+	}
+	
+	/**
+	 * Generate the page path for docheader
+	 *
+	 * @return	string	Page path
+	 */
+	function getPagePath() {
+		global $LANG;
+		
+		if ($this->id)	{	// If there IS a real page...:
+
+				// Setting the path of the page
+			$pagePath = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path', 1) . ': <strong>' . htmlspecialchars(t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'], -50)) . '</strong>';
+			
+		}
+		
+		return $pagePath;
+	}
+	
+	/**
+	 * Setting title of page + icon with clickmenu + uid for docheader
+	 *
+	 * @return	string	Page info
+	 */
+	function getPageInfo() {
+		global $LANG, $BACK_PATH;
+		
+		$alttext = t3lib_BEfunc::getRecordIconAltText($this->pageinfo, 'pages');
+		$iconImg = t3lib_iconWorks::getIconImage('pages', $this->pageinfo, $BACK_PATH, 'class="absmiddle" title="'. htmlspecialchars($alttext) . '"');
+		
+				// Add icon with clickmenu, etc:
+		if ($this->id)	{	// If there IS a real page...:
+				// Make Icon:
+			$theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, 'pages', $this->id);
+						
+				// Setting title of page + icon with clickmenu + uid
+			$pageInfo = $LANG->getLL('viewTemplates', 1) . $theIcon . '<strong>' . htmlspecialchars($this->pageinfo['title']) . '</strong> <em>[pid: ' . $this->pageinfo['uid'] . ']</em>';
+								
+		}
+		
+		return $pageInfo;
+	}
+
 	// ***************************
 	// OTHER FUNCTIONS:
 	// ***************************
Index: typo3/sysext/tstemplate/ts/locallang.xml
===================================================================
--- typo3/sysext/tstemplate/ts/locallang.xml	(revision 0)
+++ typo3/sysext/tstemplate/ts/locallang.xml	(revision 0)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+	<meta type="array">
+		<description>Labels for the Web&gt;Template module</description>
+		<type>module</type>
+	</meta>
+	<data type="array">
+		<languageKey index="default" type="array">
+			<label index="moduleTitle">Template tools</label>
+			<label index="viewTemplates">Viewing templates of</label>moduleTitle
+		</languageKey>
+	</data>
+</T3locallang>
\ No newline at end of file
Index: typo3/template.php
===================================================================
--- typo3/template.php	(revision 2980)
+++ typo3/template.php	(working copy)
@@ -1805,10 +1805,26 @@
 			}
 		}
 	}
+
+
+	/**
+	 * Function to load a HTML template file with markers. Can be overriden with  
+	 * 
+	 * @param	string		tmpl name, usually in the typo3/template/ directory, can be overriden by 
+	 * @param	string		Default width/height, defined like 'width="12" height="14"'
+	 * @param	integer		Mode: 0 (zero) is default and returns src/width/height. 1 returns value of src+backpath, 2 returns value of w/h.
+	 * @return	string		Returns ' src="[backPath][src]" [wHattribs]'
+	 * @see skinImgFile()
+	 */
+	function getHtmlTemplate($filename)	{
+		if ($GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]) {
+			$filename = $GLOBALS['TBE_STYLES']['htmlTemplates'][$filename];
+		}
+		return ($filename ? t3lib_div::getURL($this->backPath.$filename) : '');
+	}
 }
 
 
-
 // ******************************
 // Extension classes of the template class.
 // These are meant to provide backend screens with different widths.
Index: typo3/templates/db_list.html
===================================================================
--- typo3/templates/db_list.html	(revision 0)
+++ typo3/templates/db_list.html	(revision 0)
@@ -0,0 +1,29 @@
+<!-- ###DOCHEADER### -->
+	<!-- Page header with buttons for saving & closing and path details -->
+	<div id="typo3-docheader">
+		<div id="typo3-docheader-row1">
+			<div class="buttonsleft">###BUTTONLIST###</div>
+		</div>
+		<div id="typo3-docheader-row2">
+			<div class="pagepath">###PAGEPATH###</div>
+			<div class="infooptions">###PAGEINFO###</div>
+		</div>
+	</div>
+<!-- ###DOCHEADER### -->
+
+
+<!-- Grouping the icons on top -->
+
+<!-- ###BUTTON_GROUP_WRAP### -->
+	<div class="buttongroup">###BUTTONS###</div>
+<!-- ###BUTTON_GROUP_WRAP### -->
+
+<!-- ###BUTTON_GROUPS### -->
+<!-- ###BUTTON_GROUP1### -->###CSH###<!-- ###BUTTON_GROUP1### -->
+<!-- ###BUTTON_GROUP2### -->###VIEW######EDIT######HIDE_UNHIDE######MOVE###<!-- ###BUTTON_GROUP2### -->
+<!-- ###BUTTON_GROUP3### -->###NEW_RECORD######PASTE###<!-- ###BUTTON_GROUP3### -->
+<!-- ###BUTTON_GROUP4### -->###LEVEL_UP######BACK###<!-- ###BUTTON_GROUP4### -->
+<!-- ###BUTTON_GROUP5### -->###CACHE######RELOAD######SHORTCUT###<!-- ###BUTTON_GROUP5### -->
+<!-- ###BUTTON_GROUP6### -->###CSV######EXPORT###<!-- ###BUTTON_GROUP6### -->
+<!-- ###BUTTON_GROUPS### -->
+
Index: typo3/templates/db_layout.html
===================================================================
--- typo3/templates/db_layout.html	(revision 0)
+++ typo3/templates/db_layout.html	(revision 0)
@@ -0,0 +1,33 @@
+<!-- ###DOCHEADER### -->
+	<!-- Page header with buttons for saving & closing and path details -->
+	<div id="typo3-docheader">
+		<div id="typo3-docheader-row1">
+			<div class="buttonsleft">###BUTTONLIST###</div>
+			<div class="buttonsright">###TOP_FUNCTION_MENU###</div>
+		</div>
+		<div id="typo3-docheader-row2">
+			<div class="pagepath">###PAGEPATH###</div>
+			<div class="infooptions">###PAGEINFO###</div>
+		</div>
+	</div>
+<!-- ###DOCHEADER### -->
+
+<!-- Grouping the icons on top -->
+
+<!-- ###BUTTON_GROUP_WRAP### -->
+	<div class="buttongroup">###BUTTONS###</div>
+<!-- ###BUTTON_GROUP_WRAP### -->
+
+<!-- ###BUTTON_GROUPS_DEFAULT### -->
+<!-- ###BUTTON_GROUP1### -->###CSH###<!-- ###BUTTON_GROUP1### -->
+<!-- ###BUTTON_GROUP2### -->###VIEW######RECORD_LIST######HISTORY_PAGE######MOVE_PAGE######NEW_PAGE######EDIT_PAGE######SHORTCUT######CACHE###<!-- ###BUTTON_GROUP2### -->
+<!-- ###BUTTON_GROUP3### -->###NEW_CONTENT###<!-- ###BUTTON_GROUP3### -->
+<!-- ###BUTTON_GROUPS_DEFAULT### -->
+
+<!-- ###BUTTON_GROUPS_QUICKEDIT### -->
+<!-- ###BUTTON_GROUP1### -->###CSH###<!-- ###BUTTON_GROUP1### -->
+<!-- ###BUTTON_GROUP2### -->###VIEW######RECORD_LIST######MOVE_RECORD######NEW_PAGE######EDIT_PAGE######SHORTCUT###<!-- ###BUTTON_GROUP2### -->
+<!-- ###BUTTON_GROUP3### -->###NEW_CONTENT###<!-- ###BUTTON_GROUP3### -->
+<!-- ###BUTTON_GROUP4### -->###SAVEDOK######SAVEDOKSHOW######CLOSEDOK######DELETEDOK######UNDO######HISTORY_RECORD###<!-- ###BUTTON_GROUP4### -->
+<!-- ###BUTTON_GROUPS_QUICKEDIT### -->
+
Index: typo3/templates/tstemplate.html
===================================================================
--- typo3/templates/tstemplate.html	(revision 0)
+++ typo3/templates/tstemplate.html	(revision 0)
@@ -0,0 +1,27 @@
+<!-- ###DOCHEADER### -->
+	<!-- Page header with buttons for saving & closing and path details -->
+	<div id="typo3-docheader">
+		<div id="typo3-docheader-row1">
+			<div class="buttonsleft">###BUTTONLIST###</div>
+			<div class="buttonsright">###FUNC_MENU###</div>
+		</div>
+		<div id="typo3-docheader-row2">
+			<div class="pagepath">###PAGEPATH###</div>
+			<div class="infooptions">###PAGEINFO###</div>
+		</div>
+	</div>
+<!-- ###DOCHEADER### -->
+
+
+<!-- Grouping the icons on top -->
+
+<!-- ###BUTTON_GROUP_WRAP### -->
+	<div class="buttongroup">###BUTTONS###</div>
+<!-- ###BUTTON_GROUP_WRAP### -->
+
+<!-- ###BUTTON_GROUPS### -->
+<!-- ###BUTTON_GROUP1### -->###VIEW###<!-- ###BUTTON_GROUP1### -->
+<!-- ###BUTTON_GROUP2### -->###RECORD_LIST###<!-- ###BUTTON_GROUP2### -->
+<!-- ###BUTTON_GROUP3### -->###SHORTCUT###<!-- ###BUTTON_GROUP3### -->
+<!-- ###BUTTON_GROUPS### -->
+
Index: typo3/templates/alt_doc.html
===================================================================
--- typo3/templates/alt_doc.html	(revision 0)
+++ typo3/templates/alt_doc.html	(revision 0)
@@ -0,0 +1,37 @@
+<!-- ###DOCHEADER### -->
+	<!-- Page header with buttons for saving & closing and path details -->
+	<div id="typo3-docheader">
+		<div id="typo3-docheader-row1">
+			<div class="buttonsleft">###BUTTONLIST###</div>
+			<div class="buttonsright">###DOCUMENT_SELECTOR### ###CACHE_MENU###</div>
+		</div>
+		<div id="typo3-docheader-row2">
+			<div class="pagepath">###PAGEPATH###</div>
+			<div class="infooptions">###LANGSELECTOR###</div>
+		</div>
+		###EXTRAHEADER###
+	</div>
+<!-- ###DOCHEADER### -->
+
+<!-- ###DOCHEADER_EXTRAHEADER### -->
+		<div id="typo3-docheader-rowextra">###EXTRAHEADER###</div>
+<!-- ###DOCHEADER_EXTRAHEADER### -->
+
+<!-- ###DOCHEADER_LANGSELECTOR### -->
+<div class="langselector">###LANGSELECTOR###</div>
+<!-- ###DOCHEADER_LANGSELECTOR### -->
+
+
+<!-- Grouping the icons on top -->
+
+<!-- ###BUTTON_GROUP_WRAP### -->
+	<div class="buttongroup">###BUTTONS###</div>
+<!-- ###BUTTON_GROUP_WRAP### -->
+
+<!-- ###BUTTON_GROUPS### -->
+<!-- ###BUTTON_GROUP1### -->###CLOSE###<!-- ###BUTTON_GROUP1### -->
+<!-- ###BUTTON_GROUP2### -->###SAVE######SAVE_VIEW######SAVE_CLOSE######SAVE_NEW###<!-- ###BUTTON_GROUP2### -->
+<!-- ###BUTTON_GROUP3### -->###DELETE######UNDO######HISTORY###<!-- ###BUTTON_GROUP3### -->
+<!-- ###BUTTON_GROUP4### -->###SHORTCUT######COLUMNS_ONLY######OPEN_IN_NEW_WINDOW###<!-- ###BUTTON_GROUP4### -->
+<!-- ###BUTTON_GROUPS### -->
+
Index: typo3/templates/alt_doc.html
===================================================================
--- typo3/templates/alt_doc.html	(revision 0)
+++ typo3/templates/alt_doc.html	(revision 0)
@@ -0,0 +1,37 @@
+<!-- ###DOCHEADER### -->
+	<!-- Page header with buttons for saving & closing and path details -->
+	<div id="typo3-docheader">
+		<div id="typo3-docheader-row1">
+			<div class="buttonsleft">###BUTTONLIST###</div>
+			<div class="buttonsright">###DOCUMENT_SELECTOR### ###CACHE_MENU###</div>
+		</div>
+		<div id="typo3-docheader-row2">
+			<div class="pagepath">###PAGEPATH###</div>
+			<div class="infooptions">###LANGSELECTOR###</div>
+		</div>
+		###EXTRAHEADER###
+	</div>
+<!-- ###DOCHEADER### -->
+
+<!-- ###DOCHEADER_EXTRAHEADER### -->
+		<div id="typo3-docheader-rowextra">###EXTRAHEADER###</div>
+<!-- ###DOCHEADER_EXTRAHEADER### -->
+
+<!-- ###DOCHEADER_LANGSELECTOR### -->
+<div class="langselector">###LANGSELECTOR###</div>
+<!-- ###DOCHEADER_LANGSELECTOR### -->
+
+
+<!-- Grouping the icons on top -->
+
+<!-- ###BUTTON_GROUP_WRAP### -->
+	<div class="buttongroup">###BUTTONS###</div>
+<!-- ###BUTTON_GROUP_WRAP### -->
+
+<!-- ###BUTTON_GROUPS### -->
+<!-- ###BUTTON_GROUP1### -->###CLOSE###<!-- ###BUTTON_GROUP1### -->
+<!-- ###BUTTON_GROUP2### -->###SAVE######SAVE_VIEW######SAVE_CLOSE######SAVE_NEW###<!-- ###BUTTON_GROUP2### -->
+<!-- ###BUTTON_GROUP3### -->###DELETE######UNDO######HISTORY###<!-- ###BUTTON_GROUP3### -->
+<!-- ###BUTTON_GROUP4### -->###SHORTCUT######COLUMNS_ONLY######OPEN_IN_NEW_WINDOW###<!-- ###BUTTON_GROUP4### -->
+<!-- ###BUTTON_GROUPS### -->
+
Index: typo3/templates/db_layout.html
===================================================================
--- typo3/templates/db_layout.html	(revision 0)
+++ typo3/templates/db_layout.html	(revision 0)
@@ -0,0 +1,33 @@
+<!-- ###DOCHEADER### -->
+	<!-- Page header with buttons for saving & closing and path details -->
+	<div id="typo3-docheader">
+		<div id="typo3-docheader-row1">
+			<div class="buttonsleft">###BUTTONLIST###</div>
+			<div class="buttonsright">###TOP_FUNCTION_MENU###</div>
+		</div>
+		<div id="typo3-docheader-row2">
+			<div class="pagepath">###PAGEPATH###</div>
+			<div class="infooptions">###PAGEINFO###</div>
+		</div>
+	</div>
+<!-- ###DOCHEADER### -->
+
+<!-- Grouping the icons on top -->
+
+<!-- ###BUTTON_GROUP_WRAP### -->
+	<div class="buttongroup">###BUTTONS###</div>
+<!-- ###BUTTON_GROUP_WRAP### -->
+
+<!-- ###BUTTON_GROUPS_DEFAULT### -->
+<!-- ###BUTTON_GROUP1### -->###CSH###<!-- ###BUTTON_GROUP1### -->
+<!-- ###BUTTON_GROUP2### -->###VIEW######RECORD_LIST######HISTORY_PAGE######MOVE_PAGE######NEW_PAGE######EDIT_PAGE######SHORTCUT######CACHE###<!-- ###BUTTON_GROUP2### -->
+<!-- ###BUTTON_GROUP3### -->###NEW_CONTENT###<!-- ###BUTTON_GROUP3### -->
+<!-- ###BUTTON_GROUPS_DEFAULT### -->
+
+<!-- ###BUTTON_GROUPS_QUICKEDIT### -->
+<!-- ###BUTTON_GROUP1### -->###CSH###<!-- ###BUTTON_GROUP1### -->
+<!-- ###BUTTON_GROUP2### -->###VIEW######RECORD_LIST######MOVE_RECORD######NEW_PAGE######EDIT_PAGE######SHORTCUT###<!-- ###BUTTON_GROUP2### -->
+<!-- ###BUTTON_GROUP3### -->###NEW_CONTENT###<!-- ###BUTTON_GROUP3### -->
+<!-- ###BUTTON_GROUP4### -->###SAVEDOK######SAVEDOKSHOW######CLOSEDOK######DELETEDOK######UNDO######HISTORY_RECORD###<!-- ###BUTTON_GROUP4### -->
+<!-- ###BUTTON_GROUPS_QUICKEDIT### -->
+
Index: typo3/templates/db_list.html
===================================================================
--- typo3/templates/db_list.html	(revision 0)
+++ typo3/templates/db_list.html	(revision 0)
@@ -0,0 +1,29 @@
+<!-- ###DOCHEADER### -->
+	<!-- Page header with buttons for saving & closing and path details -->
+	<div id="typo3-docheader">
+		<div id="typo3-docheader-row1">
+			<div class="buttonsleft">###BUTTONLIST###</div>
+		</div>
+		<div id="typo3-docheader-row2">
+			<div class="pagepath">###PAGEPATH###</div>
+			<div class="infooptions">###PAGEINFO###</div>
+		</div>
+	</div>
+<!-- ###DOCHEADER### -->
+
+
+<!-- Grouping the icons on top -->
+
+<!-- ###BUTTON_GROUP_WRAP### -->
+	<div class="buttongroup">###BUTTONS###</div>
+<!-- ###BUTTON_GROUP_WRAP### -->
+
+<!-- ###BUTTON_GROUPS### -->
+<!-- ###BUTTON_GROUP1### -->###CSH###<!-- ###BUTTON_GROUP1### -->
+<!-- ###BUTTON_GROUP2### -->###VIEW######EDIT######HIDE_UNHIDE######MOVE###<!-- ###BUTTON_GROUP2### -->
+<!-- ###BUTTON_GROUP3### -->###NEW_RECORD######PASTE###<!-- ###BUTTON_GROUP3### -->
+<!-- ###BUTTON_GROUP4### -->###LEVEL_UP######BACK###<!-- ###BUTTON_GROUP4### -->
+<!-- ###BUTTON_GROUP5### -->###CACHE######RELOAD######SHORTCUT###<!-- ###BUTTON_GROUP5### -->
+<!-- ###BUTTON_GROUP6### -->###CSV######EXPORT###<!-- ###BUTTON_GROUP6### -->
+<!-- ###BUTTON_GROUPS### -->
+
Index: typo3/templates/tstemplate.html
===================================================================
--- typo3/templates/tstemplate.html	(revision 0)
+++ typo3/templates/tstemplate.html	(revision 0)
@@ -0,0 +1,27 @@
+<!-- ###DOCHEADER### -->
+	<!-- Page header with buttons for saving & closing and path details -->
+	<div id="typo3-docheader">
+		<div id="typo3-docheader-row1">
+			<div class="buttonsleft">###BUTTONLIST###</div>
+			<div class="buttonsright">###FUNC_MENU###</div>
+		</div>
+		<div id="typo3-docheader-row2">
+			<div class="pagepath">###PAGEPATH###</div>
+			<div class="infooptions">###PAGEINFO###</div>
+		</div>
+	</div>
+<!-- ###DOCHEADER### -->
+
+
+<!-- Grouping the icons on top -->
+
+<!-- ###BUTTON_GROUP_WRAP### -->
+	<div class="buttongroup">###BUTTONS###</div>
+<!-- ###BUTTON_GROUP_WRAP### -->
+
+<!-- ###BUTTON_GROUPS### -->
+<!-- ###BUTTON_GROUP1### -->###VIEW###<!-- ###BUTTON_GROUP1### -->
+<!-- ###BUTTON_GROUP2### -->###RECORD_LIST###<!-- ###BUTTON_GROUP2### -->
+<!-- ###BUTTON_GROUP3### -->###SHORTCUT###<!-- ###BUTTON_GROUP3### -->
+<!-- ###BUTTON_GROUPS### -->
+
