Index: t3lib/class.t3lib_timetrack.php =================================================================== --- t3lib/class.t3lib_timetrack.php (revision 9098) +++ t3lib/class.t3lib_timetrack.php (revision ) @@ -1,38 +1,38 @@ -*/ + * Contains class with time tracking functions + * + * $Id: class.t3lib_timetrack.php 9098 2010-10-16 17:34:50Z benni $ + * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj + * XHTML compliant + * + * @author Kasper Skårhøj + */ /** * [CLASS/FUNCTION INDEX of SCRIPT] * @@ -40,24 +40,24 @@ * * 88: class t3lib_timeTrack * - * SECTION: Logging parsing times in the scripts + * SECTION: Logging parsing times in the scripts - * 144: function start() + * 144: function start() - * 164: function push($tslabel, $value='') + * 164: function push($tslabel, $value='') - * 189: function pull($content='') + * 189: function pull($content='') - * 207: function setTSlogMessage($content,$num=0) + * 207: function setTSlogMessage($content,$num=0) - * 221: function setTSselectQuery($query,$msg) + * 221: function setTSselectQuery($query,$msg) - * 234: function incStackPointer() + * 234: function incStackPointer() - * 245: function decStackPointer() + * 245: function decStackPointer() - * 255: function mtime() + * 255: function mtime() - * 265: function convertMicrotime($microtime) + * 265: function convertMicrotime($microtime) * - * SECTION: Printing the parsing time information (for Admin Panel) + * SECTION: Printing the parsing time information (for Admin Panel) - * 298: function printTSlog() + * 298: function printTSlog() - * 447: function fixContent(&$arr, $content, $depthData='', $first=0, $vKey='') + * 447: function fixContent(&$arr, $content, $depthData='', $first=0, $vKey='') - * 511: function fixCLen($c,$v) + * 511: function fixCLen($c,$v) - * 527: function fw($str) + * 527: function fw($str) - * 541: function createHierarchyArray(&$arr,$pointer,$uniqueId) + * 541: function createHierarchyArray(&$arr,$pointer,$uniqueId) - * 561: function debug_typo3PrintError($header,$text,$js,$baseUrl='') + * 561: function debug_typo3PrintError($header,$text,$js,$baseUrl='') * * TOTAL FUNCTIONS: 15 * (This index is automatically created/updated by the extension "extdeveval") @@ -65,15 +65,6 @@ */ - - - - - - - - - /** * Frontend Timetracking functions * @@ -86,13 +77,13 @@ * @see t3lib_tsfeBeUserAuth, tslib_fe, tslib_cObj, TSpagegen */ class t3lib_timeTrack { - var $starttime = 0; // Is loaded with the millisecond time when this object is created + var $starttime = 0; // Is loaded with the millisecond time when this object is created - var $LR = 1; // Log Rendering flag. If set, ->push() and ->pull() is called from the cObj->cObjGetSingle(). This determines whether or not the TypoScript parsing activity is logged. But it also slows down the rendering + var $LR = 1; // Log Rendering flag. If set, ->push() and ->pull() is called from the cObj->cObjGetSingle(). This determines whether or not the TypoScript parsing activity is logged. But it also slows down the rendering - var $printConf=array( + var $printConf = array( 'showParentKeys' => 1, - 'contentLength' => 10000, // Determines max lenght of displayed content before it gets cropped. + 'contentLength' => 10000, // Determines max lenght of displayed content before it gets cropped. - 'contentLength_FILE' => 400, // Determines max lenght of displayed content FROM FILE cObjects before it gets cropped. Reason is that most FILE cObjects are huge and often used as template-code. + 'contentLength_FILE' => 400, // Determines max lenght of displayed content FROM FILE cObjects before it gets cropped. Reason is that most FILE cObjects are huge and often used as template-code. 'flag_tree' => 1, 'flag_messages' => 1, 'flag_queries' => 0, @@ -114,19 +105,14 @@ var $tsStackPointer = 0; var $currentHashPointer = array(); - var $highlightLongerThan = 0; // Log entries that take than this number of milliseconds (own time) will be highlighted during log display. Set 0 to disable highlighting. + var $highlightLongerThan = 0; // Log entries that take than this number of milliseconds (own time) will be highlighted during log display. Set 0 to disable highlighting. - - - - - /******************************************* - * - * Logging parsing times in the scripts - * - *******************************************/ + * + * Logging parsing times in the scripts + * + *******************************************/ /** * Constructor @@ -136,17 +122,17 @@ */ public function start() { $this->wrapError = array( - 0 => array('',''), + 0 => array('', ''), - 1 => array('',''), + 1 => array('', ''), - 2 => array('',''), + 2 => array('', ''), - 3 => array('','') + 3 => array('', '') ); $this->wrapIcon = array( 0 => '', - 1 => '', + 1 => '', - 2 => '', + 2 => '', - 3 => '' + 3 => '' ); $this->starttime = $this->getMilliseconds(); @@ -162,7 +148,7 @@ */ public function push($tslabel, $value = '') { array_push($this->tsStack[$this->tsStackPointer], $tslabel); - array_push($this->currentHashPointer, 'timetracker_'.$this->uniqueCounter++); + array_push($this->currentHashPointer, 'timetracker_' . $this->uniqueCounter++); $this->tsStackLevel++; $this->tsStackLevelMax[] = $this->tsStackLevel; @@ -173,7 +159,7 @@ 'level' => $this->tsStackLevel, 'tsStack' => $this->tsStack, 'value' => $value, - 'starttime' => microtime(true), + 'starttime' => microtime(TRUE), 'stackPointer' => $this->tsStackPointer ); } @@ -187,7 +173,7 @@ */ public function pull($content = '') { $k = end($this->currentHashPointer); - $this->tsStackLog[$k]['endtime'] = microtime(true); + $this->tsStackLog[$k]['endtime'] = microtime(TRUE); $this->tsStackLog[$k]['content'] = $content; $this->tsStackLevel--; @@ -207,10 +193,10 @@ end($this->currentHashPointer); $k = current($this->currentHashPointer); - if (strlen($content)>30) { // Enlarge the "details" column by adding a wide clear.gif + if (strlen($content) > 30) { // Enlarge the "details" column by adding a wide clear.gif - $placeholder = '
'; + $placeholder = '
'; } - $this->tsStackLog[$k]['message'][] = $this->wrapIcon[$num].$this->wrapError[$num][0].htmlspecialchars($content).$this->wrapError[$num][1].$placeholder; + $this->tsStackLog[$k]['message'][] = $this->wrapIcon[$num] . $this->wrapError[$num][0] . htmlspecialchars($content) . $this->wrapError[$num][1] . $placeholder; } /** @@ -239,7 +225,7 @@ */ public function incStackPointer() { $this->tsStackPointer++; - $this->tsStack[$this->tsStackPointer]=array(); + $this->tsStack[$this->tsStackPointer] = array(); } /** @@ -275,8 +261,8 @@ public function convertMicrotime($microtime) { t3lib_div::logDeprecatedFunction(); - $parts = explode(' ',$microtime); + $parts = explode(' ', $microtime); - return round(($parts[0]+$parts[1])*1000); + return round(($parts[0] + $parts[1]) * 1000); } /** @@ -287,7 +273,7 @@ */ public function getMilliseconds($microtime = NULL) { if (!isset($microtime)) { - $microtime = microtime(true); + $microtime = microtime(TRUE); } return round($microtime * 1000); } @@ -303,26 +289,11 @@ } - - - - - - - - - - - - - - - /******************************************* - * - * Printing the parsing time information (for Admin Panel) - * - *******************************************/ + * + * Printing the parsing time information (for Admin Panel) + * + *******************************************/ /** * Print TypoScript parsing log @@ -365,10 +336,10 @@ $out = ''; foreach ($outputArr as $row) { - $out.= ' + $out .= ' - '.$row.''; + ' . $row . ''; } - $out = ''.$out.''; + $out = '' . $out . ''; $flag_tree = $this->printConf['flag_tree']; $flag_messages = $this->printConf['flag_messages']; @@ -379,15 +350,15 @@ $col = $this->printConf['col']; $highlight_col = $this->printConf['highlight_col']; - $c=0; + $c = 0; foreach ($this->tsStackLog as $uniqueId => $data) { - $bgColor = ' background-color:'.($c%2 ? t3lib_div::modifyHTMLColor($col,$factor,$factor,$factor) : $col).';'; + $bgColor = ' background-color:' . ($c % 2 ? t3lib_div::modifyHTMLColor($col, $factor, $factor, $factor) : $col) . ';'; if ($this->highlightLongerThan && intval($data['owntime']) > intval($this->highlightLongerThan)) { - $bgColor = ' background-color:'.$highlight_col.';'; + $bgColor = ' background-color:' . $highlight_col . ';'; } $item = ''; - if (!$c) { // If first... + if (!$c) { // If first... $data['icons'] = ''; $data['key'] = 'Script Start'; $data['value'] = ''; @@ -399,37 +370,37 @@ if (!$flag_tree && $data['stackPointer']) { $temp = array(); foreach ($data['tsStack'] as $k => $v) { - $temp[] = t3lib_div::fixed_lgd_cs(implode($v,$k?'.':'/'),-$keyLgd); + $temp[] = t3lib_div::fixed_lgd_cs(implode($v, $k ? '.' : '/'), -$keyLgd); } array_pop($temp); $temp = array_reverse($temp); array_pop($temp); if (count($temp)) { - $keyLabel = '
'.implode($temp,'
').'
'; + $keyLabel = '
' . implode($temp, '
') . '
'; } } if ($flag_tree) { - $tmp = t3lib_div::trimExplode('.',$data['key'],1); + $tmp = t3lib_div::trimExplode('.', $data['key'], 1); $theLabel = end($tmp); } else { $theLabel = $data['key']; } $theLabel = t3lib_div::fixed_lgd_cs($theLabel, -$keyLgd); - $theLabel = $data['stackPointer'] ? ''.$theLabel.'' : $theLabel; + $theLabel = $data['stackPointer'] ? '' . $theLabel . '' : $theLabel; - $keyLabel = $theLabel.$keyLabel; + $keyLabel = $theLabel . $keyLabel; - $item.= ''.($flag_tree?$data['icons']:'').$this->fw($keyLabel).''; + $item .= '' . ($flag_tree ? $data['icons'] : '') . $this->fw($keyLabel) . ''; // key value: $keyValue = $data['value']; - $item.= ''.$this->fw(htmlspecialchars($keyValue)).''; + $item .= '' . $this->fw(htmlspecialchars($keyValue)) . ''; if ($this->printConf['allTime']) { - $item.= ' '.$this->fw($data['starttime']).''; + $item .= ' ' . $this->fw($data['starttime']) . ''; - $item.= ' '.$this->fw($data['owntime']).''; + $item .= ' ' . $this->fw($data['owntime']) . ''; - $item.= ' '.$this->fw($data['subtime'] ? '+'.$data['subtime'] : '').''; + $item .= ' ' . $this->fw($data['subtime'] ? '+' . $data['subtime'] : '') . ''; - $item.= ' '.$this->fw($data['subtime'] ? '='.$data['deltatime'] : '').''; + $item .= ' ' . $this->fw($data['subtime'] ? '=' . $data['deltatime'] : '') . ''; } else { - $item.= ' '.$this->fw($data['owntime']).''; + $item .= ' ' . $this->fw($data['owntime']) . ''; } @@ -444,24 +415,24 @@ if ($flag_queries && is_array($data['selectQuery'])) { $msgArr[] = t3lib_utility_Debug::viewArray($data['selectQuery']); } - if ($flag_content && strcmp($data['content'],'')) { + if ($flag_content && strcmp($data['content'], '')) { $maxlen = 120; - if (preg_match_all('/(\S{'.$maxlen.',})/', $data['content'], $reg)) { // Break lines which are too longer than $maxlen chars (can happen if content contains long paths...) + if (preg_match_all('/(\S{' . $maxlen . ',})/', $data['content'], $reg)) { // Break lines which are too longer than $maxlen chars (can happen if content contains long paths...) - foreach ($reg[1] as $key=>$match) { + foreach ($reg[1] as $key => $match) { - $match = preg_replace('/(.{'.$maxlen.'})/', '$1 ', $match); + $match = preg_replace('/(.{' . $maxlen . '})/', '$1 ', $match); $data['content'] = str_replace($reg[0][$key], $match, $data['content']); } } - $msgArr[] = ''.nl2br($data['content']).''; + $msgArr[] = '' . nl2br($data['content']) . ''; } if (count($msgArr)) { - $msg = implode($msgArr,'
'); + $msg = implode($msgArr, '
'); } - $item.= ''.$this->fw($msg).''; + $item .= '' . $this->fw($msg) . ''; - $out.= ''.$item.''; + $out .= '' . $item . ''; $c++; } - $out = ''.$out.'
'; + $out = '' . $out . '
'; return $out; } @@ -476,8 +447,8 @@ * @return string Returns the $content string generated/modified. Also the $arr array is modified! */ protected function fixContent(&$arr, $content, $depthData = '', $first = 0, $vKey = '') { - $ac=0; + $ac = 0; - $c=0; + $c = 0; // First, find number of entries foreach ($arr as $k => $v) { if (t3lib_div::testInt($k)) { @@ -485,43 +456,43 @@ } } // Traverse through entries - $subtime=0; + $subtime = 0; foreach ($arr as $k => $v) { if (t3lib_div::testInt($k)) { $c++; - $deeper = is_array($arr[$k.'.']) ? 1 : 0; + $deeper = is_array($arr[$k . '.']) ? 1 : 0; $PM = 'join'; - $LN = ($ac==$c)?'blank':'line'; + $LN = ($ac == $c) ? 'blank' : 'line'; - $BTM = ($ac==$c)?'bottom':''; + $BTM = ($ac == $c) ? 'bottom' : ''; - $PM = is_array($arr[$k.'.']) ? ($deeper ? 'minus':'plus') : 'join'; + $PM = is_array($arr[$k . '.']) ? ($deeper ? 'minus' : 'plus') : 'join'; - $this->tsStackLog[$v]['icons'] = $depthData.($first?'':''); + $this->tsStackLog[$v]['icons'] = $depthData . ($first ? '' : ''); if (strlen($this->tsStackLog[$v]['content'])) { - $content = str_replace($this->tsStackLog[$v]['content'],$v, $content); + $content = str_replace($this->tsStackLog[$v]['content'], $v, $content); } - if (is_array($arr[$k.'.'])) { + if (is_array($arr[$k . '.'])) { - $this->tsStackLog[$v]['content'] = $this->fixContent($arr[$k.'.'], $this->tsStackLog[$v]['content'], $depthData.($first?'':''), 0, $v); + $this->tsStackLog[$v]['content'] = $this->fixContent($arr[$k . '.'], $this->tsStackLog[$v]['content'], $depthData . ($first ? '' : ''), 0, $v); } else { $this->tsStackLog[$v]['content'] = $this->fixCLen($this->tsStackLog[$v]['content'], $this->tsStackLog[$v]['value']); $this->tsStackLog[$v]['subtime'] = ''; $this->tsStackLog[$v]['owntime'] = $this->tsStackLog[$v]['deltatime']; } - $subtime+= $this->tsStackLog[$v]['deltatime']; + $subtime += $this->tsStackLog[$v]['deltatime']; } } // Set content with special chars if (isset($this->tsStackLog[$vKey])) { $this->tsStackLog[$vKey]['subtime'] = $subtime; - $this->tsStackLog[$vKey]['owntime'] = $this->tsStackLog[$vKey]['deltatime']-$subtime; + $this->tsStackLog[$vKey]['owntime'] = $this->tsStackLog[$vKey]['deltatime'] - $subtime; } - $content=$this->fixCLen($content, $this->tsStackLog[$vKey]['value']); + $content = $this->fixCLen($content, $this->tsStackLog[$vKey]['value']); // Traverse array again, this time substitute the unique hash with the red key foreach ($arr as $k => $v) { if (t3lib_div::testInt($k)) { if (strlen($this->tsStackLog[$v]['content'])) { - $content = str_replace($v, '['.$this->tsStackLog[$v]['key'].']', $content); + $content = str_replace($v, '[' . $this->tsStackLog[$v]['key'] . ']', $content); } } } @@ -537,9 +508,9 @@ * @return string */ protected function fixCLen($c, $v) { - $len = $v=='FILE'?$this->printConf['contentLength_FILE']:$this->printConf['contentLength']; + $len = $v == 'FILE' ? $this->printConf['contentLength_FILE'] : $this->printConf['contentLength']; - if (strlen($c)>$len) { + if (strlen($c) > $len) { - $c = ''.htmlspecialchars(t3lib_div::fixed_lgd_cs($c,$len)).''; + $c = '' . htmlspecialchars(t3lib_div::fixed_lgd_cs($c, $len)) . ''; } else { $c = htmlspecialchars($c); } @@ -553,7 +524,7 @@ * @return string */ protected function fw($str) { - return ''.$str.' '; + return '' . $str . ' '; } /** @@ -570,10 +541,10 @@ if (!is_array($arr)) { $arr = array(); } - if ($pointer>0) { + if ($pointer > 0) { end($arr); $k = key($arr); - $this->createHierarchyArray($arr[intval($k).'.'],$pointer-1,$uniqueId); + $this->createHierarchyArray($arr[intval($k) . '.'], $pointer - 1, $uniqueId); } else { $arr[] = $uniqueId; } @@ -607,7 +578,7 @@ 'baseUrl' => $baseUrl, 'errorMessage' => &$errorMessage ); - $null = null; + $null = NULL; foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_timetrack.php']['debug_typo3PrintError'] as $hookMethod) { t3lib_div::callUserFunction($hookMethod, $params, $null); }