XCL Web Application Platform
2.5.0
The XoopsCube Legacy Project
📘
Loading...
Searching...
No Matches
Legacy_Debugger.class.php
1
<?php
10
11
if
(!defined(
'XOOPS_ROOT_PATH'
)) {
12
exit();
13
}
14
15
require_once XOOPS_ROOT_PATH .
'/class/errorhandler.php'
;
16
17
const
XOOPS_DEBUG_OFF = 0;
18
const
XOOPS_DEBUG_PHP = 1;
19
const
XOOPS_DEBUG_MYSQL = 2;
20
const
XOOPS_DEBUG_SMARTY = 3;
21
22
class
Legacy_DebuggerManager
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
57
class
Legacy_AbstractDebugger
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
84
class
Legacy_NonDebugger
extends
Legacy_AbstractDebugger
85
{
86
}
87
88
/***
89
* @internal
90
This class works for "PHP debugging mode".
91
*/
92
class
Legacy_PHPDebugger
extends
Legacy_AbstractDebugger
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
108
This class works for "Mysql debugging mode".
109
*/
110
class
Legacy_MysqlDebugger
extends
Legacy_AbstractDebugger
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
145
This class works for "Smarty debugging mode".
146
*/
147
class
Legacy_SmartyDebugger
extends
Legacy_AbstractDebugger
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
}
Legacy_AbstractDebugger
Definition
Legacy_Debugger.class.php:58
Legacy_DebuggerManager
Definition
Legacy_Debugger.class.php:23
Legacy_MysqlDebugger
Definition
Legacy_Debugger.class.php:111
Legacy_NonDebugger
Definition
Legacy_Debugger.class.php:85
Legacy_PHPDebugger
Definition
Legacy_Debugger.class.php:93
Legacy_SmartyDebugger
Definition
Legacy_Debugger.class.php:148
XoopsErrorHandler\getInstance
static & getInstance()
Definition
errorhandler.php:60
XoopsLogger\instance
static & instance()
Definition
logger.php:45
html
modules
legacy
class
Legacy_Debugger.class.php
Generated by
1.13.2