* @access public
*/
function showResults( $term ) {
+ $fname = 'SpecialSearch::showResults';
+ wfProfileIn( $fname );
+
$this->setupPage( $term );
global $wgUser, $wgOut;
$wgOut->addWikiText(
'==' . wfMsg( 'badquery' ) . "==\n" .
wfMsg( 'badquerytext' ) );
+ wfProfileOut( $fname );
return;
}
$wgOut->addHTML( wfMsg( 'googlesearch',
htmlspecialchars( $term ),
htmlspecialchars( $wgInputEncoding ) ) );
+ wfProfileOut( $fname );
return;
}
$wgOut->addHTML( "<p>{$prevnext}</p>\n" );
}
$wgOut->addHTML( $this->powerSearchBox( $term ) );
+ wfProfileOut( $fname );
}
#------------------------------------------------------------------
* @param string $terms partial regexp for highlighting terms
*/
function showMatches( &$matches, $terms ) {
+ $fname = 'SpecialSearch::showMatches';
+ wfProfileIn( $fname );
+
global $wgOut;
$off = $this->offset + 1;
$out = "<ol start='{$off}'>\n";
$out .= $this->showHit( $row, $terms );
}
$out .= "</ol>\n";
+ wfProfileOut( $fname );
return $out;
}
* @param string $terms partial regexp for highlighting terms
*/
function showHit( $row, $terms ) {
+ $fname = 'SpecialSearch::showHit';
+ wfProfileIn( $fname );
global $wgUser, $wgContLang;
- $t = Title::makeName( $row->cur_namespace, $row->cur_title );
+ $t = Title::makeTitle( $row->cur_namespace, $row->cur_title );
if( is_null( $t ) ) {
+ wfProfileOut( $fname );
return "<!-- Broken link in search result -->\n";
}
- $sk = $wgUser->getSkin();
+ $sk =& $wgUser->getSkin();
$contextlines = $wgUser->getOption( 'contextlines' );
if ( '' == $contextlines ) { $contextlines = 5; }
$contextchars = $wgUser->getOption( 'contextchars' );
if ( '' == $contextchars ) { $contextchars = 50; }
- $link = $sk->makeKnownLink( $t, '' );
+ $link = $sk->makeKnownLinkObj( $t, '' );
$size = wfMsg( 'nbytes', strlen( $row->cur_text ) );
$lines = explode( "\n", $row->cur_text );
- $pat1 = "/(.*)($terms)(.*)/i";
+ $max = IntVal( $contextchars ) + 1;
+ $pat1 = "/(.*)($terms)(.{0,$max})/i";
$lineno = 0;
$extract = '';
+ wfProfileIn( "$fname-extract" );
foreach ( $lines as $line ) {
if ( 0 == $contextlines ) {
break;
$extract .= "<br /><small>{$lineno}: {$line}</small>\n";
}
+ wfProfileOut( "$fname-extract" );
+ wfProfileOut( $fname );
return "<li>{$link} ({$size}){$extract}</li>\n";
}