Project

General

Profile

Feature #19513 » 9657v1.diff

Administrator Admin, 2008-11-05 01:27

View differences:

typo3/sysext/cms/tslib/index_ts.php (working copy)
// *********************
// Timetracking started
// *********************
require_once(PATH_t3lib.'class.t3lib_timetrack.php');
$TT = new t3lib_timeTrack;
$trackTime = false;
if (isset($_GET['TSFE_ADMIN_PANEL']['display_tsdebug'])) {
//TODO setting/unsetting of the cookie can also be done in JS (as soon as we have all of the admin panel JS bundled in a dedicated class)
if ($_GET['TSFE_ADMIN_PANEL']['display_tsdebug']) {
// the user opened the admin panel TS section
setcookie('enable_admin_panel', '1', $_SERVER['REQUEST_TIME'] + 31104000);
$trackTime = true;
} else {
// the user closed the admin panel TS section,
// so let the cookie expire at the end of the session
setcookie('enable_admin_panel', '0', 0);
}
}
if ($trackTime || (isset($_COOKIE['enable_admin_panel']) && $_COOKIE['enable_admin_panel'] == 1)) {
require_once(PATH_t3lib.'class.t3lib_timetrack.php');
$TT = new t3lib_timeTrack;
} else {
require_once(PATH_t3lib.'class.t3lib_timetracknull.php');
$TT = new t3lib_timeTrackNull;
}
$TT->start();
$TT->push('','Script start');
// *********************
// Mandatory libraries included
// *********************
......
new gzip_encode($TYPO3_CONF_VARS['FE']['compressionLevel'], false, $TYPO3_CONF_VARS['FE']['compressionDebugInfo']);
}
?>
?>
t3lib/class.t3lib_timetrack.php (working copy)
require_once(PATH_t3lib . 'interfaces/interface.t3lib_timetracker.php');
......
* @subpackage t3lib
* @see t3lib_tsfeBeUserAuth, tslib_fe, tslib_cObj, TSpagegen
*/
class t3lib_timeTrack {
class t3lib_timeTrack implements t3lib_TimeTracker {
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 $printConf=array(
'showParentKeys' => 1,
'contentLength' => 10000, // Determines max lenght of displayed content before it gets cropped.
'showParentKeys' => 1,
'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.
'flag_tree' => 1,
'flag_messages' => 1,
'flag_queries' => 0,
'flag_content' => 0,
'allTime' => 0,
'keyLgd' => 40,
'factor' => 10,
'col' => '#D9D5C9',
'highlight_col' => '#FF9933'
'flag_tree' => 1,
'flag_messages' => 1,
'flag_queries' => 0,
'flag_content' => 0,
'allTime' => 0,
'keyLgd' => 40,
'factor' => 10,
'col' => '#D9D5C9',
'highlight_col' => '#FF9933'
);
var $wrapError = array();
......
*
* @return void
*/
function start() {
public function start() {
$this->wrapError = array(
0 => array('',''),
1 => array('<strong>','</strong>'),
......
* @return void
* @see tslib_cObj::cObjGetSingle(), pull()
*/
function push($tslabel, $value='') {
public function push($tslabel, $value = '') {
array_push($this->tsStack[$this->tsStackPointer], $tslabel);
array_push($this->currentHashPointer, 'timetracker_'.$this->uniqueCounter++);
......
* @return void
* @see tslib_cObj::cObjGetSingle(), push()
*/
function pull($content='') {
public function pull($content = '') {
$k = end($this->currentHashPointer);
$this->tsStackLog[$k]['endtime'] = microtime();
$this->tsStackLog[$k]['content'] = $content;
......
* @return void
* @see tslib_cObj::CONTENT()
*/
function setTSlogMessage($content,$num=0) {
public function setTSlogMessage($content, $num = 0) {
end($this->currentHashPointer);
$k = current($this->currentHashPointer);
......
* @param string Message/Label to attach
* @return void
*/
function setTSselectQuery(array $data,$msg='') {
public function setTSselectQuery(array $data, $msg = '') {
end($this->currentHashPointer);
$k = current($this->currentHashPointer);
......
* @return void
* @see decStackPointer(), TSpagegen::renderContent(), tslib_cObj::cObjGetSingle()
*/
function incStackPointer() {
public function incStackPointer() {
$this->tsStackPointer++;
$this->tsStack[$this->tsStackPointer]=array();
}
......
* @return void
* @see incStackPointer(), TSpagegen::renderContent(), tslib_cObj::cObjGetSingle()
*/
function decStackPointer() {
public function decStackPointer() {
unset($this->tsStack[$this->tsStackPointer]);
$this->tsStackPointer--;
}
......
*
* @return integer
*/
function mtime() {
protected function mtime() {
return $this->convertMicrotime(microtime())-$this->starttime;
}
......
* @param string PHP microtime string
* @return integer
*/
function convertMicrotime($microtime) {
public function convertMicrotime($microtime) {
$parts = explode(' ',$microtime);
return round(($parts[0]+$parts[1])*1000);
}
......
* @return string HTML table with the information about parsing times.
* @see t3lib_tsfeBeUserAuth::extGetCategory_tsdebug()
*/
function printTSlog() {
public function printTSlog() {
// Calculate times and keys for the tsStackLog
$preEndtime = 0;
foreach($this->tsStackLog as $uniqueId=>$data) {
......
* @param string Seems to be the previous tsStackLog key
* @return string Returns the $content string generated/modified. Also the $arr array is modified!
*/
function fixContent(&$arr, $content, $depthData='', $first=0, $vKey='') {
protected function fixContent(&$arr, $content, $depthData='', $first=0, $vKey='') {
$ac=0;
$c=0;
// First, find number of entries
......
* @param string Command: If "FILE" then $this->printConf['contentLength_FILE'] is used for content length comparison, otherwise $this->printConf['contentLength']
* @return string
*/
function fixCLen($c,$v) {
protected function fixCLen($c,$v) {
$len = $v=='FILE'?$this->printConf['contentLength_FILE']:$this->printConf['contentLength'];
if (strlen($c)>$len) {
$c = '<span style="color:green;">'.htmlspecialchars(t3lib_div::fixed_lgd($c,$len)).'</span>';
......
* @param string The string to be wrapped
* @return string
*/
function fw($str) {
protected function fw($str) {
return '<span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:10px; color:black; vertical-align:top;">'.$str.'&nbsp;</span>';
}
......
* @access private
* @see printTSlog()
*/
function createHierarchyArray(&$arr,$pointer,$uniqueId) {
protected function createHierarchyArray(&$arr,$pointer,$uniqueId) {
if (!is_array($arr)) {
$arr = array();
}
......
* @param string URL for the <base> tag (if you want it)
* @return string
*/
function debug_typo3PrintError($header,$text,$js,$baseUrl='') {
protected function debug_typo3PrintError($header,$text,$js,$baseUrl='') {
if ($js) {
echo "alert('".t3lib_div::slashJS($header."\n".$text)."');";
} else {
t3lib/interfaces/interface.t3lib_timetracker.php (revision 0)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2008 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* time tracker interface
*
* @package TYPO3
* @subpackage t3lib
* @see t3lib_div::makeInstance()
*/
interface t3lib_TimeTracker {
/**
* "Constructor"
* Sets the starting time
*
* @return void
*/
public function start();
/**
* Pushes an element to the TypoScript tracking array
*
* @param string Label string for the entry, eg. TypoScript property name
* @param string Additional value(?)
* @return void
*/
public function push($tslabel, $value = '');
/**
* Pulls an element from the TypoScript tracking array
*
* @param string The content string generated within the push/pull part.
* @return void
*/
public function pull($content = '');
/**
* Set TSselectQuery - for messages in TypoScript debugger.
*
* @param array Query array
* @param string Message/Label to attach
* @return void
*/
public function setTSselectQuery(array $data, $msg = '');
/**
* Logs the TypoScript entry
*
* @param string The message string
* @param integer Message type: 0: information, 1: message, 2: warning, 3: error
* @return void
*/
public function setTSlogMessage($content, $num = 0);
/**
* Print TypoScript parsing log
*
* @return string HTML table with the information about parsing times.
*/
public function printTSlog();
/**
* Increases the stack pointer
*
* @return void
*/
public function incStackPointer();
/**
* Decreases the stack pointer
*
* @return void
*/
public function decStackPointer();
/**
* Returns microtime input to milliseconds
*
* @param string PHP microtime string
* @return integer
*/
public function convertMicrotime($microtime);
}
?>
t3lib/class.t3lib_timetracknull.php (revision 0)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2008 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
require_once(PATH_t3lib . 'interfaces/interface.t3lib_timetracker.php');
/**
* A fake time tracker that does nothing but implementing the time tracker
* interface. This is done to save some performance over the real time tracker.
*
* @author Ingo Renner <ingo@typo3.org>
* @package TYPO3
* @subpackage t3lib
*/
class t3lib_TimeTrackNull implements t3lib_TimeTracker {
/**
* "Constructor"
* Sets the starting time
*
* does nothing
*
* @return void
*/
public function start() {}
/**
* Pushes an element to the TypoScript tracking array
*
* does nothing
*
* @param string Label string for the entry, eg. TypoScript property name
* @param string Additional value(?)
* @return void
*/
public function push($tslabel, $value = '') {}
/**
* Pulls an element from the TypoScript tracking array
*
* does nothing
*
* @param string The content string generated within the push/pull part.
* @return void
*/
public function pull($content = '') {}
/**
* Set TSselectQuery - for messages in TypoScript debugger.
*
* does nothing
*
* @param array Query array
* @param string Message/Label to attach
* @return void
*/
public function setTSselectQuery(array $data, $msg = '') {}
/**
* Logs the TypoScript entry
*
* does nothing
*
* @param string The message string
* @param integer Message type: 0: information, 1: message, 2: warning, 3: error
* @return void
*/
public function setTSlogMessage($content, $num = 0) {}
/**
* Print TypoScript parsing log
*
* does nothing
*
* @return string HTML table with the information about parsing times.
*/
public function printTSlog() {}
/**
* Increases the stack pointer
*
* does nothing
*
* @return void
*/
public function incStackPointer() {}
/**
* Decreases the stack pointer
*
* does nothing
*
* @return void
*/
public function decStackPointer() {}
/**
* Returns microtime input to milliseconds
*
* does nothing
*
* @param string PHP microtime string
* @return integer
*/
public function convertMicrotime($microtime) {}
}
// XCLASSing is not possible for this class
?>
(2-2/4)