1: <?php
2:
3: 4: 5: 6: 7:
8:
9:
10:
11: 12: 13: 14: 15: 16:
17: class NDebugBar extends NObject
18: {
19:
20: private $panels = array();
21:
22:
23: 24: 25: 26: 27: 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: 44: 45:
46: public function render()
47: {
48: $obLevel = ob_get_level();
49: $panels = array();
50: foreach ($this->panels as $id => $panel) {
51: try {
52: $panels[] = array(
53: 'id' => preg_replace('#[^a-z0-9]+#i', '-', $id),
54: 'tab' => $tab = (string) $panel->getTab(),
55: 'panel' => $tab ? (string) $panel->getPanel() : NULL,
56: );
57: } catch (Exception $e) {
58: $panels[] = array(
59: 'id' => "error-" . preg_replace('#[^a-z0-9]+#i', '-', $id),
60: 'tab' => "Error in $id",
61: 'panel' => '<h1>Error: ' . $id . '</h1><div class="nette-inner">' . nl2br(htmlSpecialChars($e)) . '</div>',
62: );
63: while (ob_get_level() > $obLevel) {
64: ob_end_clean();
65: }
66: }
67: }
68: require dirname(__FILE__) . '/templates/bar.phtml';
69: }
70:
71: }
72: