blogger
Revisión | 93795e62c389822fda2aaa15d63d1c236f4fa456 (tree) |
---|---|
Tiempo | 2017-09-09 22:22:55 |
Autor | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack/2430 Remove author line from text-search target
@@ -204,6 +204,18 @@ function remove_author_info($wikitext) | ||
204 | 204 | return preg_replace('/^\s*#author\([^\n]*(\n|$)/m', '', $wikitext); |
205 | 205 | } |
206 | 206 | |
207 | +function remove_author_lines($lines) | |
208 | +{ | |
209 | + $author_head = '#author('; | |
210 | + $len = strlen($author_head); | |
211 | + for ($i = 0; $i < 5; $i++) { | |
212 | + if (substr($lines[$i], 0, $len) === $author_head) { | |
213 | + unset($lines[$i]); | |
214 | + } | |
215 | + } | |
216 | + return $lines; | |
217 | +} | |
218 | + | |
207 | 219 | function get_date_atom($timestamp) |
208 | 220 | { |
209 | 221 | // Compatible with DATE_ATOM format |
@@ -345,7 +345,8 @@ function do_search($word, $type = 'AND', $non_format = FALSE, $base = '') | ||
345 | 345 | |
346 | 346 | // Search for page contents |
347 | 347 | foreach ($keys as $key) { |
348 | - $b_match = preg_match($key, get_source($page, TRUE, TRUE)); | |
348 | + $lines = remove_author_lines(get_source($page, TRUE, FALSE)); | |
349 | + $b_match = preg_match($key, join('', $lines)); | |
349 | 350 | if ($b_type xor $b_match) break; // OR |
350 | 351 | } |
351 | 352 | if ($b_match) continue; |