Index: trunk/phase3/includes/specials/SpecialSearch.php |
— | — | @@ -72,6 +72,7 @@ |
73 | 73 | $this->searchAdvanced = $request->getVal( 'advanced' ); |
74 | 74 | $this->active = 'advanced'; |
75 | 75 | $this->sk = $user->getSkin(); |
| 76 | + $this->didYouMeanHtml = ''; # html of did you mean... link |
76 | 77 | } |
77 | 78 | |
78 | 79 | /** |
— | — | @@ -117,26 +118,6 @@ |
118 | 119 | $this->setupPage( $term ); |
119 | 120 | $this->searchEngine = SearchEngine::create(); |
120 | 121 | |
121 | | - $t = Title::newFromText( $term ); |
122 | | - |
123 | | - $wgOut->addHtml( |
124 | | - Xml::openElement( 'table', array( 'border'=>0, 'cellpadding'=>0, 'cellspacing'=>0 ) ) . |
125 | | - Xml::openElement( 'tr' ) . |
126 | | - Xml::openElement( 'td' ) . "\n" . |
127 | | - ( $this->searchAdvanced ? $this->powerSearchBox( $term ) : $this->shortDialog( $term ) ) . |
128 | | - Xml::closeElement('td') . |
129 | | - Xml::closeElement('tr') . |
130 | | - Xml::closeElement('table') |
131 | | - ); |
132 | | - |
133 | | - $filePrefix = $wgContLang->getFormattedNsText(NS_FILE).':'; |
134 | | - if( '' === trim( $term ) || $filePrefix === trim( $term ) ) { |
135 | | - $wgOut->addHTML( $this->searchAdvanced ? $this->powerSearchFocus() : $this->searchFocus() ); |
136 | | - // Empty query -- straight view of search form |
137 | | - wfProfileOut( __METHOD__ ); |
138 | | - return; |
139 | | - } |
140 | | - |
141 | 122 | if( $wgDisableTextSearch ) { |
142 | 123 | global $wgSearchForwardUrl; |
143 | 124 | if( $wgSearchForwardUrl ) { |
— | — | @@ -160,7 +141,9 @@ |
161 | 142 | wfProfileOut( __METHOD__ ); |
162 | 143 | return; |
163 | 144 | } |
164 | | - |
| 145 | + |
| 146 | + $t = Title::newFromText( $term ); |
| 147 | + // fetch search results |
165 | 148 | $search =& $this->searchEngine; |
166 | 149 | $search->setLimitOffset( $this->limit, $this->offset ); |
167 | 150 | $search->setNamespaces( $this->namespaces ); |
— | — | @@ -168,16 +151,9 @@ |
169 | 152 | $rewritten = $search->replacePrefixes($term); |
170 | 153 | |
171 | 154 | $titleMatches = $search->searchTitle( $rewritten ); |
| 155 | + if( !($titleMatches instanceof SearchResultTooMany)) |
| 156 | + $textMatches = $search->searchText( $rewritten ); |
172 | 157 | |
173 | | - // Sometimes the search engine knows there are too many hits |
174 | | - if( $titleMatches instanceof SearchResultTooMany ) { |
175 | | - $wgOut->addWikiText( '==' . wfMsg( 'toomanymatches' ) . "==\n" ); |
176 | | - wfProfileOut( __METHOD__ ); |
177 | | - return; |
178 | | - } |
179 | | - |
180 | | - $textMatches = $search->searchText( $rewritten ); |
181 | | - |
182 | 158 | // did you mean... suggestions |
183 | 159 | if( $textMatches && $textMatches->hasSuggestion() ) { |
184 | 160 | $st = SpecialPage::getTitleFor( 'Search' ); |
— | — | @@ -188,8 +164,34 @@ |
189 | 165 | $suggestLink = '<a href="'.$st->escapeLocalURL($stParams).'">'. |
190 | 166 | $textMatches->getSuggestionSnippet().'</a>'; |
191 | 167 | |
192 | | - $wgOut->addHTML('<div class="searchdidyoumean">'.wfMsg('search-suggest',$suggestLink).'</div>'); |
| 168 | + $this->didYouMeanHtml = '<div class="searchdidyoumean">'.wfMsg('search-suggest',$suggestLink).'</div>'; |
193 | 169 | } |
| 170 | + |
| 171 | + // start rendering the page |
| 172 | + $wgOut->addHtml( |
| 173 | + Xml::openElement( 'table', array( 'border'=>0, 'cellpadding'=>0, 'cellspacing'=>0 ) ) . |
| 174 | + Xml::openElement( 'tr' ) . |
| 175 | + Xml::openElement( 'td' ) . "\n" . |
| 176 | + ( $this->searchAdvanced ? $this->powerSearchBox( $term ) : $this->shortDialog( $term ) ) . |
| 177 | + Xml::closeElement('td') . |
| 178 | + Xml::closeElement('tr') . |
| 179 | + Xml::closeElement('table') |
| 180 | + ); |
| 181 | + |
| 182 | + // Sometimes the search engine knows there are too many hits |
| 183 | + if( $titleMatches instanceof SearchResultTooMany ) { |
| 184 | + $wgOut->addWikiText( '==' . wfMsg( 'toomanymatches' ) . "==\n" ); |
| 185 | + wfProfileOut( __METHOD__ ); |
| 186 | + return; |
| 187 | + } |
| 188 | + |
| 189 | + $filePrefix = $wgContLang->getFormattedNsText(NS_FILE).':'; |
| 190 | + if( '' === trim( $term ) || $filePrefix === trim( $term ) ) { |
| 191 | + $wgOut->addHTML( $this->searchAdvanced ? $this->powerSearchFocus() : $this->searchFocus() ); |
| 192 | + // Empty query -- straight view of search form |
| 193 | + wfProfileOut( __METHOD__ ); |
| 194 | + return; |
| 195 | + } |
194 | 196 | |
195 | 197 | // show direct page/create link |
196 | 198 | if( !is_null($t) ) { |
— | — | @@ -503,7 +505,7 @@ |
504 | 506 | $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>". |
505 | 507 | wfMsg('search-interwiki-caption')."</div>\n"; |
506 | 508 | $off = $this->offset + 1; |
507 | | - $out .= "<ul start='{$off}' class='mw-search-iwresults'>\n"; |
| 509 | + $out .= "<ul class='mw-search-iwresults'>\n"; |
508 | 510 | |
509 | 511 | // work out custom project captions |
510 | 512 | $customCaptions = array(); |
— | — | @@ -600,32 +602,41 @@ |
601 | 603 | $redirect = Xml::check( 'redirs', $this->searchRedirects, array( 'value' => '1', 'id' => 'redirs' ) ); |
602 | 604 | $redirectLabel = Xml::label( wfMsg( 'powersearch-redir' ), 'redirs' ); |
603 | 605 | $searchField = Xml::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'powerSearchText' ) ); |
604 | | - $searchButton = Xml::submitButton( wfMsg( 'powersearch' ), array( 'name' => 'fulltext' ) ) . "\n"; |
| 606 | + $searchButton = Xml::submitButton( wfMsg( 'powersearch' ), array( 'name' => 'fulltext' )) . "\n"; |
605 | 607 | $searchTitle = SpecialPage::getTitleFor( 'Search' ); |
606 | 608 | |
| 609 | + $redirectText = ''; |
| 610 | + // show redirects check only if backend supports it |
| 611 | + if($this->searchEngine->acceptListRedirects()){ |
| 612 | + "<p>". |
| 613 | + $redirectText = $redirect . " " . $redirectLabel |
| 614 | + ."</p>"; |
| 615 | + } |
| 616 | + |
607 | 617 | $out = Xml::openElement( 'form', array( 'id' => 'powersearch', 'method' => 'get', 'action' => $wgScript ) ) . |
608 | 618 | Xml::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n" . |
609 | 619 | "<p>" . |
610 | 620 | wfMsgExt( 'powersearch-ns', array( 'parseinline' ) ) . |
611 | 621 | "</p>\n" . |
| 622 | + '<input type="hidden" name="advanced" value="'.$this->searchAdvanced."\"/>\n". |
612 | 623 | $tables . |
613 | | - "<hr style=\"clear: both\" />\n" . |
614 | | - "<p>" . |
615 | | - $redirect . " " . $redirectLabel . |
616 | | - "</p>\n" . |
| 624 | + "<hr style=\"clear: both;\" />\n". |
| 625 | + $redirectText ."\n". |
| 626 | + "<div style=\"padding-top:2px;padding-bottom:2px;\">". |
617 | 627 | wfMsgExt( 'powersearch-field', array( 'parseinline' ) ) . |
618 | 628 | " " . |
619 | 629 | $searchField . |
620 | 630 | " " . |
621 | 631 | $searchButton . |
| 632 | + "</div>". |
622 | 633 | "</form>"; |
623 | 634 | $t = Title::newFromText( $term ); |
624 | | - if( $t != null && count($this->namespaces) === 1 ) { |
| 635 | + /* if( $t != null && count($this->namespaces) === 1 ) { |
625 | 636 | $out .= wfMsgExt( 'searchmenu-prefix', array('parseinline'), $term ); |
626 | | - } |
| 637 | + } */ |
627 | 638 | return Xml::openElement( 'fieldset', array('id' => 'mw-searchoptions','style' => 'margin:0em;') ) . |
628 | 639 | Xml::element( 'legend', null, wfMsg('powersearch-legend') ) . |
629 | | - $this->formHeader($term) . $out . |
| 640 | + $this->formHeader($term) . $out . $this->didYouMeanHtml . |
630 | 641 | Xml::closeElement( 'fieldset' ); |
631 | 642 | } |
632 | 643 | |
— | — | @@ -729,8 +740,8 @@ |
730 | 741 | $searchable = SearchEngine::searchableNamespaces(); |
731 | 742 | $out = Xml::openElement( 'form', array( 'id' => 'search', 'method' => 'get', 'action' => $wgScript ) ); |
732 | 743 | $out .= Xml::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n"; |
733 | | - // If searching several, but not all namespaces, show what we are searching. |
734 | | - if( count($this->namespaces) > 1 && $this->namespaces !== array_keys($searchable) ) { |
| 744 | + // show namespaces only for advanced search |
| 745 | + if( $this->active == 'advanced' ) { |
735 | 746 | $active = array(); |
736 | 747 | foreach( $this->namespaces as $ns ) { |
737 | 748 | $active[$ns] = $searchable[$ns]; |
— | — | @@ -752,12 +763,12 @@ |
753 | 764 | $out .= Xml::closeElement( 'form' ); |
754 | 765 | // Add prefix link for single-namespace searches |
755 | 766 | $t = Title::newFromText( $term ); |
756 | | - if( $t != null && count($this->namespaces) === 1 ) { |
| 767 | + /*if( $t != null && count($this->namespaces) === 1 ) { |
757 | 768 | $out .= wfMsgExt( 'searchmenu-prefix', array('parseinline'), $term ); |
758 | | - } |
| 769 | + }*/ |
759 | 770 | return Xml::openElement( 'fieldset', array('id' => 'mw-searchoptions','style' => 'margin:0em;') ) . |
760 | 771 | Xml::element( 'legend', null, wfMsg('searchmenu-legend') ) . |
761 | | - $this->formHeader($term) . $out . |
| 772 | + $this->formHeader($term) . $out . $this->didYouMeanHtml . |
762 | 773 | Xml::closeElement( 'fieldset' ); |
763 | 774 | } |
764 | 775 | |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1443,7 +1443,7 @@ |
1444 | 1444 | 'viewprevnext' => 'View ($1) ($2) ($3)', |
1445 | 1445 | 'searchmenu-legend' => 'Search options', |
1446 | 1446 | 'searchmenu-exists' => "'''There is page named \"[[\$1]]\" on this wiki'''", |
1447 | | -'searchmenu-new' => "'''[[:$1|Create]] the page ''$1'' on this wiki!'''", |
| 1447 | +'searchmenu-new' => "'''Create the page \"[[:$1|$1]]\" on this wiki!'''", |
1448 | 1448 | 'searchhelp-url' => 'Help:Contents', |
1449 | 1449 | 'searchmenu-prefix' => '[[Special:PrefixIndex/$1|Browse pages with this prefix]]', |
1450 | 1450 | 'searchmenu-help' => '[[{{MediaWiki:Searchhelp-url}}|{{int:help}}]]?', # do not translate or duplicate this message to other languages |