1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
function dump($value,$varname = "",$level=0,$dumper = "") |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
if ($varname) $varname .= " = "; |
6
|
|
|
|
7
|
|
|
if ($level==-1) |
8
|
|
|
{ |
9
|
|
|
$trans[' ']='∴'; |
|
|
|
|
10
|
|
|
$trans["\t"]='⇒'; |
11
|
|
|
$trans["\n"]='¶;'; |
12
|
|
|
$trans["\r"]='⇐'; |
13
|
|
|
$trans["\0"]='⊕'; |
14
|
|
|
return strtr(htmlspecialchars($value),$trans); |
15
|
|
|
} |
16
|
|
|
if ($level==0) $dumper = '<pre>' . $varname; |
17
|
|
|
|
18
|
|
|
$type = gettype($value); |
19
|
|
|
$dumper .= $type; |
20
|
|
|
|
21
|
|
|
if ($type=='string') |
22
|
|
|
{ |
23
|
|
|
$dumper .= '('.strlen($value).')'; |
24
|
|
|
$value = dump($value,"",-1); |
25
|
|
|
} |
26
|
|
|
elseif ($type=='boolean') $value= ($value?'true':'false'); |
27
|
|
|
elseif ($type=='object') |
28
|
|
|
{ |
29
|
|
|
$props= get_class_vars(get_class($value)); |
30
|
|
|
$dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
31
|
|
|
foreach($props as $key=>$val) |
32
|
|
|
{ |
33
|
|
|
$dumper .= "\n".str_repeat("\t",$level+1).$key.' => '; |
34
|
|
|
$dumper .= dump($value->$key,"",$level+1); |
35
|
|
|
} |
36
|
|
|
$value= ''; |
37
|
|
|
} |
38
|
|
View Code Duplication |
elseif ($type=='array') |
|
|
|
|
39
|
|
|
{ |
40
|
|
|
$dumper .= '('.count($value).')'; |
41
|
|
|
foreach($value as $key=>$val) |
42
|
|
|
{ |
43
|
|
|
$dumper .= "\n".str_repeat("\t",$level+1).dump($key,"",-1).' => '; |
44
|
|
|
$dumper .= dump($val,"",$level+1); |
45
|
|
|
} |
46
|
|
|
$value= ''; |
47
|
|
|
} |
48
|
|
|
$dumper .= " <b>$value</b>"; |
49
|
|
|
if ($level==0) $dumper .= '</pre>'; |
50
|
|
|
return $dumper; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
function pdump($value, $varname = '') |
|
|
|
|
54
|
|
|
{ |
55
|
|
|
print('<span style="text-align: left">' . dump($value, $varname) . '</span>'); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
function debug($value, $varname = '') |
|
|
|
|
59
|
|
|
{ |
60
|
|
|
return pdump($value, $varname); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
function buf_print($string) |
64
|
|
|
{ |
65
|
|
|
global $output_buffer; |
66
|
|
|
|
67
|
|
|
$output_buffer .= $string; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
if(substr(getcwd(), -4) != 'docs') |
71
|
|
|
{ |
72
|
|
|
$path_prefix = 'docs/'; |
73
|
|
|
} |
74
|
|
|
else |
75
|
|
|
{ |
76
|
|
|
$path_prefix = ''; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
$output_buffer = ''; |
80
|
|
|
|
81
|
|
|
$filename = 'changelog'; |
82
|
|
|
|
83
|
|
|
$input = file_get_contents($path_prefix . $filename . '.txt'); |
84
|
|
|
//$input = iconv('CP1251', 'UTF-8', $input); |
|
|
|
|
85
|
|
|
|
86
|
|
|
$input = preg_replace("/\r\n\d\d\d\d\-\d\d\-\d\d\ \d\d\:\d\d/", "[D] $0", $input); |
87
|
|
|
|
88
|
|
|
while(strpos($input, "\r\n\r\n") !== false) |
89
|
|
|
{ |
90
|
|
|
$input = str_replace("\r\n\r\n", "\r\n", $input); |
91
|
|
|
} |
92
|
|
|
while(strpos($input, "~~~") !== false) |
93
|
|
|
{ |
94
|
|
|
$input = str_replace("~~~", "~~", $input); |
95
|
|
|
} |
96
|
|
|
$input = str_replace("\r\n~~", "~~", $input); |
97
|
|
|
|
98
|
|
|
while(strpos($input, "===") !== false) |
99
|
|
|
{ |
100
|
|
|
$input = str_replace("===", "==", $input); |
101
|
|
|
} |
102
|
|
|
$input = str_replace("\r\n==", "==", $input); |
103
|
|
|
|
104
|
|
|
$input = preg_split("/\r\n(.+)[\~\=]{2}/", $input, -1, PREG_SPLIT_DELIM_CAPTURE + PREG_SPLIT_NO_EMPTY); // |
105
|
|
|
|
106
|
|
|
$prev_chapter_is_header = false; |
107
|
|
|
$output = array(); |
108
|
|
|
$buffer = array(); |
109
|
|
|
foreach($input as &$chapter) |
110
|
|
|
{ |
111
|
|
|
$chapter = preg_split("/(\r\n[\[])/", $chapter, -1, PREG_SPLIT_NO_EMPTY); // , PREG_SPLIT_DELIM_CAPTURE |
112
|
|
|
|
113
|
|
|
if(count($chapter) == 1 && !$prev_chapter_is_header) |
114
|
|
|
{ |
115
|
|
|
if(!empty($chapter)) |
116
|
|
|
{ |
117
|
|
|
$output[] = $buffer; |
118
|
|
|
$buffer = array(); |
119
|
|
|
$buffer['name'] = $chapter[0]; |
120
|
|
|
} |
121
|
|
|
$prev_chapter_is_header = true; |
122
|
|
|
} |
123
|
|
|
else |
124
|
|
|
{ |
125
|
|
|
$prev_chapter_is_header = false; |
126
|
|
|
foreach($chapter as &$note) |
127
|
|
|
{ |
128
|
|
|
$note = explode("\r\n", $note); |
129
|
|
|
$new_note = true; |
130
|
|
|
$buf_str = ''; |
131
|
|
|
|
132
|
|
|
$note_out = array(); |
133
|
|
|
|
134
|
|
|
foreach($note as &$line) |
135
|
|
|
{ |
136
|
|
|
if(!$line) |
137
|
|
|
{ |
138
|
|
|
continue; |
139
|
|
|
} |
140
|
|
|
if($new_note) |
141
|
|
|
{ |
142
|
|
|
// 78 - 3 = 75 |
143
|
|
|
$note_out['style'] = $line[0]; |
144
|
|
|
$line = substr($line, 3); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
$buf_str .= $line; |
148
|
|
|
if(mb_strlen($line, 'utf-8') < ($new_note ? 75 : 79)) |
149
|
|
|
{ |
150
|
|
|
if(!isset($note_out['name'])) |
151
|
|
|
{ |
152
|
|
|
$note_out['name'] = $buf_str; |
153
|
|
|
} |
154
|
|
|
else |
155
|
|
|
{ |
156
|
|
|
$note_out['lines'][] = $buf_str; |
157
|
|
|
} |
158
|
|
|
$buf_str = ''; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
$new_note = false; |
162
|
|
|
} |
163
|
|
|
$buffer['content'][] = $note_out; |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
} |
167
|
|
|
$output[] = $buffer; |
168
|
|
|
|
169
|
|
|
buf_print('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
170
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="ru" xml:lang="ru" dir="LTR"> |
171
|
|
|
<head> |
172
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
173
|
|
|
<style type="text/css"><!-- |
174
|
|
|
body {font-family: monospace} |
175
|
|
|
li, ol, ul, pre {margin: 0} |
176
|
|
|
div {margin-bottom: 10px} |
177
|
|
|
|
178
|
|
|
.important {color: green; font-weight: bold;} |
179
|
|
|
.added {color: green;} |
180
|
|
|
.removed {font-style: italic; color: red} |
181
|
|
|
.changed {color: blue} |
182
|
|
|
.fixed {color: red} |
183
|
|
|
.admin {font-style: italic;} |
184
|
|
|
.module {color: purple; font-weight: bold;} |
185
|
|
|
.todo {} |
186
|
|
|
.date {margin-bottom: 0; color: grey} |
187
|
|
|
--></style> |
188
|
|
|
</head> |
189
|
|
|
<body> |
190
|
|
|
'); |
191
|
|
|
// ; text-decoration: underline; |
192
|
|
|
$styles = array( |
193
|
|
|
'!' => 'important', |
194
|
|
|
'+' => 'added', |
195
|
|
|
'-' => 'removed', |
196
|
|
|
'~' => 'changed', |
197
|
|
|
'%' => 'fixed', |
198
|
|
|
'@' => 'admin', |
199
|
|
|
'#' => 'module', |
200
|
|
|
'*' => 'todo', |
201
|
|
|
'D' => 'date', |
202
|
|
|
); |
203
|
|
|
|
204
|
|
|
foreach($output as $chapter) |
205
|
|
|
{ |
206
|
|
|
if(!$chapter) |
|
|
|
|
207
|
|
|
{ |
208
|
|
|
continue; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
buf_print("<h1>{$chapter['name']}</h1>\r\n"); |
212
|
|
|
foreach($chapter['content'] as $block) |
213
|
|
|
{ |
214
|
|
|
buf_print("<div class=\"{$styles[$block['style']]}\">" . ($block['style'] != 'D' ? "[{$block['style']}] " : '')); |
215
|
|
|
buf_print(preg_replace("/\s{2,10}/", " ", $block['name']) . '<br />'); |
216
|
|
|
if(isset($block['lines'])) |
217
|
|
|
{ |
218
|
|
|
$last_spaces = ''; |
219
|
|
|
$depth = array(); |
220
|
|
|
foreach($block['lines'] as $line) |
221
|
|
|
{ |
222
|
|
|
if(preg_match("/^(\s+)(\d*|\s)\.*\s*(.*)/", $line, $matches)) |
223
|
|
|
{ |
224
|
|
|
//$line = strlen($matches[1]) . '/' . $matches[2] . '/' . $matches[3]; |
|
|
|
|
225
|
|
|
$line = $matches[3]; |
226
|
|
|
if(strlen($matches[1]) > strlen($last_spaces)) |
227
|
|
|
{ |
228
|
|
|
if($matches[2]) |
229
|
|
|
{ |
230
|
|
|
buf_print("<ol>\r\n"); |
231
|
|
|
} |
232
|
|
|
else |
233
|
|
|
{ |
234
|
|
|
buf_print("<ul>\r\n"); |
235
|
|
|
} |
236
|
|
|
buf_print('<li>'); |
237
|
|
|
$last_spaces = $matches[1]; |
238
|
|
|
$depth[] = $matches[2]; |
239
|
|
|
} |
240
|
|
|
elseif(strlen($matches[1]) < strlen($last_spaces) && count($depth)) |
241
|
|
|
{ |
242
|
|
|
if(array_pop($depth)) |
243
|
|
|
{ |
244
|
|
|
buf_print("</ol>\r\n"); |
245
|
|
|
} |
246
|
|
|
else |
247
|
|
|
{ |
248
|
|
|
buf_print("</ul>\r\n"); |
249
|
|
|
} |
250
|
|
|
$last_spaces = $matches[1]; |
251
|
|
|
buf_print('<li>'); |
252
|
|
|
} |
253
|
|
|
elseif(strlen($last_spaces) == strlen($matches[1])) |
254
|
|
|
{ |
255
|
|
|
if($matches[2] == '' && $depth[count($depth) - 1] != '') |
256
|
|
|
{ |
257
|
|
|
buf_print("</ol>\r\n"); |
258
|
|
|
buf_print("<ul>\r\n"); |
259
|
|
|
} |
260
|
|
|
elseif($matches[2] != '' && $depth[count($depth) - 1] == '') |
261
|
|
|
{ |
262
|
|
|
buf_print("</ul>\r\n"); |
263
|
|
|
buf_print("<ol>\r\n"); |
264
|
|
|
} |
265
|
|
|
$depth[count($depth) - 1] = $matches[2]; |
266
|
|
|
buf_print('<li>'); |
267
|
|
|
} |
268
|
|
|
} |
269
|
|
|
$line = preg_replace("/\s{2,10}/", " ", $line); |
270
|
|
|
buf_print($line . "<br />\r\n"); |
271
|
|
|
} |
272
|
|
|
while(count($depth)) |
273
|
|
|
{ |
274
|
|
|
if(array_pop($depth)) |
275
|
|
|
{ |
276
|
|
|
buf_print("</ol>\r\n"); |
277
|
|
|
} |
278
|
|
|
else |
279
|
|
|
{ |
280
|
|
|
buf_print("</ul>\r\n"); |
281
|
|
|
} |
282
|
|
|
} |
283
|
|
|
} |
284
|
|
|
buf_print("</div>\r\n"); |
285
|
|
|
} |
286
|
|
|
} |
287
|
|
|
buf_print("</body>\r\n</html>\r\n"); |
288
|
|
|
|
289
|
|
|
$html = file_get_contents($path_prefix . 'html/' . $filename . '.html'); |
290
|
|
|
if($html != $output_buffer) |
291
|
|
|
{ |
292
|
|
|
file_put_contents($path_prefix . 'html/' . $filename . '.html', $output_buffer); |
293
|
|
|
if(!$path_prefix) |
294
|
|
|
{ |
295
|
|
|
print($output_buffer); |
296
|
|
|
} |
297
|
|
|
exit(1); |
298
|
|
|
} |
299
|
|
|
exit(0); |
300
|
|
|
|
This check looks for functions that have already been defined in other files.
Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the
@ignore
annotation.See also the PhpDoc documentation for @ignore.