Packages

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • NDebugBar
  • NDebugBlueScreen
  • NDebugger
  • NDebugHelpers
  • NFireLogger
  • NLogger

Interfaces

  • IBarPanel
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (http://nette.org)
 5:  *
 6:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 7:  *
 8:  * For the full copyright and license information, please view
 9:  * the file license.txt that was distributed with this source code.
10:  * @package Nette\Diagnostics
11:  */
12: 
13: 
14: 
15: /**
16:  * Debug Bar.
17:  *
18:  * @author     David Grudl
19:  * @package Nette\Diagnostics
20:  */
21: class NDebugBar extends NObject
22: {
23:     /** @var array */
24:     private $panels = array();
25: 
26: 
27: 
28:     /**
29:      * Add custom panel.
30:      * @param  IBarPanel
31:      * @param  string
32:      * @return NDebugBar  provides a fluent interface
33:      */
34:     public function addPanel(IBarPanel $panel, $id = NULL)
35:     {
36:         if ($id === NULL) {
37:             $c = 0;
38:             do {
39:                 $id = get_class($panel) . ($c++ ? "-$c" : '');
40:             } while (isset($this->panels[$id]));
41:         }
42:         $this->panels[$id] = $panel;
43:         return $this;
44:     }
45: 
46: 
47: 
48:     /**
49:      * Renders debug bar.
50:      * @return void
51:      */
52:     public function render()
53:     {
54:         $obLevel = ob_get_level();
55:         $panels = array();
56:         foreach ($this->panels as $id => $panel) {
57:             try {
58:                 $panels[] = array(
59:                     'id' => preg_replace('#[^a-z0-9]+#i', '-', $id),
60:                     'tab' => $tab = (string) $panel->getTab(),
61:                     'panel' => $tab ? (string) $panel->getPanel() : NULL,
62:                 );
63:             } catch (Exception $e) {
64:                 $panels[] = array(
65:                     'id' => "error-" . preg_replace('#[^a-z0-9]+#i', '-', $id),
66:                     'tab' => "Error in $id",
67:                     'panel' => '<h1>Error: ' . $id . '</h1><div class="nette-inner">' . nl2br(htmlSpecialChars($e)) . '</div>',
68:                 );
69:                 while (ob_get_level() > $obLevel) { // restore ob-level if broken
70:                     ob_end_clean();
71:                 }
72:             }
73:         }
74:         require dirname(__FILE__) . '/templates/bar.phtml';
75:     }
76: 
77: }
78: 
Nette Framework 2.0.1 (for PHP 5.2, prefixed) API API documentation generated by ApiGen 2.7.0