Skip to content

Commit 5b2902b

Browse files
committed
Much nicer debug output
1 parent a227077 commit 5b2902b

File tree

14 files changed

+36
-10
lines changed

14 files changed

+36
-10
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Contao Open Source CMS Changelog
44
Version 3.0.beta1 (XXXX-XX-XX)
55
------------------------------
66

7+
### Improved
8+
Much nicer debug output.
9+
710
### Changed
811
Modules are now disabled by adding a `.skip` file instead of using the global
912
`inactiveModules` array. This way the local configuration file does not have to

contao/install.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function run()
135135
$this->Template->ftpUserError = true;
136136
$this->outputAndExit();
137137
}
138-
elseif (ftp_size($resFtp, $GLOBALS['TL_CONFIG']['ftpPath'] . 'system/contao.css') == -1)
138+
elseif (ftp_size($resFtp, $GLOBALS['TL_CONFIG']['ftpPath'] . 'assets/css/contao.css') == -1)
139139
{
140140
$this->Template->ftpPathError = true;
141141
$this->outputAndExit();

robots.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Disallow: /share.php
1111
Disallow: /GPL.txt
1212
Disallow: /README.md
1313
Disallow: /LGPL.txt
14-
Allow: /system/html/
15-
Allow: /system/contao.css
14+
Allow: /assets/
1615
Allow: /plugins/*.js
1716
Allow: /plugins/*.css

system/initialize.php

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
*/
2929

3030

31+
/**
32+
* Store the microtime
33+
*/
34+
define('TL_START', microtime(true));
35+
36+
3137
/**
3238
* Define the root path to the Contao installation
3339
*/

system/library/Contao/Database/Statement.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ protected function debugQuery($objResult=null)
401401
if ($objResult !== null || strncmp(strtoupper($this->strQuery), 'SELECT', 6) !== 0)
402402
{
403403
$arrData[] = sprintf('%d rows affected', $this->affectedRows);
404-
$GLOBALS['TL_DEBUG'][] = $arrData;
404+
$GLOBALS['TL_DEBUG']['db'][] = $arrData;
405405

406406
return;
407407
}
@@ -413,7 +413,7 @@ protected function debugQuery($objResult=null)
413413
$arrData[] = $arrExplain;
414414
}
415415

416-
$GLOBALS['TL_DEBUG'][] = $arrData;
416+
$GLOBALS['TL_DEBUG']['db'][] = $arrData;
417417
}
418418

419419

system/library/Contao/Template.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,13 @@ public function output()
295295
// Debug information
296296
if ($GLOBALS['TL_CONFIG']['debugMode'])
297297
{
298-
echo "\n\n" . '<pre id="debug" style="width:80%;overflow:auto;margin:24px auto;padding:9px;background:#fff">' . "\n";
299-
echo "<strong>Debug information</strong>\n\n";
298+
echo "\n\n"
299+
. '<div id="debug">' . "\n"
300+
. '<p><span class="info">Contao debug information</span> <span class="time">Execution time: ' . $this->getFormattedNumber(microtime(true) - TL_START, 4) . ' seconds</span> <span class="memory">Memory usage: ' . $this->getReadableSize(memory_get_peak_usage()) . '</span> <span class="db">Database queries: ' . count($GLOBALS['TL_DEBUG']['db']) . '</span></p>' . "\n"
301+
. '<div><pre>' . "\n";
300302
print_r($GLOBALS['TL_DEBUG']);
301-
echo '</pre>';
303+
echo '</pre></div>'
304+
. '<script>$$("#debug p", "#debug div").setStyle("width", window.getSize().x)</script>';
302305
}
303306
}
304307

system/modules/backend/Automator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function purgeScriptsFolder()
194194
{
195195
foreach ($arrScripts as $strFile)
196196
{
197-
if ($strFile != 'index.html' && $strFile != 'contao.css' && !is_dir(TL_ROOT . '/system/scripts/' . $strFile))
197+
if ($strFile != 'index.html' && $strFile != 'contao.css' && $strFile != 'debug.css' && !is_dir(TL_ROOT . '/system/scripts/' . $strFile))
198198
{
199199
unlink(TL_ROOT . '/assets/css/' . $strFile);
200200
}

system/modules/backend/BackendTemplate.php

+6
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ public function output()
114114
$this->stylesheets = $strStyleSheets;
115115
}
116116

117+
// Add the debug style sheet
118+
if ($GLOBALS['TL_CONFIG']['debugMode'])
119+
{
120+
$this->stylesheets .= '<link rel="stylesheet" href="' . $this->addStaticUrlTo('assets/css/debug.css') . '" media="all">' . "\n";
121+
}
122+
117123
// JavaScripts
118124
if (is_array($GLOBALS['TL_JAVASCRIPT']) && !empty($GLOBALS['TL_JAVASCRIPT']))
119125
{

system/modules/backend/StyleSheets.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function updateStyleSheets()
9797
foreach (scan(TL_ROOT . '/assets/css', true) as $file)
9898
{
9999
// Skip directories
100-
if (is_dir(TL_ROOT . '/assets/css/' . $file) || $file == 'contao.css')
100+
if (is_dir(TL_ROOT . '/assets/css/' . $file) || $file == 'contao.css' || $file == 'debug.css')
101101
{
102102
continue;
103103
}

system/modules/backend/templates/be_install.html5

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<link rel="stylesheet" href="<?php echo TL_SCRIPT_URL; ?>system/themes/<?php echo $this->theme; ?>/basic.css" media="all">
99
<link rel="stylesheet" href="<?php echo TL_SCRIPT_URL; ?>system/themes/<?php echo $this->theme; ?>/install.css" media="all">
1010
<!--[if IE]><link rel="stylesheet" href="<?php echo TL_SCRIPT_URL; ?>system/themes/<?php echo $this->theme; ?>/iefixes.css"><![endif]-->
11+
<?php echo $this->stylesheets; ?>
1112
<script><?php echo $this->getLocaleString(); ?></script>
1213
<script src="<?php echo TL_PLUGINS_URL; ?>plugins/mootools/<?php echo MOOTOOLS; ?>/mootools-core.js"></script>
1314
<script src="<?php echo TL_PLUGINS_URL; ?>plugins/mootools/<?php echo MOOTOOLS; ?>/mootools-more.js"></script>

system/modules/backend/templates/be_login.html5

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
echo $objCombiner->getCombinedFile();
1313
?>" media="all">
1414
<!--[if IE]><link rel="stylesheet" href="<?php echo TL_SCRIPT_URL; ?>system/themes/<?php echo $this->theme; ?>/iefixes.css"><![endif]-->
15+
<?php echo $this->stylesheets; ?>
1516
<script><?php echo $this->getLocaleString(); ?></script>
1617
<script src="<?php
1718
$objCombiner = new Combiner();

system/modules/backend/templates/be_password.html5

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
echo $objCombiner->getCombinedFile();
1212
?>" media="all">
1313
<!--[if IE]><link rel="stylesheet" href="<?php echo TL_SCRIPT_URL; ?>system/themes/<?php echo $this->theme; ?>/iefixes.css"><![endif]-->
14+
<?php echo $this->stylesheets; ?>
1415
<script><?php echo $this->getLocaleString(); ?></script>
1516
<script src="<?php
1617
$objCombiner = new Combiner();

system/modules/frontend/PageRegular.php

+6
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,12 @@ protected function createHeaderScripts(Database_Result $objPage, Database_Result
437437
$strStyleSheets .= '<link' . (($objPage->outputFormat == 'xhtml') ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . $objCombiner->getCombinedFile() . '" media="all"' . $strTagEnding . "\n";
438438
}
439439

440+
// Add the debug style sheet
441+
if ($GLOBALS['TL_CONFIG']['debugMode'])
442+
{
443+
$strStyleSheets .= '<link rel="stylesheet" href="' . $this->addStaticUrlTo('assets/css/debug.css') . '" media="all">' . "\n";
444+
}
445+
440446
// Always add conditional style sheets at the end
441447
$strStyleSheets .= $strCcStyleSheets;
442448

system/themes/default/images/db.gif

422 Bytes
Loading

0 commit comments

Comments
 (0)