diff --git a/classes/kohana/debugtoolbar.php b/classes/kohana/debugtoolbar.php index a2fc29d..b72d90b 100644 --- a/classes/kohana/debugtoolbar.php +++ b/classes/kohana/debugtoolbar.php @@ -31,6 +31,8 @@ abstract class Kohana_DebugToolbar { */ protected static $_custom_tabs = array(); + protected static $_custom_sections = array(); + /** * Can we render toolbar? * @@ -104,6 +106,7 @@ abstract class Kohana_DebugToolbar { if ($config->panels['customs'] === TRUE) { $template->set('customs', self::get_customs()); + $template->set('sections', self::get_custom_sections()); } // FirePHP @@ -163,6 +166,18 @@ abstract class Kohana_DebugToolbar { self::$_custom_tabs[$tab_name] = $data; } + /** + * Register additional sections. Supports callbacks for title or content params + * + * @param mixed $title section title (string or callback) + * @param mixed $data section content (string or callback) + * @param string $logo @TODO not used + */ + public static function add_section($title, $data, $logo = NULL) + { + self::$_custom_sections[] = array($title, $data, $logo); + } + /** * Get user vars * @@ -185,6 +200,27 @@ abstract class Kohana_DebugToolbar { return $result; } + /** + * Get custom sections + * + * @return array + */ + public static function get_custom_sections() + { + $result = array(); + foreach(self::$_custom_sections as $section) + { + list($title, $data, $logo) = $section; + $result[] = array( + 'title' => is_callable($title) ? call_user_func($title) : (string)$title, + 'content' => is_callable($data) ? call_user_func($data) : $data, + 'logo' => $logo + ); + } + + return $result; + } + /** * Retrieves query benchmarks from Database * diff --git a/views/toolbar.php b/views/toolbar.php index 12fe768..b735d40 100644 --- a/views/toolbar.php +++ b/views/toolbar.php @@ -94,6 +94,12 @@ load('debug_toolbar.panels.customs')): ?> + $section) : ?> +
  • + customs + +
  • +
  • customs customs @@ -368,6 +374,17 @@ + + load('debug_toolbar.panels.customs') && count($sections) > 0): ?> + $section) : ?> + + + + load('debug_toolbar.panels.customs') && count($customs) > 0): $r_counter = 0; ?>