r1698 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r1697‎ | r1698 | r1699 >
Date:22:46, 21 September 2003
Author:vibber
Status:old
Tags:
Comment:
Disable search take out title search too; display cleaner message
Modified paths:
  • /branches/stable/phase3/includes/SearchEngine.php (modified) (history)

Diff [purge]

Index: branches/stable/phase3/includes/SearchEngine.php
@@ -154,83 +154,79 @@
155155 $wgOut->setArticleFlag( false );
156156 $wgOut->setRobotpolicy( "noindex,nofollow" );
157157
158 - $sk = $wgUser->getSkin();
159 - $text = wfMsg( "searchresulttext", $sk->makeKnownLink(
160 - wfMsg( "searchhelppage" ), wfMsg( "searchingwikipedia" ) ) );
161 - $wgOut->addHTML( $text );
162 -
163 - $this->parseQuery();
164 - if ( "" == $this->mTitlecond || "" == $this->mTextcond ) {
165 - $wgOut->addHTML( "<h2>" . wfMsg( "badquery" ) . "</h2>\n" .
166 - "<p>" . wfMsg( "badquerytext" ) );
167 - return;
168 - }
169 - list( $limit, $offset ) = wfCheckLimits( 20, "searchlimit" );
170 -
171 - $searchnamespaces = $this->queryNamespaces();
172 - $redircond = $this->searchRedirects();
173 -
174 - $sql = "SELECT cur_id,cur_namespace,cur_title," .
175 - "cur_text FROM cur,searchindex " .
176 - "WHERE cur_id=si_page AND {$this->mTitlecond} " .
177 - "{$searchnamespaces} {$redircond}" .
178 - "LIMIT {$offset}, {$limit}";
179 - $res1 = wfQuery( $sql, $fname );
180 - $num = wfNumRows($res1);
181 -
182158 if ( $wgDisableTextSearch ) {
183 - $res2 = 0;
 159+ $wgOut->addHTML( str_replace( "$1",
 160+ htmlspecialchars( $search ), wfMsg( "searchdisabled" ) ) );
184161 } else {
 162+ $sk = $wgUser->getSkin();
 163+ $text = wfMsg( "searchresulttext", $sk->makeKnownLink(
 164+ wfMsg( "searchhelppage" ), wfMsg( "searchingwikipedia" ) ) );
 165+ $wgOut->addHTML( $text );
 166+
 167+ $this->parseQuery();
 168+ if ( "" == $this->mTitlecond || "" == $this->mTextcond ) {
 169+ $wgOut->addHTML( "<h2>" . wfMsg( "badquery" ) . "</h2>\n" .
 170+ "<p>" . wfMsg( "badquerytext" ) );
 171+ return;
 172+ }
 173+ list( $limit, $offset ) = wfCheckLimits( 20, "searchlimit" );
 174+
 175+ $searchnamespaces = $this->queryNamespaces();
 176+ $redircond = $this->searchRedirects();
 177+
185178 $sql = "SELECT cur_id,cur_namespace,cur_title," .
186179 "cur_text FROM cur,searchindex " .
 180+ "WHERE cur_id=si_page AND {$this->mTitlecond} " .
 181+ "{$searchnamespaces} {$redircond}" .
 182+ "LIMIT {$offset}, {$limit}";
 183+ $res1 = wfQuery( $sql, $fname );
 184+ $num = wfNumRows($res1);
 185+
 186+ $sql = "SELECT cur_id,cur_namespace,cur_title," .
 187+ "cur_text FROM cur,searchindex " .
187188 "WHERE cur_id=si_page AND {$this->mTextcond} " .
188189 "{$searchnamespaces} {$redircond} " .
189190 "LIMIT {$offset}, {$limit}";
190191 $res2 = wfQuery( $sql, $fname );
191192 $num = $num + wfNumRows($res2);
192 - }
193193
194 - if ( $num == $limit ) {
195 - $top = wfShowingResults( $offset, $limit);
196 - } else {
197 - $top = wfShowingResultsNum( $offset, $limit, $num );
198 - }
199 - $wgOut->addHTML( "<p>{$top}\n" );
200 -
201 - # For powersearch
202 -
203 - $a2l = "" ;
204 - $akk = array_keys( $this->addtoquery ) ;
205 - foreach ( $akk AS $ak ) {
206 - $a2l .= "&{$ak}={$this->addtoquery[$ak]}" ;
207 - }
208 -
209 - $sl = wfViewPrevNext( $offset, $limit, "",
210 - "search=" . wfUrlencode( $this->mUsertext ) . $a2l );
211 - $wgOut->addHTML( "<br>{$sl}\n" );
212 -
213 - $foundsome = false;
214 -
215 - if ( 0 == wfNumRows( $res1 ) ) {
216 - $wgOut->addHTML( "<h2>" . wfMsg( "notitlematches" ) .
217 - "</h2>\n" );
218 - } else {
219 - $foundsome = true;
220 - $off = $offset + 1;
221 - $wgOut->addHTML( "<h2>" . wfMsg( "titlematches" ) .
222 - "</h2>\n<ol start='{$off}'>" );
223 -
224 - while ( $row = wfFetchObject( $res1 ) ) {
225 - $this->showHit( $row );
 194+ if ( $num == $limit ) {
 195+ $top = wfShowingResults( $offset, $limit);
 196+ } else {
 197+ $top = wfShowingResultsNum( $offset, $limit, $num );
226198 }
227 - wfFreeResult( $res1 );
228 - $wgOut->addHTML( "</ol>\n" );
229 - }
 199+ $wgOut->addHTML( "<p>{$top}\n" );
 200+
 201+ # For powersearch
 202+
 203+ $a2l = "" ;
 204+ $akk = array_keys( $this->addtoquery ) ;
 205+ foreach ( $akk AS $ak ) {
 206+ $a2l .= "&{$ak}={$this->addtoquery[$ak]}" ;
 207+ }
 208+
 209+ $sl = wfViewPrevNext( $offset, $limit, "",
 210+ "search=" . wfUrlencode( $this->mUsertext ) . $a2l );
 211+ $wgOut->addHTML( "<br>{$sl}\n" );
 212+
 213+ $foundsome = false;
 214+
 215+ if ( 0 == wfNumRows( $res1 ) ) {
 216+ $wgOut->addHTML( "<h2>" . wfMsg( "notitlematches" ) .
 217+ "</h2>\n" );
 218+ } else {
 219+ $foundsome = true;
 220+ $off = $offset + 1;
 221+ $wgOut->addHTML( "<h2>" . wfMsg( "titlematches" ) .
 222+ "</h2>\n<ol start='{$off}'>" );
 223+
 224+ while ( $row = wfFetchObject( $res1 ) ) {
 225+ $this->showHit( $row );
 226+ }
 227+ wfFreeResult( $res1 );
 228+ $wgOut->addHTML( "</ol>\n" );
 229+ }
230230
231 - if ( $wgDisableTextSearch ) {
232 - $wgOut->addHTML( str_replace( "$1",
233 - htmlspecialchars( $search ), wfMsg( "searchdisabled" ) ) );
234 - } else {
235231 if ( 0 == wfNumRows( $res2 ) ) {
236232 $wgOut->addHTML( "<h2>" . wfMsg( "notextmatches" ) .
237233 "</h2>\n" );
@@ -245,12 +241,12 @@
246242 wfFreeResult( $res2 );
247243 $wgOut->addHTML( "</ol>\n" );
248244 }
 245+ if ( ! $foundsome ) {
 246+ $wgOut->addHTML( "<p>" . wfMsg( "nonefound" ) . "\n" );
 247+ }
 248+ $wgOut->addHTML( "<p>{$sl}\n" );
 249+ $wgOut->addHTML( $powersearch );
249250 }
250 - if ( ! $foundsome ) {
251 - $wgOut->addHTML( "<p>" . wfMsg( "nonefound" ) . "\n" );
252 - }
253 - $wgOut->addHTML( "<p>{$sl}\n" );
254 - $wgOut->addHTML( $powersearch );
255251 }
256252
257253 function legalSearchChars()

Status & tagging log