Namespaces

  • 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

  • Bar
  • BlueScreen
  • Debugger
  • FireLogger
  • Helpers
  • Logger

Interfaces

  • IBarPanel
  • Overview
  • Namespace
  • 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:  */
11: 
12: namespace Nette\Diagnostics;
13: 
14: use Nette;
15: 
16: 
17: /**
18:  * Debug Bar.
19:  *
20:  * @author     David Grudl
21:  */
22: class Bar extends Nette\Object
23: {
24:     /** @var array */
25:     private $panels = array();
26: 
27: 
28:     /**
29:      * Add custom panel.
30:      * @param  IBarPanel
31:      * @param  string
32:      * @return self
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:      * Renders debug bar.
49:      * @return void
50:      */
51:     public function render()
52:     {
53:         $obLevel = ob_get_level();
54:         $panels = array();
55:         foreach ($this->panels as $id => $panel) {
56:             try {
57:                 $panels[] = array(
58:                     'id' => preg_replace('#[^a-z0-9]+#i', '-', $id),
59:                     'tab' => $tab = (string) $panel->getTab(),
60:                     'panel' => $tab ? (string) $panel->getPanel() : NULL,
61:                 );
62:             } catch (\Exception $e) {
63:                 $panels[] = array(
64:                     'id' => "error-" . preg_replace('#[^a-z0-9]+#i', '-', $id),
65:                     'tab' => "Error in $id",
66:                     'panel' => '<h1>Error: ' . $id . '</h1><div class="nette-inner">' . nl2br(htmlSpecialChars($e)) . '</div>',
67:                 );
68:                 while (ob_get_level() > $obLevel) { // restore ob-level if broken
69:                     ob_end_clean();
70:                 }
71:             }
72:         }
73:         require __DIR__ . '/templates/bar.phtml';
74:     }
75: 
76: }
77: 
Nette Framework 2.0.11 API API documentation generated by ApiGen 2.8.0