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