r96122 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96121‎ | r96122 | r96123 >
Date:16:43, 2 September 2011
Author:robin
Status:ok (Comments)
Tags:
Comment:
* Use more specific css for .subpages and mark it important, because it's overridden by other css
* Make ListUsersTestWiki work for "incubator" option; reuse existing IncubatorTest::getUrlParam(); nicer SQL queries with arrays
* Remove link in user right message
Modified paths:
  • /trunk/extensions/WikimediaIncubator/InfoPage.css (modified) (history)
  • /trunk/extensions/WikimediaIncubator/ListUsersTestWiki.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/WikimediaIncubator.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaIncubator/ListUsersTestWiki.php
@@ -5,21 +5,27 @@
66 */
77 class ListUsersTestWiki {
88 /**
9 - * Get the &testwiki=wx/xyz parameter and validate it
10 - * @return Array
 9+ * If the &testwiki= parameter matches the project site (Incubator), return that
 10+ * @return Array or null
1111 */
12 - static function getTestWiki() {
13 - global $wgRequest;
14 - return IncubatorTest::analyzePrefix( $wgRequest->getVal( 'testwiki' ), true );
 12+ static function getProjectInput() {
 13+ global $wmincProjectSite, $wgRequest;
 14+ $input = strtolower( $wgRequest->getVal( 'testwiki' ) );
 15+ if( $input == strtolower( $wmincProjectSite['name'] ) || $input == strtolower( $wmincProjectSite['short'] ) ) {
 16+ return $wmincProjectSite;
 17+ }
 18+ return;
1519 }
1620
1721 /**
1822 * Input form
1923 */
2024 static function onSpecialListusersHeaderForm( $pager, &$out ) {
21 - $testwiki = self::getTestWiki();
 25+ $testwiki = IncubatorTest::getUrlParam();
 26+ $project = self::getProjectInput();
 27+ $input = $project ? $project['name'] : ( $testwiki ? $testwiki['prefix'] : null );
2228 $out .= Xml::label( wfMsg( 'wminc-testwiki' ), 'testwiki' ) . ' ' .
23 - Xml::input( 'testwiki', 20, ( $testwiki['error'] ? null : $testwiki['prefix'] ), array( 'id' => 'testwiki' ) ) . '<br />';
 29+ Xml::input( 'testwiki', 20, $input, array( 'id' => 'testwiki' ) ) . '<br />';
2430 return true;
2531 }
2632
@@ -27,9 +33,11 @@
2834 * Show a message that you are viewing a list of users of a certain test wiki
2935 */
3036 static function onSpecialListusersHeader( $pager, &$out ) {
31 - $testwiki = self::getTestWiki();
32 - if( !$testwiki['error'] ) {
33 - $out .= wfMsgWikiHtml( 'wminc-listusers-testwiki', $testwiki['prefix'] );
 37+ if( $project = self::getProjectInput() ) {
 38+ $out .= wfMsgWikiHtml( 'wminc-listusers-testwiki', '"' . $project['name'] . '"' );
 39+ } elseif( $testwiki = IncubatorTest::getUrlParam() ) {
 40+ $link = Linker::linkKnown( Title::newFromText( $testwiki['prefix'] ) );
 41+ $out .= wfMsgWikiHtml( 'wminc-listusers-testwiki', $link );
3442 }
3543 return true;
3644 }
@@ -38,21 +46,25 @@
3947 * Query
4048 */
4149 static function onSpecialListusersQueryInfo( $pager, &$query ) {
42 - $testwiki = self::getTestWiki();
43 - if( !$testwiki['error'] ) {
44 - global $wmincPref;
45 - $dbr = wfGetDB( DB_SLAVE );
46 - $projectPrefName = $dbr->addQuotes( "$wmincPref-project" );
47 - $projectPrefVal = $dbr->addQuotes( $testwiki['project'] );
48 - $langPrefName = $dbr->addQuotes( "$wmincPref-code" );
49 - $langPrefVal = $dbr->addQuotes( $testwiki['lang'] );
50 - $query['tables']['p1'] = 'user_properties';
51 - $query['tables']['p2'] = 'user_properties';
52 - $query['join_conds']['p1'] = array( 'JOIN',
53 - "user_id=p1.up_user AND (p1.up_property=$projectPrefName AND p1.up_value=$projectPrefVal)" );
54 - $query['join_conds']['p2'] = array( 'JOIN',
55 - "user_id=p2.up_user AND (p2.up_property=$langPrefName AND p2.up_value=$langPrefVal)" );
 50+ $testwiki = IncubatorTest::getUrlParam();
 51+ $project = self::getProjectInput();
 52+ if( !$project && !$testwiki ) {
 53+ return true; # no input or invalid input
5654 }
 55+ global $wmincPref;
 56+ $query['tables']['p1'] = 'user_properties';
 57+ $query['join_conds']['p1'] = array( 'JOIN', array( 'user_id=p1.up_user',
 58+ 'p1.up_property' => "$wmincPref-project",
 59+ 'p1.up_value' => $project ? $project['short'] : $testwiki['project']
 60+ ) );
 61+ if( $project ) {
 62+ return true; # project site doesn't need language code = returning
 63+ }
 64+ $query['tables']['p2'] = 'user_properties';
 65+ $query['join_conds']['p2'] = array( 'JOIN', array( 'user_id=p2.up_user',
 66+ 'p2.up_property' => "$wmincPref-code",
 67+ 'p2.up_value' => $testwiki['lang']
 68+ ) );
5769 return true;
5870 }
5971 }
Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.i18n.php
@@ -45,7 +45,7 @@
4646 'wminc-ip' => '"$1" is an IP address.',
4747
4848 # User groups
49 - 'right-viewuserlang' => 'View [[Special:ViewUserLang|user language and test wiki]]',
 49+ 'right-viewuserlang' => 'View user language and test wiki',
5050 'group-test-sysop' => 'Test wiki administrators',
5151 'group-test-sysop-member' => 'test wiki administrator',
5252 'grouppage-test-sysop' => 'Project:Test wiki administrators',
@@ -56,7 +56,7 @@
5757 'wminc-code-retired' => 'This language code has been changed and no longer refers to the original language.',
5858
5959 # Special:ListUsers
60 - 'wminc-listusers-testwiki' => 'You are viewing users who have set their test wiki preference to [[$1]].',
 60+ 'wminc-listusers-testwiki' => 'You are viewing users who have set their test wiki preference to $1.',
6161 );
6262
6363 /** Message documentation (Message documentation)
Index: trunk/extensions/WikimediaIncubator/InfoPage.css
@@ -50,6 +50,6 @@
5151 #ca-nstab-main a {
5252 color: black;
5353 }
54 -.subpages {
55 - display: none;
 54+span.subpages {
 55+ display: none !important;
5656 }
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r96138* Call core function Language::getTranslatedLanguageName() if found, instead ...robin18:18, 2 September 2011
r105776MFT for WikimediaIncubator: r95582, r96122, r96138, r96141, r97175, r98670, r...siebrand00:32, 11 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95582Ability to filter list of users based on their test wiki preferencerobin23:24, 26 August 2011

Comments

#Comment by Nikerabbit (talk | contribs)   08:05, 21 September 2011

You should try to get rid of wfMsgWikiHtml, it is going to be deprecated.

#Comment by SPQRobin (talk | contribs)   19:39, 21 September 2011

Ok, thanks for the info. Is there a recommended function to use instead?

#Comment by Nikerabbit (talk | contribs)   19:41, 21 September 2011

wfMessage() ;)

Status & tagging log