r103752 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103751‎ | r103752 | r103753 >
Date:11:41, 20 November 2011
Author:reedy
Status:ok
Tags:
Comment:
Fix spaces to tabs
Modified paths:
  • /trunk/phase3/includes/search/SearchEngine.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/search/SearchEngine.php
@@ -346,7 +346,7 @@
347347 // get search everything preference, that can be set to be read for logged-in users
348348 $searcheverything = false;
349349 if ( ( $wgSearchEverythingOnlyLoggedIn && $user->isLoggedIn() )
350 - || !$wgSearchEverythingOnlyLoggedIn )
 350+ || !$wgSearchEverythingOnlyLoggedIn )
351351 $searcheverything = $user->getOption( 'searcheverything' );
352352
353353 // searcheverything overrides other options
@@ -1098,7 +1098,7 @@
10991099 } else {
11001100 // if begin of the article contains the whole phrase, show only that !!
11011101 if ( array_key_exists( $first, $snippets ) && preg_match( $pat1, $snippets[$first] )
1102 - && $offsets[$first] < $contextchars * 2 ) {
 1102+ && $offsets[$first] < $contextchars * 2 ) {
11031103 $snippets = array ( $first => $snippets[$first] );
11041104 }
11051105
@@ -1119,10 +1119,10 @@
11201120 // add more lines
11211121 $add = $index + 1;
11221122 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] );
11271127 $extended[$add] = $tt;
11281128 $len += strlen( $tt );
11291129 $add++;
@@ -1152,7 +1152,7 @@
11531153 if ( ! isset( $processed[$term] ) ) {
11541154 $pat3 = "/$patPre(" . $term . ")$patPost/ui"; // highlight word
11551155 $extract = preg_replace( $pat3,
1156 - "\\1<span class='searchmatch'>\\2</span>\\3", $extract );
 1156+ "\\1<span class='searchmatch'>\\2</span>\\3", $extract );
11571157 $processed[$term] = true;
11581158 }
11591159 }
@@ -1187,8 +1187,9 @@
11881188 global $wgContLang;
11891189 if ( strlen( $matches[0] ) > 1 ) {
11901190 return '[' . $wgContLang->lc( $matches[0] ) . $wgContLang->uc( $matches[0] ) . ']';
1191 - } else
 1191+ } else {
11921192 return $matches[0];
 1193+ }
11931194 }
11941195
11951196 /**
@@ -1342,61 +1343,61 @@
13431344 }
13441345
13451346 /**
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__;
13581359
1359 - $lines = explode( "\n", $text );
 1360+ $lines = explode( "\n", $text );
13601361
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";
13641365
1365 - $lineno = 0;
 1366+ $lineno = 0;
13661367
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 );
13811382
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+ }
13871388
1388 - $found = $m[2];
 1389+ $found = $m[2];
13891390
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 );
13941395
1395 - $extract .= "${line}\n";
1396 - }
1397 - wfProfileOut( "$fname-extract" );
 1396+ $extract .= "${line}\n";
 1397+ }
 1398+ wfProfileOut( "$fname-extract" );
13981399
1399 - return $extract;
1400 - }
 1400+ return $extract;
 1401+ }
14011402
14021403 }
14031404

Status & tagging log