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
  • Deprecated
 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:      * Add custom panel.
29:      * @param  IBarPanel
30:      * @param  string
31:      * @return self
32:      */
33:     public function addPanel(IBarPanel $panel, $id = NULL)
34:     {
35:         if ($id === NULL) {
36:             $c = 0;
37:             do {
38:                 $id = get_class($panel) . ($c++ ? "-$c" : '');
39:             } while (isset($this->panels[$id]));
40:         }
41:         $this->panels[$id] = $panel;
42:         return $this;
43:     }
44: 
45: 
46:     /**
47:      * Renders debug bar.
48:      * @return void
49:      */
50:     public function render()
51:     {
52:         $obLevel = ob_get_level();
53:         $panels = array();
54:         foreach ($this->panels as $id => $panel) {
55:             try {
56:                 $panels[] = array(
57:                     'id' => preg_replace('#[^a-z0-9]+#i', '-', $id),
58:                     'tab' => $tab = (string) $panel->getTab(),
59:                     'panel' => $tab ? (string) $panel->getPanel() : NULL,
60:                 );
61:             } catch (Exception $e) {
62:                 $panels[] = array(
63:                     'id' => "error-" . preg_replace('#[^a-z0-9]+#i', '-', $id),
64:                     'tab' => "Error in $id",
65:                     'panel' => '<h1>Error: ' . $id . '</h1><div class="nette-inner">' . nl2br(htmlSpecialChars($e)) . '</div>',
66:                 );
67:                 while (ob_get_level() > $obLevel) { // restore ob-level if broken
68:                     ob_end_clean();
69:                 }
70:             }
71:         }
72:         require dirname(__FILE__) . '/templates/bar.phtml';
73:     }
74: 
75: }
76: 
Nette Framework 2.0.11 (for PHP 5.2, prefixed) API API documentation generated by ApiGen 2.8.0