2 namespace TYPO3\CMS\Core\Utility;
31 public static function debug($var =
'', $header =
'', $group =
'Debug')
34 if (ob_get_level() == 0) {
37 $debug = self::convertVariableToString($var);
38 if (TYPO3_MODE ===
'BE' && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI)) {
39 $tabHeader = $header ?:
'Debug';
45 if (top.TYPO3.DebugConsole) {
46 top.TYPO3.DebugConsole.add(message, header, group);
48 var consoleMessage = [group, header, message].join(" | ");
49 if (typeof console === "object" && typeof console.log === "function") {
50 console.log(consoleMessage);
69 if (is_array($variable)) {
70 $string = self::viewArray($variable);
71 }
elseif (is_object($variable)) {
72 $string = json_encode($variable,
true);
73 }
elseif ((
string)$variable !==
'') {
74 $string = htmlspecialchars((
string)$variable);
76 $string =
'| debug |';
90 $debugString = self::convertVariableToString($debugVariable);
97 browserWindow = function(debug, header, group) {
98 var newWindow = window.open("", "TYPO3DebugWindow_" + group,
99 "width=600,height=400,menubar=0,toolbar=1,status=0,scrollbars=1,resizable=1"
101 if (newWindow.document.body.innerHTML) {
102 newWindow.document.body.innerHTML = newWindow.document.body.innerHTML +
103 "<hr />" + debugMessage;
105 newWindow.document.writeln(
106 "<html><head><title>Debug: " + header + "(" + group + ")</title></head>"
107 + "<body onload=\\"self.focus()\\">"
114 if (top && typeof top.TYPO3 !== "undefined" && typeof top.TYPO3.Modal !== "undefined") {
115 top.TYPO3.Modal.show(
116 "Debug: " + header + " (" + group + ")",
118 top.TYPO3.Severity.notice
121 browserWindow(debugMessage, header, group);
135 $trail = debug_backtrace();
136 $trail = array_reverse($trail);
139 foreach ($trail as $dat) {
140 $pathFragment = $dat[
'class'] . $dat[
'type'] . $dat[
'function'];
142 if (in_array($dat[
'function'], array(
'require',
'include',
'require_once',
'include_once'))) {
145 $path[] = $pathFragment .
'#' . $dat[
'line'];
147 return implode(
' // ', $path);
158 public static function debugRows($rows, $header =
'', $returnHTML =
false)
160 if ($returnHTML !==
false) {
175 if (strlen($string) < $characters) {
176 $characters = strlen($string);
179 for ($i = 0; $i < $characters; $i++) {
180 $valuestring .=
' ' . ord(substr($string, $i, 1));
182 return trim($valuestring);
207 echo self::viewArray($array_in);