Index: typo3/stylesheet.css
===================================================================
--- typo3/stylesheet.css	(revision 6446)
+++ typo3/stylesheet.css	(working copy)
@@ -2989,13 +2989,19 @@
 }
 
 
-/* Visual debugging: */
+/*** Visual debugging: ***/
+/* view_array */
+.view_array-array {
+	border-right: 1px solid black;
+	border-top: 1px solid black;
+}
 
-/*
-h2,
-h3,
-h4,
-div {
-	border: 1px dotted #666;
+.view_array-array td {
+	border-bottom: 1px solid black;
+	border-left: 1px solid black;
+	padding: 2px;
+}
+
+.view_array-key {
+	font-weight: bold;
 }
-*/
Index: typo3/sysext/cms/tslib/class.tslib_fe.php
===================================================================
--- typo3/sysext/cms/tslib/class.tslib_fe.php	(revision 6446)
+++ typo3/sysext/cms/tslib/class.tslib_fe.php	(working copy)
@@ -3401,6 +3401,37 @@
 			$this->contentStrReplace();
 		}
 
+			// get the flash messages, which are sent by extension
+		$flashMessages = t3lib_FlashMessageQueue::renderFlashMessages();
+		if (!empty($flashMessages)) {
+			$flashMessages = '<div id="typo3-messages">' . $flashMessages . '</div>';
+		}
+			// add CSS needed by 
+		if (!empty($flashMessages)) {
+			$style .= '	<style type="text/css">
+				/* Flash Messages */
+				#typo3-messages { margin-bottom: 10px; }
+				.typo3-message { padding: 6px; padding-left: 26px; margin-bottom: 4px; background-repeat: no-repeat; background-position: 4px 4px; border: 1px solid; }
+				.typo3-message a { text-decoration: underline; }
+				.typo3-message ul, .typo3-message ol { padding-left: 16px; }
+				.typo3-message .message-header { display: block; margin-bottom: 5px; margin-top: -1px; font-size: 11px; font-weight: bold; }
+				.message-notice { background-image: url(/'.TYPO3_mainDir.'gfx/notice.png); background-color: #f6f7fa; border-color: #c2cbcf; }
+				.message-information { background-image: url(/'.TYPO3_mainDir.'gfx/information.png); background-color: #ddeef9; border-color: #8aafc4; }
+				.message-ok { background-image: url(/'.TYPO3_mainDir.'gfx/ok.png); background-color: #cdeaca; border-color: #58b548; }
+				.message-warning { background-image: url(/'.TYPO3_mainDir.'gfx/warning.png); background-color: #fbffb3; border-color: #c4b70d; }
+				.message-error { background-image: url(/'.TYPO3_mainDir.'gfx/error.png); background-color: #fbb19b; border-color: #dc4c42; }
+				.view_array-array { border-right: 1px solid black; border-top: 1px solid black; }
+				.view_array-array td { border-bottom: 1px solid black; border-left: 1px solid black; padding: 2px; }
+				.view_array-key { font-weight: bold; }
+				</style>';
+				
+				// need to use replace to inject style needed by flash messages
+			$this->content = str_replace('</head>', $style.'</head>', $this->content);
+		}		
+			// need to search for body tag and inject the flash messages right after the body tag
+		preg_match('/(<(body)[^>]*>)/',$this->content,$matches);
+		$this->content = str_replace($matches[0],$matches[0].$flashMessages,$this->content);
+		
 			// Tidy up the code, if flag...
 		if ($this->TYPO3_CONF_VARS['FE']['tidy_option'] == 'output') {
 			$GLOBALS['TT']->push('Tidy, output','');
Index: typo3/template.php
===================================================================
--- typo3/template.php	(revision 6446)
+++ typo3/template.php	(working copy)
@@ -747,7 +747,15 @@
 
 			// Construct page header.
 		$str = $this->pageRenderer->render(t3lib_PageRenderer::PART_HEADER);
-
+		
+		if ($this->pageRenderer->getShowFlashMessages() && $this->showFlashMessages) {
+				// render flashmessages for old modules
+			$flashMessages = t3lib_FlashMessageQueue::renderFlashMessages();
+			if (!empty($flashMessages)) {
+				$str .= '<div id="typo3-messages">' . $flashMessages . '</div>';
+			}
+		}
+		
 		$this->JScodeLibArray = array();
 		$this->JScode = $this->extJScode = '';
 		$this->JScodeArray = array();
@@ -793,7 +801,13 @@
 
 			// Logging: Can't find better place to put it:
 		if (TYPO3_DLOG)	t3lib_div::devLog('END of BACKEND session', 'template', 0, array('_FLUSH' => true));
-
+		
+		if ($this->showFlashMessages) {
+			$flashMessages = t3lib_FlashMessageQueue::renderFlashMessages();
+			if (!empty($flashMessages)) {
+				$str= '<div id="typo3-messages">' . $flashMessages . '</div>' . $this->bodyContent;
+			}
+		}
 		return $str;
 	}
 
@@ -1856,6 +1870,7 @@
 	function setModuleTemplate($filename) {
 			// Load Prototype lib for IE event
 		$this->pageRenderer->loadPrototype();
+		$this->pageRenderer->setShowFlashMessages(FALSE);
 		$this->loadJavascriptLib('js/iecompatibility.js');
 		$this->moduleTemplate = $this->getHtmlTemplate($filename);
 	}
Index: t3lib/class.t3lib_pagerenderer.php
===================================================================
--- t3lib/class.t3lib_pagerenderer.php	(revision 6446)
+++ t3lib/class.t3lib_pagerenderer.php	(working copy)
@@ -80,7 +80,8 @@
 	protected $cssInline = array ();
 
 	protected $bodyContent;
-
+	protected $showFlashMessages = TRUE;
+	
 	protected $templateFile;
 
 	protected $jsLibraryNames = array ('prototype', 'scriptaculous', 'extjs');
@@ -282,6 +283,16 @@
 		$this->bodyContent = $content;
 	}
 
+	/**
+	 * Sets Flag showFlashMessages (set to FALSE supress flashmessages
+	 *
+	 * @param boolean $showFlashMessages
+	 * @return void
+	 */
+	public function setShowFlashMessages($showFlashMessages) {
+		$this->showFlashMessages = $showFlashMessages;
+	}
+	
 	/*****************************************************/
 	/*                                                   */
 	/*  Public Enablers                                  */
@@ -472,6 +483,15 @@
 		return $this->bodyContent;
 	}
 
+	/**
+	 * Gets Flag showFlashMessages
+	 *
+	 * @return boolean
+	 */
+	public function getShowFlashMessages() {
+		return $this->showFlashMessages;
+	}
+	
 	/*****************************************************/
 	/*                                                   */
 	/*  Public Function to add Data                      */
@@ -1077,7 +1097,14 @@
 			$jsFooterInline = $jsInline . chr(10) . $jsFooterInline;
 			$jsInline = '';
 		}
-
+		
+		if ($this->showFlashMessages) {
+			$flashMessages = t3lib_FlashMessageQueue::renderFlashMessages();
+			if (!empty($flashMessages)) {
+				$this->bodyContent = '<div id="typo3-messages">' . $flashMessages . '</div>' . $this->bodyContent;
+			}
+		}
+		
 		$markerArray = array(
 			'XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType,
 			'HTMLTAG'           => $this->htmlTag,
Index: t3lib/class.t3lib_div.php
===================================================================
--- t3lib/class.t3lib_div.php	(revision 6446)
+++ t3lib/class.t3lib_div.php	(working copy)
@@ -3390,14 +3390,15 @@
 	public static function view_array($array_in)	{
 		if (is_array($array_in))	{
 			$result='
-			<table border="1" cellpadding="1" cellspacing="0" bgcolor="white">';
+			<table cellpadding="1" cellspacing="0" class="view_array-array">';
 			if (count($array_in) == 0)	{
-				$result.= '<tr><td><font face="Verdana,Arial" size="1"><b>EMPTY!</b></font></td></tr>';
+				$result.= '<tr><td class="view_array-string">EMPTY!</td></tr>';
 			} else	{
+				$i = 0;
 				foreach ($array_in as $key => $val)	{
-					$result.= '<tr>
-						<td valign="top"><font face="Verdana,Arial" size="1">'.htmlspecialchars((string)$key).'</font></td>
-						<td>';
+					$result.= '<tr class="view_array-row view_array-row'. ($i%2 ? 'Even':'Odd') .'">
+						<td valign="top" class="view_array-key">'.htmlspecialchars((string)$key).'</td>
+						<td class="view_array-value">';
 					if (is_array($val))	{
 						$result.=t3lib_div::view_array($val);
 					} elseif (is_object($val))	{
@@ -3405,24 +3406,25 @@
 						if (method_exists($val, '__toString'))	{
 							$string .= ': '.(string)$val;
 						}
-						$result .= '<font face="Verdana,Arial" size="1" color="red">'.nl2br(htmlspecialchars($string)).'<br /></font>';
+						$result .= nl2br(htmlspecialchars($string)).'<br />';
 					} else	{
 						if (gettype($val) == 'object')	{
 							$string = 'Unknown object';
 						} else	{
 							$string = (string)$val;
 						}
-						$result.= '<font face="Verdana,Arial" size="1" color="red">'.nl2br(htmlspecialchars($string)).'<br /></font>';
+						$result.= nl2br(htmlspecialchars($string)).'<br />';
 					}
 					$result.= '</td>
 					</tr>';
+					$i++;
 				}
 			}
 			$result.= '</table>';
 		} else {
-			$result  = '<table border="1" cellpadding="1" cellspacing="0" bgcolor="white">
+			$result  = '<table cellpadding="1" cellspacing="0" class="view_array-string">
 				<tr>
-					<td><font face="Verdana,Arial" size="1" color="red">'.nl2br(htmlspecialchars((string)$array_in)).'<br /></font></td>
+					<td>'.nl2br(htmlspecialchars((string)$array_in)).'<br /></td>
 				</tr>
 			</table>';	// Output it as a string.
 		}
@@ -3453,34 +3455,27 @@
 	 * @return	void
 	 */
 	public static function debug($var='',$brOrHeader=0)	{
-			// buffer the output of debug if no buffering started before
-		if (ob_get_level()==0) {
-			ob_start();
-		}
-
-		if ($brOrHeader && !t3lib_div::testInt($brOrHeader))	{
-			echo '<table class="typo3-debug" border="0" cellpadding="0" cellspacing="0" bgcolor="white" style="border:0px; margin-top:3px; margin-bottom:3px;"><tr><td style="background-color:#bbbbbb; font-family: verdana,arial; font-weight: bold; font-size: 10px;">'.htmlspecialchars((string)$brOrHeader).'</td></tr><tr><td>';
-		} elseif ($brOrHeader<0)	{
-			for($a=0;$a<abs(intval($brOrHeader));$a++){echo '<br />';}
-		}
-
+		//flashMessage
+		$message = '';
 		if (is_array($var))	{
-			t3lib_div::print_array($var);
+			$message .= t3lib_div::view_array($var);
 		} elseif (is_object($var))	{
-			echo '<b>|Object:<pre>';
-			print_r($var);
-			echo '</pre>|</b>';
+			$message .= '<b>|Object:<pre>';
+			$message .= print_r($var, TRUE);
+			$message .= '</pre>|</b>';
 		} elseif ((string)$var!='')	{
-			echo '<b>|'.htmlspecialchars((string)$var).'|</b>';
+			$message .= '<b>|'.htmlspecialchars((string)$var).'|</b>';
 		} else {
-			echo '<b>| debug |</b>';
+			$message .='<b>| debug |</b>';
 		}
-
-		if ($brOrHeader && !t3lib_div::testInt($brOrHeader))	{
-			echo '</td></tr></table>';
-		} elseif ($brOrHeader>0)	{
-			for($a=0;$a<intval($brOrHeader);$a++){echo '<br />';}
-		}
+		
+		$flashMessage = t3lib_div::makeInstance(
+			't3lib_FlashMessage',
+			$message,
+			'DEBUG: ' . ($brOrHeader === 0 ? '' : htmlspecialchars($brOrHeader)),
+			t3lib_FlashMessage::INFO
+		);
+		t3lib_FlashMessageQueue::addMessage($flashMessage);		
 	}
 
 	/**
Index: t3lib/class.t3lib_flashmessagequeue.php
===================================================================
--- t3lib/class.t3lib_flashmessagequeue.php	(revision 6446)
+++ t3lib/class.t3lib_flashmessagequeue.php	(working copy)
@@ -55,10 +55,7 @@
 			$queuedFlashMessages = self::getFlashMessagesFromSession();
 			$queuedFlashMessages[] = $message;
 
-			$GLOBALS['BE_USER']->setAndSaveSessionData(
-				'core.template.flashMessages',
-				$queuedFlashMessages
-			);
+			self::persistInSessionData($queuedFlashMessages);
 		} else {
 			self::$messages[] = $message;
 		}
@@ -76,10 +73,7 @@
 		$queuedFlashMessagesFromSession = self::getFlashMessagesFromSession();
 		if (!empty($queuedFlashMessagesFromSession)) {
 				// reset messages in user session
-			$GLOBALS['BE_USER']->setAndSaveSessionData(
-				'core.template.flashMessages',
-				null
-			);
+			self::persistInSessionData(null);
 		}
 
 		$queuedFlashMessages = array_merge($queuedFlashMessagesFromSession, self::$messages);
@@ -118,7 +112,25 @@
 		return $content;
 	}
 
-
+	/**
+	 * Persists data in user session.
+	 *
+	 * @param	mixed		$data: Data to be persisted
+	 * @return	void
+	 */
+	protected function persistInSessionData($data) {
+		if (TYPO3_MODE === 'FE') {
+			$GLOBALS['TSFE']->fe_user->setKey(
+				'core.tsfe.flashMessages',
+				$data
+			);
+		} elseif (TYPO3_MODE === 'BE') {
+			$GLOBALS['BE_USER']->setAndSaveSessionData(
+				'core.template.flashMessages',
+				$data
+			);
+		}
+	}
 }
 
 
