From 5ba4e307cff1de94adaeb472c6e886002463265a Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Fri, 2 Jan 2009 02:17:27 +0000 Subject: [PATCH] Make "did you mean" more Googley It wasn't prominent enough; the red text and bolding should make it more visible, and also more familiar (since I took the styling straight from Google). I also moved it up way to the top: it *needs* to be one of the first things the user sees to be really useful. This was particularly terrible on enwiki, where the enormous bloated help message means you have to scroll down through half a page of largely useless nonsense before even seeing the suggestion. --- RELEASE-NOTES | 1 + includes/specials/SpecialSearch.php | 37 ++++++++++++++--------------- skins/common/shared.css | 10 ++++++-- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e2204e1ed8..77d3a8ac00 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -256,6 +256,7 @@ The following extensions are migrated into MediaWiki 1.14: * (bug 16121) Add a note that a page move was without creating a redirect in the move log * Image moving is now enabled for sysops by default +* Make "Did you mean" search feature more noticeable === Bug fixes in 1.14 === diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 3dcf3b09e0..08d4f456df 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -930,6 +930,24 @@ class SpecialSearchOld { $this->setupPage( $term ); + $rewritten = $search->replacePrefixes($term); + $titleMatches = $search->searchTitle( $rewritten ); + $textMatches = $search->searchText( $rewritten ); + + // did you mean... suggestions + if($textMatches && $textMatches->hasSuggestion()){ + $st = SpecialPage::getTitleFor( 'Search' ); + $stParams = wfArrayToCGI( array( + 'search' => $textMatches->getSuggestionQuery(), + 'fulltext' => wfMsg('search')), + $this->powerSearchOptions()); + + $suggestLink = ''. + $textMatches->getSuggestionSnippet().''; + + $wgOut->addHTML('
'.wfMsg('search-suggest',$suggestLink).'
'); + } + $wgOut->addWikiMsg( 'searchresulttext' ); if( '' === trim( $term ) ) { @@ -967,9 +985,6 @@ class SpecialSearchOld { } $wgOut->addHTML( $this->shortDialog( $term ) ); - $rewritten = $search->replacePrefixes($term); - - $titleMatches = $search->searchTitle( $rewritten ); // Sometimes the search engine knows there are too many hits if ($titleMatches instanceof SearchResultTooMany) { @@ -980,22 +995,6 @@ class SpecialSearchOld { return; } - $textMatches = $search->searchText( $rewritten ); - - // did you mean... suggestions - if($textMatches && $textMatches->hasSuggestion()){ - $st = SpecialPage::getTitleFor( 'Search' ); - $stParams = wfArrayToCGI( array( - 'search' => $textMatches->getSuggestionQuery(), - 'fulltext' => wfMsg('search')), - $this->powerSearchOptions()); - - $suggestLink = ''. - $textMatches->getSuggestionSnippet().''; - - $wgOut->addHTML('
'.wfMsg('search-suggest',$suggestLink).'
'); - } - // show number of results $num = ( $titleMatches ? $titleMatches->numRows() : 0 ) + ( $textMatches ? $textMatches->numRows() : 0); diff --git a/skins/common/shared.css b/skins/common/shared.css index 6be252dd79..bd30616740 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -142,8 +142,14 @@ span.searchalttitle { div.searchdidyoumean { font-size: 127%; - padding-bottom:1ex; - padding-top:1ex; + margin-bottom: 1ex; + margin-top: 1ex; + /* Note that this color won't affect the link, as desired. */ + color: #c00; +} + +div.searchdidyoumean em { + font-weight: bold; } .searchmatch { -- 2.20.1