Index: trunk/extensions/WikimediaIncubator/IncubatorTest.php |
— | — | @@ -130,7 +130,28 @@ |
131 | 131 | return false; |
132 | 132 | } |
133 | 133 | |
| 134 | + |
134 | 135 | /** |
| 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 | + /** |
135 | 156 | * Whether the given project (or preference by default) is one of the |
136 | 157 | * projects using the format Wx/xxx (as defined in $wmincProjects) |
137 | 158 | * @param $project the project code |
Index: trunk/extensions/WikimediaIncubator/SpecialMyMainPage.php |
— | — | @@ -25,9 +25,12 @@ |
26 | 26 | global $wgRequest; |
27 | 27 | $title = Title::newFromText( IncubatorTest::displayPrefix() ); |
28 | 28 | if( $wgRequest->getVal( 'goto' ) != 'infopage' ) { |
29 | | - # Used in development version |
30 | | - $params = array( 'goto' => 'mainpage' ); |
| 29 | + $params['goto'] = 'mainpage'; |
31 | 30 | } |
| 31 | + $url = IncubatorTest::getUrlParam(); |
| 32 | + if( $url ) { |
| 33 | + $params['testwiki'] = $url['prefix']; |
| 34 | + } |
32 | 35 | } |
33 | 36 | |
34 | 37 | # 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 @@ |
11 | 11 | class TestWikiRC { |
12 | 12 | static function getValues() { |
13 | 13 | 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' ); |
16 | 17 | $projectvalue = strtolower( $wgRequest->getVal( 'rc-testwiki-project', $projectvalue ) ); |
17 | 18 | $codevalue = strtolower( $wgRequest->getVal( 'rc-testwiki-code', $codevalue ) ); |
18 | 19 | return array( $projectvalue, $codevalue ); |