Namespaces

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

Classes

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

Interfaces

  • IBarPanel
  • ILogger
  • 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: 
 11: /**
 12:  * Debug Bar.
 13:  */
 14: class Bar
 15: {
 16:     /** @deprecated */
 17:     public $info = array();
 18: 
 19:     /** @var IBarPanel[] */
 20:     private $panels = array();
 21: 
 22: 
 23:     /**
 24:      * Add custom panel.
 25:      * @param  IBarPanel
 26:      * @param  string
 27:      * @return self
 28:      */
 29:     public function addPanel(IBarPanel $panel, $id = NULL)
 30:     {
 31:         if ($id === NULL) {
 32:             $c = 0;
 33:             do {
 34:                 $id = get_class($panel) . ($c++ ? "-$c" : '');
 35:             } while (isset($this->panels[$id]));
 36:         }
 37:         $this->panels[$id] = $panel;
 38:         return $this;
 39:     }
 40: 
 41: 
 42:     /**
 43:      * Returns panel with given id
 44:      * @param  string
 45:      * @return IBarPanel|NULL
 46:      */
 47:     public function getPanel($id)
 48:     {
 49:         return isset($this->panels[$id]) ? $this->panels[$id] : NULL;
 50:     }
 51: 
 52: 
 53:     /**
 54:      * Renders debug bar.
 55:      * @return void
 56:      */
 57:     public function render()
 58:     {
 59:         @session_start(); // @ session may be already started or it is not possible to start session
 60:         $session = & $_SESSION['__NF']['tracybar-2.3'];
 61:         $redirect = preg_match('#^Location:#im', implode("\n", headers_list()));
 62:         if ($redirect) {
 63:             Dumper::fetchLiveData();
 64:             Dumper::$livePrefix = count($session) . 'p';
 65:         }
 66: 
 67:         $obLevel = ob_get_level();
 68:         $panels = array();
 69:         foreach ($this->panels as $id => $panel) {
 70:             $idHtml = preg_replace('#[^a-z0-9]+#i', '-', $id);
 71:             try {
 72:                 $tab = (string) $panel->getTab();
 73:                 $panelHtml = $tab ? (string) $panel->getPanel() : NULL;
 74:                 if ($tab && $panel instanceof \Nette\Diagnostics\IBarPanel) {
 75:                     $panelHtml = preg_replace('~(["\'.\s#])nette-(debug|inner|collapsed|toggle|toggle-collapsed)(["\'\s])~', '$1tracy-$2$3', $panelHtml);
 76:                     $panelHtml = str_replace('tracy-toggle-collapsed', 'tracy-toggle tracy-collapsed', $panelHtml);
 77:                 }
 78:                 $panels[] = array('id' => $idHtml, 'tab' => $tab, 'panel' => $panelHtml);
 79: 
 80:             } catch (\Throwable $e) {
 81:             } catch (\Exception $e) {
 82:             }
 83:             if (isset($e)) {
 84:                 $panels[] = array(
 85:                     'id' => "error-$idHtml",
 86:                     'tab' => "Error in $id",
 87:                     'panel' => '<h1>Error: ' . $id . '</h1><div class="tracy-inner">'
 88:                         . nl2br(htmlSpecialChars($e, ENT_IGNORE, 'UTF-8')) . '</div>',
 89:                 );
 90:                 while (ob_get_level() > $obLevel) { // restore ob-level if broken
 91:                     ob_end_clean();
 92:                 }
 93:             }
 94:         }
 95: 
 96:         if ($redirect) {
 97:             $session[] = array('panels' => $panels, 'liveData' => Dumper::fetchLiveData());
 98:             return;
 99:         }
100: 
101:         $liveData = Dumper::fetchLiveData();
102: 
103:         foreach (array_reverse((array) $session) as $reqId => $info) {
104:             $panels[] = array(
105:                 'tab' => '<span title="Previous request before redirect">previous</span>',
106:                 'panel' => NULL,
107:                 'previous' => TRUE,
108:             );
109:             foreach ($info['panels'] as $panel) {
110:                 $panel['id'] .= '-' . $reqId;
111:                 $panels[] = $panel;
112:             }
113:             $liveData += $info['liveData'];
114:         }
115:         $session = NULL;
116: 
117:         require __DIR__ . '/assets/Bar/bar.phtml';
118:     }
119: 
120: }
121: 
Nette 2.3-20161221 API API documentation generated by ApiGen 2.8.0