Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationLatte
      • ApplicationTracy
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsLatte
      • Framework
      • HttpTracy
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Templating
    • Utils
  • NetteModule
  • none
  • Tracy

Classes

  • Bar
  • BlueScreen
  • Debugger
  • Dumper
  • FireLogger
  • Helpers
  • Logger
  • OutputDebugger

Interfaces

  • IBarPanel
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Tracy (https://tracy.nette.org)
  5:  * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
  6:  */
  7: 
  8: namespace Tracy;
  9: 
 10: use Tracy;
 11: 
 12: 
 13: /**
 14:  * Debug Bar.
 15:  *
 16:  * @author     David Grudl
 17:  */
 18: class Bar
 19: {
 20:     /** @var string[] */
 21:     public $info = array();
 22: 
 23:     /** @var IBarPanel[] */
 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:      * Returns panel with given id
 48:      * @param  string
 49:      * @return IBarPanel|NULL
 50:      */
 51:     public function getPanel($id)
 52:     {
 53:         return isset($this->panels[$id]) ? $this->panels[$id] : NULL;
 54:     }
 55: 
 56: 
 57:     /**
 58:      * Renders debug bar.
 59:      * @return void
 60:      */
 61:     public function render()
 62:     {
 63:         $obLevel = ob_get_level();
 64:         $panels = array();
 65:         foreach ($this->panels as $id => $panel) {
 66:             $idHtml = preg_replace('#[^a-z0-9]+#i', '-', $id);
 67:             try {
 68:                 $tab = (string) $panel->getTab();
 69:                 $panelHtml = $tab ? (string) $panel->getPanel() : NULL;
 70:                 if ($tab && $panel instanceof \Nette\Diagnostics\IBarPanel) {
 71:                     $panelHtml = preg_replace('~(["\'.\s#])nette-(debug|inner|collapsed|toggle|toggle-collapsed)(["\'\s])~', '$1tracy-$2$3', $panelHtml);
 72:                     $panelHtml = str_replace('tracy-toggle-collapsed', 'tracy-toggle tracy-collapsed', $panelHtml);
 73:                 }
 74:                 $panels[] = array('id' => $idHtml, 'tab' => $tab, 'panel' => $panelHtml);
 75: 
 76:             } catch (\Throwable $e) {
 77:             } catch (\Exception $e) {
 78:             }
 79:             if (isset($e)) {
 80:                 $panels[] = array(
 81:                     'id' => "error-$idHtml",
 82:                     'tab' => "Error in $id",
 83:                     'panel' => '<h1>Error: ' . $id . '</h1><div class="tracy-inner">'
 84:                         . nl2br(htmlSpecialChars($e, ENT_IGNORE, 'UTF-8')) . '</div>',
 85:                 );
 86:                 while (ob_get_level() > $obLevel) { // restore ob-level if broken
 87:                     ob_end_clean();
 88:                 }
 89:             }
 90:         }
 91: 
 92:         @session_start();
 93:         $session = & $_SESSION['__NF']['debuggerbar'];
 94:         if (preg_match('#^Location:#im', implode("\n", headers_list()))) {
 95:             $session[] = $panels;
 96:             return;
 97:         }
 98: 
 99:         foreach (array_reverse((array) $session) as $reqId => $oldpanels) {
100:             $panels[] = array(
101:                 'tab' => '<span title="Previous request before redirect">previous</span>',
102:                 'panel' => NULL,
103:                 'previous' => TRUE,
104:             );
105:             foreach ($oldpanels as $panel) {
106:                 $panel['id'] .= '-' . $reqId;
107:                 $panels[] = $panel;
108:             }
109:         }
110:         $session = NULL;
111: 
112:         $info = array_filter($this->info);
113:         require __DIR__ . '/templates/bar.phtml';
114:     }
115: 
116: }
117: 
Nette 2.2 API documentation generated by ApiGen 2.8.0