53 'showParentKeys' => 1,
54 'contentLength' => 10000,
56 'contentLength_FILE' => 400,
70 1 => [
'<strong>',
'</strong>'],
71 2 => [
'<strong style="color:#ff6600;">',
'</strong>'],
72 3 => [
'<strong style="color:#ff0000;">',
'</strong>']
80 1 =>
'actions-document-info',
81 2 =>
'status-dialog-warning',
82 3 =>
'status-dialog-error'
148 if (!$this->isEnabled) {
161 public function push($tslabel, $value =
'')
163 if (!$this->isEnabled) {
167 $this->currentHashPointer[] =
'timetracker_' . $this->uniqueCounter++;
168 $this->tsStackLevel++;
171 $k = end($this->currentHashPointer);
172 $this->tsStackLog[$k] = [
176 'starttime' => microtime(
true),
187 public function pull($content =
'')
189 if (!$this->isEnabled) {
192 $k = end($this->currentHashPointer);
193 $this->tsStackLog[$k][
'endtime'] = microtime(
true);
194 $this->tsStackLog[$k][
'content'] = $content;
195 $this->tsStackLevel--;
196 array_pop($this->tsStack[$this->tsStackPointer]);
197 array_pop($this->currentHashPointer);
209 if (!$this->isEnabled) {
212 end($this->currentHashPointer);
213 $k = current($this->currentHashPointer);
216 if (strlen($content) > 30) {
217 $placeholder =
'<br /><span style="width: 300px; height: 1px; display: inline-block;"></span>';
219 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
220 $this->tsStackLog[$k][
'message'][] = $iconFactory->getIcon($this->wrapIcon[$num],
Icon::SIZE_SMALL)->render() . $this->wrapError[$num][0] . htmlspecialchars($content) . $this->wrapError[$num][1] . $placeholder;
231 if (!$this->isEnabled) {
234 end($this->currentHashPointer);
235 $k = current($this->currentHashPointer);
239 $this->tsStackLog[$k][
'selectQuery'][] = $data;
249 if (!$this->isEnabled) {
252 $this->tsStackPointer++;
263 if (!$this->isEnabled) {
266 unset($this->tsStack[$this->tsStackPointer]);
267 $this->tsStackPointer--;
278 if (!$this->isEnabled) {
281 if (!isset($microtime)) {
282 $microtime = microtime(
true);
284 return round($microtime * 1000);
310 $beUserInitialization = $beUserInitializationEnd - $beUserInitializationStart;
313 $totalParseTime = $processEnd - $processStart;
315 if ($beUserInitialization > 0) {
316 $totalParseTime -= $beUserInitialization;
319 return $totalParseTime;
334 if (!$this->isEnabled) {
338 foreach ($this->tsStackLog as $uniqueId => &$data) {
341 $data[
'deltatime'] = $data[
'endtime'] - $data[
'starttime'];
342 if (is_array($data[
'tsStack'])) {
343 $data[
'key'] = implode($data[
'stackPointer'] ?
'.' :
'/', end($data[
'tsStack']));
349 foreach ($this->tsStackLog as $uniqueId => $data) {
353 $this->tsStackLog[$arr[
'0.'][0]][
'content'] = $this->
fixContent($arr[
'0.'], $this->tsStackLog[$arr[
'0.'][0]][
'content'] ??
'',
'', $arr[
'0.'][0]);
356 $outputArr[] = $this->
fw(
'TypoScript Key');
357 $outputArr[] = $this->
fw(
'Value');
358 if ($this->printConf[
'allTime']) {
359 $outputArr[] = $this->
fw(
'Time');
360 $outputArr[] = $this->
fw(
'Own');
361 $outputArr[] = $this->
fw(
'Sub');
362 $outputArr[] = $this->
fw(
'Total');
364 $outputArr[] = $this->
fw(
'Own');
366 $outputArr[] = $this->
fw(
'Details');
368 foreach ($outputArr as $row) {
369 $out .=
'<th>' . $row .
'</th>';
371 $out =
'<thead><tr>' . $out .
'</tr></thead>';
372 $flag_tree = $this->printConf[
'flag_tree'];
373 $flag_messages = $this->printConf[
'flag_messages'];
374 $flag_content = $this->printConf[
'flag_content'];
375 $keyLgd = $this->printConf[
'keyLgd'];
377 foreach ($this->tsStackLog as $uniqueId => $data) {
379 if ($this->highlightLongerThan && (
int)$data[
'owntime'] > (
int)$this->highlightLongerThan) {
380 $logRowClass =
'typo3-adminPanel-logRow-highlight';
386 $data[
'key'] =
'Script Start';
391 if (!$flag_tree && $data[
'stackPointer']) {
393 foreach ($data[
'tsStack'] as $k => $v) {
394 $temp[] = GeneralUtility::fixed_lgd_cs(implode($k ?
'.' :
'/', $v), -$keyLgd);
397 $temp = array_reverse($temp);
400 $keyLabel =
'<br /><span style="color:#999999;">' . implode(
'<br />', $temp) .
'</span>';
404 $tmp = GeneralUtility::trimExplode(
'.', $data[
'key'],
true);
405 $theLabel = end($tmp);
407 $theLabel = $data[
'key'];
409 $theLabel = GeneralUtility::fixed_lgd_cs($theLabel, -$keyLgd);
410 $theLabel = $data[
'stackPointer'] ?
'<span class="stackPointer">' . $theLabel .
'</span>' : $theLabel;
411 $keyLabel = $theLabel . $keyLabel;
412 $item .=
'<th scope="row" class="typo3-adminPanel-table-cell-key ' . $logRowClass .
'">' . ($flag_tree ? $data[
'icons'] :
'') . $this->
fw($keyLabel) .
'</th>';
414 $keyValue = $data[
'value'];
415 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime">' . $this->
fw(htmlspecialchars($keyValue)) .
'</td>';
416 if ($this->printConf[
'allTime']) {
417 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw($data[
'starttime']) .
'</td>';
418 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw($data[
'owntime']) .
'</td>';
419 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw(($data[
'subtime'] ?
'+' . $data[
'subtime'] :
'')) .
'</td>';
420 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw(($data[
'subtime'] ?
'=' . $data[
'deltatime'] :
'')) .
'</td>';
422 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw($data[
'owntime']) .
'</td>';
427 if ($flag_messages && is_array($data[
'message'])) {
428 foreach ($data[
'message'] as $v) {
429 $msgArr[] = nl2br($v);
432 if ($flag_content && (
string)$data[
'content'] !==
'') {
435 if (preg_match_all(
'/(\\S{' . $maxlen .
',})/', $data[
'content'], $reg)) {
436 foreach ($reg[1] as $key => $match) {
437 $match = preg_replace(
'/(.{' . $maxlen .
'})/',
'$1 ', $match);
438 $data[
'content'] = str_replace($reg[0][$key], $match, $data[
'content']);
441 $msgArr[] = nl2br($data[
'content']);
443 if (!empty($msgArr)) {
444 $msg = implode(
'<hr />', $msgArr);
446 $item .=
'<td class="typo3-adminPanel-table-cell-content">' . $this->
fw($msg) .
'</td>';
447 $out .=
'<tr>' . $item .
'</tr>';
450 $out =
'<div class="typo3-adminPanel-table-overflow"><table class="typo3-adminPanel-table typo3-adminPanel-table-debug">' . $out .
'</table></div>';
463 protected function fixContent(&$arr, $content, $depthData =
'', $vKey =
'')
468 foreach ($arr as $k => $v) {
470 if (\
TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($k)) {
476 foreach ($arr as $k => $v) {
477 if (\
TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($k)) {
479 $hasChildren = isset($arr[$k .
'.']);
480 $lastEntry = $entriesCount === $c;
482 $PM =
'<span class="treeline-icon treeline-icon-join' . ($lastEntry ?
'bottom' :
'') .
'"></span>';
484 $this->tsStackLog[$v][
'icons'] = $depthData . $PM;
485 if ($this->tsStackLog[$v][
'content'] !==
'') {
486 $content = str_replace($this->tsStackLog[$v][
'content'], $v, $content);
489 $lineClass = $lastEntry ?
'treeline-icon-clear' :
'treeline-icon-line';
490 $this->tsStackLog[$v][
'content'] = $this->
fixContent($arr[$k .
'.'], $this->tsStackLog[$v][
'content'], $depthData .
'<span class="treeline-icon ' . $lineClass .
'"></span>', $v);
492 $this->tsStackLog[$v][
'content'] = $this->
fixCLen($this->tsStackLog[$v][
'content'], $this->tsStackLog[$v][
'value']);
493 $this->tsStackLog[$v][
'subtime'] =
'';
494 $this->tsStackLog[$v][
'owntime'] = $this->tsStackLog[$v][
'deltatime'];
496 $subtime += $this->tsStackLog[$v][
'deltatime'];
500 if (isset($this->tsStackLog[$vKey])) {
501 $this->tsStackLog[$vKey][
'subtime'] = $subtime;
502 $this->tsStackLog[$vKey][
'owntime'] = $this->tsStackLog[$vKey][
'deltatime'] - $subtime;
504 $content = $this->
fixCLen($content, $this->tsStackLog[$vKey][
'value']);
506 foreach ($arr as $k => $v) {
507 if (\
TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($k)) {
508 if ($this->tsStackLog[$v][
'content'] !==
'') {
509 $content = str_replace($v,
'<strong style="color:red;">[' . $this->tsStackLog[$v][
'key'] .
']</strong>', $content);
526 $len = $v ===
'FILE' ? $this->printConf[
'contentLength_FILE'] : $this->printConf[
'contentLength'];
527 if (strlen($c) > $len) {
528 $c =
'<span style="color:green;">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($c, $len)) .
'</span>';
530 $c = htmlspecialchars($c);
541 protected function fw($str)
543 return '<span>' . $str .
'</span>';
557 if (!is_array($arr)) {