2 namespace TYPO3\CMS\Core\TimeTracker;
46 'showParentKeys' => 1,
47 'contentLength' => 10000,
49 'contentLength_FILE' => 400,
124 $this->wrapError = array(
126 1 => array(
'<strong>',
'</strong>'),
127 2 => array(
'<strong style="color:#ff6600;">',
'</strong>'),
128 3 => array(
'<strong style="color:#ff0000;">',
'</strong>')
130 $this->wrapIcon = array(
132 1 =>
'actions-document-info',
133 2 =>
'status-dialog-warning',
134 3 =>
'status-dialog-error'
147 public function push($tslabel, $value =
'')
149 array_push($this->tsStack[$this->tsStackPointer], $tslabel);
150 array_push($this->currentHashPointer,
'timetracker_' . $this->uniqueCounter++);
151 $this->tsStackLevel++;
154 $k = end($this->currentHashPointer);
155 $this->tsStackLog[$k] = array(
156 'level' => $this->tsStackLevel,
157 'tsStack' => $this->tsStack,
159 'starttime' => microtime(
true),
160 'stackPointer' => $this->tsStackPointer
171 public function pull($content =
'')
173 $k = end($this->currentHashPointer);
174 $this->tsStackLog[$k][
'endtime'] = microtime(
true);
175 $this->tsStackLog[$k][
'content'] = $content;
176 $this->tsStackLevel--;
177 array_pop($this->tsStack[$this->tsStackPointer]);
178 array_pop($this->currentHashPointer);
191 end($this->currentHashPointer);
192 $k = current($this->currentHashPointer);
194 if (strlen($content) > 30) {
195 $placeholder =
'<br /><span style="width: 300px; height: 1px; display: inline-block;"></span>';
198 $this->tsStackLog[$k][
'message'][] = $iconFactory->getIcon($this->wrapIcon[$num],
Icon::SIZE_SMALL)->render() . $this->wrapError[$num][0] . htmlspecialchars($content) . $this->wrapError[$num][1] . $placeholder;
210 end($this->currentHashPointer);
211 $k = current($this->currentHashPointer);
215 $this->tsStackLog[$k][
'selectQuery'][] = $data;
226 $this->tsStackPointer++;
238 unset($this->tsStack[$this->tsStackPointer]);
239 $this->tsStackPointer--;
250 if (!isset($microtime)) {
251 $microtime = microtime(
true);
253 return round($microtime * 1000);
280 foreach ($this->tsStackLog as $uniqueId => &$data) {
283 $data[
'deltatime'] = $data[
'endtime'] - $data[
'starttime'];
284 if (is_array($data[
'tsStack'])) {
285 $data[
'key'] = implode($data[
'stackPointer'] ?
'.' :
'/', end($data[
'tsStack']));
291 foreach ($this->tsStackLog as $uniqueId => $data) {
295 $this->tsStackLog[$arr[
'0.'][0]][
'content'] = $this->
fixContent($arr[
'0.'], $this->tsStackLog[$arr[
'0.'][0]][
'content'],
'', 0, $arr[
'0.'][0]);
297 $outputArr = array();
298 $outputArr[] = $this->
fw(
'TypoScript Key');
299 $outputArr[] = $this->
fw(
'Value');
300 if ($this->printConf[
'allTime']) {
301 $outputArr[] = $this->
fw(
'Time');
302 $outputArr[] = $this->
fw(
'Own');
303 $outputArr[] = $this->
fw(
'Sub');
304 $outputArr[] = $this->
fw(
'Total');
306 $outputArr[] = $this->
fw(
'Own');
308 $outputArr[] = $this->
fw(
'Details');
310 foreach ($outputArr as $row) {
312 <th><strong>' . $row .
'</strong></th>';
314 $out =
'<tr class="typo3-adminPanel-itemRow">' . $out .
'</tr>';
315 $flag_tree = $this->printConf[
'flag_tree'];
316 $flag_messages = $this->printConf[
'flag_messages'];
317 $flag_content = $this->printConf[
'flag_content'];
318 $flag_queries = $this->printConf[
'flag_queries'];
319 $keyLgd = $this->printConf[
'keyLgd'];
320 $factor = $this->printConf[
'factor'];
321 $col = $this->printConf[
'col'];
322 $highlight_col = $this->printConf[
'highlight_col'];
324 foreach ($this->tsStackLog as $uniqueId => $data) {
325 if ($this->highlightLongerThan && (
int)$data[
'owntime'] > (
int)$this->highlightLongerThan) {
326 $logRowClass =
'typo3-adminPanel-logRow-highlight';
328 $logRowClass = $c % 2 ?
'line-odd' :
'line-even';
330 $logRowClass .=
' typo3-adminPanel-section-content-title';
335 $data[
'key'] =
'Script Start';
340 if (!$flag_tree && $data[
'stackPointer']) {
342 foreach ($data[
'tsStack'] as $k => $v) {
346 $temp = array_reverse($temp);
349 $keyLabel =
'<br /><span style="color:#999999;">' . implode($temp,
'<br />') .
'</span>';
354 $theLabel = end($tmp);
356 $theLabel = $data[
'key'];
359 $theLabel = $data[
'stackPointer'] ?
'<span class="stackPointer">' . $theLabel .
'</span>' : $theLabel;
360 $keyLabel = $theLabel . $keyLabel;
361 $item .=
'<td class="' . $logRowClass .
'">' . ($flag_tree ? $data[
'icons'] :
'') . $this->
fw($keyLabel) .
'</td>';
363 $keyValue = $data[
'value'];
364 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime">' . $this->
fw(htmlspecialchars($keyValue)) .
'</td>';
365 if ($this->printConf[
'allTime']) {
366 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw($data[
'starttime']) .
'</td>';
367 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw($data[
'owntime']) .
'</td>';
368 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw(($data[
'subtime'] ?
'+' . $data[
'subtime'] :
'')) .
'</td>';
369 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw(($data[
'subtime'] ?
'=' . $data[
'deltatime'] :
'')) .
'</td>';
371 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw($data[
'owntime']) .
'</td>';
376 if ($flag_messages && is_array($data[
'message'])) {
377 foreach ($data[
'message'] as $v) {
378 $msgArr[] = nl2br($v);
381 if ($flag_queries && is_array($data[
'selectQuery'])) {
382 $msgArr[] = \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($data[
'selectQuery']);
384 if ($flag_content && (
string)$data[
'content'] !==
'') {
387 if (preg_match_all(
'/(\\S{' . $maxlen .
',})/', $data[
'content'], $reg)) {
388 foreach ($reg[1] as $key => $match) {
389 $match = preg_replace(
'/(.{' . $maxlen .
'})/',
'$1 ', $match);
390 $data[
'content'] = str_replace($reg[0][$key], $match, $data[
'content']);
393 $msgArr[] =
'<span style="color:#000066;">' . nl2br($data[
'content']) .
'</span>';
395 if (!empty($msgArr)) {
396 $msg = implode($msgArr,
'<hr />');
398 $item .=
'<td valign="top" class="' . $logRowClass .
'" style="text-align:left;">' . $this->
fw($msg) .
'</td>';
399 $out .=
'<tr class="typo3-adminPanel-itemRow">' . $item .
'</tr>';
402 $out =
'<table class="typo3-adminPanel-table typo3-adminPanel-tsLog">' . $out .
'</table>';
416 protected function fixContent(&$arr, $content, $depthData =
'', $first = 0, $vKey =
'')
421 foreach ($arr as $k => $v) {
422 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($k)) {
428 foreach ($arr as $k => $v) {
429 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($k)) {
431 $deeper = is_array($arr[$k .
'.']) ? 1 : 0;
432 $LN = $ac == $c ?
'blank' :
'line';
434 $BTM = $ac == $c ?
'bottom' :
'';
435 $PM = is_array($arr[$k .
'.']) ?
'<i class="fa fa-' . ($deeper ?
'minus' :
'plus') .
'-square-o"></i>' :
'<span class="treeline-icon treeline-icon-join' . ($BTM ?
'bottom' :
'') .
'"></span>';
437 $this->tsStackLog[$v][
'icons'] = $depthData . ($first ?
'' : $PM);
438 if ($this->tsStackLog[$v][
'content'] !==
'') {
439 $content = str_replace($this->tsStackLog[$v][
'content'], $v, $content);
441 if (is_array($arr[$k .
'.'])) {
442 $this->tsStackLog[$v][
'content'] = $this->
fixContent($arr[$k .
'.'], $this->tsStackLog[$v][
'content'], $depthData . ($first ?
'' :
'<span class="treeline-icon treeline-icon-' . $LN .
'"></span>'), 0, $v);
444 $this->tsStackLog[$v][
'content'] = $this->
fixCLen($this->tsStackLog[$v][
'content'], $this->tsStackLog[$v][
'value']);
445 $this->tsStackLog[$v][
'subtime'] =
'';
446 $this->tsStackLog[$v][
'owntime'] = $this->tsStackLog[$v][
'deltatime'];
448 $subtime += $this->tsStackLog[$v][
'deltatime'];
452 if (isset($this->tsStackLog[$vKey])) {
453 $this->tsStackLog[$vKey][
'subtime'] = $subtime;
454 $this->tsStackLog[$vKey][
'owntime'] = $this->tsStackLog[$vKey][
'deltatime'] - $subtime;
456 $content = $this->
fixCLen($content, $this->tsStackLog[$vKey][
'value']);
458 foreach ($arr as $k => $v) {
459 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($k)) {
460 if ($this->tsStackLog[$v][
'content'] !==
'') {
461 $content = str_replace($v,
'<strong style="color:red;">[' . $this->tsStackLog[$v][
'key'] .
']</strong>', $content);
478 $len = $v ==
'FILE' ? $this->printConf[
'contentLength_FILE'] : $this->printConf[
'contentLength'];
479 if (strlen($c) > $len) {
482 $c = htmlspecialchars($c);
493 protected function fw($str)
495 return '<span>' . $str .
'</span>';
510 if (!is_array($arr)) {