r43499 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43498‎ | r43499 | r43500 >
Date:19:11, 14 November 2008
Author:brion
Status:ok (Comments)
Tags:
Comment:
Reverting in-development search changes pending fixing.

Can we please do these sorts of experimental developments on branches before putting them to trunk? Our trunk is meant to be functional and ready to deploy at all times; doing experiments on trunk delays deployments because we have to test and fix them or roll them back.

Reverted:
r43376
r43385
r43403
r43404
r43405
r43406
r43423

Issues I noticed during a few minutes testing:
* Background color mismatch on the frameset for wikis that set a BG color on Special:
* 'browse pages with this prefix' is kind of funky in "Pages & Project" (goes to main namespace only)
* Which namespaces are in "Pages & Project" is not discoverable
* Default link to nonexistent help page Project:Searching kind of sucks. we should avoid doing those by default. It used to link to Help:Contents; any reason for the change from one page which might have previously existed to one which doesn't?
* "Create the page "Stuff" on this wiki!" - Double page creation links seem kind of weird. There should only be one, otherwise why have two?
* Bad prefix link output when search terms are not a valid wiki title
* We've lost the Whatlinkshere link from the old results
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/SearchEngine.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialSearch.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)
  • /trunk/phase3/skins/common/shared.css (modified) (history)
  • /trunk/phase3/skins/monobook/main.css (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -760,6 +760,11 @@
761761 'search' => array(
762762 'searchresults',
763763 'searchresults-title',
 764+ 'searchresulttext',
 765+ 'searchsubtitle',
 766+ 'searchsubtitleinvalid',
 767+ 'noexactmatch',
 768+ 'noexactmatch-nocreate',
764769 'toomanymatches',
765770 'titlematches',
766771 'notitlematches',
@@ -768,25 +773,6 @@
769774 'prevn',
770775 'nextn',
771776 'viewprevnext',
772 - 'searchmenu-legend',
773 - 'searchmenu-exists',
774 - 'searchmenu-new',
775 - 'searchhelp-url',
776 - 'searchmenu-prefix',
777 - 'searchmenu-help',
778 - 'searchprofile-articles',
779 - 'searchprofile-articles-and-proj',
780 - 'searchprofile-project',
781 - 'searchprofile-images',
782 - 'searchprofile-everything',
783 - 'searchprofile-advanced',
784 - 'searchprofile-articles-tooltip',
785 - 'searchprofile-project-tooltip',
786 - 'searchprofile-images-tooltip',
787 - 'searchprofile-everything-tooltip',
788 - 'searchprofile-advanced-tooltip',
789 - 'prefs-search-nsdefault',
790 - 'prefs-search-nscustom',
791777 'search-result-size',
792778 'search-result-score',
793779 'search-redirect',
@@ -805,7 +791,7 @@
806792 'showingresults',
807793 'showingresultsnum',
808794 'showingresultstotal',
809 - 'search-nonefound',
 795+ 'nonefound',
810796 'powersearch',
811797 'powersearch-legend',
812798 'powersearch-ns',
@@ -879,6 +865,7 @@
880866 'allowemail',
881867 'prefs-searchoptions',
882868 'prefs-namespaces',
 869+ 'defaultns',
883870 'default',
884871 'files',
885872 ),
Index: trunk/phase3/skins/monobook/main.css
@@ -1409,10 +1409,6 @@
14101410 padding:2px;
14111411 }
14121412
1413 -#powersearch p {
1414 - margin-top:0px;
1415 -}
1416 -
14171413 div.multipageimagenavbox {
14181414 border: solid 1px silver;
14191415 padding: 4px;
Index: trunk/phase3/skins/common/shared.css
@@ -106,18 +106,12 @@
107107 }
108108 .mw-search-results li {
109109 padding-bottom: 1em;
110 - list-style:none;
111110 }
112111 .mw-search-result-data {
113112 color: green;
114113 font-size: 97%;
115114 }
116115
117 -td#mw-search-menu {
118 - padding-left:6em;
119 - font-size:85%;
120 -}
121 -
122116 div#mw-search-interwiki {
123117 float: right;
124118 width: 18em;
@@ -150,14 +144,6 @@
151145 font-weight: bold;
152146 }
153147
154 -div.searchresults {
155 - border:1px solid darkblue;
156 - padding-top: 5px;
157 - padding-bottom: 5px;
158 - padding-left: 15px;
159 - padding-right: 15px;
160 -}
161 -
162148 /*
163149 * UserRights stuff
164150 */
Index: trunk/phase3/includes/SearchEngine.php
@@ -43,11 +43,6 @@
4444 return null;
4545 }
4646
47 - /** If this search backend can list/unlist redirects */
48 - function acceptListRedirects() {
49 - return true;
50 - }
51 -
5247 /**
5348 * If an exact title match can be find, or a very slightly close match,
5449 * return the title. If no match, returns NULL.
@@ -267,52 +262,8 @@
268263
269264 return array_keys($wgNamespacesToBeSearchedDefault, true);
270265 }
271 -
 266+
272267 /**
273 - * Get a list of namespace names useful for showing in tooltips
274 - * and preferences
275 - *
276 - * @param unknown_type $namespaces
277 - */
278 - public static function namespacesAsText( $namespaces ){
279 - global $wgContLang;
280 -
281 - $formatted = array_map( array($wgContLang,'getFormattedNsText'), $namespaces );
282 - foreach( $formatted as $key => $ns ){
283 - if ( empty($ns) )
284 - $formatted[$key] = wfMsg( 'blanknamespace' );
285 - }
286 - return $formatted;
287 - }
288 -
289 - /**
290 - * An array of "project" namespaces indexes typically searched
291 - * by logged-in users
292 - *
293 - * @return array
294 - * @static
295 - */
296 - public static function projectNamespaces() {
297 - global $wgNamespacesToBeSearchedDefault, $wgNamespacesToBeSearchedProject;
298 -
299 - return array_keys( $wgNamespacesToBeSearchedProject, true );
300 - }
301 -
302 - /**
303 - * An array of "project" namespaces indexes typically searched
304 - * by logged-in users in addition to the default namespaces
305 - *
306 - * @return array
307 - * @static
308 - */
309 - public static function defaultAndProjectNamespaces() {
310 - global $wgNamespacesToBeSearchedDefault, $wgNamespacesToBeSearchedProject;
311 -
312 - return array_keys( $wgNamespacesToBeSearchedDefault +
313 - $wgNamespacesToBeSearchedProject, true);
314 - }
315 -
316 - /**
317268 * Return a 'cleaned up' search string
318269 *
319270 * @return string
@@ -534,11 +485,11 @@
535486 var $mRevision = null;
536487 var $mImage = null;
537488
538 - function __construct( $row ) {
 489+ function SearchResult( $row ) {
539490 $this->mTitle = Title::makeTitle( $row->page_namespace, $row->page_title );
540491 if( !is_null($this->mTitle) ){
541492 $this->mRevision = Revision::newFromTitle( $this->mTitle );
542 - if( $this->mTitle->getNamespace() === NS_IMAGE )
 493+ if($this->mTitle->getNamespace() == NS_IMAGE)
543494 $this->mImage = wfFindFile( $this->mTitle );
544495 }
545496 }
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1436,7 +1436,7 @@
14371437 * to ensure that client-side caches don't keep obsolete copies of global
14381438 * styles.
14391439 */
1440 -$wgStyleVersion = '184';
 1440+$wgStyleVersion = '183';
14411441
14421442
14431443 # Server-side caching:
@@ -1924,20 +1924,6 @@
19251925 );
19261926
19271927 /**
1928 - * Additional namespaces to those in $wgNamespacesToBeSearchedDefault that
1929 - * will be added to default search for "project" page inclusive searches
1930 - *
1931 - * Same format as $wgNamespacesToBeSearchedDefault
1932 - */
1933 -$wgNamespacesToBeSearchedProject = array(
1934 - NS_USER => true,
1935 - NS_PROJECT => true,
1936 - NS_HELP => true,
1937 - NS_CATEGORY => true,
1938 -);
1939 -
1940 -
1941 -/**
19421928 * Site notice shown at the top of each page
19431929 *
19441930 * This message can contain wiki text, and can also be set through the
Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -39,8 +39,7 @@
4040 $searchPage = new SpecialSearch( $wgRequest, $wgUser );
4141 if( $wgRequest->getVal( 'fulltext' )
4242 || !is_null( $wgRequest->getVal( 'offset' ))
43 - || !is_null( $wgRequest->getVal( 'searchx' )) )
44 - {
 43+ || !is_null( $wgRequest->getVal( 'searchx' ))) {
4544 $searchPage->showResults( $search, 'search' );
4645 } else {
4746 $searchPage->goResult( $search );
@@ -70,7 +69,6 @@
7170 }
7271
7372 $this->searchRedirects = $request->getcheck( 'redirs' ) ? true : false;
74 - $this->searchAdvanced = $request->getVal('advanced');
7573 }
7674
7775 /**
@@ -79,7 +77,8 @@
8078 * @public
8179 */
8280 function goResult( $term ) {
83 - global $wgOut, $wgGoToEdit;
 81+ global $wgOut;
 82+ global $wgGoToEdit;
8483
8584 $this->setupPage( $term );
8685
@@ -87,7 +86,7 @@
8887 $t = Title::newFromText( $term );
8988
9089 # If the string cannot be used to create a title
91 - if( is_null( $t ) ) {
 90+ if( is_null( $t ) ){
9291 return $this->showResults( $term );
9392 }
9493
@@ -103,12 +102,19 @@
104103 if( ! is_null( $t ) ) {
105104 wfRunHooks( 'SpecialSearchNogomatch', array( &$t ) );
106105 # If the feature is enabled, go straight to the edit page
107 - if( $wgGoToEdit ) {
 106+ if ( $wgGoToEdit ) {
108107 $wgOut->redirect( $t->getFullURL( 'action=edit' ) );
109108 return;
110109 }
111110 }
112111
 112+ $wgOut->wrapWikiMsg( "==$1==\n", 'notitlematches' );
 113+ if( $t->quickUserCan( 'create' ) && $t->quickUserCan( 'edit' ) ) {
 114+ $wgOut->addWikiMsg( 'noexactmatch', wfEscapeWikiText( $term ) );
 115+ } else {
 116+ $wgOut->addWikiMsg( 'noexactmatch-nocreate', wfEscapeWikiText( $term ) );
 117+ }
 118+
113119 return $this->showResults( $term );
114120 }
115121
@@ -123,36 +129,20 @@
124130 $sk = $wgUser->getSkin();
125131
126132 $this->setupPage( $term );
127 - $this->searchEngine = SearchEngine::create();
128 -
129 - $t = Title::newFromText( $term );
130133
131 - $wgOut->addHtml(
132 - Xml::openElement( 'table', array( 'border'=>0, 'cellpadding'=>0, 'cellspacing'=>0 ) ) .
133 - Xml::openElement( 'tr' ) .
134 - Xml::openElement( 'td' ) . "\n"
135 - );
136 - if( $this->searchAdvanced ) {
137 - $wgOut->addHTML( $this->powerSearchBox( $term ) );
138 - $showMenu = false;
139 - } else {
140 - $wgOut->addHTML( $this->shortDialog( $term ) );
141 - $showMenu = true;
142 - }
143 - $wgOut->addHtml(
144 - Xml::closeElement('td') .
145 - Xml::closeElement('tr') .
146 - Xml::closeElement('table')
147 - );
 134+ $wgOut->addWikiMsg( 'searchresulttext' );
148135
149136 if( '' === trim( $term ) ) {
150137 // Empty query -- straight view of search form
 138+ $wgOut->setSubtitle( '' );
 139+ $wgOut->addHTML( $this->powerSearchBox( $term ) );
 140+ $wgOut->addHTML( $this->powerSearchFocus() );
151141 wfProfileOut( $fname );
152142 return;
153143 }
154144
155145 global $wgDisableTextSearch;
156 - if( $wgDisableTextSearch ) {
 146+ if ( $wgDisableTextSearch ) {
157147 global $wgSearchForwardUrl;
158148 if( $wgSearchForwardUrl ) {
159149 $url = str_replace( '$1', urlencode( $term ), $wgSearchForwardUrl );
@@ -175,7 +165,9 @@
176166 return;
177167 }
178168
179 - $search =& $this->searchEngine;
 169+ $wgOut->addHTML( $this->shortDialog( $term ) );
 170+
 171+ $search = SearchEngine::create();
180172 $search->setLimitOffset( $this->limit, $this->offset );
181173 $search->setNamespaces( $this->namespaces );
182174 $search->showRedirects = $this->searchRedirects;
@@ -184,53 +176,43 @@
185177 $titleMatches = $search->searchTitle( $rewritten );
186178
187179 // Sometimes the search engine knows there are too many hits
188 - if( $titleMatches instanceof SearchResultTooMany ) {
 180+ if ($titleMatches instanceof SearchResultTooMany) {
189181 $wgOut->addWikiText( '==' . wfMsg( 'toomanymatches' ) . "==\n" );
 182+ $wgOut->addHTML( $this->powerSearchBox( $term ) );
 183+ $wgOut->addHTML( $this->powerSearchFocus() );
190184 wfProfileOut( $fname );
191185 return;
192186 }
193187
194188 $textMatches = $search->searchText( $rewritten );
195 -
 189+
196190 // did you mean... suggestions
197 - if( $textMatches && $textMatches->hasSuggestion() ) {
 191+ if($textMatches && $textMatches->hasSuggestion()){
198192 $st = SpecialPage::getTitleFor( 'Search' );
199 - $stParams = wfArrayToCGI(
200 - array( 'search' => $textMatches->getSuggestionQuery(), 'fulltext' => wfMsg('search') ),
201 - $this->powerSearchOptions()
202 - );
 193+ $stParams = wfArrayToCGI( array(
 194+ 'search' => $textMatches->getSuggestionQuery(),
 195+ 'fulltext' => wfMsg('search')),
 196+ $this->powerSearchOptions());
 197+
203198 $suggestLink = '<a href="'.$st->escapeLocalURL($stParams).'">'.
204 - $textMatches->getSuggestionSnippet().'</a>';
205 -
 199+ $textMatches->getSuggestionSnippet().'</a>';
 200+
206201 $wgOut->addHTML('<div class="searchdidyoumean">'.wfMsg('search-suggest',$suggestLink).'</div>');
207202 }
208 -
209 - // show direct page/create link
210 - if( !is_null($t) ) {
211 - if( !$t->exists() ) {
212 - $wgOut->addWikiMsg( 'searchmenu-new', wfEscapeWikiText( $t->getPrefixedText() ) );
213 - } else {
214 - $wgOut->addWikiMsg( 'searchmenu-exists', wfEscapeWikiText( $t->getPrefixedText() ) );
215 - }
216 - }
217 -
 203+
218204 // show number of results
219 - $numTitleMatches = $titleMatches ? $titleMatches->numRows() : 0;
220 - $numTextMatches = $textMatches ? $textMatches->numRows() : 0;
221 - $highestNum = max( $numTitleMatches, $numTextMatches );
222 - // Total query matches (possible false positives)
223 - $num = $numTitleMatches + $numTextMatches;
224 - // Get total actual results
 205+ $num = ( $titleMatches ? $titleMatches->numRows() : 0 )
 206+ + ( $textMatches ? $textMatches->numRows() : 0);
225207 $totalNum = 0;
226 - if( $titleMatches && !is_null($titleMatches->getTotalHits()) )
 208+ if($titleMatches && !is_null($titleMatches->getTotalHits()))
227209 $totalNum += $titleMatches->getTotalHits();
228 - if( $textMatches && !is_null($textMatches->getTotalHits()) )
 210+ if($textMatches && !is_null($textMatches->getTotalHits()))
229211 $totalNum += $textMatches->getTotalHits();
230 - if( $num > 0 ) {
231 - if( $totalNum > 0 ) {
 212+ if ( $num > 0 ) {
 213+ if ( $totalNum > 0 ){
232214 $top = wfMsgExt('showingresultstotal', array( 'parseinline' ),
233215 $this->offset+1, $this->offset+$num, $totalNum, $num );
234 - } elseif( $num >= $this->limit ) {
 216+ } elseif ( $num >= $this->limit ) {
235217 $top = wfShowingResults( $this->offset, $this->limit );
236218 } else {
237219 $top = wfShowingResultsNum( $this->offset, $this->limit, $num );
@@ -242,17 +224,16 @@
243225 if( $num || $this->offset ) {
244226 $prevnext = wfViewPrevNext( $this->offset, $this->limit,
245227 SpecialPage::getTitleFor( 'Search' ),
246 - wfArrayToCGI( $this->powerSearchOptions(), array( 'search' => $term ) ),
247 - ($highestNum < $this->limit)
248 - );
 228+ wfArrayToCGI(
 229+ $this->powerSearchOptions(),
 230+ array( 'search' => $term ) ),
 231+ ($num < $this->limit) );
249232 $wgOut->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" );
250233 wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) );
251234 } else {
252235 wfRunHooks( 'SpecialSearchNoResults', array( $term ) );
253236 }
254237
255 - $wgOut->addHtml( "<div class='searchresults'>" );
256 -
257238 if( $titleMatches ) {
258239 if( $titleMatches->numRows() ) {
259240 $wgOut->wrapWikiMsg( "==$1==\n", 'titlematches' );
@@ -282,27 +263,30 @@
283264 $textMatches->free();
284265 }
285266
286 - if( $num == 0 ) {
287 - $wgOut->addWikiMsg( 'search-nonefound' );
 267+ if ( $num == 0 ) {
 268+ $wgOut->addWikiMsg( 'nonefound' );
288269 }
289 -
290 - $wgOut->addHtml( "</div>" );
291 -
292270 if( $num || $this->offset ) {
293271 $wgOut->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
294272 }
 273+ $wgOut->addHTML( $this->powerSearchBox( $term ) );
295274 wfProfileOut( $fname );
296275 }
 276+
 277+ #------------------------------------------------------------------
 278+ # Private methods below this line
297279
298280 /**
299281 *
300282 */
301 - protected function setupPage( $term ) {
 283+ function setupPage( $term ) {
302284 global $wgOut;
303 - if( !empty( $term ) ) {
 285+ if( !empty( $term ) ){
304286 $wgOut->setPageTitle( wfMsg( 'searchresults') );
305287 $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'searchresults-title', $term) ) );
306288 }
 289+ $subtitlemsg = ( Title::newFromText( $term ) ? 'searchsubtitle' : 'searchsubtitleinvalid' );
 290+ $wgOut->setSubtitle( $wgOut->parse( wfMsg( $subtitlemsg, wfEscapeWikiText($term) ) ) );
307291 $wgOut->setArticleRelated( false );
308292 $wgOut->setRobotPolicy( 'noindex,nofollow' );
309293 }
@@ -313,8 +297,9 @@
314298 *
315299 * @param WebRequest $request
316300 * @return array
 301+ * @private
317302 */
318 - protected function powerSearch( &$request ) {
 303+ function powerSearch( &$request ) {
319304 $arr = array();
320305 foreach( SearchEngine::searchableNamespaces() as $ns => $name ) {
321306 if( $request->getCheck( 'ns' . $ns ) ) {
@@ -327,15 +312,14 @@
328313 /**
329314 * Reconstruct the 'power search' options for links
330315 * @return array
 316+ * @private
331317 */
332 - protected function powerSearchOptions() {
 318+ function powerSearchOptions() {
333319 $opt = array();
334320 foreach( $this->namespaces as $n ) {
335321 $opt['ns' . $n] = 1;
336322 }
337323 $opt['redirs'] = $this->searchRedirects ? 1 : 0;
338 - if( $this->searchAdvanced )
339 - $opt['advanced'] = $this->searchAdvanced;
340324 return $opt;
341325 }
342326
@@ -344,11 +328,11 @@
345329 *
346330 * @param SearchResultSet $matches
347331 */
348 - protected function showMatches( &$matches ) {
349 - global $wgContLang;
 332+ function showMatches( &$matches ) {
350333 $fname = 'SpecialSearch::showMatches';
351334 wfProfileIn( $fname );
352335
 336+ global $wgContLang;
353337 $terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
354338
355339 $out = "";
@@ -360,12 +344,14 @@
361345
362346 $off = $this->offset + 1;
363347 $out .= "<ul class='mw-search-results'>\n";
 348+
364349 while( $result = $matches->next() ) {
365350 $out .= $this->showHit( $result, $terms );
366351 }
367352 $out .= "</ul>\n";
368353
369354 // convert the whole thing to desired language variant
 355+ global $wgContLang;
370356 $out = $wgContLang->convert( $out );
371357 wfProfileOut( $fname );
372358 return $out;
@@ -376,7 +362,7 @@
377363 * @param SearchResult $result
378364 * @param array $terms terms to highlight
379365 */
380 - protected function showHit( $result, $terms ) {
 366+ function showHit( $result, $terms ) {
381367 $fname = 'SpecialSearch::showHit';
382368 wfProfileIn( $fname );
383369 global $wgUser, $wgContLang, $wgLang;
@@ -394,7 +380,7 @@
395381 //If page content is not readable, just return the title.
396382 //This is not quite safe, but better than showing excerpts from non-readable pages
397383 //Note that hiding the entry entirely would screw up paging.
398 - if(!$t->userCanRead()) {
 384+ if (!$t->userCanRead()) {
399385 wfProfileOut( $fname );
400386 return "<li>{$link}</li>\n";
401387 }
@@ -448,7 +434,7 @@
449435
450436 // link to related articles if supported
451437 $related = '';
452 - if( $result->hasRelated() ) {
 438+ if( $result->hasRelated() ){
453439 $st = SpecialPage::getTitleFor( 'Search' );
454440 $stParams = wfArrayToCGI( $this->powerSearchOptions(),
455441 array('search' => wfMsgForContent('searchrelated').':'.$t->getPrefixedText(),
@@ -466,13 +452,14 @@
467453 if( $thumb ) {
468454 $desc = $img->getShortDesc();
469455 wfProfileOut( $fname );
 456+ // Ugly table. :D
470457 // Float doesn't seem to interact well with the bullets.
471 - // Table messes up vertical alignment of the bullets.
472 - // Bullets are therefore disabled (didn't look great anyway).
 458+ // Table messes up vertical alignment of the bullet, but I'm
 459+ // not sure what more I can do about that. :(
473460 return "<li>" .
474461 '<table class="searchResultImage">' .
475462 '<tr>' .
476 - '<td width="120" align="center" valign="top">' .
 463+ '<td width="120" align="center">' .
477464 $thumb->toHtml( array( 'desc-link' => true ) ) .
478465 '</td>' .
479466 '<td valign="top">' .
@@ -499,22 +486,21 @@
500487 *
501488 * @param SearchResultSet $matches
502489 */
503 - protected function showInterwiki( &$matches, $query ) {
 490+ function showInterwiki( &$matches, $query ) {
504491 $fname = 'SpecialSearch::showInterwiki';
505492 wfProfileIn( $fname );
506493
507494 global $wgContLang;
508495 $terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
509496
510 - $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>".
511 - wfMsg('search-interwiki-caption')."</div>\n";
 497+ $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>".wfMsg('search-interwiki-caption')."</div>\n";
512498 $off = $this->offset + 1;
513499 $out .= "<ul start='{$off}' class='mw-search-iwresults'>\n";
514500
515501 // work out custom project captions
516502 $customCaptions = array();
517503 $customLines = explode("\n",wfMsg('search-interwiki-custom')); // format per line <iwprefix>:<caption>
518 - foreach($customLines as $line) {
 504+ foreach($customLines as $line){
519505 $parts = explode(":",$line,2);
520506 if(count($parts) == 2) // validate line
521507 $customCaptions[$parts[0]] = $parts[1];
@@ -545,7 +531,7 @@
546532 * @param string $query
547533 * @param array $customCaptions iw prefix -> caption
548534 */
549 - protected function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions) {
 535+ function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions){
550536 $fname = 'SpecialSearch::showInterwikiHit';
551537 wfProfileIn( $fname );
552538 global $wgUser, $wgContLang, $wgLang;
@@ -571,7 +557,7 @@
572558
573559 $out = "";
574560 // display project name
575 - if(is_null($lastInterwiki) || $lastInterwiki != $t->getInterwiki()) {
 561+ if(is_null($lastInterwiki) || $lastInterwiki != $t->getInterwiki()){
576562 if( key_exists($t->getInterwiki(),$customCaptions) )
577563 // captions from 'search-interwiki-custom'
578564 $caption = $customCaptions[$t->getInterwiki()];
@@ -585,8 +571,7 @@
586572 $searchTitle = Title::newFromText($t->getInterwiki().":Special:Search");
587573 $searchLink = $sk->makeKnownLinkObj( $searchTitle, wfMsg('search-interwiki-more'),
588574 wfArrayToCGI(array('search' => $query, 'fulltext' => 'Search')));
589 - $out .= "</ul><div class='mw-search-interwiki-project'><span class='mw-search-interwiki-more'>
590 - {$searchLink}</span>{$caption}</div>\n<ul>";
 575+ $out .= "</ul><div class='mw-search-interwiki-project'><span class='mw-search-interwiki-more'>{$searchLink}</span>{$caption}</div>\n<ul>";
591576 }
592577
593578 $out .= "<li>{$link} {$redirect}</li>\n";
@@ -600,7 +585,7 @@
601586 * @param $term string: search term
602587 * @return $out string: HTML form
603588 */
604 - protected function powerSearchBox( $term ) {
 589+ function powerSearchBox( $term ) {
605590 global $wgScript;
606591
607592 $namespaces = '';
@@ -614,189 +599,61 @@
615600 Xml::closeElement( 'span' ) . "\n";
616601 }
617602
618 - if( $this->searchEngine->acceptListRedirects() ) {
619 - $redirect = Xml::check( 'redirs', $this->searchRedirects, array( 'value' => '1', 'id' => 'redirs' ) );
620 - $redirectLabel = Xml::label( wfMsg( 'powersearch-redir' ), 'redirs' );
621 - } else{
622 - $redirect = '';
623 - $redirectLabel = '';
624 - }
 603+ $redirect = Xml::check( 'redirs', $this->searchRedirects, array( 'value' => '1', 'id' => 'redirs' ) );
 604+ $redirectLabel = Xml::label( wfMsg( 'powersearch-redir' ), 'redirs' );
625605 $searchField = Xml::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'powerSearchText' ) );
626606 $searchButton = Xml::submitButton( wfMsg( 'powersearch' ), array( 'name' => 'fulltext' ) ) . "\n";
627607 $searchTitle = SpecialPage::getTitleFor( 'Search' );
628608
629609 $out = Xml::openElement( 'form', array( 'id' => 'powersearch', 'method' => 'get', 'action' => $wgScript ) ) .
630 - Xml::hidden( 'title', $searchTitle->getPrefixedText() ) .
631 - Xml::hidden( 'advanced', 1 ) .
632 - "<p>" .
633 - wfMsgExt( 'powersearch-ns', array( 'parseinline' ) ) .
634 - "<br />" .
635 - $namespaces .
636 - "</p>" .
637 - "<p>" .
638 - $redirect . " " . $redirectLabel .
639 - "</p>" .
640 - wfMsgExt( 'powersearch-field', array( 'parseinline' ) ) .
641 - "&nbsp;" .
642 - $searchField .
643 - "&nbsp;" .
644 - $searchButton .
645 - ' (' . wfMsgExt('searchmenu-help',array('parseinline') ) . ')' .
 610+ Xml::fieldset( wfMsg( 'powersearch-legend' ),
 611+ Xml::hidden( 'title', $searchTitle->getPrefixedText() ) .
 612+ "<p>" .
 613+ wfMsgExt( 'powersearch-ns', array( 'parseinline' ) ) .
 614+ "<br />" .
 615+ $namespaces .
 616+ "</p>" .
 617+ "<p>" .
 618+ $redirect . " " . $redirectLabel .
 619+ "</p>" .
 620+ wfMsgExt( 'powersearch-field', array( 'parseinline' ) ) .
 621+ "&nbsp;" .
 622+ $searchField .
 623+ "&nbsp;" .
 624+ $searchButton ) .
646625 "</form>";
647 - if( $term )
648 - $out .= wfMsgExt( 'searchmenu-prefix', array('parseinline'), $term );
649626
650 - return Xml::openElement( 'fieldset', array('id' => 'mw-searchoptions','style' => 'margin:0em;') ) .
651 - Xml::element( 'legend', null, wfMsg('searchmenu-legend') ) .
652 - $this->formHeader($term) . $out .
653 - Xml::closeElement( 'fieldset' );
 627+ return $out;
654628 }
655629
656 - protected function powerSearchFocus() {
 630+ function powerSearchFocus() {
657631 global $wgJsMimeType;
658632 return "<script type=\"$wgJsMimeType\">" .
659 - "hookEvent(\"load\", function() {" .
 633+ "hookEvent(\"load\", function(){" .
660634 "document.getElementById('powerSearchText').focus();" .
661635 "});" .
662636 "</script>";
663637 }
664 -
665 - /** Make a search link with some target namespaces */
666 - protected function makeSearchLink( $term, $namespaces, $label, $tooltip, $params=array() ) {
667 - $opt = $params;
668 - foreach( $namespaces as $n ) {
669 - $opt['ns' . $n] = 1;
670 - }
671 - $opt['redirs'] = $this->searchRedirects ? 1 : 0;
672638
673 - $st = SpecialPage::getTitleFor( 'Search' );
674 - $stParams = wfArrayToCGI( array( 'search' => $term, 'fulltext' => wfMsg( 'search' ) ), $opt );
675 -
676 - return Xml::element( 'a',
677 - array( 'href'=> $st->getLocalURL( $stParams ), 'title' => $tooltip ),
678 - $label );
679 - }
680 -
681 - /** Check if query starts with image: prefix */
682 - protected function startsWithImage( $term ) {
683 - global $wgContLang;
684 -
685 - $p = explode( ':', $term );
686 - if( count( $p ) > 1 ) {
687 - return $wgContLang->getNsIndex( $p[0] ) == NS_IMAGE;
688 - }
689 - return false;
690 - }
691 -
692 - protected function formHeader( $term ) {
693 - global $wgContLang, $wgCanonicalNamespaceNames;
694 -
695 - $sep = '&nbsp;&nbsp;&nbsp;';
696 - $out = Xml::openElement('div', array( 'style' => 'padding-bottom:0.5em;' ) );
697 -
698 - $bareterm = $term;
699 - if( $this->startsWithImage( $term ) )
700 - $bareterm = substr( $term, strpos( $term, ':' ) + 1 ); // delete all/image prefix
701 -
702 - $nsAllSet = array_keys( SearchEngine::searchableNamespaces() );
703 - // figure out the active search profile header
704 - if( $this->searchAdvanced )
705 - $active = 'advanced';
706 - else if( $this->namespaces === NS_IMAGE || $this->startsWithImage( $term ) )
707 - $active = 'images';
708 - elseif( $this->namespaces === $nsAllSet )
709 - $active = 'all';
710 - elseif( $this->namespaces === SearchEngine::defaultNamespaces() )
711 - $active = 'default';
712 - elseif( $this->namespaces === SearchEngine::defaultAndProjectNamespaces() )
713 - $active = 'withproject';
714 - elseif( $this->namespaces === SearchEngine::projectNamespaces() )
715 - $active = 'project';
716 - else
717 - $active = 'advanced';
718 -
719 -
720 - // search profiles headers
721 - $m = wfMsg( 'searchprofile-articles' );
722 - $tt = wfMsg( 'searchprofile-articles-tooltip',
723 - implode( ', ', SearchEngine::namespacesAsText( SearchEngine::defaultNamespaces() ) ) );
724 - if( $active == 'default' ) {
725 - $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m );
726 - } else {
727 - $out .= $this->makeSearchLink( $bareterm, SearchEngine::defaultNamespaces(), $m, $tt );
728 - }
729 - $out .= $sep;
730 -
731 - $m = wfMsg( 'searchprofile-images' );
732 - $tt = wfMsg( 'searchprofile-images-tooltip' );
733 - if( $active == 'images' ) {
734 - $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m );
735 - } else {
736 - $imageTextForm = $wgContLang->getFormattedNsText(NS_IMAGE).':'.$bareterm;
737 - $out .= $this->makeSearchLink( $imageTextForm, array( NS_IMAGE ) , $m, $tt );
738 - }
739 - $out .= $sep;
740 -
741 - $m = wfMsg( 'searchprofile-articles-and-proj' );
742 - $tt = wfMsg( 'searchprofile-project-tooltip',
743 - implode( ', ', SearchEngine::namespacesAsText( SearchEngine::defaultAndProjectNamespaces() ) ) );
744 - if( $active == 'withproject' ) {
745 - $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m );
746 - } else {
747 - $out .= $this->makeSearchLink( $bareterm, SearchEngine::defaultAndProjectNamespaces(), $m, $tt );
748 - }
749 - $out .= $sep;
750 -
751 - $m = wfMsg( 'searchprofile-project' );
752 - $tt = wfMsg( 'searchprofile-project-tooltip',
753 - implode( ', ', SearchEngine::namespacesAsText( SearchEngine::projectNamespaces() ) ) );
754 - if( $active == 'project' ) {
755 - $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m );
756 - } else {
757 - $out .= $this->makeSearchLink( $bareterm, SearchEngine::projectNamespaces(), $m, $tt );
758 - }
759 - $out .= $sep;
760 -
761 - $m = wfMsg( 'searchprofile-everything' );
762 - $tt = wfMsg( 'searchprofile-everything-tooltip' );
763 - if( $active == 'all' ) {
764 - $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m );
765 - } else {
766 - $out .= $this->makeSearchLink( $bareterm, $nsAllSet, $m, $tt );
767 - }
768 - $out .= $sep;
769 -
770 - $m = wfMsg( 'searchprofile-advanced' );
771 - $tt = wfMsg( 'searchprofile-advanced-tooltip' );
772 - if( $active == 'advanced' ) {
773 - $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m );
774 - } else {
775 - $out .= $this->makeSearchLink( $bareterm, $this->namespaces, $m, $tt, array( 'advanced' => '1' ) );
776 - }
777 - $out .= Xml::closeElement('div') ;
778 -
779 - return $out;
780 - }
781 -
782 - protected function shortDialog( $term ) {
 639+ function shortDialog($term) {
783640 global $wgScript;
784 - $out = Xml::openElement( 'form', array( 'id' => 'search', 'method' => 'get', 'action' => $wgScript ) );
 641+
 642+ $out = Xml::openElement( 'form', array(
 643+ 'id' => 'search',
 644+ 'method' => 'get',
 645+ 'action' => $wgScript
 646+ ));
785647 $searchTitle = SpecialPage::getTitleFor( 'Search' );
786 - $out .= Xml::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n";
787 - $out .= Xml::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'searchText' ) ) . "\n";
 648+ $out .= Xml::hidden( 'title', $searchTitle->getPrefixedText() );
 649+ $out .= Xml::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'searchText' ) ) . ' ';
788650 foreach( SearchEngine::searchableNamespaces() as $ns => $name ) {
789651 if( in_array( $ns, $this->namespaces ) ) {
790652 $out .= Xml::hidden( "ns{$ns}", '1' );
791653 }
792654 }
793655 $out .= Xml::submitButton( wfMsg( 'searchbutton' ), array( 'name' => 'fulltext' ) );
794 - $out .= ' (' . wfMsgExt('searchmenu-help',array('parseinline') ) . ')';
795656 $out .= Xml::closeElement( 'form' );
796 - if( $term )
797 - $out .= wfMsgExt( 'searchmenu-prefix', array('parseinline'), $term );
798 - return Xml::openElement( 'fieldset', array('id' => 'mw-searchoptions','style' => 'margin:0em;') ) .
799 - Xml::element( 'legend', null, wfMsg('searchmenu-legend') ) .
800 - $this->formHeader($term) . $out .
801 - Xml::closeElement( 'fieldset' );
 657+
 658+ return $out;
802659 }
803660 }
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1418,61 +1418,49 @@
14191419 'diff-strike' => "'''strikethrough'''",
14201420
14211421 # Search results
1422 -'searchresults' => 'Search results',
1423 -'searchresults-title' => 'Search results for "$1"',
1424 -'toomanymatches' => 'Too many matches were returned, please try a different query',
1425 -'titlematches' => 'Page title matches',
1426 -'notitlematches' => 'No page title matches',
1427 -'textmatches' => 'Page text matches',
1428 -'notextmatches' => 'No page text matches',
1429 -'prevn' => 'previous $1',
1430 -'nextn' => 'next $1',
1431 -'viewprevnext' => 'View ($1) ($2) ($3)',
1432 -'searchmenu-legend' => 'Search options',
1433 -'searchmenu-exists' => "'''There is page named \"[[\$1]]\" on this wiki'''",
1434 -'searchmenu-new' => "'''[[:\$1|Create]] the page \"[[\$1]]\" on this wiki!'''",
1435 -'searchhelp-url' => 'Project:Searching',
1436 -'searchmenu-prefix' => '[[Special:PrefixIndex/$1|Browse pages with this prefix]]',
1437 -'searchmenu-help' => '[[{{MediaWiki:Searchhelp-url}}|{{int:help}}]]?', # do not translate or duplicate this message to other languages
1438 -'searchprofile-articles' => 'Pages',
1439 -'searchprofile-articles-and-proj' => 'Pages & Project',
1440 -'searchprofile-project' => 'Project',
1441 -'searchprofile-images' => 'Files',
1442 -'searchprofile-everything' => 'Everything',
1443 -'searchprofile-advanced' => 'Advanced',
1444 -'searchprofile-articles-tooltip' => 'Search in $1',
1445 -'searchprofile-project-tooltip' => 'Search in $1',
1446 -'searchprofile-images-tooltip' => 'Search for files',
1447 -'searchprofile-everything-tooltip' => 'Search all of content (including talk pages)',
1448 -'searchprofile-advanced-tooltip' => 'Search in custom namespaces',
1449 -'prefs-search-nsdefault' => 'Search using defaults:',
1450 -'prefs-search-nscustom' => 'Search custom namespaces:',
1451 -'search-result-size' => '$1 ({{PLURAL:$2|1 word|$2 words}})',
1452 -'search-result-score' => 'Relevance: $1%',
1453 -'search-redirect' => '(redirect $1)',
1454 -'search-section' => '(section $1)',
1455 -'search-suggest' => 'Did you mean: $1',
1456 -'search-interwiki-caption' => 'Sister projects',
1457 -'search-interwiki-default' => '$1 results:',
1458 -'search-interwiki-custom' => '', # do not translate or duplicate this message to other languages
1459 -'search-interwiki-more' => '(more)',
1460 -'search-mwsuggest-enabled' => 'with suggestions',
1461 -'search-mwsuggest-disabled' => 'no suggestions',
1462 -'search-relatedarticle' => 'Related',
1463 -'mwsuggest-disable' => 'Disable AJAX suggestions',
1464 -'searchrelated' => 'related',
1465 -'searchall' => 'all',
1466 -'showingresults' => "Showing below up to {{PLURAL:$1|'''1''' result|'''$1''' results}} starting with #'''$2'''.",
1467 -'showingresultsnum' => "Showing below {{PLURAL:$3|'''1''' result|'''$3''' results}} starting with #'''$2'''.",
1468 -'showingresultstotal' => "Showing below {{PLURAL:$4|result '''$1''' of '''$3'''|results '''$1 - $2''' of '''$3'''}}",
1469 -'search-nonefound' => 'There were no results matching the query.',
1470 -'powersearch' => 'Advanced search',
1471 -'powersearch-legend' => 'Advanced search',
1472 -'powersearch-ns' => 'Search in namespaces:',
1473 -'powersearch-redir' => 'List redirects',
1474 -'powersearch-field' => 'Search for',
1475 -'search-external' => 'External search',
1476 -'searchdisabled' => '{{SITENAME}} search is disabled.
 1422+'searchresults' => 'Search results',
 1423+'searchresults-title' => 'Search results for $1',
 1424+'searchresulttext' => 'For more information about searching {{SITENAME}}, see [[{{MediaWiki:Helppage}}|{{int:help}}]].',
 1425+'searchsubtitle' => 'You searched for \'\'\'[[:$1]]\'\'\' ([[Special:Prefixindex/$1|all pages starting with "$1"]] | [[Special:WhatLinksHere/$1|all pages that link to "$1"]])',
 1426+'searchsubtitleinvalid' => "You searched for '''$1'''",
 1427+'noexactmatch' => "'''There is no page titled \"\$1\".'''
 1428+You can [[:\$1|create this page]].",
 1429+'noexactmatch-nocreate' => "'''There is no page titled \"\$1\".'''",
 1430+'toomanymatches' => 'Too many matches were returned, please try a different query',
 1431+'titlematches' => 'Page title matches',
 1432+'notitlematches' => 'No page title matches',
 1433+'textmatches' => 'Page text matches',
 1434+'notextmatches' => 'No page text matches',
 1435+'prevn' => 'previous $1',
 1436+'nextn' => 'next $1',
 1437+'viewprevnext' => 'View ($1) ($2) ($3)',
 1438+'search-result-size' => '$1 ({{PLURAL:$2|1 word|$2 words}})',
 1439+'search-result-score' => 'Relevance: $1%',
 1440+'search-redirect' => '(redirect $1)',
 1441+'search-section' => '(section $1)',
 1442+'search-suggest' => 'Did you mean: $1',
 1443+'search-interwiki-caption' => 'Sister projects',
 1444+'search-interwiki-default' => '$1 results:',
 1445+'search-interwiki-custom' => '', # do not translate or duplicate this message to other languages
 1446+'search-interwiki-more' => '(more)',
 1447+'search-mwsuggest-enabled' => 'with suggestions',
 1448+'search-mwsuggest-disabled' => 'no suggestions',
 1449+'search-relatedarticle' => 'Related',
 1450+'mwsuggest-disable' => 'Disable AJAX suggestions',
 1451+'searchrelated' => 'related',
 1452+'searchall' => 'all',
 1453+'showingresults' => "Showing below up to {{PLURAL:$1|'''1''' result|'''$1''' results}} starting with #'''$2'''.",
 1454+'showingresultsnum' => "Showing below {{PLURAL:$3|'''1''' result|'''$3''' results}} starting with #'''$2'''.",
 1455+'showingresultstotal' => "Showing below {{PLURAL:$4|result '''$1''' of '''$3'''|results '''$1 - $2''' of '''$3'''}}",
 1456+'nonefound' => "'''Note''': Only some namespaces are searched by default.
 1457+Try prefixing your query with ''all:'' to search all content (including talk pages, templates, etc), or use the desired namespace as prefix.",
 1458+'powersearch' => 'Advanced search',
 1459+'powersearch-legend' => 'Advanced search',
 1460+'powersearch-ns' => 'Search in namespaces:',
 1461+'powersearch-redir' => 'List redirects',
 1462+'powersearch-field' => 'Search for',
 1463+'search-external' => 'External search',
 1464+'searchdisabled' => '{{SITENAME}} search is disabled.
14771465 You can search via Google in the meantime.
14781466 Note that their indexes of {{SITENAME}} content may be out of date.',
14791467 'googlesearch' => '<form method="get" action="http://www.google.com/search" id="googlesearch">

Follow-up revisions

RevisionCommit summaryAuthorDate
r43512Recover from r43499. Gotta love having all messages in a database :)siebrand23:59, 14 November 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r43376* Recommitting Search UI changes from r42352...aaron00:03, 11 November 2008
r43385Cleanup for r43376:...raymond15:23, 11 November 2008
r43403Suppress index link if no term givenaaron01:27, 12 November 2008
r43404Add valign="top"aaron01:53, 12 November 2008
r43405Fix link for imagesaaron01:56, 12 November 2008
r43406'advanced' link consistencyaaron02:13, 12 November 2008
r43423Fix prefix linkaaron21:12, 12 November 2008

Comments

#Comment by Aaron Schulz (talk | contribs)   23:24, 14 November 2008

Background color mismatch would probably be a local issue. Also, the prefix link there has the same issue as the one in use now.

#Comment by Aaron Schulz (talk | contribs)   23:29, 14 November 2008

Is 'Whatlinkshere' even useful here?

Status & tagging log