1
0
Fork 0
mirror of https://github.com/Oreolek/debug-toolbar.git synced 2024-05-04 10:08:14 +03:00

Code style fix

This commit is contained in:
biakaveron 2012-11-10 15:07:05 +04:00
parent 305c8217bb
commit 39d713c4ce
2 changed files with 92 additions and 51 deletions

View file

@ -5,7 +5,7 @@
*
* @package Debug Toolbar
* @author Aaron Forsander <http://grimhappy.com/>
* @author Brotkin Ivan (BIakaVeron) <BIakaVeron@gmail.com>
* @author Ivan Brotkin (BIakaVeron) <BIakaVeron@gmail.com>
* @author Sergei Gladkovskiy <smgladkovskiy@gmail.com>
*/
abstract class Kohana_DebugToolbar {
@ -47,7 +47,9 @@ abstract class Kohana_DebugToolbar {
public static function render()
{
if ( ! self::is_enabled())
{
return FALSE;
}
$token = Profiler::start('custom', self::$benchmark_name);
@ -132,6 +134,7 @@ abstract class Kohana_DebugToolbar {
*
* @param string $tab_name
* @param mixed $data
*
* @return void
*/
public static function add_custom($tab_name, $data)
@ -193,16 +196,26 @@ abstract class Kohana_DebugToolbar {
$total = Profiler::total($token);
$sub_time += $total[0];
$sub_memory += $total[1];
$result[$name][] = array('name' => $query, 'time' => $total[0], 'memory' => $total[1]);
$result[$name][] = array(
'name' => $query,
'time' => $total[0],
'memory' => $total[1]
);
}
}
$count += $sub_count;
$time += $sub_time;
$memory += $sub_memory;
$result[$name]['total'] = array($sub_count, $sub_time, $sub_memory);
}
}
self::$_queries = array('count' => $count, 'time' => $time, 'memory' => $memory, 'data' => $result);
self::$_queries = array(
'count' => $count,
'time' => $time,
'memory' => $memory,
'data' => $result
);
return self::$_queries;
}
@ -334,12 +347,17 @@ abstract class Kohana_DebugToolbar {
// Database
$query_stats = self::get_queries();
//$total_time = $total_rows = 0;
$table = array();
$table[] = array('DB profile', 'SQL Statement','Time','Memory');
$table[] = array(
'DB profile',
'SQL Statement',
'Time',
'Memory'
);
foreach ((array)$query_stats['data'] as $db => $queries)
{unset($queries['total']);
{
unset($queries['total']);
foreach ($queries as $query)
{
$table[] = array(
@ -362,7 +380,13 @@ abstract class Kohana_DebugToolbar {
$total = array_pop($groups);
$table = array();
$table[] = array('Group', 'Benchmark', 'Count', 'Time', 'Memory');
$table[] = array(
'Group',
'Benchmark',
'Count',
'Time',
'Memory'
);
foreach ((array)$groups as $group => $benchmarks)
{
@ -394,25 +418,35 @@ abstract class Kohana_DebugToolbar {
$config = Kohana::$config->load('debug_toolbar');
// Auto render if secret key isset
if ($config->secret_key !== FALSE and isset($_GET[$config->secret_key]))
if ($config->secret_key !== FALSE AND isset($_GET[$config->secret_key]))
{
return TRUE;
}
// Don't auto render when in PRODUCTION (this can obviously be
// overridden by the above secret key)
if (Kohana::$environment == Kohana::PRODUCTION)
{
return FALSE;
}
// Don't auto render toolbar for ajax requests
if (Request::initial()->is_ajax())
{
return FALSE;
}
// Don't auto render toolbar for cli requests
if (Kohana::$is_cli)
{
return FALSE;
}
// Don't auto render toolbar if $_GET['debug'] = 'false'
if (isset($_GET['debug']) and strtolower($_GET['debug']) == 'false')
if (isset($_GET['debug']) AND strtolower($_GET['debug']) == 'false')
{
return FALSE;
}
return TRUE;
}

View file

@ -1,12 +1,19 @@
<?php defined('SYSPATH') or die('No direct script access.');
// Load FirePHP if it enabled in config
if(Kohana::$config->load('debug_toolbar.firephp_enabled') === TRUE){
if (Kohana::$config->load('debug_toolbar.firephp_enabled') === TRUE)
{
$file = 'firephp/packages/core/lib/FirePHPCore/FirePHP.class';
$firePHP = Kohana::find_file('vendor', $file);
if( ! $firePHP) throw new Kohana_Exception('The FirePHP :file could not be found', array(':file'=>$file));
if ( ! $firePHP) {
throw new Kohana_Exception('The FirePHP :file could not be found', array(':file' => $file));
}
require_once $firePHP;
}
// Render Debug Toolbar on the end of application execution
if (Kohana::$config->load('debug_toolbar.auto_render') === TRUE)
{
register_shutdown_function('debugtoolbar::render');
}