XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
Legacy_Debugger.class.php
1<?php
10
11if (!defined('XOOPS_ROOT_PATH')) {
12 exit();
13}
14
15require_once XOOPS_ROOT_PATH . '/class/errorhandler.php';
16
17const XOOPS_DEBUG_OFF = 0;
18const XOOPS_DEBUG_PHP = 1;
19const XOOPS_DEBUG_MYSQL = 2;
20const XOOPS_DEBUG_SMARTY = 3;
21
23{
24 /***
25 * Create XoopsDebugger instance.
26 * You must not communicate with this method directly.
27 * @param $instance
28 * @param $debug_mode
29 */
30 public static function createInstance(&$instance, $debug_mode)
31 {
32 if (is_object($instance)) {
33 return;
34 }
35
36 switch ($debug_mode) {
37 case XOOPS_DEBUG_PHP:
38 $instance = new Legacy_PHPDebugger();
39 break;
40
41 case XOOPS_DEBUG_MYSQL:
42 $instance = new Legacy_MysqlDebugger();
43 break;
44
45 case XOOPS_DEBUG_SMARTY:
46 $instance = new Legacy_SmartyDebugger();
47 break;
48
49 case XOOPS_DEBUG_OFF:
50 default:
51 $instance = new Legacy_NonDebugger();
52 break;
53 }
54 }
55}
56
58{
59 public function __construct()
60 {
61 }
62
63 public function prepare()
64 {
65 }
66
67 public function isDebugRenderSystem()
68 {
69 return false;
70 }
71
72 /***
73 * @return string Log as html code.
74 */
75 public function renderLog()
76 {
77 }
78
79 public function displayLog()
80 {
81 }
82}
83
87
88/***
89 * @internal
90This class works for "PHP debugging mode".
91*/
93{
94 public function prepare()
95 {
96 if (defined('XOOPS_ERROR_REPORTING_LEVEL')) {
97 error_reporting(XOOPS_ERROR_REPORTING_LEVEL);
98 } else {
99 error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE);
100 }
101 $GLOBALS['xoopsErrorHandler'] =& XoopsErrorHandler::getInstance();
102 $GLOBALS['xoopsErrorHandler']->activate(true);
103 }
104}
105
106/***
107 * @internal
108This class works for "Mysql debugging mode".
109*/
111{
112 public function prepare()
113 {
114 $GLOBALS['xoopsErrorHandler'] =& XoopsErrorHandler::getInstance();
115 $GLOBALS['xoopsErrorHandler']->activate(true);
116 }
117
118 public function renderLog()
119 {
120 $xoopsLogger =& XoopsLogger::instance();
121 return $xoopsLogger->dumpAll();
122 }
123
124 // TODO ! @gigamaster debug
125 public function displayLog()
126 {
127 echo '<script type="text/javascript">
128 <!--//
129 debug_window = openWithSelfMain("Debug", "xoops_debug", 680, 600, true);
130 ';
131 $content = '<html lang="'._CHARSET.'"><head><meta http-equiv="content-type" content="text/html; charset='._CHARSET.'" /><meta http-equiv="content-language" content="'._LANGCODE.'" /><title>'.htmlspecialchars($GLOBALS['xoopsConfig']['sitename']).'</title><link rel="stylesheet" type="text/css" media="all" href="'.getcss($GLOBALS['xoopsConfig']['theme_set']).'" /></head><body>'.$this->renderLog().'<div style="text-align:center;"><input class="btn close" value="'._CLOSE.'" type="button" onclick="javascript:window.close();"></div></body></html>';
132 $lines = preg_split("/(\r\n|\r|\n)( *)/", $content);
133 foreach ($lines as $line) {
134 echo 'debug_window.document.writeln("'.str_replace('"', '\"', $line).'");';
135 }
136 echo '
137 debug_window.document.close();
138 //-->
139 </script>';
140 }
141}
142
143/***
144 * @internal
145This class works for "Smarty debugging mode".
146*/
148{
149 public function prepare()
150 {
151 $GLOBALS['xoopsErrorHandler'] =& XoopsErrorHandler::getInstance();
152 $GLOBALS['xoopsErrorHandler']->activate(true);
153 }
154
155 public function isDebugRenderSystem()
156 {
157 $root =& XCube_Root::getSingleton();
158 $user =& $root->mContext->mXoopsUser;
159
160 return is_object($user) ? $user->isAdmin(0) : false;
161 }
162}
static & getInstance()
static & instance()
Definition logger.php:45