1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13:
14:
15: 16: 17: 18: 19: 20:
21: class NDebugBar extends NObject
22: {
23:
24: private $panels = array();
25:
26:
27: 28: 29: 30: 31: 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: 48: 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) {
68: ob_end_clean();
69: }
70: }
71: }
72: require dirname(__FILE__) . '/templates/bar.phtml';
73: }
74:
75: }
76: