4026b667bca5b8260dda188a6064b7437ef0ee0a

Author: chawbacca

Date: 2009-07-01 22:45:37 -0500

Merge from debug_kit.git

diff --git a/controllers/components/toolbar.php b/controllers/components/toolbar.php index 02fff3f..599f955 100644 --- a/controllers/components/toolbar.php +++ b/controllers/components/toolbar.php @@ -92,9 +92,10 @@ class ToolbarComponent extends Object { $panels = $this->_defaultPanels; if (isset($settings['panels'])) { - $panels = $settings['panels']; + $panels = $this->_makePanelList($settings['panels']); unset($settings['panels']); } + $this->cacheKey .= $controller->Session->read('Config.userAgent'); if (!isset($settings['history']) || (isset($settings['history']) && $settings['history'] !== false)) { $this->_createCacheConfig(); @@ -108,6 +109,28 @@ class ToolbarComponent extends Object { } /** + * Go through user panels and remove default panels as indicated. + * + * @param array $userPanels The list of panels ther user has added removed. + * @return array Array of panels to use. + **/ + function _makePanelList($userPanels) { + $panels = $this->_defaultPanels; + foreach ($userPanels as $key => $value) { + if (is_numeric($key)) { + $panels[] = $value; + } + if (is_string($key) && $value == false) { + $index = array_search($key, $panels); + if ($index !== false) { + unset($panels[$index]); + } + } + } + return $panels; + } + +/** * Component Startup * * @return bool @@ -146,6 +169,9 @@ class ToolbarComponent extends Object { * @return void **/ function beforeRedirect(&$controller) { + if (!class_exists('DebugKitDebugger')) { + return null; + } DebugKitDebugger::stopTimer('controllerAction'); $vars = $this->_gatherVars($controller); $this->_saveState($controller, $vars); @@ -213,6 +239,7 @@ class ToolbarComponent extends Object { } $vars[$panelName]['elementName'] = $elementName; $vars[$panelName]['plugin'] = $panel->plugin; + $vars[$panelName]['title'] = $panel->title; $vars[$panelName]['disableTimer'] = true; } return $vars; @@ -231,6 +258,9 @@ class ToolbarComponent extends Object { trigger_error(sprintf(__d('debug_kit', 'Could not load DebugToolbar panel %s', true), $panel), E_USER_WARNING); continue; } + if (strpos($className, '.') !== false) { + list($plugin, $className) = explode('.', $className); + } $panelObj =& new $className($settings); if (is_subclass_of($panelObj, 'DebugPanel') || is_subclass_of($panelObj, 'debugpanel')) { $this->panels[$panel] =& $panelObj; @@ -249,15 +279,27 @@ class ToolbarComponent extends Object { function _makeViewClass($baseClassName) { if (!class_exists('DoppelGangerView')) { App::import('View', $baseClassName); - if (strpos('View', $baseClassName) === false) { + if (strpos($baseClassName, '.') !== false) { + list($plugin, $baseClassName) = explode('.', $baseClassName); + } + if (strpos($baseClassName, 'View') === false) { $baseClassName .= 'View'; } $class = "class DoppelGangerView extends $baseClassName {}"; - eval($class); + $this->_eval($class); } } /** + * Method wrapper for eval() for testing uses. + * + * @return void + **/ + function _eval($code) { + eval($code); + } + +/** * Save the current state of the toolbar varibles to the cache file. * * @param object $controller Controller instance @@ -300,6 +342,13 @@ class DebugPanel extends Object { var $plugin = null; /** + * Defines the title for displaying on the toolbar. + * + * @var string + */ + var $title = null; + +/** * startup the panel * * Pull information from the controller / request @@ -576,20 +625,26 @@ class SqlLogPanel extends DebugPanel { **/ function _explainQuery(&$db, $queryString) { $driver = $db->config['driver']; - $results = null; + $return = null; if ($driver === 'mysqli' || $driver === 'mysql' || $driver === 'postgres') { $results = $db->query('EXPLAIN ' . $queryString); if ($driver === 'postgres') { $queryPlan = array(); foreach ($results as $postgreValue) { - $queryPlan[] = $postgreValue[0]['QUERY PLAN']; + $queryPlan[] = array($postgreValue[0]['QUERY PLAN']); + } + $results = array_merge(array(array('')), $queryPlan); + } else { + $keys = array_keys($results[0][0]); + foreach ($results as $mysqlValue) { + $queryPlan[] = array_values($mysqlValue[0]); } - $results[0][0] = array('Query Plan' => implode("<br />", $queryPlan)); + $results = array_merge(array($keys), $queryPlan); } - $results = $results[0][0]; - $results['query'] = $queryString; + $return['explain'] = $results; + $return['query'] = $queryString; } - return $results; + return $return; } } diff --git a/tests/cases/controllers/components/toolbar.test.php b/tests/cases/controllers/components/toolbar.test.php index ec20bc7..9dbbd5e 100644 --- a/tests/cases/controllers/components/toolbar.test.php +++ b/tests/cases/controllers/components/toolbar.test.php @@ -20,19 +20,34 @@ App::import('Component', 'DebugKit.Toolbar'); class TestToolbarComponent extends ToolbarComponent { + var $evalTest = false; + var $evalCode = ''; + function loadPanels($panels, $settings = array()) { $this->_loadPanels($panels, $settings); } + + function _eval($code) { + if ($this->evalTest) { + $this->evalCode = $code; + return; + } + eval($code); + } } Mock::generate('DebugPanel'); if (!class_exists('AppController')) { class AppController extends Controller { - + } } +class TestPanel extends DebugPanel { + +} + /** * DebugToolbar Test case */ @@ -88,6 +103,19 @@ class DebugToolbarTestCase extends CakeTestCase { } /** + * find the debug_kit path + * + * @return void + **/ + function _findPlugin() { + $paths = Configure::read('pluginPaths'); + foreach ($paths as $path) { + if (is_dir($path . 'debug_kit')) { + return $path . 'debug_kit' . DS; + } + } + } +/** * test Loading of panel classes * * @return void @@ -96,23 +124,51 @@ class DebugToolbarTestCase extends CakeTestCase { $this->Controller->Toolbar->loadPanels(array('session', 'request')); $this->assertTrue(is_a($this->Controller->Toolbar->panels['session'], 'SessionPanel')); $this->assertTrue(is_a($this->Controller->Toolbar->panels['request'], 'RequestPanel')); - + $this->Controller->Toolbar->loadPanels(array('history'), array('history' => 10)); $this->assertEqual($this->Controller->Toolbar->panels['history']->history, 10); - + $this->expectError(); $this->Controller->Toolbar->loadPanels(array('randomNonExisting', 'request')); } /** + * test Loading of panel classes from a plugin + * + * @return void + **/ + function testLoadPluginPanels() { + $this->Controller->Toolbar->loadPanels(array('plugin.test')); + $this->assertTrue(is_a($this->Controller->Toolbar->panels['plugin.test'], 'TestPanel')); + } + +/** + * test generating a DoppelGangerView with a pluginView. + * + * @return void + **/ + function testPluginViewParsing() { + App::import('Vendor', 'DebugKit.DebugKitDebugger'); + $this->Controller->Toolbar->evalTest = true; + $this->Controller->view = 'Plugin.OtherView'; + $this->Controller->Toolbar->startup($this->Controller); + $this->assertPattern('/class DoppelGangerView extends OtherView/', $this->Controller->Toolbar->evalCode); + } + +/** * test loading of vendor panels from test_app folder * * @access public * @return void */ function testVendorPanels() { - $f = Configure::read('pluginPaths'); - Configure::write('vendorPaths', array($f[1] . 'debug_kit' . DS . 'tests' . DS . 'test_app' . DS . 'vendors' . DS)); + $debugKitPath = $this->_findPlugin(); + $skip = $this->skipIf(empty($debugKitPath), 'Could not find debug_kit in plugin paths, skipping %s'); + if ($skip) { + return; + } + + Configure::write('vendorPaths', array($debugKitPath . 'tests' . DS . 'test_app' . DS . 'vendors' . DS)); $this->Controller->components = array( 'DebugKit.Toolbar' => array( 'panels' => array('test'), @@ -143,6 +199,39 @@ class DebugToolbarTestCase extends CakeTestCase { } /** + * test initialize w/ custom panels and defaults + * + * @return void + * @access public + **/ + function testInitializeCustomPanelsWithDefaults() { + $this->Controller->components = array( + 'DebugKit.Toolbar' => array('panels' => array('test')) + ); + $this->Controller->Component->init($this->Controller); + $this->Controller->Component->initialize($this->Controller); + + $expected = array('history', 'session', 'request', 'sqlLog', 'timer', 'log', 'variables', 'test'); + $this->assertEqual($expected, array_keys($this->Controller->Toolbar->panels)); + } + +/** + * test syntax for removing panels + * + * @return void + **/ + function testInitializeRemovingPanels() { + $this->Controller->components = array( + 'DebugKit.Toolbar' => array('panels' => array('session' => false, 'history' => false, 'test')) + ); + $this->Controller->Component->init($this->Controller); + $this->Controller->Component->initialize($this->Controller); + + $expected = array('request', 'sqlLog', 'timer', 'log', 'variables', 'test'); + $this->assertEqual($expected, array_keys($this->Controller->Toolbar->panels)); + } + +/** * ensure that enabled = false when debug == 0 on initialize * * @return void @@ -189,7 +278,6 @@ class DebugToolbarTestCase extends CakeTestCase { $this->Controller->Toolbar->panels['MockDebug']->expectOnce('startup'); $this->Controller->Toolbar->startup($this->Controller); - $this->assertEqual(count($this->Controller->Toolbar->panels), 1); $this->assertEqual($this->Controller->view, 'DebugKit.Debug'); $this->assertTrue(isset($this->Controller->helpers['DebugKit.Toolbar'])); @@ -211,7 +299,7 @@ class DebugToolbarTestCase extends CakeTestCase { $this->Controller->Component->init($this->Controller); $this->Controller->Component->initialize($this->Controller); $this->Controller->Component->startup($this->Controller); - + $results = Cache::config('debug_kit'); $this->assertTrue(is_array($results)); } @@ -231,7 +319,7 @@ class DebugToolbarTestCase extends CakeTestCase { $this->Controller->Component->startup($this->Controller); $this->Controller->set('test', 'testing'); $this->Controller->Component->beforeRender($this->Controller); - + $result = Cache::read('toolbar_history', $configName); $this->assertEqual($result[0]['variables']['content']['test'], 'testing'); Cache::delete('toolbar_history', $configName); @@ -252,7 +340,7 @@ class DebugToolbarTestCase extends CakeTestCase { $this->Controller->Component->initialize($this->Controller); $this->Controller->Toolbar->panels['MockDebug']->expectOnce('beforeRender'); $this->Controller->Toolbar->beforeRender($this->Controller); - + $this->assertTrue(isset($this->Controller->viewVars['debugToolbarPanels'])); $vars = $this->Controller->viewVars['debugToolbarPanels']; @@ -261,6 +349,7 @@ class DebugToolbarTestCase extends CakeTestCase { 'elementName' => 'session_panel', 'content' => $this->Controller->Session->read(), 'disableTimer' => true, + 'title' => '' ); $this->assertEqual($expected, $vars['session']); } @@ -290,7 +379,7 @@ class DebugToolbarTestCase extends CakeTestCase { $result = Cache::read('toolbar_history', $configName); $this->assertTrue(isset($result[0]['session'])); $this->assertTrue(isset($result[0]['mock_debug'])); - + $timers = DebugKitDebugger::getTimers(); $this->assertTrue(isset($timers['controllerAction'])); } @@ -319,7 +408,7 @@ class DebugToolbarTestCase extends CakeTestCase { $this->Controller->log('This is a log I made this request'); $this->Controller->log('This is the second log I made this request'); $this->Controller->log('This time in the debug log!', LOG_DEBUG); - + $this->Controller->components = array( 'DebugKit.Toolbar' => array( 'panels' => array('log', 'session') @@ -330,17 +419,17 @@ class DebugToolbarTestCase extends CakeTestCase { $this->Controller->Component->startup($this->Controller); $this->Controller->Component->beforeRender($this->Controller); $result = $this->Controller->viewVars['debugToolbarPanels']['log']; - + $this->assertEqual(count($result['content']), 2); $this->assertEqual(count($result['content']['error.log']), 4); $this->assertEqual(count($result['content']['debug.log']), 2); - + $this->assertEqual(trim($result['content']['debug.log'][1]), 'Debug: This time in the debug log!'); $this->assertEqual(trim($result['content']['error.log'][1]), 'Error: This is a log I made this request'); } /** - * Test that history state urls set prefix = null and admin = null so generated urls do not + * Test that history state urls set prefix = null and admin = null so generated urls do not * adopt these params. * * @return void @@ -360,7 +449,7 @@ class DebugToolbarTestCase extends CakeTestCase { $this->Controller->Component->initialize($this->Controller); $this->Controller->Toolbar->cacheKey = 'url_test'; $this->Controller->Component->beforeRender($this->Controller); - + $result = $this->Controller->Toolbar->panels['history']->beforeRender($this->Controller); $expected = array( 'plugin' => 'debug_kit', 'controller' => 'toolbar_access', 'action' => 'history_state', @@ -390,14 +479,19 @@ class DebugToolbarTestCase extends CakeTestCase { * @return void **/ function testNoRequestActionInterference() { - $f = Configure::read('pluginPaths'); - $testapp = $f[1] . 'debug_kit' . DS . 'tests' . DS . 'test_app' . DS . 'controllers' . DS; - array_unshift($f, $testapp); - Configure::write('controllerPaths', $f); + $debugKitPath = $this->_findPlugin(); + $skip = $this->skipIf(empty($debugKitPath), 'Could not find debug_kit in plugin paths, skipping %s'); + if ($skip) { + return; + } + + $controllers = Configure::read('controllerPaths'); + $testapp = $debugKitPath . 'tests' . DS . 'test_app' . DS . 'controllers' . DS; + array_unshift($controllers, $testapp); + Configure::write('controllerPaths', $controllers); - $plugins = Configure::read('pluginPaths'); $views = Configure::read('viewPaths'); - $testapp = $plugins[1] . 'debug_kit' . DS . 'tests' . DS . 'test_app' . DS . 'views' . DS; + $testapp = $debugKitPath . 'tests' . DS . 'test_app' . DS . 'views' . DS; array_unshift($views, $testapp); Configure::write('viewPaths', $views); @@ -417,7 +511,7 @@ class DebugToolbarTestCase extends CakeTestCase { App::import('Core', 'Model'); $Article = new Model(array('ds' => 'test_suite', 'name' => 'Article')); $Article->find('first', array('conditions' => array('Article.id' => 1))); - + $this->Controller->components = array( 'DebugKit.Toolbar' => array( 'panels' => array('SqlLog') @@ -428,11 +522,11 @@ class DebugToolbarTestCase extends CakeTestCase { $this->Controller->Component->startup($this->Controller); $this->Controller->Component->beforeRender($this->Controller); $result = $this->Controller->viewVars['debugToolbarPanels']['sql_log']; - + $this->assertTrue(isset($result['content']['test_suite']['queries'])); $this->assertTrue(isset($result['content']['test_suite']['explains'])); $query = array_pop($result['content']['test_suite']['queries']); - + $this->assertPattern('/\d/', $query[0], 'index not found. %s'); $this->assertPattern('/SELECT `Article/', $query[1], 'query not found. %s'); $this->assertEqual(count($query), 6, 'There are not 6 columns, something is wonky. %s'); diff --git a/tests/cases/views/helpers/fire_php_toobar.test.php b/tests/cases/views/helpers/fire_php_toobar.test.php deleted file mode 100644 index f45d0a1..0000000 --- a/tests/cases/views/helpers/fire_php_toobar.test.php +++ /dev/null @@ -1,129 +0,0 @@ -<?php -/** - * Toolbar Abstract Helper Test Case - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) - * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) - * - * Licensed under The MIT License - * Redistributions of files must retain the above copyright notice. - * - * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) - * @link http://cakephp.org - * @package debug_kit - * @subpackage debug_kit.tests.views.helpers - * @since DebugKit 0.1 - * @license MIT License (http://www.opensource.org/licenses/mit-license.php) - **/ -App::import('Helper', 'DebugKit.FirePhpToolbar'); -App::import('Core', array('View', 'Controller')); -App::import('File', 'TestFireCake', false, Configure::read('pluginPaths'), 'test_objects.php'); - -FireCake::getInstance('TestFireCake'); - -class FirePhpToolbarHelperTestCase extends CakeTestCase { -/** - * setUp - * - * @return void - **/ - function setUp() { - Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); - Router::parse('/'); - - $this->Toolbar =& new ToolbarHelper(array('output' => 'DebugKit.FirePhpToolbar')); - $this->Toolbar->FirePhpToolbar =& new FirePhpToolbarHelper(); - - $this->Controller =& ClassRegistry::init('Controller'); - if (isset($this->_debug)) { - Configure::write('debug', $this->_debug); - } - } -/** - * start Case - switch view paths - * - * @return void - **/ - function startCase() { - $this->_viewPaths = Configure::read('viewPaths'); - Configure::write('viewPaths', array( - TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, - APP . 'plugins' . DS . 'debug_kit' . DS . 'views'. DS, - ROOT . DS . LIBS . 'view' . DS - )); - $this->_debug = Configure::read('debug'); - $this->firecake =& FireCake::getInstance(); - } -/** - * test neat array (dump)creation - * - * @return void - */ - function testMakeNeatArray() { - $this->Toolbar->makeNeatArray(array(1,2,3)); - $result = $this->firecake->sentHeaders; - $this->assertTrue(isset($result['X-Wf-1-1-1-1'])); - $this->assertPattern('/\[1,2,3\]/', $result['X-Wf-1-1-1-1']); - } -/** - * testAfterlayout element rendering - * - * @return void - */ - function testAfterLayout(){ - $this->Controller->viewPath = 'posts'; - $this->Controller->action = 'index'; - $this->Controller->params = array( - 'action' => 'index', - 'controller' => 'posts', - 'plugin' => null, - 'url' => array('url' => 'posts/index', 'ext' => 'xml'), - 'base' => null, - 'here' => '/posts/index', - ); - $this->Controller->layout = 'default'; - $this->Controller->uses = null; - $this->Controller->components = array('DebugKit.Toolbar'); - $this->Controller->constructClasses(); - $this->Controller->Component->initialize($this->Controller); - $this->Controller->Component->startup($this->Controller); - $this->Controller->Component->beforeRender($this->Controller); - $result = $this->Controller->render(); - $this->assertNoPattern('/debug-toolbar/', $result); - $result = $this->firecake->sentHeaders; - $this->assertTrue(is_array($result)); - - } -/** - * endTest() - * - * @return void - */ - function endTest() { - TestFireCake::reset(); - } -/** - * reset the view paths - * - * @return void - **/ - function endCase() { - Configure::write('viewPaths', $this->_viewPaths); - } - -/** - * tearDown - * - * @access public - * @return void - */ - function tearDown() { - unset($this->Toolbar, $this->Controller); - ClassRegistry::removeObject('view'); - ClassRegistry::flush(); - Router::reload(); - } -} -?> \ No newline at end of file diff --git a/tests/cases/views/helpers/fire_php_toolbar.test.php b/tests/cases/views/helpers/fire_php_toolbar.test.php new file mode 100644 index 0000000..05147c0 --- /dev/null +++ b/tests/cases/views/helpers/fire_php_toolbar.test.php @@ -0,0 +1,148 @@ +<?php +/** + * Toolbar Abstract Helper Test Case + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) + * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://cakephp.org + * @package debug_kit + * @subpackage debug_kit.tests.views.helpers + * @since DebugKit 0.1 + * @license MIT License (http://www.opensource.org/licenses/mit-license.php) + **/ +App::import('Helper', 'DebugKit.FirePhpToolbar'); +App::import('Core', array('View', 'Controller')); +App::import('File', 'TestFireCake', false, Configure::read('pluginPaths'), 'test_objects.php'); + +FireCake::getInstance('TestFireCake'); + +class FirePhpToolbarHelperTestCase extends CakeTestCase { +/** + * setUp + * + * @return void + **/ + function startTest() { + Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); + Router::parse('/'); + + $this->Toolbar =& new ToolbarHelper(array('output' => 'DebugKit.FirePhpToolbar')); + $this->Toolbar->FirePhpToolbar =& new FirePhpToolbarHelper(); + + $this->Controller =& ClassRegistry::init('Controller'); + if (isset($this->_debug)) { + Configure::write('debug', $this->_debug); + } + } +/** + * start Case - switch view paths + * + * @return void + **/ + function startCase() { + $this->_viewPaths = Configure::read('viewPaths'); + Configure::write('viewPaths', array( + TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, + APP . 'plugins' . DS . 'debug_kit' . DS . 'views'. DS, + ROOT . DS . LIBS . 'view' . DS + )); + $this->_debug = Configure::read('debug'); + $this->firecake =& FireCake::getInstance(); + } +/** + * test neat array (dump)creation + * + * @return void + */ + function testMakeNeatArray() { + $this->Toolbar->makeNeatArray(array(1,2,3)); + $result = $this->firecake->sentHeaders; + $this->assertTrue(isset($result['X-Wf-1-1-1-1'])); + $this->assertPattern('/\[1,2,3\]/', $result['X-Wf-1-1-1-1']); + } +/** + * testAfterlayout element rendering + * + * @return void + */ + function testAfterLayout(){ + $this->Controller->viewPath = 'posts'; + $this->Controller->action = 'index'; + $this->Controller->params = array( + 'action' => 'index', + 'controller' => 'posts', + 'plugin' => null, + 'url' => array('url' => 'posts/index', 'ext' => 'xml'), + 'base' => null, + 'here' => '/posts/index', + ); + $this->Controller->layout = 'default'; + $this->Controller->uses = null; + $this->Controller->components = array('DebugKit.Toolbar'); + $this->Controller->constructClasses(); + $this->Controller->Component->initialize($this->Controller); + $this->Controller->Component->startup($this->Controller); + $this->Controller->Component->beforeRender($this->Controller); + $result = $this->Controller->render(); + $this->assertNoPattern('/debug-toolbar/', $result); + $result = $this->firecake->sentHeaders; + $this->assertTrue(is_array($result)); + } +/** + * test starting a panel + * + * @return void + **/ + function testPanelStart() { + $this->Toolbar->panelStart('My Panel', 'my_panel'); + $result = $this->firecake->sentHeaders; + $this->assertPattern('/GROUP_START.+My Panel/', $result['X-Wf-1-1-1-1']); + } +/** + * test ending a panel + * + * @return void + **/ + function testPanelEnd() { + $this->Toolbar->panelEnd(); + $result = $this->firecake->sentHeaders; + $this->assertPattern('/GROUP_END/', $result['X-Wf-1-1-1-1']); + } +/** + * endTest() + * + * @return void + */ + function endTest() { + TestFireCake::reset(); + } +/** + * reset the view paths + * + * @return void + **/ + function endCase() { + Configure::write('viewPaths', $this->_viewPaths); + } + +/** + * tearDown + * + * @access public + * @return void + */ + function tearDown() { + unset($this->Toolbar, $this->Controller); + ClassRegistry::removeObject('view'); + ClassRegistry::flush(); + Router::reload(); + } +} +?> \ No newline at end of file diff --git a/tests/cases/views/helpers/html_toolbar.test.php b/tests/cases/views/helpers/html_toolbar.test.php index e5106d6..b7054c3 100644 --- a/tests/cases/views/helpers/html_toolbar.test.php +++ b/tests/cases/views/helpers/html_toolbar.test.php @@ -299,6 +299,29 @@ class HtmlToolbarHelperTestCase extends CakeTestCase { $this->assertTags($result, $expected); } /** + * test starting a panel + * + * @return void + **/ + function testStartPanel() { + $result = $this->Toolbar->panelStart('My Panel', 'my_panel'); + $expected = array( + 'a' => array('href' => '#my_panel'), + 'My Panel', + '/a' + ); + $this->assertTags($result, $expected); + } +/** + * test ending a panel + * + * @return void + **/ + function testPanelEnd() { + $result = $this->Toolbar->panelEnd(); + $this->assertNull($result); + } +/** * reset the view paths * * @return void diff --git a/vendors/css/debug_toolbar.css b/vendors/css/debug_toolbar.css index ede2227..5b5714e 100644 --- a/vendors/css/debug_toolbar.css +++ b/vendors/css/debug_toolbar.css @@ -48,7 +48,10 @@ #debug-kit-toolbar .panel-tab.icon a { padding: 4px; } - +#debug-kit-toolbar .panel-tab a.edit-value { + float: none; + display: inline; +} /* Hovering over link shows tab, useful for no js */ #debug-kit-toolbar .panel-tab a:hover + .panel-content, #debug-kit-toolbar .panel-tab a + .panel-content:hover { @@ -146,7 +149,6 @@ background:#f7f7f7; } - /** code tables **/ #debug-kit-toolbar .code-table td { white-space: pre; @@ -195,6 +197,7 @@ font-weight: bold; } + /* expandable sections */ .neat-array li.expandable { cursor: pointer; @@ -228,9 +231,21 @@ #debug-kit-toolbar .debug-kit-graph-bar-value { background-color: #CE9E23; } -#sql_log-tab td { +/* Sql Log */ +#sql_log-tab td, +#sql_log-tab .slow-query-container p { font-family: Monaco, 'Corsiva', "Courier New", Courier, monospaced; } +#debug-kit-toolbar #sql_log-tab a.show-slow { + display:block; + margin: 3px; + float:none; +} +#sql_log-tab .slow-query-container p { + display:block; + clear:both; + margin: 20px 0 5px; +} /* previous panels */ #debug-kit-toolbar .panel-content-history { diff --git a/vendors/js/js_debug_toolbar.js b/vendors/js/js_debug_toolbar.js index 8fe9057..4dcb838 100755 --- a/vendors/js/js_debug_toolbar.js +++ b/vendors/js/js_debug_toolbar.js @@ -316,6 +316,9 @@ DEBUGKIT.toolbar = function () { clickedEl = clickedEl.parentNode; } var subUl = clickedEl.lastChild; + if (subUl.nodeName.toUpperCase() != 'UL') { + return; + } var hide = Boolean(subUl.style.display === 'block'); if (hide) { Element.hide(subUl); diff --git a/views/elements/debug_toolbar.ctp b/views/elements/debug_toolbar.ctp index fc992d6..9930faa 100644 --- a/views/elements/debug_toolbar.ctp +++ b/views/elements/debug_toolbar.ctp @@ -33,9 +33,10 @@ <?php foreach ($debugToolbarPanels as $panelName => $panelInfo): ?> <?php $panelUnderscore = Inflector::underscore($panelName);?> <li class="panel-tab"> - <a href="#<?php echo $panelUnderscore; ?>"> - <?php __d('debug_kit', Inflector::humanize($panelUnderscore)); ?> - </a> + <?php + $title = (empty($panelInfo['title'])) ? Inflector::humanize($panelUnderscore) : $panelInfo['title']; + echo $toolbar->panelStart($title, $panelUnderscore); + ?> <div class="panel-content" id="<?php echo $panelUnderscore ?>-tab"> <div class="panel-content-data"> <?php echo $this->element($panelInfo['elementName'], $panelInfo); ?> @@ -44,6 +45,7 @@ <!-- content here --> </div> </div> + <?php $toolbar->panelEnd(); ?> </li> <?php endforeach ?> </ul> diff --git a/views/elements/sql_log_panel.ctp b/views/elements/sql_log_panel.ctp index 76a1ac3..3771829 100644 --- a/views/elements/sql_log_panel.ctp +++ b/views/elements/sql_log_panel.ctp @@ -32,8 +32,11 @@ echo $html->link($name, '#', array('class' => 'show-slow')); echo '<div class="slow-query-container">'; - $headers = array_keys($queryLog['explains'][0]); - echo $toolbar->table($queryLog['explains'], $headers, array('title' => 'Slow Queries ' . $dbName)); + foreach ($queryLog['explains'] as $explain): + echo $toolbar->message(__d('debug_kit', 'Query:', true), $explain['query']); + $headers = array_shift($explain['explain']); + echo $toolbar->table($explain['explain'], $headers); + endforeach; echo '</div>'; else: echo $toolbar->message('Warning', __d('debug_kit', 'No slow queries!, or your database does not support EXPLAIN', true)); diff --git a/views/helpers/fire_php_toolbar.php b/views/helpers/fire_php_toolbar.php index f99af3c..b886a57 100644 --- a/views/helpers/fire_php_toolbar.php +++ b/views/helpers/fire_php_toolbar.php @@ -39,7 +39,6 @@ class FirePhpToolbarHelper extends ToolbarHelper { function _send() { $view =& ClassRegistry::getObject('view'); $view->element('debug_toolbar', array('plugin' => 'debug_kit', 'disableTimer' => true)); - Configure::write('debug', 1); } /** * makeNeatArray. @@ -78,5 +77,21 @@ class FirePhpToolbarHelper extends ToolbarHelper { array_unshift($rows, $headers); FireCake::table($title, $rows); } +/** + * Start a panel which is a 'Group' in FirePHP + * + * @return void + **/ + function panelStart($title, $anchor) { + FireCake::group($title); + } +/** + * End a panel (Group) + * + * @return void + **/ + function panelEnd() { + FireCake::groupEnd(); + } } ?> \ No newline at end of file diff --git a/views/helpers/html_toolbar.php b/views/helpers/html_toolbar.php index 859b692..e71e3e5 100644 --- a/views/helpers/html_toolbar.php +++ b/views/helpers/html_toolbar.php @@ -100,6 +100,15 @@ class HtmlToolbarHelper extends ToolbarHelper { return sprintf('<p><strong>%s</strong> %s</p>', $label, $message); } /** + * Start a panel. + * make a link and anchor. + * + * @return void + **/ + function panelStart($title, $anchor) { + return $this->Html->link($title, '#' . $anchor); + } +/** * Create a table. * * @param array $rows Rows to make.