Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | 'path' => __FILE__, |
13 | 13 | 'name' => 'Wikimedia Incubator', |
14 | 14 | 'author' => 'SPQRobin', |
15 | | - 'version' => '2.4', |
| 15 | + 'version' => '3.0', |
16 | 16 | 'url' => 'http://www.mediawiki.org/wiki/Extension:WikimediaIncubator', |
17 | 17 | 'descriptionmsg' => 'wminc-desc', |
18 | 18 | ); |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | $wgGroupPermissions['*']['viewuserlang'] = false; |
22 | 22 | $wgGroupPermissions['sysop']['viewuserlang'] = true; |
23 | 23 | |
24 | | -/* General (kind of globals) */ |
| 24 | +/* General (globals and/or configuration) */ |
25 | 25 | $wmincPref = 'incubatortestwiki'; // Name of the preference |
26 | 26 | $dir = dirname( __FILE__ ) . '/'; |
27 | 27 | $wmincProjects = array( |
— | — | @@ -34,6 +34,12 @@ |
35 | 35 | 'name' => 'Incubator', |
36 | 36 | 'short' => 'inc', |
37 | 37 | ); |
| 38 | +$wmincTestWikiNamespaces = array( |
| 39 | + NS_MAIN, NS_TALK, |
| 40 | + NS_TEMPLATE, NS_TEMPLATE_TALK, |
| 41 | + NS_CATEGORY, NS_CATEGORY_TALK, |
| 42 | +); |
| 43 | +$wmincLangCodeLength = 3; // can be increased if needed (depends on policy) |
38 | 44 | |
39 | 45 | $wgExtensionMessagesFiles['WikimediaIncubator'] = $dir . 'WikimediaIncubator.i18n.php'; |
40 | 46 | |
— | — | @@ -42,7 +48,7 @@ |
43 | 49 | $wgSpecialPages['ViewUserLang'] = 'SpecialViewUserLang'; |
44 | 50 | $wgSpecialPageGroups['ViewUserLang'] = 'users'; |
45 | 51 | $wgAvailableRights[] = 'viewuserlang'; |
46 | | -$wgHooks['ContributionsToolLinks'][] = 'efLoadViewUserLangLink'; |
| 52 | +$wgHooks['ContributionsToolLinks'][] = 'IncubatorTest::efLoadViewUserLangLink'; |
47 | 53 | |
48 | 54 | /* TestWiki preference */ |
49 | 55 | $wgAutoloadClasses['IncubatorTest'] = $dir . 'IncubatorTest.php'; |
— | — | @@ -52,7 +58,7 @@ |
53 | 59 | $wgHooks['ParserGetVariableValueSwitch'][] = 'IncubatorTest::magicWordValue'; |
54 | 60 | |
55 | 61 | /* Edit page */ |
56 | | -$wgHooks['EditPage::showEditForm:initial'][] = 'IncubatorTest::editPageCheckPrefix'; |
| 62 | +$wgHooks['EditPage::showEditForm:initial'][] = 'IncubatorTest::checkPrefixOnEditPage'; |
57 | 63 | |
58 | 64 | /* Recent Changes */ |
59 | 65 | $wgAutoloadClasses['TestWikiRC'] = $dir . 'TestWikiRC.php'; |
Index: trunk/extensions/WikimediaIncubator/SpecialRandomByTest.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | { |
10 | 10 | public function __construct() { |
11 | 11 | global $wgUser, $wmincPref, $wmincProjectSite; |
12 | | - if(IncubatorTest::isNormalPrefix()) { |
| 12 | + if( IncubatorTest::isContentProject() ) { |
13 | 13 | $dbr = wfGetDB( DB_SLAVE ); |
14 | 14 | $this->extra[] = 'page_title' . |
15 | 15 | $dbr->buildLike( IncubatorTest::displayPrefix() . '/', $dbr->anyString() ); |
Index: trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php |
— | — | @@ -32,11 +32,7 @@ |
33 | 33 | return; |
34 | 34 | } |
35 | 35 | |
36 | | - if ( $subpage ) { |
37 | | - $target = $subpage; |
38 | | - } else { |
39 | | - $target = $wgRequest->getText( 'target' ); |
40 | | - } |
| 36 | + $target = $wgRequest->getText( 'target', $subpage ); |
41 | 37 | |
42 | 38 | $this->showForm( $target ); |
43 | 39 | |
— | — | @@ -53,13 +49,13 @@ |
54 | 50 | global $wgScript, $wgOut; |
55 | 51 | |
56 | 52 | $wgOut->addHTML( |
57 | | - Xml::fieldset( wfMsg( 'wminc-viewuserlang' ) ) . |
| 53 | + Xml::fieldset( wfMsgHtml( 'wminc-viewuserlang' ) ) . |
58 | 54 | Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . |
59 | 55 | Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . |
60 | 56 | "<p>" . |
61 | | - Xml::inputLabel( wfMsg( 'wminc-viewuserlang-user' ), 'target', 'viewuserlang-username', 40, $target ) . |
| 57 | + Xml::inputLabel( wfMsgHtml( 'wminc-viewuserlang-user' ), 'target', 'viewuserlang-username', 40, $target ) . |
62 | 58 | ' ' . |
63 | | - Xml::submitButton( wfMsg( 'wminc-viewuserlang-go' ) ) . |
| 59 | + Xml::submitButton( wfMsgHtml( 'wminc-viewuserlang-go' ) ) . |
64 | 60 | "</p>" . |
65 | 61 | Xml::closeElement( 'form' ) . |
66 | 62 | Xml::closeElement( 'fieldset' ) |
— | — | @@ -79,22 +75,21 @@ |
80 | 76 | // show error if a user with that name does not exist |
81 | 77 | $wgOut->addHTML( Xml::span( wfMsg( 'wminc-userdoesnotexist', $target ), 'error' ) ); |
82 | 78 | } else { |
83 | | - if ( IncubatorTest::isNormalPrefix() == true ) { |
84 | | - $testwiki = Linker::link( 'W' . $user->getOption($wmincPref . '-project') . |
85 | | - '/' . $user->getOption($wmincPref . '-code') ); |
| 79 | + if ( IncubatorTest::isContentProject() ) { |
| 80 | + $testwiki = $sk->link( Title::newFromText( IncubatorTest::displayPrefix() ) ); |
86 | 81 | } elseif ( IncubatorTest::displayPrefix() == $wmincProjectSite['short'] ) { |
87 | | - $testwiki = $wmincProjectSite['name']; |
| 82 | + $testwiki = htmlspecialchars( $wmincProjectSite['name'] ); |
88 | 83 | } else { |
89 | | - $testwiki = wfMsg( 'wminc-testwiki-none' ); |
| 84 | + $testwiki = wfMsgHtml( 'wminc-testwiki-none' ); |
90 | 85 | } |
91 | 86 | $name = $user->getName(); |
92 | 87 | $wgOut->addHtml( |
93 | 88 | Xml::openElement( 'ul' ) . |
94 | | - '<li>' . wfMsg( 'username' ) . ' ' . |
| 89 | + '<li>' . wfMsgHtml( 'username' ) . ' ' . |
95 | 90 | $sk->userLink( $name, $name ) . $sk->userToolLinks( $name, $name ) . '</li>' . |
96 | | - '<li>' . wfMsg( 'loginlanguagelabel', $langNames[$user->getOption( 'language' )] . |
| 91 | + '<li>' . wfMsgHtml( 'loginlanguagelabel', $langNames[$user->getOption( 'language' )] . |
97 | 92 | ' (' . $user->getOption( 'language' ) . ')' ) . '</li>' . |
98 | | - '<li>' . wfMsg( 'wminc-testwiki' ) . ' ' . $testwiki . '</li>' . |
| 93 | + '<li>' . wfMsgHtml( 'wminc-testwiki' ) . ' ' . $testwiki . '</li>' . |
99 | 94 | Xml::closeElement( 'ul' ) |
100 | 95 | ); |
101 | 96 | } |
Index: trunk/extensions/WikimediaIncubator/CreateAccountTestWiki.php |
— | — | @@ -7,11 +7,11 @@ |
8 | 8 | * change their preferences (automatically is always better :p) |
9 | 9 | */ |
10 | 10 | class AutoTestWiki { |
11 | | - function onUserCreateForm( $template ) { |
| 11 | + public static function onUserCreateForm( $template ) { |
12 | 12 | global $wgRequest, $wmincProjects; |
13 | 13 | $projectvalue = strtolower( $wgRequest->getVal( 'testwikiproject', '' ) ); |
14 | 14 | $codevalue = strtolower( $wgRequest->getVal( 'testwikicode', '' ) ); |
15 | | - if ( preg_match( '/[a-z][a-z][a-z]?/', $codevalue ) && in_array( $projectvalue, (array)$wmincProjects ) ) { |
| 15 | + if ( IncubatorTest::validateLanguageCode( $codevalue ) && in_array( $projectvalue, (array)$wmincProjects ) ) { |
16 | 16 | $template->set( 'header', |
17 | 17 | Html::hidden('testwiki-project', $projectvalue). |
18 | 18 | Html::hidden('testwiki-code', $codevalue) |
— | — | @@ -20,13 +20,13 @@ |
21 | 21 | return true; |
22 | 22 | } |
23 | 23 | |
24 | | - function onAddNewAccount( $user ) { |
25 | | - global $wgRequest, $wmincPref; |
26 | | - $getprojectvalue = $wgRequest->getVal( 'testwiki-project' ); |
27 | | - $getcodevalue = $wgRequest->getVal( 'testwiki-code' ); |
28 | | - if ( $getprojectvalue && $getcodevalue ) { |
29 | | - $user->setOption( $wmincPref . '-project', $getprojectvalue ); |
30 | | - $user->setOption( $wmincPref . '-code', $getcodevalue ); |
| 24 | + public static function onAddNewAccount( $user ) { |
| 25 | + global $wgRequest, $wmincProjects, $wmincPref; |
| 26 | + $projectvalue = $wgRequest->getVal( 'testwiki-project' ); |
| 27 | + $codevalue = $wgRequest->getVal( 'testwiki-code' ); |
| 28 | + if ( IncubatorTest::validateLanguageCode( $codevalue ) && in_array( $projectvalue, (array)$wmincProjects ) ) { |
| 29 | + $user->setOption( $wmincPref . '-project', $projectvalue ); |
| 30 | + $user->setOption( $wmincPref . '-code', $codevalue ); |
31 | 31 | $user->saveSettings(); |
32 | 32 | } |
33 | 33 | return true; |
Index: trunk/extensions/WikimediaIncubator/IncubatorTest.php |
— | — | @@ -6,7 +6,8 @@ |
7 | 7 | class IncubatorTest |
8 | 8 | { |
9 | 9 | static function onGetPreferences( $user, &$preferences ) { |
10 | | - global $wmincPref, $wmincProjects, $wmincProjectSite, $wmincPrefProject, $wmincPrefNone, $wgDefaultUserOptions; |
| 10 | + global $wmincPref, $wmincProjects, $wmincProjectSite, |
| 11 | + $wmincLangCodeLength, $wgDefaultUserOptions; |
11 | 12 | |
12 | 13 | $preferences['language']['help-message'] = 'wminc-prefinfo-language'; |
13 | 14 | |
— | — | @@ -24,10 +25,10 @@ |
25 | 26 | 'section' => 'personal/i18n', |
26 | 27 | 'label-message' => 'wminc-testwiki', |
27 | 28 | 'id' => $wmincPref . '-code', |
28 | | - 'maxlength' => 3, |
29 | | - 'size' => 3, |
| 29 | + 'maxlength' => (int)$wmincLangCodeLength, |
| 30 | + 'size' => (int)$wmincLangCodeLength, |
30 | 31 | 'help-message' => 'wminc-prefinfo-code', |
31 | | - 'validation-callback' => array( 'IncubatorTest', 'CodeValidation' ), |
| 32 | + 'validation-callback' => array( 'IncubatorTest', 'validateCodePreference' ), |
32 | 33 | ); |
33 | 34 | |
34 | 35 | $wgDefaultUserOptions[$wmincPref . '-project'] = 'none'; |
— | — | @@ -37,7 +38,7 @@ |
38 | 39 | return true; |
39 | 40 | } |
40 | 41 | |
41 | | - function codeValidation( $input, $alldata ) { |
| 42 | + static function validateCodePreference( $input, $alldata ) { |
42 | 43 | global $wmincPref, $wmincProjects; |
43 | 44 | // If the user selected a project that NEEDS a language code, but the user DID NOT enter a language code, give an error |
44 | 45 | if ( isset( $alldata[$wmincPref.'-project'] ) && in_array( $alldata[$wmincPref.'-project'], $wmincProjects ) && !$input ) { |
— | — | @@ -47,48 +48,89 @@ |
48 | 49 | } |
49 | 50 | } |
50 | 51 | |
51 | | - function isNormalPrefix() { |
| 52 | + /* |
| 53 | + * This validates a language code. Currently it is set |
| 54 | + * to only allow two or three-letter codes strictly, but |
| 55 | + * it can be changed when the policy changes. |
| 56 | + * See also $wmincLangCodeLength. |
| 57 | + */ |
| 58 | + static function validateLanguageCode( $code ) { |
| 59 | + return (bool) preg_match( '/[a-z][a-z][a-z]?/', $code ); |
| 60 | + } |
| 61 | + |
| 62 | + /* |
| 63 | + * Same as above, but for full prefix in a given title. |
| 64 | + * @param $onlyprefix Bool Whether to validate only the prefix, or |
| 65 | + * also allow other text within the page title (Wx/xxx vs Wx/xxx/Text) |
| 66 | + */ |
| 67 | + static function validatePrefix( $title, $onlyprefix = false ) { |
| 68 | + global $wmincProjects; |
| 69 | + $listProjects = implode( '', $wmincProjects ); // something like: pbtqn |
| 70 | + return (bool) preg_match( '/^W['.$listProjects.']\/[a-z][a-z][a-z]?' . |
| 71 | + ($onlyprefix ? '' : '' ) . '/', $title ); |
| 72 | + } |
| 73 | + |
| 74 | + /* |
| 75 | + * Returns true if the given project (or preference |
| 76 | + * by default) is one of the projects using the |
| 77 | + * format Wx/xxx (as defined in $wmincProjects) |
| 78 | + */ |
| 79 | + static function isContentProject( $project = '' ) { |
52 | 80 | global $wgUser, $wmincPref, $wmincProjects; |
53 | | - if ( in_array( $wgUser->getOption($wmincPref . '-project'), $wmincProjects ) ) { |
54 | | - return true; // true because this is a normal prefix |
55 | | - } else { |
56 | | - return false; // false because this is NOT a normal prefix |
57 | | - } |
| 81 | + $project = ($project ? $project : $wgUser->getOption($wmincPref . '-project') ); |
| 82 | + return (bool) in_array( $project, $wmincProjects ); |
58 | 83 | } |
59 | 84 | |
60 | | - function displayPrefix() { |
61 | | - // display the prefix of the user preference |
| 85 | + /* |
| 86 | + * display the prefix by the given project and code |
| 87 | + * (or the user preference if no parameters are given) |
| 88 | + */ |
| 89 | + static function displayPrefix( $project = '', $code = '' ) { |
62 | 90 | global $wgUser, $wmincPref; |
63 | | - if ( self::isNormalPrefix() == true ) { |
64 | | - return 'W' . $wgUser->getOption($wmincPref . '-project') . '/' . $wgUser->getOption($wmincPref . '-code'); // return the prefix |
| 91 | + if ( self::isContentProject() ) { |
| 92 | + // return the prefix |
| 93 | + return 'W' . ( $project ? $project : $wgUser->getOption($wmincPref . '-project') ) . |
| 94 | + '/' . ( $code ? $code : $wgUser->getOption($wmincPref . '-code') ); // return the prefix |
65 | 95 | } else { |
66 | | - return $wgUser->getOption($wmincPref . '-project'); // still provide the value |
| 96 | + // still provide the value |
| 97 | + return $wgUser->getOption($wmincPref . '-project'); |
67 | 98 | } |
68 | 99 | } |
69 | 100 | |
70 | | - function displayPrefixedTitle( $title, $namespace = '' ) { |
71 | | - global $wgUser, $wmincPref; |
72 | | - $out = ''; |
73 | | - if ( self::isNormalPrefix() ) { |
74 | | - if ( $namespace ) { $out .= $namespace . ':'; } |
75 | | - $out .= self::displayPrefix() . '/' . $title; |
| 101 | + /* |
| 102 | + * Makes a full prefixed title of a given page title and namespace |
| 103 | + * @param $ns Tnt numeric value of namespace |
| 104 | + */ |
| 105 | + static function displayPrefixedTitle( $title, $ns = 0 ) { |
| 106 | + global $wgLang, $wmincTestWikiNamespaces; |
| 107 | + if( in_array( $ns, $wmincTestWikiNamespaces ) ) { |
| 108 | + /* Standard namespace as defined by |
| 109 | + * $wmincTestWikiNamespaces, so use format: |
| 110 | + * TITLE + NS => NS:Wx/xxx/TITLE |
| 111 | + */ |
| 112 | + $title = Title::makeTitleSafe( $ns, self::displayPrefix() . '/' . $title ); |
76 | 113 | } else { |
77 | | - $out .= self::displayPrefix(); |
| 114 | + /* Non-standard namespace, so use format: |
| 115 | + * TITLE + NS => Wx/xxx/NS:TITLE |
| 116 | + * (with localized namespace name) |
| 117 | + */ |
| 118 | + $title = Title::makeTitleSafe( NULL, self::displayPrefix() . '/' . |
| 119 | + $wgLang->getNsText( $ns ) . ':' . $title ); |
78 | 120 | } |
79 | | - return $out; |
| 121 | + return $title; |
80 | 122 | } |
81 | 123 | |
82 | | - function magicWordVariable( &$magicWords ) { |
| 124 | + static function magicWordVariable( &$magicWords ) { |
83 | 125 | $magicWords[] = 'usertestwiki'; |
84 | 126 | return true; |
85 | 127 | } |
86 | 128 | |
87 | | - function magicWord( &$magicWords, $langCode ) { |
| 129 | + static function magicWord( &$magicWords, $langCode ) { |
88 | 130 | $magicWords['usertestwiki'] = array( 0, 'USERTESTWIKI' ); |
89 | 131 | return true; |
90 | 132 | } |
91 | 133 | |
92 | | - function magicWordValue( &$parser, &$cache, &$magicWordId, &$ret ) { |
| 134 | + static function magicWordValue( &$parser, &$cache, &$magicWordId, &$ret ) { |
93 | 135 | if( !self::displayPrefix() ) { |
94 | 136 | $ret = 'none'; |
95 | 137 | } else { |
— | — | @@ -97,55 +139,57 @@ |
98 | 140 | return true; |
99 | 141 | } |
100 | 142 | |
101 | | - function editPageCheckPrefix( $editpage ) { |
| 143 | + static function checkPrefixOnEditPage( $editpage ) { |
| 144 | + global $wmincProjectSite; |
102 | 145 | // If user has "project" as test wiki preference, it isn't needed to check |
103 | | - if ( self::displayPrefix() == 'inc' ) { |
| 146 | + if ( self::displayPrefix() == $wmincProjectSite['short'] ) { |
104 | 147 | return true; |
105 | 148 | } |
106 | | - global $wgTitle; |
107 | | - $namespaces = array( NS_MAIN, NS_TALK, NS_TEMPLATE, NS_TEMPLATE_TALK, NS_CATEGORY, NS_CATEGORY_TALK ); |
108 | | - // If it is in one of the above namespace, check if the page title has a prefix |
109 | | - if ( in_array( $wgTitle->getNamespace(), $namespaces ) && !preg_match( '/W[bnpqt]\/[a-z][a-z][a-z]?/', $wgTitle->getText() ) ) { |
110 | | - global $wgOut; |
111 | | - |
112 | | - $warning = '<div id="wminc-warning"><span id="wm-warning-unprefixed">' |
113 | | - . wfMsg( 'wminc-warning-unprefixed' ) |
| 149 | + global $wgTitle, $wmincTestWikiNamespaces; |
| 150 | + $title = $wgTitle->getText(); |
| 151 | + $ns = $wgTitle->getNamespace(); |
| 152 | + // If it's in one of the content namespaces or if the page title has a prefix, return |
| 153 | + if ( !in_array( $ns, $wmincTestWikiNamespaces ) || self::validatePrefix( $title ) ) { |
| 154 | + return true; |
| 155 | + } |
| 156 | + $warning = '<div id="wminc-warning"><span id="wm-warning-unprefixed">' |
| 157 | + . wfMsg( 'wminc-warning-unprefixed' ) |
| 158 | + . '</span>'; |
| 159 | + // If the user has a test wiki pref, suggest a page title with prefix |
| 160 | + if ( self::isContentProject() ) { |
| 161 | + global $wgUser; |
| 162 | + $suggest = self::displayPrefixedTitle( $title, $ns ); |
| 163 | + if ( !$wgTitle->exists() ) { // Creating a page, so suggest to create a prefixed page |
| 164 | + $warning .= ' <span id="wminc-warning-suggest">' |
| 165 | + . wfMsg( 'wminc-warning-suggest', $suggest ) |
114 | 166 | . '</span>'; |
115 | | - // If the user has a test wiki pref, suggest a page title with prefix |
116 | | - if ( self::isNormalPrefix() ) { |
117 | | - global $wgUser; |
118 | | - $suggest = self::displayPrefixedTitle( $wgTitle->getText(), $wgTitle->getNsText() ); |
119 | | - if ( !$wgTitle->exists() ) { // Creating a page, so suggest to create a prefixed page |
120 | | - $warning .= ' <span id="wminc-warning-suggest">' |
121 | | - . wfMsg( 'wminc-warning-suggest', $suggest ) |
122 | | - . '</span>'; |
123 | | - } elseif ( $wgUser->isAllowed( 'move' ) ) { // Page exists, so suggest to move |
124 | | - $warning .= ' <span id="wminc-warning-suggest-move" class="plainlinks">' |
125 | | - . wfMsg( 'wminc-warning-suggest-move', $suggest, urlencode( $suggest ), urlencode( $wgTitle ) ) |
126 | | - . '</span>'; |
127 | | - } |
128 | | - } |
129 | | - $warning .= '</div>'; |
130 | | - $wgOut->addWikiText( $warning ); |
| 167 | + } elseif ( $wgUser->isAllowed( 'move' ) ) { // Page exists, so suggest to move |
| 168 | + $warning .= ' <span id="wminc-warning-suggest-move" class="plainlinks">' |
| 169 | + . wfMsg( 'wminc-warning-suggest-move', $suggest, wfUrlencode( $suggest ), wfUrlencode( $wgTitle ) ) |
| 170 | + . '</span>'; |
| 171 | + } |
131 | 172 | } |
| 173 | + $warning .= '</div>'; |
| 174 | + global $wgOut; |
| 175 | + $wgOut->addWikiText( $warning ); |
132 | 176 | return true; |
133 | 177 | } |
134 | | -} |
135 | 178 | |
136 | | -/** |
137 | | - * Add a link to Special:ViewUserLang from Special:Contributions/USERNAME |
138 | | - * if the user has 'viewuserlang' permission |
139 | | - * Based on code from extension LookupUser made by Tim Starling |
140 | | - * @return true |
141 | | - */ |
142 | | -function efLoadViewUserLangLink( $id, $nt, &$links ) { |
143 | | - global $wgUser; |
144 | | - if ( $wgUser->isAllowed( 'viewuserlang' ) ) { |
145 | | - |
146 | | - $links[] = $wgUser->getSkin()->makeKnownLinkObj( |
147 | | - SpecialPage::getTitleFor( 'ViewUserLang' ), |
148 | | - wfMsgHtml( 'wminc-viewuserlang' ), |
149 | | - '&target=' . urlencode( $nt->getText() ) ); |
| 179 | + /** |
| 180 | + * Add a link to Special:ViewUserLang from Special:Contributions/USERNAME |
| 181 | + * if the user has 'viewuserlang' permission |
| 182 | + * Based on code from extension LookupUser made by Tim Starling |
| 183 | + * @return true |
| 184 | + */ |
| 185 | + static function efLoadViewUserLangLink( $id, $nt, &$links ) { |
| 186 | + global $wgUser; |
| 187 | + if ( $wgUser->isAllowed( 'viewuserlang' ) ) { |
| 188 | + $user = wfUrlencode( $nt->getText() ); |
| 189 | + $links[] = $wgUser->getSkin()->link( |
| 190 | + SpecialPage::getTitleFor( 'ViewUserLang', $user ), |
| 191 | + wfMsgHtml( 'wminc-viewuserlang' ) |
| 192 | + ); |
| 193 | + } |
| 194 | + return true; |
150 | 195 | } |
151 | | - return true; |
152 | | -} |
| 196 | +} |
\ No newline at end of file |
Index: trunk/extensions/WikimediaIncubator/TestWikiRC.php |
— | — | @@ -5,15 +5,15 @@ |
6 | 6 | |
7 | 7 | class TestWikiRC { |
8 | 8 | static function onRcQuery( &$conds, &$tables, &$join_conds, $opts ) { |
9 | | - global $wgUser, $wgRequest, $wmincPref, $wmincProjectSite; |
| 9 | + global $wgUser, $wgRequest, $wmincPref, $wmincProjectSite, $wmincTestWikiNamespaces; |
10 | 10 | $projectvalue = strtolower( $wgRequest->getVal( 'rc-testwiki-project', $wgUser->getOption($wmincPref . '-project') ) ); |
11 | 11 | $codevalue = strtolower( $wgRequest->getVal( 'rc-testwiki-code', $wgUser->getOption($wmincPref . '-code') ) ); |
12 | | - $fullprefix = 'W' . $projectvalue . '/' . $codevalue; |
| 12 | + $fullprefix = IncubatorTest::displayPrefix( $projectvalue, $codevalue ); |
13 | 13 | $opts->add( 'rc-testwiki-project', false ); |
14 | 14 | $opts->setValue( 'rc-testwiki-project', $projectvalue ); |
15 | 15 | $opts->add( 'rc-testwiki-code', false ); |
16 | 16 | $opts->setValue( 'rc-testwiki-code', $codevalue ); |
17 | | - if ( $projectvalue == 'none' OR $projectvalue == '' ) { |
| 17 | + if ( $projectvalue == 'none' || $projectvalue == '' ) { |
18 | 18 | // If "none" is selected, display normal recent changes |
19 | 19 | return true; |
20 | 20 | } elseif ( $projectvalue == $wmincProjectSite['short'] ) { |
— | — | @@ -23,8 +23,7 @@ |
24 | 24 | } else { |
25 | 25 | // Else, display changes to the selected test wiki (in main, template and category namespace) |
26 | 26 | $dbr = wfGetDB( DB_SLAVE ); |
27 | | - $namespaces = array( NS_MAIN, NS_TALK, NS_TEMPLATE, NS_TEMPLATE_TALK, NS_CATEGORY, NS_CATEGORY_TALK ); |
28 | | - $conds[] = 'rc_namespace IN (' . $dbr->makeList( $namespaces ) . ')'; |
| 27 | + $conds['rc_namespace'] = $wmincTestWikiNamespaces; |
29 | 28 | $conds[] = 'rc_title ' . $dbr->buildLike( $fullprefix . '/', $dbr->anyString() ) . |
30 | 29 | ' OR rc_title = ' . $dbr->addQuotes( $fullprefix ); |
31 | 30 | return true; |
— | — | @@ -32,7 +31,7 @@ |
33 | 32 | } |
34 | 33 | |
35 | 34 | static function onRcForm( &$items, $opts ) { |
36 | | - global $wgUser, $wgRequest, $wmincPref, $wmincProjects, $wmincProjectSite; |
| 35 | + global $wgUser, $wgRequest, $wmincPref, $wmincProjects, $wmincProjectSite, $wmincLangCodeLength; |
37 | 36 | |
38 | 37 | $projectvalue = $wgRequest->getVal( 'rc-testwiki-project', $wgUser->getOption($wmincPref . '-project') ); |
39 | 38 | $langcodevalue = $wgRequest->getVal( 'rc-testwiki-code', $wgUser->getOption($wmincPref . '-code') ); |
— | — | @@ -45,7 +44,8 @@ |
46 | 45 | $select->addOption( $name, $prefix ); |
47 | 46 | } |
48 | 47 | $select->addOption( $wmincProjectSite['name'], $wmincProjectSite['short'] ); |
49 | | - $langcode = Xml::input( 'rc-testwiki-code', 3, $langcodevalue, array( 'id' => 'rc-testwiki-code', 'maxlength' => 3 ) ); |
| 48 | + $langcode = Xml::input( 'rc-testwiki-code', (int)$wmincLangCodeLength, $langcodevalue, |
| 49 | + array( 'id' => 'rc-testwiki-code', 'maxlength' => (int)$wmincLangCodeLength ) ); |
50 | 50 | $items['testwiki'] = array( $label, $select->getHTML() . ' ' . $langcode ); |
51 | 51 | return true; |
52 | 52 | } |