42 'showParentKeys' => 1,
43 'contentLength' => 10000,
45 'contentLength_FILE' => 400,
118 $this->wrapError = array(
120 1 => array(
'<strong>',
'</strong>'),
121 2 => array(
'<strong style="color:#ff6600;">',
'</strong>'),
122 3 => array(
'<strong style="color:#ff0000;">',
'</strong>')
124 $this->wrapIcon = array(
126 1 =>
'<img src="' . TYPO3_mainDir .
'gfx/icon_note.gif" width="18" height="16" align="absmiddle" alt="" />',
127 2 =>
'<img src="' . TYPO3_mainDir .
'gfx/icon_warning2.gif" width="18" height="16" align="absmiddle" alt="" />',
128 3 =>
'<img src="' . TYPO3_mainDir .
'gfx/icon_fatalerror.gif" width="18" height="16" align="absmiddle" alt="" />' 141 public function push($tslabel, $value =
'') {
142 array_push($this->tsStack[$this->tsStackPointer], $tslabel);
143 array_push($this->currentHashPointer,
'timetracker_' . $this->uniqueCounter++);
144 $this->tsStackLevel++;
147 $k = end($this->currentHashPointer);
148 $this->tsStackLog[$k] = array(
149 'level' => $this->tsStackLevel,
150 'tsStack' => $this->tsStack,
152 'starttime' => microtime(TRUE),
153 'stackPointer' => $this->tsStackPointer
164 public function pull($content =
'') {
165 $k = end($this->currentHashPointer);
166 $this->tsStackLog[$k][
'endtime'] = microtime(TRUE);
167 $this->tsStackLog[$k][
'content'] = $content;
168 $this->tsStackLevel--;
169 array_pop($this->tsStack[$this->tsStackPointer]);
170 array_pop($this->currentHashPointer);
182 end($this->currentHashPointer);
183 $k = current($this->currentHashPointer);
185 if (strlen($content) > 30) {
186 $placeholder =
'<br /><img src="' . TYPO3_mainDir .
'clear.gif" width="300" height="1" alt="" />';
188 $this->tsStackLog[$k][
'message'][] = $this->wrapIcon[$num] . $this->wrapError[$num][0] . htmlspecialchars($content) . $this->wrapError[$num][1] . $placeholder;
199 end($this->currentHashPointer);
200 $k = current($this->currentHashPointer);
204 $this->tsStackLog[$k][
'selectQuery'][] = $data;
214 $this->tsStackPointer++;
225 unset($this->tsStack[$this->tsStackPointer]);
226 $this->tsStackPointer--;
236 if (!isset($microtime)) {
237 $microtime = microtime(TRUE);
239 return round($microtime * 1000);
264 foreach ($this->tsStackLog as $uniqueId => &$data) {
267 $data[
'deltatime'] = $data[
'endtime'] - $data[
'starttime'];
268 if (is_array($data[
'tsStack'])) {
269 $data[
'key'] = implode($data[
'stackPointer'] ?
'.' :
'/', end($data[
'tsStack']));
275 foreach ($this->tsStackLog as $uniqueId => $data) {
279 $this->tsStackLog[$arr[
'0.'][0]][
'content'] = $this->
fixContent($arr[
'0.'], $this->tsStackLog[$arr[
'0.'][0]][
'content'],
'', 0, $arr[
'0.'][0]);
281 $outputArr = array();
282 $outputArr[] = $this->
fw(
'TypoScript Key');
283 $outputArr[] = $this->
fw(
'Value');
284 if ($this->printConf[
'allTime']) {
285 $outputArr[] = $this->
fw(
'Time');
286 $outputArr[] = $this->
fw(
'Own');
287 $outputArr[] = $this->
fw(
'Sub');
288 $outputArr[] = $this->
fw(
'Total');
290 $outputArr[] = $this->
fw(
'Own');
292 $outputArr[] = $this->
fw(
'Details');
294 foreach ($outputArr as $row) {
296 <th><strong>' . $row .
'</strong></th>';
298 $out =
'<tr>' . $out .
'</tr>';
299 $flag_tree = $this->printConf[
'flag_tree'];
300 $flag_messages = $this->printConf[
'flag_messages'];
301 $flag_content = $this->printConf[
'flag_content'];
302 $flag_queries = $this->printConf[
'flag_queries'];
303 $keyLgd = $this->printConf[
'keyLgd'];
304 $factor = $this->printConf[
'factor'];
305 $col = $this->printConf[
'col'];
306 $highlight_col = $this->printConf[
'highlight_col'];
308 foreach ($this->tsStackLog as $uniqueId => $data) {
309 if ($this->highlightLongerThan && (
int)$data[
'owntime'] > (
int)$this->highlightLongerThan) {
310 $logRowClass =
'typo3-adminPanel-logRow-highlight';
312 $logRowClass = $c % 2 ?
'line-odd' :
'line-even';
318 $data[
'key'] =
'Script Start';
323 if (!$flag_tree && $data[
'stackPointer']) {
325 foreach ($data[
'tsStack'] as $k => $v) {
329 $temp = array_reverse($temp);
332 $keyLabel =
'<br /><span style="color:#999999;">' . implode($temp,
'<br />') .
'</span>';
337 $theLabel = end($tmp);
339 $theLabel = $data[
'key'];
342 $theLabel = $data[
'stackPointer'] ?
'<span class="stackPointer">' . $theLabel .
'</span>' : $theLabel;
343 $keyLabel = $theLabel . $keyLabel;
344 $item .=
'<td class="' . $logRowClass .
'">' . ($flag_tree ? $data[
'icons'] :
'') . $this->
fw($keyLabel) .
'</td>';
346 $keyValue = $data[
'value'];
347 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime">' . $this->
fw(htmlspecialchars($keyValue)) .
'</td>';
348 if ($this->printConf[
'allTime']) {
349 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw($data[
'starttime']) .
'</td>';
350 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw($data[
'owntime']) .
'</td>';
351 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw(($data[
'subtime'] ?
'+' . $data[
'subtime'] :
'')) .
'</td>';
352 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw(($data[
'subtime'] ?
'=' . $data[
'deltatime'] :
'')) .
'</td>';
354 $item .=
'<td class="' . $logRowClass .
' typo3-adminPanel-tsLogTime"> ' . $this->
fw($data[
'owntime']) .
'</td>';
359 if ($flag_messages && is_array($data[
'message'])) {
360 foreach ($data[
'message'] as $v) {
361 $msgArr[] = nl2br($v);
364 if ($flag_queries && is_array($data[
'selectQuery'])) {
367 if ($flag_content && (
string)$data[
'content'] !==
'') {
370 if (preg_match_all(
'/(\\S{' . $maxlen .
',})/', $data[
'content'], $reg)) {
371 foreach ($reg[1] as $key => $match) {
372 $match = preg_replace(
'/(.{' . $maxlen .
'})/',
'$1 ', $match);
373 $data[
'content'] = str_replace($reg[0][$key], $match, $data[
'content']);
376 $msgArr[] =
'<span style="color:#000066;">' . nl2br($data[
'content']) .
'</span>';
378 if (count($msgArr)) {
379 $msg = implode($msgArr,
'<hr />');
381 $item .=
'<td valign="top" class="' . $logRowClass .
'" style="text-align:left;">' . $this->
fw($msg) .
'</td>';
382 $out .=
'<tr>' . $item .
'</tr>';
385 $out =
'<table class="admin-panel-table typo3-adminPanel-tsLog">' . $out .
'</table>';
399 protected function fixContent(&$arr, $content, $depthData =
'', $first = 0, $vKey =
'') {
403 foreach ($arr as $k => $v) {
404 if (\
TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($k)) {
410 foreach ($arr as $k => $v) {
411 if (\
TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($k)) {
413 $deeper = is_array($arr[$k .
'.']) ? 1 : 0;
415 $LN = $ac == $c ?
'blank' :
'line';
416 $BTM = $ac == $c ?
'bottom' :
'';
417 $PM = is_array($arr[$k .
'.']) ? ($deeper ?
'minus' :
'plus') :
'join';
418 $this->tsStackLog[$v][
'icons'] = $depthData . ($first ?
'' :
'<img src="' . TYPO3_mainDir .
'gfx/ol/' . $PM . $BTM .
'.gif" width="18" height="16" align="top" border="0" alt="" />');
419 if (strlen($this->tsStackLog[$v][
'content'])) {
420 $content = str_replace($this->tsStackLog[$v][
'content'], $v, $content);
422 if (is_array($arr[$k .
'.'])) {
423 $this->tsStackLog[$v][
'content'] = $this->
fixContent($arr[$k .
'.'], $this->tsStackLog[$v][
'content'], $depthData . ($first ?
'' :
'<img src="' . TYPO3_mainDir .
'gfx/ol/' . $LN .
'.gif" width="18" height="16" align="top" border="0" alt="" />'), 0, $v);
425 $this->tsStackLog[$v][
'content'] = $this->
fixCLen($this->tsStackLog[$v][
'content'], $this->tsStackLog[$v][
'value']);
426 $this->tsStackLog[$v][
'subtime'] =
'';
427 $this->tsStackLog[$v][
'owntime'] = $this->tsStackLog[$v][
'deltatime'];
429 $subtime += $this->tsStackLog[$v][
'deltatime'];
433 if (isset($this->tsStackLog[$vKey])) {
434 $this->tsStackLog[$vKey][
'subtime'] = $subtime;
435 $this->tsStackLog[$vKey][
'owntime'] = $this->tsStackLog[$vKey][
'deltatime'] - $subtime;
437 $content = $this->
fixCLen($content, $this->tsStackLog[$vKey][
'value']);
439 foreach ($arr as $k => $v) {
440 if (\
TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($k)) {
441 if (strlen($this->tsStackLog[$v][
'content'])) {
442 $content = str_replace($v,
'<strong style="color:red;">[' . $this->tsStackLog[$v][
'key'] .
']</strong>', $content);
458 $len = $v ==
'FILE' ? $this->printConf[
'contentLength_FILE'] : $this->printConf[
'contentLength'];
459 if (strlen($c) > $len) {
460 $c =
'<span style="color:green;">' . htmlspecialchars(\
TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($c, $len)) .
'</span>';
462 $c = htmlspecialchars($c);
473 protected function fw($str) {
474 return '<span>' . $str .
'</span>';
488 if (!is_array($arr)) {
getDifferenceToStarttime($microtime=NULL)
fixContent(&$arr, $content, $depthData='', $first=0, $vKey='')
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
setTSselectQuery(array $data, $msg='')
createHierarchyArray(&$arr, $pointer, $uniqueId)
push($tslabel, $value='')
static viewArray($array_in)
static fixed_lgd_cs($string, $chars, $appendString='...')
getMilliseconds($microtime=NULL)
setTSlogMessage($content, $num=0)