mirror of
https://github.com/Oreolek/debug-toolbar.git
synced 2024-06-16 23:00:50 +03:00
implemented #2
This commit is contained in:
parent
13b46475c0
commit
fc24a6154b
|
@ -4,6 +4,7 @@ class DebugToolbar
|
|||
{
|
||||
protected static $_queries = FALSE;
|
||||
protected static $_benchmarks = FALSE;
|
||||
protected static $_custom_tabs = array();
|
||||
|
||||
public static $benchmark_name = 'debug_toolbar';
|
||||
|
||||
|
@ -48,6 +49,12 @@ class DebugToolbar
|
|||
$template->set('routes', self::get_routes());
|
||||
}
|
||||
|
||||
// Custom data
|
||||
if (Kohana::config('debug_toolbar.panels.customs') === TRUE)
|
||||
{
|
||||
$template->set('customs', self::get_customs());
|
||||
}
|
||||
|
||||
// FirePHP
|
||||
if (Kohana::config('debug_toolbar.firephp_enabled') === TRUE)
|
||||
{
|
||||
|
@ -114,8 +121,44 @@ class DebugToolbar
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom data to render in a separate tab
|
||||
*
|
||||
* @param string $tab_name
|
||||
* @param mixed $data
|
||||
* @return void
|
||||
*/
|
||||
public static function add_custom($tab_name, $data)
|
||||
{
|
||||
self::$_custom_tabs[$tab_name] = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user vars
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_customs()
|
||||
{
|
||||
$result = array();
|
||||
|
||||
foreach(self::$_custom_tabs as $tab => $data)
|
||||
{
|
||||
if (is_array($data) OR is_object($data))
|
||||
{
|
||||
$data = Kohana::dump($data);
|
||||
}
|
||||
|
||||
$result[$tab] = $data;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves query benchmarks from Database
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_queries()
|
||||
{
|
||||
|
@ -226,6 +269,7 @@ class DebugToolbar
|
|||
}
|
||||
|
||||
/**
|
||||
* Get module list
|
||||
*
|
||||
* @return array module_name => module_path
|
||||
*/
|
||||
|
@ -234,6 +278,11 @@ class DebugToolbar
|
|||
return Kohana::modules();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all application routes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_routes()
|
||||
{
|
||||
return Route::all();
|
||||
|
|
|
@ -34,6 +34,7 @@ $config['panels'] = array(
|
|||
'files' => TRUE,
|
||||
'modules' => TRUE,
|
||||
'routes' => TRUE,
|
||||
'customs' => TRUE,
|
||||
);
|
||||
|
||||
/*
|
||||
|
|
BIN
images/custom.png
Executable file
BIN
images/custom.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 634 B |
|
@ -192,4 +192,33 @@ div#kohana-debug-toolbar div#debug-ajax {
|
|||
padding: 3px 0px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
/* Custom data */
|
||||
div#kohana-debug-toolbar div#debug-customs {
|
||||
padding: 3px 0px;
|
||||
}
|
||||
div#kohana-debug-toolbar div#debug-customs pre {
|
||||
background-color: #ddd;
|
||||
padding: 5px;
|
||||
color: #333;
|
||||
}
|
||||
div#kohana-debug-toolbar div#debug-customs .sectionmenu {
|
||||
margin: 20px 0 0 0;
|
||||
height: 23px;
|
||||
}
|
||||
div#kohana-debug-toolbar div#debug-customs .sectionmenu li {
|
||||
float: left;
|
||||
display: block;
|
||||
padding: 5px;
|
||||
margin: 0 6px 0 0;
|
||||
border-top: 1px solid #999;
|
||||
border-left: 1px solid #999;
|
||||
border-right: 1px solid #999;
|
||||
cursor: pointer;
|
||||
}
|
||||
div#kohana-debug-toolbar div#debug-customs .sectionmenu li.active {
|
||||
background-color: #ddd;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
</style>
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
<!-- Kohana version -->
|
||||
<li>
|
||||
<?php echo html::anchor("http://kohanaphp.com/home", Kohana::VERSION, array('target' => '_blank')) ?>
|
||||
<?php echo html::anchor("http://kohanaframework.org", Kohana::VERSION, array('target' => '_blank')) ?>
|
||||
</li>
|
||||
|
||||
<!-- Benchmarks -->
|
||||
|
@ -95,6 +95,14 @@
|
|||
</li>
|
||||
<?php endif ?>
|
||||
|
||||
<!-- Custom data -->
|
||||
<?php if (Kohana::config('debug_toolbar.panels.customs')): ?>
|
||||
<li id="toggle-customs" onclick="debugToolbar.show('debug-customs'); return false;">
|
||||
<?php echo html::image(Kohana::config('debug_toolbar.icon_path').'/custom.png', array('alt' => 'customs')) ?>
|
||||
customs
|
||||
</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')) ?>
|
||||
|
@ -324,4 +332,22 @@
|
|||
</table>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<!-- Custom data-->
|
||||
<?php if (Kohana::config('debug_toolbar.panels.customs') && count($customs) > 0):
|
||||
$r_counter = 0; ?>
|
||||
<div id="debug-customs" class="top" style="display: none;">
|
||||
<h1>Custom data</h1>
|
||||
<ul class="sectionmenu">
|
||||
<?php foreach($customs as $section => $data): ?>
|
||||
<li onclick="debugToolbar.showvar(this, 'customs-<?php echo $section ?>'); return false;"><?php echo $section ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php foreach($customs as $section => $data): ?>
|
||||
<div style="display: none;" id="customs-<?php echo $section ?>">
|
||||
<pre><?php echo $data ?></pre>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
Loading…
Reference in a new issue