Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | 'path' => __FILE__, |
16 | 16 | 'name' => 'Wikimedia Incubator', |
17 | 17 | 'author' => 'SPQRobin', |
18 | | - 'version' => '4.2', |
| 18 | + 'version' => '4.3', |
19 | 19 | 'url' => 'http://www.mediawiki.org/wiki/Extension:WikimediaIncubator', |
20 | 20 | 'descriptionmsg' => 'wminc-desc', |
21 | 21 | ); |
— | — | @@ -141,3 +141,9 @@ |
142 | 142 | |
143 | 143 | /* Set page content language depending on the prefix */ |
144 | 144 | $wgHooks['PageContentLanguage'][] = 'IncubatorTest::onPageContentLanguage'; |
| 145 | + |
| 146 | +/* List of users */ |
| 147 | +$wgAutoloadClasses['ListUsersTestWiki'] = $dir . 'ListUsersTestWiki.php'; |
| 148 | +$wgHooks['SpecialListusersHeaderForm'][] = 'ListUsersTestWiki::onSpecialListusersHeaderForm'; |
| 149 | +$wgHooks['SpecialListusersQueryInfo'][] = 'ListUsersTestWiki::onSpecialListusersQueryInfo'; |
| 150 | +$wgHooks['SpecialListusersHeader'][] = 'ListUsersTestWiki::onSpecialListusersHeader'; |
\ No newline at end of file |
Index: trunk/extensions/WikimediaIncubator/ListUsersTestWiki.php |
— | — | @@ -0,0 +1,58 @@ |
| 2 | +<?php
|
| 3 | +
|
| 4 | +/**
|
| 5 | + * Ability to filter list of users based on their test wiki preference
|
| 6 | + */
|
| 7 | +class ListUsersTestWiki {
|
| 8 | + /**
|
| 9 | + * Get the &testwiki=wx/xyz parameter and validate it
|
| 10 | + * @return Array
|
| 11 | + */
|
| 12 | + static function getTestWiki() {
|
| 13 | + global $wgRequest;
|
| 14 | + return IncubatorTest::analyzePrefix( $wgRequest->getVal( 'testwiki' ), true );
|
| 15 | + }
|
| 16 | +
|
| 17 | + /**
|
| 18 | + * Input form
|
| 19 | + */
|
| 20 | + static function onSpecialListusersHeaderForm( $pager, &$out ) {
|
| 21 | + $testwiki = self::getTestWiki();
|
| 22 | + $out .= Xml::label( wfMsg( 'wminc-testwiki' ), 'testwiki' ) . ' ' .
|
| 23 | + Xml::input( 'testwiki', 20, ( $testwiki['error'] ? null : $testwiki['prefix'] ), array( 'id' => 'testwiki' ) ) . '<br />';
|
| 24 | + return true;
|
| 25 | + }
|
| 26 | +
|
| 27 | + /**
|
| 28 | + * Show a message that you are viewing a list of users of a certain test wiki
|
| 29 | + */
|
| 30 | + static function onSpecialListusersHeader( $pager, &$out ) {
|
| 31 | + $testwiki = self::getTestWiki();
|
| 32 | + if( !$testwiki['error'] ) {
|
| 33 | + $out .= wfMsgWikiHtml( 'wminc-listusers-testwiki', $testwiki['prefix'] );
|
| 34 | + }
|
| 35 | + return true;
|
| 36 | + }
|
| 37 | +
|
| 38 | + /**
|
| 39 | + * Query
|
| 40 | + */
|
| 41 | + 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)" );
|
| 56 | + }
|
| 57 | + return true;
|
| 58 | + }
|
| 59 | +} |
\ No newline at end of file |
Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.i18n.php |
— | — | @@ -53,6 +53,9 @@ |
54 | 54 | 'wminc-code-macrolanguage' => 'The [[wikipedia:$2 language|"$3" language]] is a [[wikipedia:ISO 639 macrolanguage|macrolanguage]], consisting of the following member languages:', |
55 | 55 | 'wminc-code-collective' => 'The code "$1" does not refer to a specific language, but to a collection of languages, namely the [[wikipedia:$2 language|"$3" languages]].', |
56 | 56 | 'wminc-code-retired' => 'This language code has been changed and no longer refers to the original language.', |
| 57 | + |
| 58 | + # Special:ListUsers |
| 59 | + 'wminc-listusers-testwiki' => 'You are viewing users who have set their test wiki preference to [[$1]].', |
57 | 60 | ); |
58 | 61 | |
59 | 62 | /** Message documentation (Message documentation) |