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