1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class Kint_Renderer_Plain extends Kint_Renderer_Text |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
public static $pre_render_sources = array( |
|
|
|
|
6
|
|
|
'script' => array(), |
7
|
|
|
'style' => array( |
8
|
|
|
array('Kint_Renderer_Plain', 'renderCss'), |
9
|
|
|
), |
10
|
|
|
'raw' => array(), |
11
|
|
|
); |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Path to the CSS file to load by default. |
15
|
|
|
* |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
public static $theme = 'plain.css'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Output htmlentities instead of utf8. |
22
|
|
|
* |
23
|
|
|
* @var bool |
24
|
|
|
*/ |
25
|
|
|
public static $disable_utf8 = false; |
|
|
|
|
26
|
|
|
|
27
|
|
|
protected static $been_run = false; |
|
|
|
|
28
|
|
|
|
29
|
|
|
protected $mod_return = false; |
|
|
|
|
30
|
|
|
protected $file_link_format = false; |
|
|
|
|
31
|
|
|
|
32
|
|
|
public function __construct(array $params = array()) |
33
|
|
|
{ |
34
|
|
|
parent::__construct($params); |
35
|
|
|
|
36
|
|
|
if (isset($params['settings']['return'])) { |
37
|
|
|
$this->mod_return = $params['settings']['return']; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
if (isset($params['settings']['file_link_format'])) { |
41
|
|
|
$this->file_link_format = $params['settings']['file_link_format']; |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
45
|
|
View Code Duplication |
protected function utf8_to_htmlentity($string) |
|
|
|
|
46
|
|
|
{ |
47
|
|
|
return str_replace( |
48
|
|
|
array('┌', '═', '┐', '│', '└', '─', '┘'), |
49
|
|
|
array('┌', '═', '┐', '│', '└', '─', '┘'), |
50
|
|
|
$string |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function colorValue($string) |
55
|
|
|
{ |
56
|
|
|
return '<i>'.$string.'</i>'; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function colorType($string) |
60
|
|
|
{ |
61
|
|
|
return '<b>'.$string.'</b>'; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function colorTitle($string) |
65
|
|
|
{ |
66
|
|
|
return '<u>'.$string.'</u>'; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function renderTitle(Kint_Object $o) |
|
|
|
|
70
|
|
|
{ |
71
|
|
|
if (self::$disable_utf8) { |
72
|
|
|
return $this->utf8_to_htmlentity(parent::renderTitle($o)); |
73
|
|
|
} else { |
74
|
|
|
return parent::renderTitle($o); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
View Code Duplication |
protected static function renderCss() |
|
|
|
|
79
|
|
|
{ |
80
|
|
|
if (file_exists(KINT_DIR.'/resources/compiled/'.self::$theme)) { |
81
|
|
|
return file_get_contents(KINT_DIR.'/resources/compiled/'.self::$theme); |
82
|
|
|
} else { |
83
|
|
|
return file_get_contents(self::$theme); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
87
|
|
View Code Duplication |
public function preRender() |
|
|
|
|
88
|
|
|
{ |
89
|
|
|
$output = ''; |
90
|
|
|
|
91
|
|
|
if (!self::$been_run || $this->mod_return) { |
92
|
|
|
foreach (self::$pre_render_sources as $type => $values) { |
93
|
|
|
$contents = ''; |
94
|
|
|
foreach ($values as $v) { |
95
|
|
|
if (is_callable($v)) { |
96
|
|
|
$contents .= call_user_func($v, $this); |
97
|
|
|
} elseif (is_string($v)) { |
98
|
|
|
$contents .= $v; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
if (!strlen($contents)) { |
103
|
|
|
continue; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
switch ($type) { |
107
|
|
|
case 'script': |
108
|
|
|
$output .= '<script class="kint-script">'.$contents.'</script>'; |
109
|
|
|
break; |
110
|
|
|
case 'style': |
111
|
|
|
$output .= '<style class="kint-style">'.$contents.'</style>'; |
112
|
|
|
break; |
113
|
|
|
default: |
114
|
|
|
$output .= $contents; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
if (!$this->mod_return) { |
119
|
|
|
self::$been_run = true; |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
return $output.'<div class="kint-plain">'; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function postRender() |
127
|
|
|
{ |
128
|
|
|
if (self::$disable_utf8) { |
129
|
|
|
return $this->utf8_to_htmlentity(parent::postRender()).'</div>'; |
130
|
|
|
} else { |
131
|
|
|
return parent::postRender().'</div>'; |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|
135
|
|
View Code Duplication |
public function ideLink($file, $line) |
|
|
|
|
136
|
|
|
{ |
137
|
|
|
$shortenedPath = $this->escape(Kint::shortenPath($file)); |
138
|
|
|
if (!$this->file_link_format) { |
139
|
|
|
return $shortenedPath.':'.$line; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
$ideLink = Kint::getIdeLink($file, $line); |
143
|
|
|
$class = (strpos($ideLink, 'http://') === 0) ? 'class="kint-ide-link" ' : ''; |
144
|
|
|
|
145
|
|
|
return "<a {$class}href=\"{$ideLink}\">{$shortenedPath}:{$line}</a>"; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
View Code Duplication |
public function escape($string, $encoding = false) |
|
|
|
|
149
|
|
|
{ |
150
|
|
|
if ($encoding === false) { |
151
|
|
|
$encoding = Kint_Object_Blob::detectEncoding($string); |
|
|
|
|
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
$original_encoding = $encoding; |
|
|
|
|
155
|
|
|
|
156
|
|
|
if ($encoding === false || $encoding === 'ASCII') { |
157
|
|
|
$encoding = 'UTF-8'; |
|
|
|
|
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
$string = htmlspecialchars($string, ENT_NOQUOTES, $encoding); |
|
|
|
|
161
|
|
|
|
162
|
|
|
// this call converts all non-ASCII characters into numeirc htmlentities |
163
|
|
|
if (extension_loaded('mbstring') && $original_encoding !== 'ASCII') { |
|
|
|
|
164
|
|
|
$string = mb_encode_numericentity($string, array(0x80, 0xffff, 0, 0xffff), $encoding); |
|
|
|
|
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
return $string; |
168
|
|
|
} |
169
|
|
|
} |
170
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.