1
0
Fork 0
mirror of https://github.com/Oreolek/debug-toolbar.git synced 2024-06-16 23:00:50 +03:00

added routes info

This commit is contained in:
biakaveron 2010-02-04 00:26:20 +03:00
parent ac069fdc9e
commit 89f26ffdb7
4 changed files with 71 additions and 6 deletions

View file

@ -2,6 +2,9 @@
class DebugToolbar
{
protected static $_queries = FALSE;
protected static $_benchmarks = FALSE;
public static $benchmark_name = 'debug_toolbar';
/**
@ -39,6 +42,12 @@ class DebugToolbar
$template->set('modules', self::get_modules());
}
// Routes panel
if (Kohana::config('debug_toolbar.panels.routes') === TRUE)
{
$template->set('routes', self::get_routes());
}
// FirePHP
if (Kohana::config('debug_toolbar.firephp_enabled') === TRUE)
{
@ -110,6 +119,11 @@ class DebugToolbar
*/
public static function get_queries()
{
if (self::$_queries !== FALSE)
{
return self::$_queries;
}
$result = array();
$count = $time = $memory = 0;
@ -139,7 +153,9 @@ class DebugToolbar
$result[$name]['total'] = array($sub_count, $sub_time, $sub_memory);
}
}
return array('count' => $count, 'time' => $time, 'memory' => $memory, 'data' => $result);
self::$_queries = array('count' => $count, 'time' => $time, 'memory' => $memory, 'data' => $result);
return self::$_queries;
}
/**
@ -153,6 +169,12 @@ class DebugToolbar
{
return array();
}
if (self::$_benchmarks !== FALSE)
{
return self::$_benchmarks;
}
$groups = Profiler::groups();
$result = array();
foreach(array_keys($groups) as $group)
@ -186,6 +208,8 @@ class DebugToolbar
);
self::$_benchmarks = $result;
return $result;
}
@ -210,6 +234,11 @@ class DebugToolbar
return Kohana::modules();
}
public static function get_routes()
{
return Route::all();
}
/**
* Add toolbar data to FirePHP console
*

View file

@ -33,6 +33,7 @@ $config['panels'] = array(
'ajax' => TRUE,
'files' => TRUE,
'modules' => TRUE,
'routes' => TRUE,
);
/*

View file

@ -87,16 +87,19 @@ div#kohana-debug-toolbar tr.odd td {
background-color: #ddd;
}
div#kohana-debug-toolbar th {
padding: 3px 5px;
vertical-align: top;
background-color: #999;
color: #eee;
white-space: nowrap;
padding: 3px 5px;
vertical-align: top;
background-color: #999;
color: #eee;
white-space: nowrap;
}
div#kohana-debug-toolbar td,
div#kohana-debug-toolbar th {
border: 1px solid #efefef;
}
div#kohana-debug-toolbar tr.current {
font-weight: bold;
}
/* Toolbar */
div#kohana-debug-toolbar div#debug-toolbar {

View file

@ -87,6 +87,14 @@
</li>
<?php endif ?>
<!-- Routes -->
<?php if (Kohana::config('debug_toolbar.panels.routes')): ?>
<li id="toggle-routes" onclick="debugToolbar.show('debug-routes'); return false;">
<?php echo html::image(Kohana::config('debug_toolbar.icon_path').'/route.png', array('alt' => 'routes')) ?>
routes
</li>
<?php endif ?>
<!-- Swap sides -->
<li onclick="debugToolbar.swap(); return false;">
<?php echo html::image(Kohana::config('debug_toolbar.icon_path').'/text_align_left.png', array('alt' => 'align')) ?>
@ -268,6 +276,7 @@
</div>
<?php endif ?>
<!-- Module list -->
<?php if (Kohana::config('debug_toolbar.panels.modules')):
$mod_counter = 0; ?>
<div id="debug-modules" class="top" style="display: none;">
@ -287,5 +296,28 @@
<td><?php echo realpath($path) ?></td>
</tr>
<?php endforeach ?>
</table>
<?php endif ?>
</div>
<!-- Routes -->
<?php if (Kohana::config('debug_toolbar.panels.routes')):
$r_counter = 0; ?>
<div id="debug-routes" class="top" style="display: none;">
<h1>Routes</h1>
<table cellspacing="0" cellpadding="0">
<tr align="left">
<th>#</th>
<th>name</th>
</tr>
<?php foreach($routes as $name => $route):
$class = ($route == Request::instance()->route ? ' current' : ''); ?>
<tr class="<?php echo text::alternate('odd','even').$class?>">
<td><?php echo ++$r_counter ?></td>
<td><?php echo $name ?></td>
</tr>
<?php endforeach ?>
</table>
<?php endif ?>
</div>
</div>