1: <?php
2: /**
3: * AMR debugger class
4: *
5: * @package Plugin
6: * @subpackage ModRewrite
7: * @id $Id$:
8: * @author Murat Purc <murat@purc.de>
9: * @copyright four for business AG <www.4fb.de>
10: * @license http://www.contenido.org/license/LIZENZ.txt
11: * @link http://www.4fb.de
12: * @link http://www.contenido.org
13: */
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: /**
18: * Mod rewrite debugger class.
19: *
20: * @author Murat Purc <murat@purc.de>
21: * @package Plugin
22: * @subpackage ModRewrite
23: */
24: class ModRewriteDebugger {
25:
26: /**
27: * Flag to enable debugger
28: * @var bool
29: */
30: protected static $_bEnabled = false;
31:
32: /**
33: * Enable debugger setter.
34: * @param bool $bEnabled
35: */
36: public static function setEnabled($bEnabled) {
37: self::$_bEnabled = (bool) $bEnabled;
38: }
39:
40: /**
41: * Adds variable to debugger.
42: * Wrapper for <code>cDebug::getDebugger('visible_adv')</code>.
43: *
44: * @param mixed $mVar The variable to dump
45: * @param string $sLabel Describtion for passed $mVar
46: */
47: public static function add($mVar, $sLabel = '') {
48: if (!self::$_bEnabled) {
49: return;
50: }
51: cDebug::getDebugger()->add($mVar, $sLabel);
52: }
53:
54: /**
55: * Returns output of all added variables to debug.
56: * @return string
57: */
58: public static function getAll() {
59: if (!self::$_bEnabled) {
60: return '';
61: }
62: ob_start();
63: cDebug::getDebugger()->showAll();
64: $sOutput = ob_get_contents();
65: ob_end_clean();
66: return $sOutput;
67: }
68:
69: /**
70: * Logs variable to debugger.
71: * Wrapper for <code>cDebug::getDebugger(cDebug::DEBUGGER_FILE)</code>.
72: *
73: * @param mixed $mVar The variable to log the contents
74: * @param string $sLabel Describtion for passed $mVar
75: */
76: public static function log($mVar, $sLabel = '') {
77: if (!self::$_bEnabled) {
78: return;
79: }
80: cDebug::getDebugger(cDebug::DEBUGGER_FILE)->show($mVar, $sLabel);
81: }
82:
83: }
84: