Feature #19513 » 9657v0.diff

Administrator Admin, 2008-10-31 18:59

View differences:

t3lib/interfaces/interface.t3lib_timetracker.php (revision 0)
1
<?php
2
/***************************************************************
3
*  Copyright notice
4
*
5
*  (c) 2008 Ingo Renner <ingo@typo3.org>
6
*  All rights reserved
7
*
8
*  This script is part of the TYPO3 project. The TYPO3 project is
9
*  free software; you can redistribute it and/or modify
10
*  it under the terms of the GNU General Public License as published by
11
*  the Free Software Foundation; either version 2 of the License, or
12
*  (at your option) any later version.
13
*
14
*  The GNU General Public License can be found at
15
*  http://www.gnu.org/copyleft/gpl.html.
16
*  A copy is found in the textfile GPL.txt and important notices to the license
17
*  from the author is found in LICENSE.txt distributed with these scripts.
18
*
19
*
20
*  This script is distributed in the hope that it will be useful,
21
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
*  GNU General Public License for more details.
24
*
25
*  This copyright notice MUST APPEAR in all copies of the script!
26
***************************************************************/
27

  
28
/**
29
 * time tracker interface
30
 *
31
 * @package TYPO3
32
 * @subpackage t3lib
33
 * @see t3lib_div::makeInstance()
34
 */
35
interface t3lib_TimeTracker {
36

  
37
	/**
38
	 * "Constructor"
39
	 * Sets the starting time
40
	 *
41
	 * @return	void
42
	 */
43
	public function start();
44

  
45
	/**
46
	 * Pushes an element to the TypoScript tracking array
47
	 *
48
	 * @param	string		Label string for the entry, eg. TypoScript property name
49
	 * @param	string		Additional value(?)
50
	 * @return	void
51
	 */
52
	public function push($tslabel, $value = '');
53

  
54
	/**
55
	 * Pulls an element from the TypoScript tracking array
56
	 *
57
	 * @param	string		The content string generated within the push/pull part.
58
	 * @return	void
59
	 */
60
	public function pull($content = '');
61

  
62
	/**
63
	 * Set TSselectQuery - for messages in TypoScript debugger.
64
	 *
65
	 * @param	array		Query array
66
	 * @param	string		Message/Label to attach
67
	 * @return	void
68
	 */
69
	public function setTSselectQuery(array $data, $msg = '');
70

  
71
	/**
72
	 * Logs the TypoScript entry
73
	 *
74
	 * @param	string		The message string
75
	 * @param	integer		Message type: 0: information, 1: message, 2: warning, 3: error
76
	 * @return	void
77
	 */
78
	public function setTSlogMessage($content, $num = 0);
79

  
80
	/**
81
	 * Print TypoScript parsing log
82
	 *
83
	 * @return	string		HTML table with the information about parsing times.
84
	 */
85
	public function printTSlog();
86

  
87
	/**
88
	 * Increases the stack pointer
89
	 *
90
	 * @return	void
91
	 */
92
	public function incStackPointer();
93

  
94
	/**
95
	 * Decreases the stack pointer
96
	 *
97
	 * @return	void
98
	 */
99
	public function decStackPointer();
100

  
101
	/**
102
	 * Returns microtime input to milliseconds
103
	 *
104
	 * @param	string		PHP microtime string
105
	 * @return	integer
106
	 */
107
	public function convertMicrotime($microtime);
108

  
109
}
110

  
111
?>\ No newline at end of file
t3lib/class.t3lib_timetrack.php (working copy)
69 69

  
70 70

  
71 71

  
72

  
72
require_once(PATH_t3lib . 'interfaces/interface.t3lib_timetracker.php');
73 73

  
74 74

  
75 75

  
......
85 85
 * @subpackage t3lib
86 86
 * @see t3lib_tsfeBeUserAuth, tslib_fe, tslib_cObj, TSpagegen
87 87
 */
88
class t3lib_timeTrack {
88
class t3lib_timeTrack implements t3lib_TimeTracker {
89 89
	var $starttime = 0;             // Is loaded with the millisecond time when this object is created
90 90

  
91 91
	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
92 92
	var $printConf=array(
93
		'showParentKeys' => 1,
94
		'contentLength' => 10000,       // Determines max lenght of displayed content before it gets cropped.
93
		'showParentKeys'     => 1,
94
		'contentLength'      => 10000,       // Determines max lenght of displayed content before it gets cropped.
95 95
		'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.
96
		'flag_tree' => 1,
97
		'flag_messages' => 1,
98
		'flag_queries' => 0,
99
		'flag_content' => 0,
100
		'allTime' => 0,
101
		'keyLgd' => 40,
102
		'factor' => 10,
103
		'col' => '#D9D5C9',
104
		'highlight_col' => '#FF9933'
96
		'flag_tree'          => 1,
97
		'flag_messages'      => 1,
98
		'flag_queries'       => 0,
99
		'flag_content'       => 0,
100
		'allTime'            => 0,
101
		'keyLgd'             => 40,
102
		'factor'             => 10,
103
		'col'                => '#D9D5C9',
104
		'highlight_col'      => '#FF9933'
105 105
	);
106 106

  
107 107
	var $wrapError = array();
......
134 134
	 *
135 135
	 * @return	void
136 136
	 */
137
	function start()    {
137
	public function start() {
138 138
		$this->wrapError = array(
139 139
			0 => array('',''),
140 140
			1 => array('<strong>','</strong>'),
......
161 161
	 * @return	void
162 162
	 * @see tslib_cObj::cObjGetSingle(), pull()
163 163
	 */
164
	function push($tslabel, $value='')  {
164
	public function push($tslabel, $value = '') {
165 165
		array_push($this->tsStack[$this->tsStackPointer], $tslabel);
166 166
		array_push($this->currentHashPointer, 'timetracker_'.$this->uniqueCounter++);
167 167

  
......
186 186
	 * @return	void
187 187
	 * @see tslib_cObj::cObjGetSingle(), push()
188 188
	 */
189
	function pull($content='')  {
189
	public function pull($content = '') {
190 190
		$k = end($this->currentHashPointer);
191 191
		$this->tsStackLog[$k]['endtime'] =  microtime();
192 192
		$this->tsStackLog[$k]['content'] = $content;
......
204 204
	 * @return	void
205 205
	 * @see tslib_cObj::CONTENT()
206 206
	 */
207
	function setTSlogMessage($content,$num=0)   {
207
	public function setTSlogMessage($content, $num = 0) {
208 208
		end($this->currentHashPointer);
209 209
		$k = current($this->currentHashPointer);
210 210

  
......
221 221
	 * @param	string		Message/Label to attach
222 222
	 * @return	void
223 223
	 */
224
	function setTSselectQuery(array $data,$msg='')  {
224
	public function setTSselectQuery(array $data, $msg = '') {
225 225
		end($this->currentHashPointer);
226 226
		$k = current($this->currentHashPointer);
227 227

  
......
238 238
	 * @return	void
239 239
	 * @see decStackPointer(), TSpagegen::renderContent(), tslib_cObj::cObjGetSingle()
240 240
	 */
241
	function incStackPointer()  {
241
	public function incStackPointer() {
242 242
		$this->tsStackPointer++;
243 243
		$this->tsStack[$this->tsStackPointer]=array();
244 244
	}
......
249 249
	 * @return	void
250 250
	 * @see incStackPointer(), TSpagegen::renderContent(), tslib_cObj::cObjGetSingle()
251 251
	 */
252
	function decStackPointer()  {
252
	public function decStackPointer() {
253 253
		unset($this->tsStack[$this->tsStackPointer]);
254 254
		$this->tsStackPointer--;
255 255
	}
......
259 259
	 *
260 260
	 * @return	integer
261 261
	 */
262
	function mtime()    {
262
	protected function mtime()    {
263 263
		return $this->convertMicrotime(microtime())-$this->starttime;
264 264
	}
265 265

  
......
269 269
	 * @param	string		PHP microtime string
270 270
	 * @return	integer
271 271
	 */
272
	function convertMicrotime($microtime)   {
272
	public function convertMicrotime($microtime) {
273 273
		$parts = explode(' ',$microtime);
274 274
		return round(($parts[0]+$parts[1])*1000);
275 275
	}
......
302 302
	 * @return	string		HTML table with the information about parsing times.
303 303
	 * @see t3lib_tsfeBeUserAuth::extGetCategory_tsdebug()
304 304
	 */
305
	function printTSlog() {
305
	public function printTSlog() {
306 306
			// Calculate times and keys for the tsStackLog
307 307
		$preEndtime = 0;
308 308
		foreach($this->tsStackLog as $uniqueId=>$data) {
......
454 454
	 * @param	string		Seems to be the previous tsStackLog key
455 455
	 * @return	string		Returns the $content string generated/modified. Also the $arr array is modified!
456 456
	 */
457
	function fixContent(&$arr, $content, $depthData='', $first=0, $vKey='') {
457
	protected function fixContent(&$arr, $content, $depthData='', $first=0, $vKey='') {
458 458
		$ac=0;
459 459
		$c=0;
460 460
			// First, find number of entries
......
518 518
	 * @param	string		Command: If "FILE" then $this->printConf['contentLength_FILE'] is used for content length comparison, otherwise $this->printConf['contentLength']
519 519
	 * @return	string
520 520
	 */
521
	function fixCLen($c,$v) {
521
	protected function fixCLen($c,$v) {
522 522
		$len = $v=='FILE'?$this->printConf['contentLength_FILE']:$this->printConf['contentLength'];
523 523
		if (strlen($c)>$len) {
524 524
			$c = '<span style="color:green;">'.htmlspecialchars(t3lib_div::fixed_lgd($c,$len)).'</span>';
......
534 534
	 * @param	string		The string to be wrapped
535 535
	 * @return	string
536 536
	 */
537
	function fw($str) {
537
	protected function fw($str) {
538 538
		return '<span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:10px; color:black; vertical-align:top;">'.$str.'&nbsp;</span>';
539 539
	}
540 540

  
......
548 548
	 * @access private
549 549
	 * @see printTSlog()
550 550
	 */
551
	function createHierarchyArray(&$arr,$pointer,$uniqueId) {
551
	protected function createHierarchyArray(&$arr,$pointer,$uniqueId) {
552 552
		if (!is_array($arr)) {
553 553
			$arr = array();
554 554
		}
......
570 570
	 * @param	string		URL for the <base> tag (if you want it)
571 571
	 * @return	string
572 572
	 */
573
	function debug_typo3PrintError($header,$text,$js,$baseUrl='') {
573
	protected function debug_typo3PrintError($header,$text,$js,$baseUrl='') {
574 574
		if ($js) {
575 575
			echo "alert('".t3lib_div::slashJS($header."\n".$text)."');";
576 576
		} else {
t3lib/class.t3lib_timetracknull.php (revision 0)
1
<?php
2
/***************************************************************
3
*  Copyright notice
4
*
5
*  (c) 2008 Ingo Renner <ingo@typo3.org>
6
*  All rights reserved
7
*
8
*  This script is part of the TYPO3 project. The TYPO3 project is
9
*  free software; you can redistribute it and/or modify
10
*  it under the terms of the GNU General Public License as published by
11
*  the Free Software Foundation; either version 2 of the License, or
12
*  (at your option) any later version.
13
*
14
*  The GNU General Public License can be found at
15
*  http://www.gnu.org/copyleft/gpl.html.
16
*
17
*  This script is distributed in the hope that it will be useful,
18
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
19
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
*  GNU General Public License for more details.
21
*
22
*  This copyright notice MUST APPEAR in all copies of the script!
23
***************************************************************/
24

  
25

  
26
require_once(PATH_t3lib . 'interfaces/interface.t3lib_timetracker.php');
27

  
28

  
29
/**
30
 * A fake time tracker that does nothing but implementing the time tracker
31
 * interface. This is done to save some performance over the real time tracker.
32
 *
33
 * @author	Ingo Renner <ingo@typo3.org>
34
 * @package TYPO3
35
 * @subpackage t3lib
36
 */
37
class t3lib_TimeTrackNull implements t3lib_TimeTracker {
38

  
39
	/**
40
	 * "Constructor"
41
	 * Sets the starting time
42
	 *
43
	 * does nothing
44
	 *
45
	 * @return	void
46
	 */
47
	public function start() {}
48

  
49
	/**
50
	 * Pushes an element to the TypoScript tracking array
51
	 *
52
	 * does nothing
53
	 *
54
	 * @param	string		Label string for the entry, eg. TypoScript property name
55
	 * @param	string		Additional value(?)
56
	 * @return	void
57
	 */
58
	public function push($tslabel, $value = '') {}
59

  
60
	/**
61
	 * Pulls an element from the TypoScript tracking array
62
	 *
63
	 * does nothing
64
	 *
65
	 * @param	string		The content string generated within the push/pull part.
66
	 * @return	void
67
	 */
68
	public function pull($content = '') {}
69

  
70
	/**
71
	 * Set TSselectQuery - for messages in TypoScript debugger.
72
	 *
73
	 * does nothing
74
	 *
75
	 * @param	array		Query array
76
	 * @param	string		Message/Label to attach
77
	 * @return	void
78
	 */
79
	public function setTSselectQuery(array $data, $msg = '') {}
80

  
81
	/**
82
	 * Logs the TypoScript entry
83
	 *
84
	 * does nothing
85
	 *
86
	 * @param	string		The message string
87
	 * @param	integer		Message type: 0: information, 1: message, 2: warning, 3: error
88
	 * @return	void
89
	 */
90
	public function setTSlogMessage($content, $num = 0) {}
91

  
92
	/**
93
	 * Print TypoScript parsing log
94
	 *
95
	 * does nothing
96
	 *
97
	 * @return	string		HTML table with the information about parsing times.
98
	 */
99
	public function printTSlog() {}
100

  
101
	/**
102
	 * Increases the stack pointer
103
	 *
104
	 * does nothing
105
	 *
106
	 * @return	void
107
	 */
108
	public function incStackPointer() {}
109

  
110
	/**
111
	 * Decreases the stack pointer
112
	 *
113
	 * does nothing
114
	 *
115
	 * @return	void
116
	 */
117
	public function decStackPointer() {}
118

  
119
	/**
120
	 * Returns microtime input to milliseconds
121
	 *
122
	 * does nothing
123
	 *
124
	 * @param	string		PHP microtime string
125
	 * @return	integer
126
	 */
127
	public function convertMicrotime($microtime) {}
128

  
129
}
130

  
131
// XCLASSing is not possible for this class
132

  
133
?>\ No newline at end of file
(1-1/4)