From: Robert Stojnić Date: Thu, 18 Dec 2008 18:01:06 +0000 (+0000) Subject: New search UI tweaks: X-Git-Tag: 1.31.0-rc.0~43898 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=c4c7d744494895967c35b29f4ed43ce0fd89c9c3;p=lhc%2Fweb%2Fwiklou.git New search UI tweaks: * Show namespace checkboxes only for advanced search. Showing these for "Project Pages" searches does provide information for advanced users, but clutters UI for everyone else. User should be able to refer to help pages to find out which namespace are in "Project Pages" and these are also in tooltip * put "did you mean.." inside the fieldset for increased visibility * missing 'advanced' req param was making advanced form behave strangely, fixed * remove "browse pages with this prefix", clutters, sometimes shows up, sometimes not. User cannot tell why if not familiar with namespaces and logic behind the it (e.g. it shows only when one namespace is selected) * correct placement of external search box when search is disabled * make search messages consistent for new and existing pages --- diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 55990309ec..9ed3833ddb 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -72,6 +72,7 @@ class SpecialSearch { $this->searchAdvanced = $request->getVal( 'advanced' ); $this->active = 'advanced'; $this->sk = $user->getSkin(); + $this->didYouMeanHtml = ''; # html of did you mean... link } /** @@ -117,26 +118,6 @@ class SpecialSearch { $this->setupPage( $term ); $this->searchEngine = SearchEngine::create(); - $t = Title::newFromText( $term ); - - $wgOut->addHtml( - Xml::openElement( 'table', array( 'border'=>0, 'cellpadding'=>0, 'cellspacing'=>0 ) ) . - Xml::openElement( 'tr' ) . - Xml::openElement( 'td' ) . "\n" . - ( $this->searchAdvanced ? $this->powerSearchBox( $term ) : $this->shortDialog( $term ) ) . - Xml::closeElement('td') . - Xml::closeElement('tr') . - Xml::closeElement('table') - ); - - $filePrefix = $wgContLang->getFormattedNsText(NS_FILE).':'; - if( '' === trim( $term ) || $filePrefix === trim( $term ) ) { - $wgOut->addHTML( $this->searchAdvanced ? $this->powerSearchFocus() : $this->searchFocus() ); - // Empty query -- straight view of search form - wfProfileOut( __METHOD__ ); - return; - } - if( $wgDisableTextSearch ) { global $wgSearchForwardUrl; if( $wgSearchForwardUrl ) { @@ -160,7 +141,9 @@ class SpecialSearch { wfProfileOut( __METHOD__ ); return; } - + + $t = Title::newFromText( $term ); + // fetch search results $search =& $this->searchEngine; $search->setLimitOffset( $this->limit, $this->offset ); $search->setNamespaces( $this->namespaces ); @@ -168,15 +151,8 @@ class SpecialSearch { $rewritten = $search->replacePrefixes($term); $titleMatches = $search->searchTitle( $rewritten ); - - // Sometimes the search engine knows there are too many hits - if( $titleMatches instanceof SearchResultTooMany ) { - $wgOut->addWikiText( '==' . wfMsg( 'toomanymatches' ) . "==\n" ); - wfProfileOut( __METHOD__ ); - return; - } - - $textMatches = $search->searchText( $rewritten ); + if( !($titleMatches instanceof SearchResultTooMany)) + $textMatches = $search->searchText( $rewritten ); // did you mean... suggestions if( $textMatches && $textMatches->hasSuggestion() ) { @@ -188,7 +164,33 @@ class SpecialSearch { $suggestLink = ''. $textMatches->getSuggestionSnippet().''; - $wgOut->addHTML('
'.wfMsg('search-suggest',$suggestLink).'
'); + $this->didYouMeanHtml = '
'.wfMsg('search-suggest',$suggestLink).'
'; + } + + // start rendering the page + $wgOut->addHtml( + Xml::openElement( 'table', array( 'border'=>0, 'cellpadding'=>0, 'cellspacing'=>0 ) ) . + Xml::openElement( 'tr' ) . + Xml::openElement( 'td' ) . "\n" . + ( $this->searchAdvanced ? $this->powerSearchBox( $term ) : $this->shortDialog( $term ) ) . + Xml::closeElement('td') . + Xml::closeElement('tr') . + Xml::closeElement('table') + ); + + // Sometimes the search engine knows there are too many hits + if( $titleMatches instanceof SearchResultTooMany ) { + $wgOut->addWikiText( '==' . wfMsg( 'toomanymatches' ) . "==\n" ); + wfProfileOut( __METHOD__ ); + return; + } + + $filePrefix = $wgContLang->getFormattedNsText(NS_FILE).':'; + if( '' === trim( $term ) || $filePrefix === trim( $term ) ) { + $wgOut->addHTML( $this->searchAdvanced ? $this->powerSearchFocus() : $this->searchFocus() ); + // Empty query -- straight view of search form + wfProfileOut( __METHOD__ ); + return; } // show direct page/create link @@ -503,7 +505,7 @@ class SpecialSearch { $out = "
". wfMsg('search-interwiki-caption')."
\n"; $off = $this->offset + 1; - $out .= "