From 39bcea2299691ae47a3bb82db99eabdcd9824b15 Mon Sep 17 00:00:00 2001 From: biakaveron Date: Fri, 16 Aug 2013 14:36:05 +0400 Subject: [PATCH] Custom sections added --- classes/Kohana/Debugtoolbar.php | 36 +++++++++++++++++++++++++++++++++ views/toolbar.php | 17 ++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/classes/Kohana/Debugtoolbar.php b/classes/Kohana/Debugtoolbar.php index a06e2d7..789c7fa 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? * @@ -99,6 +101,7 @@ abstract class Kohana_Debugtoolbar { if ($config->panels['customs'] === TRUE) { $template->set('customs', self::get_customs()); + $template->set('sections', self::get_custom_sections()); } // FirePHP @@ -159,6 +162,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 * @@ -181,6 +196,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 8e785e0..471dbb8 100644 --- a/views/toolbar.php +++ b/views/toolbar.php @@ -94,6 +94,12 @@ load('debug_toolbar.panels.customs')): ?> + $section) : ?> +
  • + customs + +
  • +
  • customs customs @@ -352,6 +358,17 @@ + + load('debug_toolbar.panels.customs') && count($sections) > 0): ?> + $section) : ?> + + + + load('debug_toolbar.panels.customs') && count($customs) > 0): $r_counter = 0; ?>