r45217 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45216‎ | r45217 | r45218 >
Date:04:48, 31 December 2008
Author:rainman
Status:ok
Tags:
Comment:
Backport r45215 to old search ui and move search engine creation before page setup so we can do the setup properly.
Modified paths:
  • /trunk/phase3/includes/SearchEngine.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialSearch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SearchEngine.php
@@ -13,6 +13,7 @@
1414 class SearchEngine {
1515 var $limit = 10;
1616 var $offset = 0;
 17+ var $prefix = '';
1718 var $searchTerms = array();
1819 var $namespaces = array( NS_MAIN );
1920 var $showRedirects = false;
Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -115,10 +115,17 @@
116116 public function showResults( $term ) {
117117 global $wgOut, $wgDisableTextSearch, $wgContLang;
118118 wfProfileIn( __METHOD__ );
119 -
120 - $this->setupPage( $term );
 119+
121120 $this->searchEngine = SearchEngine::create();
 121+ $search =& $this->searchEngine;
 122+ $search->setLimitOffset( $this->limit, $this->offset );
 123+ $search->setNamespaces( $this->namespaces );
 124+ $search->showRedirects = $this->searchRedirects;
 125+ $search->prefix = $this->mPrefix;
 126+ $term = $search->transformSearchTerm($term);
122127
 128+ $this->setupPage( $term );
 129+
123130 if( $wgDisableTextSearch ) {
124131 global $wgSearchForwardUrl;
125132 if( $wgSearchForwardUrl ) {
@@ -144,13 +151,8 @@
145152 }
146153
147154 $t = Title::newFromText( $term );
148 - // fetch search results
149 - $search =& $this->searchEngine;
150 - $search->setLimitOffset( $this->limit, $this->offset );
151 - $search->setNamespaces( $this->namespaces );
152 - $search->showRedirects = $this->searchRedirects;
153 - $search->prefix = $this->mPrefix;
154 - $term = $search->transformSearchTerm($term);
 155+
 156+ // fetch search results
155157 $rewritten = $search->replacePrefixes($term);
156158
157159 $titleMatches = $search->searchTitle( $rewritten );
@@ -854,7 +856,7 @@
855857 */
856858 function __construct( &$request, &$user ) {
857859 list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, 'searchlimit' );
858 -
 860+ $this->mPrefix = $request->getVal('prefix', '');
859861 $this->namespaces = $this->powerSearch( $request );
860862 if( empty( $this->namespaces ) ) {
861863 $this->namespaces = SearchEngine::userNamespaces( $user );
@@ -919,6 +921,13 @@
920922 global $wgOut, $wgUser;
921923 $sk = $wgUser->getSkin();
922924
 925+ $search = SearchEngine::create();
 926+ $search->setLimitOffset( $this->limit, $this->offset );
 927+ $search->setNamespaces( $this->namespaces );
 928+ $search->showRedirects = $this->searchRedirects;
 929+ $search->prefix = $this->mPrefix;
 930+ $term = $search->transformSearchTerm($term);
 931+
923932 $this->setupPage( $term );
924933
925934 $wgOut->addWikiMsg( 'searchresulttext' );
@@ -957,12 +966,7 @@
958967 return;
959968 }
960969
961 - $wgOut->addHTML( $this->shortDialog( $term ) );
962 -
963 - $search = SearchEngine::create();
964 - $search->setLimitOffset( $this->limit, $this->offset );
965 - $search->setNamespaces( $this->namespaces );
966 - $search->showRedirects = $this->searchRedirects;
 970+ $wgOut->addHTML( $this->shortDialog( $term ) );
967971 $rewritten = $search->replacePrefixes($term);
968972
969973 $titleMatches = $search->searchTitle( $rewritten );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r45215Pair to previous commit: handle the 'prefix' param - the default backend will...rainman03:33, 31 December 2008

Status & tagging log