r50190 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50189‎ | r50190 | r50191 >
Date:18:10, 4 May 2009
Author:siebrand
Status:deferred
Tags:
Comment:
* fix typo in 'wminc-prefinfo-language'
* stylize.php, trailing whitespace removed, updated indentation

No functional changes
Modified paths:
  • /trunk/extensions/WikimediaIncubator/CreateAccountTestWiki.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/IncubatorTest.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/TestWikiRC.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/WikimediaIncubator.alias.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/WikimediaIncubator.i18n.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/WikimediaIncubator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.php
@@ -1,5 +1,5 @@
22 <?php
3 -if( !defined( 'MEDIAWIKI' ) ) { die( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); }
 3+if ( !defined( 'MEDIAWIKI' ) ) { die( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); }
44 /**
55 * An extension that adds test wiki features (such as a preference, recent changes for a test wiki, ...) specifically for the Wikimedia Incubator
66 *
@@ -8,9 +8,9 @@
99
1010 $wgExtensionCredits['other'][] = array(
1111 'name' => 'Wikimedia Incubator',
12 - 'author' =>'SPQRobin',
13 - 'version' => '2.1.0',
14 - 'url' => 'http://www.mediawiki.org/wiki/Extension:WikimediaIncubator',
 12+ 'author' => 'SPQRobin',
 13+ 'version' => '2.1.1',
 14+ 'url' => 'http://www.mediawiki.org/wiki/Extension:WikimediaIncubator',
1515 'description' => 'Test wiki features for Wikimedia Incubator',
1616 'descriptionmsg' => 'wminc-desc',
1717 );
@@ -22,7 +22,7 @@
2323 $wgGroupPermissions['sysop']['viewuserlang'] = true;
2424
2525 /* General */
26 -$dir = dirname(__FILE__) . '/';
 26+$dir = dirname( __FILE__ ) . '/';
2727 $wgExtensionMessagesFiles['WikimediaIncubator'] = $dir . 'WikimediaIncubator.i18n.php';
2828
2929 /* Special:ViewUserLang */
@@ -49,7 +49,7 @@
5050 $wgHooks['SpecialRecentChangesPanel'][] = 'TestWikiRC::RcForm';
5151
5252 /* Automatic pref on account creation */
53 -if($wmincEnableAutoTestWiki == true) {
 53+if ( $wmincEnableAutoTestWiki == true ) {
5454 $wgAutoloadClasses['AutoTestWiki'] = $dir . 'CreateAccountTestWiki.php';
5555 $wgHooks['UserCreateForm'][] = 'AutoTestWiki::UserCreateForm';
5656 $wgHooks['AddNewAccount'][] = 'AutoTestWiki::AddNewAccount';
Index: trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php
@@ -8,8 +8,9 @@
99 *
1010 * @file
1111 */
12 -class SpecialViewUserLang extends SpecialPage {
1312
 13+class SpecialViewUserLang extends SpecialPage
 14+{
1415 public function __construct() {
1516 parent::__construct( 'ViewUserLang', 'viewuserlang' );
1617 }
@@ -93,17 +94,17 @@
9495 ) ) );
9596 $wgOut->addWikiText(
9697 '*' . wfMsg( 'loginlanguagelabel',
97 - $wgLanguageNames[$user->mOptions['language']] . ' ('.$user->mOptions['language'].')'
 98+ $wgLanguageNames[$user->mOptions['language']] . ' (' . $user->mOptions['language'] . ')'
9899 )
99100 );
100 - if(IncubatorTest::NormalPrefix() == true) {
101 - $testwiki = '[[W'.$user->mOptions[$wmincPref.'-project'].'/'.$user->mOptions[$wmincPref.'-code'].']]';
102 - } elseif(IncubatorTest::DisplayPrefix() == 'inc') {
 101+ if ( IncubatorTest::NormalPrefix() == true ) {
 102+ $testwiki = '[[W' . $user->mOptions[$wmincPref . '-project'] . '/' . $user->mOptions[$wmincPref . '-code'] . ']]';
 103+ } elseif ( IncubatorTest::DisplayPrefix() == 'inc' ) {
103104 $testwiki = 'Incubator';
104105 } else {
105 - $testwiki = wfMsg('wminc-testwiki-none' );
 106+ $testwiki = wfMsg( 'wminc-testwiki-none' );
106107 }
107 - $wgOut->addWikiText( '*' . wfMsg( 'wminc-testwiki' ) . ' '.$testwiki );
 108+ $wgOut->addWikiText( '*' . wfMsg( 'wminc-testwiki' ) . ' ' . $testwiki );
108109 }
109110 }
110111 }
Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.alias.php
@@ -13,9 +13,7 @@
1414 'ViewUserLang' => array( 'ViewUserLang' ),
1515 );
1616
17 -
1817 /** Dutch (Nederlands) */
1918 $aliases['nl'] = array(
2019 'ViewUserLang' => array( 'GebruikerstaalOpzoeken' ),
2120 );
22 -
Index: trunk/extensions/WikimediaIncubator/CreateAccountTestWiki.php
@@ -4,27 +4,27 @@
55 * This can be used to work with my toolserver project (http://toolserver.org/~robin/?tool=proposewiki), so users don't *have* to change their preferences (automatically is always better :p)
66 */
77 class AutoTestWiki {
8 - function UserCreateForm($template) {
 8+ function UserCreateForm( $template ) {
99 global $wgRequest;
10 - $projectvalue = strtolower($wgRequest->getVal( 'testwikiproject', '' ));
11 - $codevalue = strtolower($wgRequest->getVal( 'testwikicode', '' ));
12 - if(preg_match('/[a-z][a-z][a-z]?/', $codevalue) && in_array($projectvalue, array('p','b','t','q','n'))) {
13 - $template->set( 'header', '<input type="hidden" name="testwiki-project" value="'.$projectvalue.'" />
14 - <input type="hidden" name="testwiki-code" value="'.$codevalue.'" />
 10+ $projectvalue = strtolower( $wgRequest->getVal( 'testwikiproject', '' ) );
 11+ $codevalue = strtolower( $wgRequest->getVal( 'testwikicode', '' ) );
 12+ if ( preg_match( '/[a-z][a-z][a-z]?/', $codevalue ) && in_array( $projectvalue, array( 'p', 'b', 't', 'q', 'n' ) ) ) {
 13+ $template->set( 'header', '<input type="hidden" name="testwiki-project" value="' . $projectvalue . '" />
 14+ <input type="hidden" name="testwiki-code" value="' . $codevalue . '" />
1515 ' );
1616 }
1717 return true;
1818 }
19 -
20 - function AddNewAccount($user) {
 19+
 20+ function AddNewAccount( $user ) {
2121 global $wgRequest, $wmincPref;
2222 $getprojectvalue = $wgRequest->getVal( 'testwiki-project' );
2323 $getcodevalue = $wgRequest->getVal( 'testwiki-code' );
24 - if($getprojectvalue && $getcodevalue) {
25 - $user->setOption($wmincPref.'-project', $getprojectvalue);
26 - $user->setOption($wmincPref.'-code', $getcodevalue);
 24+ if ( $getprojectvalue && $getcodevalue ) {
 25+ $user->setOption( $wmincPref . '-project', $getprojectvalue );
 26+ $user->setOption( $wmincPref . '-code', $getcodevalue );
2727 $user->saveSettings();
2828 }
2929 return true;
3030 }
31 -}
\ No newline at end of file
 31+}
Index: trunk/extensions/WikimediaIncubator/IncubatorTest.php
@@ -3,49 +3,51 @@
44 * Implement test wiki preference, magic word and prefix check on edit page
55 */
66
7 -class IncubatorTest {
 7+class IncubatorTest
 8+{
89 static function AddPreferences( $user, &$preferences ) {
9 - global $wmincPref, $wmincPrefProject, $wmincPrefNone;
 10+ global $wmincPref, $wmincPrefProject, $wmincPrefNone;
 11+
1012 $preferences['language']['help-message'] = 'wminc-prefinfo-language';
11 -
12 - $prefinsert[$wmincPref.'-project'] = array(
 13+
 14+ $prefinsert[$wmincPref . '-project'] = array(
1315 'type' => 'select',
14 - 'options' => array( wfMsg('wminc-testwiki-none')=>'none', 'wikipedia'=>'p', 'wikibooks'=>'b',
15 - 'wiktionary'=>'t', 'wikiquote'=>'q', 'wikinews'=>'n', 'incubator'=>'inc' ),
 16+ 'options' => array( wfMsg( 'wminc-testwiki-none' ) => 'none', 'wikipedia' => 'p', 'wikibooks' => 'b',
 17+ 'wiktionary' => 't', 'wikiquote' => 'q', 'wikinews' => 'n', 'incubator' => 'inc' ),
1618 'section' => 'personal/i18n',
1719 'label-message' => 'wminc-testwiki',
18 - 'id' => $wmincPref.'-project',
 20+ 'id' => $wmincPref . '-project',
1921 'help-message' => 'wminc-prefinfo-project',
2022 );
21 - $prefinsert[$wmincPref.'-code'] = array(
 23+ $prefinsert[$wmincPref . '-code'] = array(
2224 'type' => 'text',
2325 'section' => 'personal/i18n',
2426 'label-message' => 'wminc-testwiki',
25 - 'id' => $wmincPref.'-code',
 27+ 'id' => $wmincPref . '-code',
2628 'maxlength' => 3,
2729 'size' => 3,
2830 'help-message' => 'wminc-prefinfo-code',
29 - 'validation-callback' => array('IncubatorTest','CodeValidation'),
 31+ 'validation-callback' => array( 'IncubatorTest', 'CodeValidation' ),
3032 );
3133
3234 $preferences = wfArrayInsertAfter( $preferences, $prefinsert, 'language' );
33 -
 35+
3436 return true;
3537 }
36 -
37 - function CodeValidation($input, $alldata) {
 38+
 39+ function CodeValidation( $input, $alldata ) {
3840 global $wmincPref;
3941 // If the user selected a project that NEEDS a language code, but the user DID NOT enter a language code, give an error
40 - if(!in_array($alldata[$wmincPref.'-project'],array('','none','inc')) && !$input) {
41 - return Xml::element( 'span', array( 'class'=>'error' ), wfMsg( 'wminc-prefinfo-error' ) );
 42+ if ( !in_array( $alldata[$wmincPref . '-project'], array( '', 'none', 'inc' ) ) && !$input ) {
 43+ return Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'wminc-prefinfo-error' ) );
4244 } else {
4345 return true;
4446 }
4547 }
46 -
 48+
4749 function NormalPrefix() {
4850 global $wgUser, $wmincPref;
49 - if(in_array($wgUser->mOptions[$wmincPref.'-project'],array('','none','inc'))) {
 51+ if ( in_array( $wgUser->mOptions[$wmincPref . '-project'], array( '', 'none', 'inc' ) ) ) {
5052 return false; // false because this is NOT a normal prefix
5153 } else {
5254 return true; // true because this is a normal prefix
@@ -53,25 +55,25 @@
5456 }
5557 function DisplayPrefix() {
5658 global $wgUser, $wmincPref;
57 - if(self::NormalPrefix() == true) {
58 - return 'W'.$wgUser->mOptions[$wmincPref.'-project'].'/'. $wgUser->mOptions[$wmincPref.'-code']; // return the prefix
 59+ if ( self::NormalPrefix() == true ) {
 60+ return 'W' . $wgUser->mOptions[$wmincPref . '-project'] . '/' . $wgUser->mOptions[$wmincPref . '-code']; // return the prefix
5961 } else {
60 - return $wgUser->mOptions[$wmincPref.'-project']; // still provide the value
 62+ return $wgUser->mOptions[$wmincPref . '-project']; // still provide the value
6163 }
6264 }
63 -
64 - function DisplayPrefixedTitle($title, $namespace='') {
 65+
 66+ function DisplayPrefixedTitle( $title, $namespace = '' ) {
6567 global $wgUser, $wmincPref;
6668 $out = '';
67 - if(self::NormalPrefix()) {
68 - if($namespace) { $out .= $namespace.':'; }
 69+ if ( self::NormalPrefix() ) {
 70+ if ( $namespace ) { $out .= $namespace . ':'; }
6971 $out .= self::DisplayPrefix() . '/' . $title;
7072 } else {
7173 $out .= self::DisplayPrefix();
7274 }
7375 return $out;
7476 }
75 -
 77+
7678 function MagicWordVariable( &$magicWords ) {
7779 $magicWords[] = 'usertestwiki';
7880 return true;
@@ -79,30 +81,30 @@
8082
8183 function MagicWord( &$magicWords, $langCode ) {
8284 $magicWords['usertestwiki'] = array( 0, 'USERTESTWIKI' );
83 - return true;
 85+ return true;
8486 }
85 -
 87+
8688 function MagicWordValue( &$parser, &$cache, &$magicWordId, &$ret ) {
8789 $ret = self::DisplayPrefix();
8890 return true;
8991 }
90 -
91 - function EditPageCheckPrefix($editpage) {
 92+
 93+ function EditPageCheckPrefix( $editpage ) {
9294 // If user has "project" as test wiki preference, it isn't needed to check
93 - if(self::DisplayPrefix() != 'inc') {
 95+ if ( self::DisplayPrefix() != 'inc' ) {
9496 global $wgTitle;
9597 $namespaces = array( NS_MAIN, NS_TALK, NS_TEMPLATE, NS_TEMPLATE_TALK, NS_CATEGORY, NS_CATEGORY_TALK );
9698 // If it is in one of the above namespace, check if the page title has a prefix
97 - if(in_array($wgTitle->getNamespace(), $namespaces) && !preg_match('/W[bnpqt]\/[a-z][a-z][a-z]?/', $wgTitle->getText())) {
 99+ if ( in_array( $wgTitle->getNamespace(), $namespaces ) && !preg_match( '/W[bnpqt]\/[a-z][a-z][a-z]?/', $wgTitle->getText() ) ) {
98100 global $wgOut;
99101 wfLoadExtensionMessages( 'WikimediaIncubator' );
100102 $warning = '<div id="wminc-warning"><span id="wm-warning-unprefixed">'
101103 . wfMsg( 'wminc-warning-unprefixed' )
102104 . '</span>';
103105 // If the user has a test wiki pref, suggest a page title with prefix
104 - if(self::NormalPrefix()) {
 106+ if ( self::NormalPrefix() ) {
105107 $warning .= ' <span id="wminc-warning-suggest">'
106 - . wfMsg( 'wminc-warning-suggest', self::DisplayPrefixedTitle($wgTitle->getText(), $wgTitle->getNsText()) )
 108+ . wfMsg( 'wminc-warning-suggest', self::DisplayPrefixedTitle( $wgTitle->getText(), $wgTitle->getNsText() ) )
107109 . '</span>';
108110 }
109111 $warning .= '</div>';
@@ -119,9 +121,9 @@
120122 * Based on code from extension LookupUser made by Tim Starling
121123 * @return true
122124 */
123 -function efLoadViewUserLangLink( $id, $nt, &$links ){
 125+function efLoadViewUserLangLink( $id, $nt, &$links ) {
124126 global $wgUser;
125 - if( $wgUser->isAllowed( 'viewuserlang' ) ) {
 127+ if ( $wgUser->isAllowed( 'viewuserlang' ) ) {
126128 wfLoadExtensionMessages( 'WikimediaIncubator' );
127129 $links[] = $wgUser->getSkin()->makeKnownLinkObj(
128130 SpecialPage::getTitleFor( 'ViewUserLang' ),
@@ -129,4 +131,4 @@
130132 '&target=' . urlencode( $nt->getText() ) );
131133 }
132134 return true;
133 -}
\ No newline at end of file
 135+}
Index: trunk/extensions/WikimediaIncubator/TestWikiRC.php
@@ -4,19 +4,19 @@
55 */
66
77 class TestWikiRC {
8 - static function RcQuery(&$conds, &$tables, &$join_conds, $opts) {
 8+ static function RcQuery( &$conds, &$tables, &$join_conds, $opts ) {
99 global $wgUser, $wgRequest, $wmincPref;
10 - $projectvalue = strtolower($wgRequest->getVal( 'rc-testwiki-project', $wgUser->mOptions[$wmincPref.'-project'] ));
11 - $codevalue = strtolower($wgRequest->getVal( 'rc-testwiki-code', $wgUser->mOptions[$wmincPref.'-code'] ));
12 - $fullprefix = 'W'.$projectvalue.'/'.$codevalue;
 10+ $projectvalue = strtolower( $wgRequest->getVal( 'rc-testwiki-project', $wgUser->mOptions[$wmincPref . '-project'] ) );
 11+ $codevalue = strtolower( $wgRequest->getVal( 'rc-testwiki-code', $wgUser->mOptions[$wmincPref . '-code'] ) );
 12+ $fullprefix = 'W' . $projectvalue . '/' . $codevalue;
1313 $opts->add( 'rc-testwiki-project', false );
1414 $opts->setValue( 'rc-testwiki-project', $projectvalue );
1515 $opts->add( 'rc-testwiki-code', false );
1616 $opts->setValue( 'rc-testwiki-code', $codevalue );
17 - if($projectvalue == 'none') {
 17+ if ( $projectvalue == 'none' ) {
1818 // If "none" is selected, display normal recent changes
1919 return true;
20 - } elseif($projectvalue == 'inc') {
 20+ } elseif ( $projectvalue == 'inc' ) {
2121 // If "inc" (incubator) is selected, display all changes except test wiki changes
2222 $conds[] = 'rc_title not like \'W_/%%\' OR \'W_/%%/%%\'';
2323 return true;
@@ -25,19 +25,19 @@
2626 $dbr = wfGetDB( DB_SLAVE );
2727 $namespaces = array( NS_MAIN, NS_TALK, NS_TEMPLATE, NS_TEMPLATE_TALK, NS_CATEGORY, NS_CATEGORY_TALK );
2828 $conds[] = 'rc_namespace IN (' . $dbr->makeList( $namespaces ) . ')';
29 - $conds[] = 'rc_title like \''.$fullprefix.'/%\' OR rc_title like \''.$fullprefix.'\'';
 29+ $conds[] = 'rc_title like \'' . $fullprefix . '/%\' OR rc_title like \'' . $fullprefix . '\'';
3030 return true;
3131 }
3232 }
33 -
34 - static function RcForm(&$items, $opts) {
 33+
 34+ static function RcForm( &$items, $opts ) {
3535 global $wgUser, $wgRequest, $wmincPref;
3636 wfLoadExtensionMessages( 'WikimediaIncubator' );
37 - $projectvalue = $wgRequest->getVal( 'rc-testwiki-project', $wgUser->mOptions[$wmincPref.'-project'] );
38 - $langcodevalue = $wgRequest->getVal( 'rc-testwiki-code', $wgUser->mOptions[$wmincPref.'-code'] );
 37+ $projectvalue = $wgRequest->getVal( 'rc-testwiki-project', $wgUser->mOptions[$wmincPref . '-project'] );
 38+ $langcodevalue = $wgRequest->getVal( 'rc-testwiki-code', $wgUser->mOptions[$wmincPref . '-code'] );
3939 $opts->consumeValue( 'rc-testwiki-project' );
4040 $opts->consumeValue( 'rc-testwiki-code' );
41 - $label = Xml::label( wfMsg('wminc-testwiki'), 'rc-testwiki' );
 41+ $label = Xml::label( wfMsg( 'wminc-testwiki' ), 'rc-testwiki' );
4242 $select = new XmlSelect( 'rc-testwiki-project', 'rc-testwiki-project', $projectvalue );
4343 $select->addOption( wfMsg( 'wminc-testwiki-none' ), 'none' );
4444 $select->addOption( 'wikipedia', 'p' );
@@ -47,7 +47,7 @@
4848 $select->addOption( 'wikinews', 'n' );
4949 $select->addOption( 'incubator', 'inc' );
5050 $langcode = Xml::input( 'rc-testwiki-code', 3, $langcodevalue, array( 'id' => 'rc-testwiki-code', 'maxlength' => 3 ) );
51 - $items['testwiki'] = array( $label, $select->getHTML() .' '. $langcode );
 51+ $items['testwiki'] = array( $label, $select->getHTML() . ' ' . $langcode );
5252 return true;
5353 }
54 -}
\ No newline at end of file
 54+}
Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.i18n.php
@@ -15,7 +15,7 @@
1616 'wminc-viewuserlang' => 'Look up user language and test wiki',
1717 'wminc-testwiki' => 'Test wiki:',
1818 'wminc-testwiki-none' => 'None/All',
19 - 'wminc-prefinfo-language' => 'Your interface language - independant from your test wiki',
 19+ 'wminc-prefinfo-language' => 'Your interface language - independent from your test wiki',
2020 'wminc-prefinfo-code' => 'The ISO 639 language code',
2121 'wminc-prefinfo-project' => 'Select the Wikimedia project (Incubator option is for users who do general work)',
2222 'wminc-prefinfo-error' => 'You selected a project that needs a language code.',
@@ -23,7 +23,6 @@
2424 'wminc-warning-suggest' => 'You can create a page at [[$1]].',
2525 );
2626
27 -
2827 /** Dutch (Nederlands)
2928 * @author SPQRobin
3029 */

Status & tagging log