From 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Mon, 12 Aug 2013 09:28:15 +0200 Subject: Update to MediaWiki 1.21.1 --- includes/specials/SpecialSearch.php | 131 +++++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 54 deletions(-) (limited to 'includes/specials/SpecialSearch.php') diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 5f5b6b4d..6c401486 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -78,7 +78,7 @@ class SpecialSearch extends SpecialPage { /** * Entry point * - * @param $par String or null + * @param string $par or null */ public function execute( $par ) { $this->setHeaders(); @@ -138,7 +138,7 @@ class SpecialSearch extends SpecialPage { // BC with old request format $profile = 'advanced'; foreach( $profiles as $key => $data ) { - if ( $nslist === $data['namespaces'] && $key !== 'advanced') { + if ( $nslist === $data['namespaces'] && $key !== 'advanced' ) { $profile = $key; } } @@ -159,7 +159,7 @@ class SpecialSearch extends SpecialPage { $default = $request->getBool( 'profile' ) ? 0 : 1; $this->searchRedirects = $request->getBool( 'redirs', $default ) ? 1 : 0; $this->didYouMeanHtml = ''; # html of did you mean... link - $this->fulltext = $request->getVal('fulltext'); + $this->fulltext = $request->getVal( 'fulltext' ); $this->profile = $profile; } @@ -218,7 +218,7 @@ class SpecialSearch extends SpecialPage { $search->showRedirects = $this->searchRedirects; // BC $search->setFeatureData( 'list-redirects', $this->searchRedirects ); $search->prefix = $this->mPrefix; - $term = $search->transformSearchTerm($term); + $term = $search->transformSearchTerm( $term ); wfRunHooks( 'SpecialSearchSetupEngine', array( $this, $this->profile, $search ) ); @@ -250,7 +250,7 @@ class SpecialSearch extends SpecialPage { $t = Title::newFromText( $term ); // fetch search results - $rewritten = $search->replacePrefixes($term); + $rewritten = $search->replacePrefixes( $term ); $titleMatches = $search->searchTitle( $rewritten ); if( !( $titleMatches instanceof SearchResultTooMany ) ) { @@ -261,7 +261,7 @@ class SpecialSearch extends SpecialPage { if( $textMatches && $textMatches->hasSuggestion() ) { $st = SpecialPage::getTitleFor( 'Search' ); - # mirror Go/Search behaviour of original request .. + # mirror Go/Search behavior of original request .. $didYouMeanParams = array( 'search' => $textMatches->getSuggestionQuery() ); if( $this->fulltext != null ) { @@ -288,6 +288,13 @@ class SpecialSearch extends SpecialPage { $this->didYouMeanHtml = '
' . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '
'; } + + if ( !wfRunHooks( 'SpecialSearchResultsPrepend', array( $this, $out, $term ) ) ) { + # Hook requested termination + wfProfileOut( __METHOD__ ); + return; + } + // start rendering the page $out->addHtml( Xml::openElement( @@ -304,9 +311,9 @@ class SpecialSearch extends SpecialPage { Xml::openElement( 'tr' ) . Xml::openElement( 'td' ) . "\n" . $this->shortDialog( $term ) . - Xml::closeElement('td') . - Xml::closeElement('tr') . - Xml::closeElement('table') + Xml::closeElement( 'td' ) . + Xml::closeElement( 'tr' ) . + Xml::closeElement( 'table' ) ); // Sometimes the search engine knows there are too many hits @@ -316,7 +323,7 @@ class SpecialSearch extends SpecialPage { return; } - $filePrefix = $wgContLang->getFormattedNsText(NS_FILE).':'; + $filePrefix = $wgContLang->getFormattedNsText( NS_FILE ) . ':'; if( trim( $term ) === '' || $filePrefix === trim( $term ) ) { $out->addHTML( $this->formHeader( $term, 0, 0 ) ); $out->addHtml( $this->getProfileForm( $this->profile, $term ) ); @@ -340,16 +347,15 @@ class SpecialSearch extends SpecialPage { // get total number of results if backend can calculate it $totalRes = 0; - if($titleMatches && !is_null( $titleMatches->getTotalHits() ) ) + if( $titleMatches && !is_null( $titleMatches->getTotalHits() ) ) $totalRes += $titleMatches->getTotalHits(); - if($textMatches && !is_null( $textMatches->getTotalHits() )) + if( $textMatches && !is_null( $textMatches->getTotalHits() ) ) $totalRes += $textMatches->getTotalHits(); // show number of results and current offset $out->addHTML( $this->formHeader( $term, $num, $totalRes ) ); $out->addHtml( $this->getProfileForm( $this->profile, $term ) ); - $out->addHtml( Xml::closeElement( 'form' ) ); $out->addHtml( "
" ); @@ -404,6 +410,7 @@ class SpecialSearch extends SpecialPage { if( $num || $this->offset ) { $out->addHTML( "

{$prevnext}

\n" ); } + wfRunHooks( 'SpecialSearchResultsAppend', array( $this, $out, $term ) ); wfProfileOut( __METHOD__ ); } @@ -423,7 +430,7 @@ class SpecialSearch extends SpecialPage { if( $t->isKnown() ) { $messageName = 'searchmenu-exists'; - } elseif( $t->userCan( 'create' ) ) { + } elseif( $t->userCan( 'create', $this->getUser() ) ) { $messageName = 'searchmenu-new'; } else { $messageName = 'searchmenu-new-nocreate'; @@ -447,9 +454,11 @@ class SpecialSearch extends SpecialPage { # Should advanced UI be used? $this->searchAdvanced = ($this->profile === 'advanced'); $out = $this->getOutput(); - if( strval( $term ) !== '' ) { + if( strval( $term ) !== '' ) { $out->setPageTitle( $this->msg( 'searchresults' ) ); - $out->setHTMLTitle( $this->msg( 'pagetitle', $this->msg( 'searchresults-title', $term )->plain() ) ); + $out->setHTMLTitle( $this->msg( 'pagetitle' )->rawParams( + $this->msg( 'searchresults-title' )->rawParams( $term )->text() + ) ); } // add javascript specific to special:search $out->addModules( 'mediawiki.special.search' ); @@ -506,7 +515,7 @@ class SpecialSearch extends SpecialPage { $out = ""; $infoLine = $matches->getInfo(); - if( !is_null($infoLine) ) { + if( !is_null( $infoLine ) ) { $out .= "\n\n"; } $out .= "