r111886 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111885‎ | r111886 | r111887 >
Date:20:18, 19 February 2012
Author:robin
Status:ok
Tags:i18nreview 
Comment:
Make it remember &uselang= so search results and info pages can be adapted to one's language
Modified paths:
  • /trunk/extensions/WikimediaIncubator/SpecialSearchWiki.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaIncubator/SpecialSearchWiki.php
@@ -29,10 +29,12 @@
3030 $languageQuery = $this->getRequest()->getText( 'searchlanguage', isset( $subpage[1] ) ? $subpage[1] : '' );
3131
3232 # Show form
 33+ $uselang = $this->getRequest()->getVal( 'uselang' );
3334 $this->getOutput()->addHTML(
3435 Xml::fieldset( wfMessage( 'wminc-searchwiki' )->plain(),
3536 Html::rawElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'wminc-searchwiki-form' ),
3637 Html::hidden( 'title', SpecialPage::getTitleFor( 'SearchWiki' ) ) .
 38+ ( $uselang ? Html::hidden( 'uselang', $uselang ) : '' ) .
3739 '<p>' . Xml::label( wfMessage( 'wminc-searchwiki-selectproject' )->text(), 'wminc-searchproject' ) .
3840 ' ' . $this->makeProjectSelector( $projectQuery ) . '</p>' .
3941 '<p>' . Xml::inputLabel( wfMessage( 'wminc-searchwiki-inputlanguage' )->text(), 'searchlanguage',
@@ -91,7 +93,7 @@
9294 }
9395
9496 if( count( $results ) === 1 ) {
95 - self::gotoWiki( $matchProject, key( $results ) );
 97+ $this->gotoWiki( $matchProject, key( $results ) );
9698 } elseif( count( $results ) < 1 ) {
9799 $noresult = Html::element( 'p', array( 'class' => 'error' ), wfMessage( 'wminc-searchwiki-noresults' )->text() );
98100 return $this->getOutput()->addHTML( $noresult );
@@ -108,8 +110,9 @@
109111 protected function goToWiki( $project, $lang ) {
110112 $lang = self::getRootCode( $lang );
111113 $status = IncubatorTest::getDBState( array( 'project' => $project, 'lang' => $lang, 'error' => null ) );
 114+ $infopageParams = array( 'goto' => 'mainpage', 'uselang' => $this->getRequest()->getVal( 'uselang' ) );
112115 $url = $status == 'existing' ? IncubatorTest::getSubdomain( $lang, $project ) :
113 - Title::newFromText( 'W' . $project . '/' . $lang )->getFullURL( array( 'goto' => 'mainpage' ) );
 116+ Title::newFromText( 'W' . $project . '/' . $lang )->getFullURL( $infopageParams );
114117 $this->getOutput()->redirect( $url );
115118 }
116119

Status & tagging log