Project

General

Profile

Bug #21570 » 12614-t3uxw09-v2.diff

Administrator Admin, 2009-11-17 17:23

View differences:

t3lib/class.t3lib_db.php 2009-11-17 15:50:04.000000000 +0100
$error = $this->sql_error();
if ($error) {
debug(
$message = t3lib_div::view_array(
array(
'caller' => 't3lib_DB::' . $func,
'ERROR' => $error,
'lastBuiltQuery' => ($query ? $query : $this->debug_lastBuiltQuery),
'debug_backtrace' => t3lib_div::debug_trail(),
),
'SQL debug'
)
);
$flashMessage = t3lib_div::makeInstance(
't3lib_FlashMessage',
$message,
'TYPO3 Database Error: ' . $error,
t3lib_FlashMessage::ERROR
);
t3lib_FlashMessageQueue::addMessage($flashMessage);
}
}
t3lib/class.t3lib_div.php 2009-11-17 12:51:47.000000000 +0100
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)) {
......
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.
}
......
* @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>';
}
if ($brOrHeader && !t3lib_div::testInt($brOrHeader)) {
echo '</td></tr></table>';
} elseif ($brOrHeader>0) {
for($a=0;$a<intval($brOrHeader);$a++){echo '<br />';}
$message .='<b>| debug |</b>';
}
$flashMessage = t3lib_div::makeInstance(
't3lib_FlashMessage',
$message,
'DEBUG: ' . ($brOrHeader === 0 ? '' : htmlspecialchars($brOrHeader)),
t3lib_FlashMessage::INFO
);
t3lib_FlashMessageQueue::addMessage($flashMessage);
}
t3lib/class.t3lib_flashmessagequeue.php 2009-11-17 15:08:15.000000000 +0100
$queuedFlashMessages = self::getFlashMessagesFromSession();
$queuedFlashMessages[] = $message;
$GLOBALS['BE_USER']->setAndSaveSessionData(
'core.template.flashMessages',
$queuedFlashMessages
);
self::persistInSessionData($queuedFlashMessages);
} else {
self::$messages[] = $message;
}
......
$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);
......
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
);
}
}
}
t3lib/class.t3lib_pagerenderer.php 2009-11-17 14:43:03.000000000 +0100
protected $cssInline = array ();
protected $bodyContent;
protected $showFlashMessages = TRUE;
protected $templateFile;
protected $jsLibraryNames = array ('prototype', 'scriptaculous', 'extjs');
......
$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 */
......
return $this->bodyContent;
}
/**
* Gets Flag showFlashMessages
*
* @return boolean
*/
public function getShowFlashMessages() {
return $this->showFlashMessages;
}
/*****************************************************/
/* */
/* Public Function to add Data */
......
$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,
typo3/stylesheet.css 2009-11-15 16:04:35.000000000 +0100
}
/* Visual debugging: */
/*** Visual debugging: ***/
/* view_array */
.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;
}
/*
h2,
h3,
h4,
div {
border: 1px dotted #666;
.view_array-key {
font-weight: bold;
}
*/
typo3/template.php 2009-11-17 12:49:49.000000000 +0100
// 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();
......
// 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;
}
......
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);
}
typo3/sysext/cms/tslib/class.tslib_fe.php 2009-11-17 16:01:17.000000000 +0100
$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','');
(3-3/3)