Index: trunk/phase3/includes/search/SearchEngine.php |
— | — | @@ -346,7 +346,7 @@ |
347 | 347 | // get search everything preference, that can be set to be read for logged-in users |
348 | 348 | $searcheverything = false; |
349 | 349 | if ( ( $wgSearchEverythingOnlyLoggedIn && $user->isLoggedIn() ) |
350 | | - || !$wgSearchEverythingOnlyLoggedIn ) |
| 350 | + || !$wgSearchEverythingOnlyLoggedIn ) |
351 | 351 | $searcheverything = $user->getOption( 'searcheverything' ); |
352 | 352 | |
353 | 353 | // searcheverything overrides other options |
— | — | @@ -1098,7 +1098,7 @@ |
1099 | 1099 | } else { |
1100 | 1100 | // if begin of the article contains the whole phrase, show only that !! |
1101 | 1101 | if ( array_key_exists( $first, $snippets ) && preg_match( $pat1, $snippets[$first] ) |
1102 | | - && $offsets[$first] < $contextchars * 2 ) { |
| 1102 | + && $offsets[$first] < $contextchars * 2 ) { |
1103 | 1103 | $snippets = array ( $first => $snippets[$first] ); |
1104 | 1104 | } |
1105 | 1105 | |
— | — | @@ -1119,10 +1119,10 @@ |
1120 | 1120 | // add more lines |
1121 | 1121 | $add = $index + 1; |
1122 | 1122 | while ( $len < $targetchars - 20 |
1123 | | - && array_key_exists( $add, $all ) |
1124 | | - && !array_key_exists( $add, $snippets ) ) { |
1125 | | - $offsets[$add] = 0; |
1126 | | - $tt = "\n" . $this->extract( $all[$add], 0, $targetchars - $len, $offsets[$add] ); |
| 1123 | + && array_key_exists( $add, $all ) |
| 1124 | + && !array_key_exists( $add, $snippets ) ) { |
| 1125 | + $offsets[$add] = 0; |
| 1126 | + $tt = "\n" . $this->extract( $all[$add], 0, $targetchars - $len, $offsets[$add] ); |
1127 | 1127 | $extended[$add] = $tt; |
1128 | 1128 | $len += strlen( $tt ); |
1129 | 1129 | $add++; |
— | — | @@ -1152,7 +1152,7 @@ |
1153 | 1153 | if ( ! isset( $processed[$term] ) ) { |
1154 | 1154 | $pat3 = "/$patPre(" . $term . ")$patPost/ui"; // highlight word |
1155 | 1155 | $extract = preg_replace( $pat3, |
1156 | | - "\\1<span class='searchmatch'>\\2</span>\\3", $extract ); |
| 1156 | + "\\1<span class='searchmatch'>\\2</span>\\3", $extract ); |
1157 | 1157 | $processed[$term] = true; |
1158 | 1158 | } |
1159 | 1159 | } |
— | — | @@ -1187,8 +1187,9 @@ |
1188 | 1188 | global $wgContLang; |
1189 | 1189 | if ( strlen( $matches[0] ) > 1 ) { |
1190 | 1190 | return '[' . $wgContLang->lc( $matches[0] ) . $wgContLang->uc( $matches[0] ) . ']'; |
1191 | | - } else |
| 1191 | + } else { |
1192 | 1192 | return $matches[0]; |
| 1193 | + } |
1193 | 1194 | } |
1194 | 1195 | |
1195 | 1196 | /** |
— | — | @@ -1342,61 +1343,61 @@ |
1343 | 1344 | } |
1344 | 1345 | |
1345 | 1346 | /** |
1346 | | - * Simple & fast snippet extraction, but gives completely unrelevant |
1347 | | - * snippets |
1348 | | - * |
1349 | | - * @param $text String |
1350 | | - * @param $terms Array |
1351 | | - * @param $contextlines Integer |
1352 | | - * @param $contextchars Integer |
1353 | | - * @return String |
1354 | | - */ |
1355 | | - public function highlightSimple( $text, $terms, $contextlines, $contextchars ) { |
1356 | | - global $wgContLang; |
1357 | | - $fname = __METHOD__; |
| 1347 | + * Simple & fast snippet extraction, but gives completely unrelevant |
| 1348 | + * snippets |
| 1349 | + * |
| 1350 | + * @param $text String |
| 1351 | + * @param $terms Array |
| 1352 | + * @param $contextlines Integer |
| 1353 | + * @param $contextchars Integer |
| 1354 | + * @return String |
| 1355 | + */ |
| 1356 | + public function highlightSimple( $text, $terms, $contextlines, $contextchars ) { |
| 1357 | + global $wgContLang; |
| 1358 | + $fname = __METHOD__; |
1358 | 1359 | |
1359 | | - $lines = explode( "\n", $text ); |
| 1360 | + $lines = explode( "\n", $text ); |
1360 | 1361 | |
1361 | | - $terms = implode( '|', $terms ); |
1362 | | - $max = intval( $contextchars ) + 1; |
1363 | | - $pat1 = "/(.*)($terms)(.{0,$max})/i"; |
| 1362 | + $terms = implode( '|', $terms ); |
| 1363 | + $max = intval( $contextchars ) + 1; |
| 1364 | + $pat1 = "/(.*)($terms)(.{0,$max})/i"; |
1364 | 1365 | |
1365 | | - $lineno = 0; |
| 1366 | + $lineno = 0; |
1366 | 1367 | |
1367 | | - $extract = ""; |
1368 | | - wfProfileIn( "$fname-extract" ); |
1369 | | - foreach ( $lines as $line ) { |
1370 | | - if ( 0 == $contextlines ) { |
1371 | | - break; |
1372 | | - } |
1373 | | - ++$lineno; |
1374 | | - $m = array(); |
1375 | | - if ( ! preg_match( $pat1, $line, $m ) ) { |
1376 | | - continue; |
1377 | | - } |
1378 | | - --$contextlines; |
1379 | | - // truncate function changes ... to relevant i18n message. |
1380 | | - $pre = $wgContLang->truncate( $m[1], - $contextchars, '...', false ); |
| 1368 | + $extract = ""; |
| 1369 | + wfProfileIn( "$fname-extract" ); |
| 1370 | + foreach ( $lines as $line ) { |
| 1371 | + if ( 0 == $contextlines ) { |
| 1372 | + break; |
| 1373 | + } |
| 1374 | + ++$lineno; |
| 1375 | + $m = array(); |
| 1376 | + if ( ! preg_match( $pat1, $line, $m ) ) { |
| 1377 | + continue; |
| 1378 | + } |
| 1379 | + --$contextlines; |
| 1380 | + // truncate function changes ... to relevant i18n message. |
| 1381 | + $pre = $wgContLang->truncate( $m[1], - $contextchars, '...', false ); |
1381 | 1382 | |
1382 | | - if ( count( $m ) < 3 ) { |
1383 | | - $post = ''; |
1384 | | - } else { |
1385 | | - $post = $wgContLang->truncate( $m[3], $contextchars, '...', false ); |
1386 | | - } |
| 1383 | + if ( count( $m ) < 3 ) { |
| 1384 | + $post = ''; |
| 1385 | + } else { |
| 1386 | + $post = $wgContLang->truncate( $m[3], $contextchars, '...', false ); |
| 1387 | + } |
1387 | 1388 | |
1388 | | - $found = $m[2]; |
| 1389 | + $found = $m[2]; |
1389 | 1390 | |
1390 | | - $line = htmlspecialchars( $pre . $found . $post ); |
1391 | | - $pat2 = '/(' . $terms . ")/i"; |
1392 | | - $line = preg_replace( $pat2, |
1393 | | - "<span class='searchmatch'>\\1</span>", $line ); |
| 1391 | + $line = htmlspecialchars( $pre . $found . $post ); |
| 1392 | + $pat2 = '/(' . $terms . ")/i"; |
| 1393 | + $line = preg_replace( $pat2, |
| 1394 | + "<span class='searchmatch'>\\1</span>", $line ); |
1394 | 1395 | |
1395 | | - $extract .= "${line}\n"; |
1396 | | - } |
1397 | | - wfProfileOut( "$fname-extract" ); |
| 1396 | + $extract .= "${line}\n"; |
| 1397 | + } |
| 1398 | + wfProfileOut( "$fname-extract" ); |
1398 | 1399 | |
1399 | | - return $extract; |
1400 | | - } |
| 1400 | + return $extract; |
| 1401 | + } |
1401 | 1402 | |
1402 | 1403 | } |
1403 | 1404 | |