44 public static function debug($var =
'', $header =
'Debug', $group =
'Debug')
47 if (ob_get_level() === 0) {
56 var message = ' . GeneralUtility::quoteJSvalue($debug) .
',
57 messagePlain = ' . GeneralUtility::quoteJSvalue($debugPlain) .
',
58 header = ' . GeneralUtility::quoteJSvalue($header) .
',
59 group = ' . GeneralUtility::quoteJSvalue($group) .
';
60 if (top.TYPO3 && top.TYPO3.DebugConsole) {
61 top.TYPO3.DebugConsole.add(message, header, group);
63 var consoleMessage = [group, header, messagePlain].join(" | ");
64 if (typeof console === "object" && typeof console.log === "function") {
65 console.log(consoleMessage);
70 echo GeneralUtility::wrapJS($script);
85 return $string ===
'' ?
'| debug |' : $string;
95 public static function debugInPopUpWindow($debugVariable, $header =
'Debug', $group =
'Debug')
97 $debugString =
self::renderDump($debugVariable, sprintf(
'%s (%s)', $header, $group));
100 var debugMessage = ' . GeneralUtility::quoteJSvalue($debugString) .
',
101 header = ' . GeneralUtility::quoteJSvalue($header) .
',
102 group = ' . GeneralUtility::quoteJSvalue($group) .
',
104 browserWindow = function(debug, header, group) {
105 var newWindow = window.open("", "TYPO3DebugWindow_" + group,
106 "width=600,height=400,menubar=0,toolbar=1,status=0,scrollbars=1,resizable=1"
108 if (newWindow.document.body.innerHTML) {
109 newWindow.document.body.innerHTML = newWindow.document.body.innerHTML +
110 "<hr />" + debugMessage;
112 newWindow.document.writeln(
113 "<html><head><title>Debug: " + header + "(" + group + ")</title></head>"
114 + "<body onload=\\"self.focus()\\">"
121 if (top && typeof top.TYPO3 !== "undefined" && typeof top.TYPO3.Modal !== "undefined") {
122 top.TYPO3.Modal.show(
123 "Debug: " + header + " (" + group + ")",
125 top.TYPO3.Severity.notice
128 browserWindow(debugMessage, header, group);
132 echo GeneralUtility::wrapJS($script);
141 public static function debugTrail($prependFileNames =
false)
143 $trail = debug_backtrace(0);
144 $trail = array_reverse($trail);
147 foreach ($trail as $dat) {
148 $fileInformation = $prependFileNames && !empty($dat[
'file']) ? $dat[
'file'] .
':' :
'';
149 $pathFragment = $fileInformation . $dat[
'class'] . $dat[
'type'] . $dat[
'function'];
151 if (in_array($dat[
'function'], [
'require',
'include',
'require_once',
'include_once'])) {
154 $path[] = $pathFragment .
'#' . $dat[
'line'];
156 return implode(
' // ', $path);
165 public static function debugRows($rows, $header =
'')
177 public static function ordinalValue($string, $characters = 100)
179 if (strlen($string) < $characters) {
180 $characters = strlen($string);
183 for ($i = 0; $i < $characters; $i++) {
184 $valuestring .=
' ' . ord(substr($string, $i, 1));
186 return trim($valuestring);
222 protected static function renderDump($variable, $title =
'', $plainText =
null, $ansiColors =
null)