r92557 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92556‎ | r92557 | r92558 >
Date:19:37, 19 July 2011
Author:robin
Status:ok
Tags:
Comment:
Ability to use &testwiki in URL (for RecentChanges and MyMainPage)
Modified paths:
  • /trunk/extensions/WikimediaIncubator/IncubatorTest.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/SpecialMyMainPage.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/TestWikiRC.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaIncubator/IncubatorTest.php
@@ -130,7 +130,28 @@
131131 return false;
132132 }
133133
 134+
134135 /**
 136+ * Get &testwiki=wx/xx and validate that prefix.
 137+ * Returns the array of analyzePrefix() on success.
 138+ * @return Array or false
 139+ */
 140+ static function getUrlParam() {
 141+ global $wgRequest;
 142+ $urlParam = $wgRequest->getVal( 'testwiki' );
 143+ if( !$urlParam ) {
 144+ return false;
 145+ }
 146+ $val = self::analyzePrefix( ucfirst( $urlParam ), true );
 147+ if( $val['error'] || !isset( $val['project'] ) || !isset( $val['lang'] )
 148+ || !$val['project'] || !$val['lang'] ) {
 149+ return false;
 150+ }
 151+ $val['prefix'] = strtolower( $val['prefix'] );
 152+ return $val;
 153+ }
 154+
 155+ /**
135156 * Whether the given project (or preference by default) is one of the
136157 * projects using the format Wx/xxx (as defined in $wmincProjects)
137158 * @param $project the project code
Index: trunk/extensions/WikimediaIncubator/SpecialMyMainPage.php
@@ -25,9 +25,12 @@
2626 global $wgRequest;
2727 $title = Title::newFromText( IncubatorTest::displayPrefix() );
2828 if( $wgRequest->getVal( 'goto' ) != 'infopage' ) {
29 - # Used in development version
30 - $params = array( 'goto' => 'mainpage' );
 29+ $params['goto'] = 'mainpage';
3130 }
 31+ $url = IncubatorTest::getUrlParam();
 32+ if( $url ) {
 33+ $params['testwiki'] = $url['prefix'];
 34+ }
3235 }
3336
3437 # Go to the main page if given invalid title, or if it's not a content project
Index: trunk/extensions/WikimediaIncubator/TestWikiRC.php
@@ -10,8 +10,9 @@
1111 class TestWikiRC {
1212 static function getValues() {
1313 global $wgUser, $wmincPref, $wgRequest;
14 - $projectvalue = $wgUser->getOption( $wmincPref . '-project' );
15 - $codevalue = $wgUser->getOption( $wmincPref . '-code' );
 14+ $url = IncubatorTest::getUrlParam();
 15+ $projectvalue = $url ? $url['project'] : $wgUser->getOption( $wmincPref . '-project' );
 16+ $codevalue = $url ? $url['lang'] : $wgUser->getOption( $wmincPref . '-code' );
1617 $projectvalue = strtolower( $wgRequest->getVal( 'rc-testwiki-project', $projectvalue ) );
1718 $codevalue = strtolower( $wgRequest->getVal( 'rc-testwiki-code', $codevalue ) );
1819 return array( $projectvalue, $codevalue );

Status & tagging log