r52221 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52220‎ | r52221 | r52222 >
Date:22:56, 20 June 2009
Author:siebrand
Status:deferred
Tags:
Comment:
* newlines in messages between sentences
* stylize.php, trailing whitespace removed
Modified paths:
  • /trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.i18n.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/OptIn/OptIn.i18n.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/OptIn/OptIn.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/OptIn/OptIn.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/OptIn/OptIn.sql (modified) (history)
  • /trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefStats/PrefStats.alias.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefStats/PrefStats.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefStats/PrefStats.i18n.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefStats/PrefStats.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefStats/PrefStats.sql (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefStats/SpecialPrefStats.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/OptIn/OptIn.php
@@ -63,7 +63,7 @@
6464 'type' => 'resolution' ),
6565 array( 'question' => 'optin-survey-question-feedback',
6666 'type' => 'textarea' )
67 -);
 67+);
6868
6969 /* Setup */
7070
Index: trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php
@@ -11,19 +11,19 @@
1212 parent::__construct( 'OptIn' );
1313 wfLoadExtensionMessages( 'OptIn' );
1414 }
15 -
 15+
1616 function execute( $par ) {
1717 global $wgRequest, $wgOut, $wgUser;
1818 $this->setHeaders();
1919 $wgOut->setPageTitle( wfMsg( 'optin-title' ) );
20 -
 20+
2121 if ( $wgUser->isAnon() ) {
2222 $url = SpecialPage::getTitleFor( 'Userlogin' )->getFullURL(
2323 array( 'returnto' => $this->getTitle()->getPrefixedUrl() ) );
2424 $wgOut->wrapWikiMsg( "<div class='plainlinks'>\n$1\n</div>", array( 'optin-needlogin', $url ) );
2525 return;
2626 }
27 -
 27+
2828 if ( $wgRequest->wasPosted() ) {
2929 if ( $wgRequest->getVal( 'opt' ) === 'in' ) {
3030 $this->optIn( $wgUser );
@@ -36,7 +36,7 @@
3737 }
3838 $this->showForm();
3939 }
40 -
 40+
4141 function showForm() {
4242 global $wgUser, $wgOut;
4343 $wgOut->addHTML( Xml::openElement( 'form', array(
@@ -55,7 +55,7 @@
5656 $wgOut->addHTML( Xml::submitButton( wfMsg( "optin-submit-$opt" ) ) );
5757 $wgOut->addHTML( Xml::closeElement( 'form' ) );
5858 }
59 -
 59+
6060 function isOptedIn( $user ) {
6161 global $wgOptInPrefs;
6262 foreach ( $wgOptInPrefs as $pref => $value ) {
@@ -65,28 +65,28 @@
6666 }
6767 return true;
6868 }
69 -
 69+
7070 function optIn( $user ) {
7171 global $wgOptInPrefs;
72 - foreach( $wgOptInPrefs as $pref => $value ) {
 72+ foreach ( $wgOptInPrefs as $pref => $value ) {
7373 $user->setOption( $pref, $value );
7474 }
7575 $user->saveSettings();
7676 }
77 -
 77+
7878 function optOut( $user ) {
7979 global $wgOptInPrefs;
80 - foreach( $wgOptInPrefs as $pref => $value ) {
 80+ foreach ( $wgOptInPrefs as $pref => $value ) {
8181 $user->setOption( $pref, null );
8282 }
8383 $user->saveSettings();
8484 }
85 -
 85+
8686 function showSurvey() {
8787 global $wgOptInSurvey, $wgOut, $wgOptInStyleVersion;
8888 UsabilityInitiativeHooks::addScript( 'OptIn/OptIn.js',
8989 $wgOptInStyleVersion );
90 -
 90+
9191 $retval = Xml::openElement( 'table' );
9292 foreach ( $wgOptInSurvey as $id => $question ) {
9393 switch ( $question['type'] ) {
@@ -183,12 +183,12 @@
184184 $retval .= Xml::closeElement( 'table' );
185185 $wgOut->addHTML( $retval );
186186 }
187 -
 187+
188188 function saveSurvey() {
189189 global $wgRequest, $wgUser, $wgOptInSurvey;
190190 $dbw = wfGetDb( DB_MASTER );
191191 $now = $dbw->timestamp( wfTimestamp() );
192 - //var_dump($wgRequest->data); die();
 192+ // var_dump($wgRequest->data); die();
193193 foreach ( $wgOptInSurvey as $id => $question ) {
194194 $insert = array(
195195 'ois_user' => $wgUser->getId(),
@@ -201,7 +201,7 @@
202202 if ( $answer === 'other' ) {
203203 $insert['ois_answer'] = null;
204204 $insert['ois_answer_data'] = $wgRequest->getVal( "survey-$id-other" );
205 - } else if ($answer === '' ) {
 205+ } else if ( $answer === '' ) {
206206 $insert['ois_answer'] = null;
207207 $insert['ois_answer_data'] = null;
208208 } else {
@@ -222,7 +222,7 @@
223223 break;
224224 case 'textarea':
225225 $answer = $wgRequest->getVal( "survey-$id" );
226 - if ($answer === '' ) {
 226+ if ( $answer === '' ) {
227227 $insert['ois_answer'] = null;
228228 $insert['ois_answer_data'] = null;
229229 } else {
Index: trunk/extensions/UsabilityInitiative/OptIn/OptIn.js
@@ -43,8 +43,8 @@
4444 browserIndex = 14;
4545 break;
4646 }
47 -
48 - var osIndex = -1;
 47+
 48+ var osIndex = -1;
4949 switch ( $.os.name ) {
5050 case 'win':
5151 osIndex = 0;
@@ -56,7 +56,7 @@
5757 osIndex = 2;
5858 break;
5959 }
60 -
 60+
6161 if ( browserIndex == -1 )
6262 $( '#survey-1' ).val( 'other' );
6363 else
@@ -65,5 +65,5 @@
6666 $( '#survey-2' ).val( 'other' );
6767 else
6868 $( '#survey-2' ).val( osIndex );
69 -
70 -});
\ No newline at end of file
 69+
 70+});
Index: trunk/extensions/UsabilityInitiative/OptIn/OptIn.sql
@@ -5,18 +5,18 @@
66 CREATE TABLE IF NOT EXISTS /*_*/optin_survey (
77 -- User ID
88 ois_user int NOT NULL,
9 -
 9+
1010 -- Timestamp
1111 ois_timestamp binary(14) NOT NULL,
12 -
 12+
1313 -- Question ID (key in $wgOptInSurvey)
1414 ois_question int unsigned NOT NULL,
15 -
 15+
1616 -- Answer ID (key in $wgOptInSurvey[ois_question]['answers'])
1717 ois_answer int unsigned NULL,
18 -
 18+
1919 -- Optional text associated with the answer
2020 ois_answer_data text NULL
2121 ) /*$wgDBTableOptions*/;
2222
23 -CREATE UNIQUE INDEX /*i*/ois_user_timestamp_question ON /*_*/optin_survey (ois_user, ois_timestamp, ois_question);
 23+CREATE UNIQUE INDEX /*i*/ois_user_timestamp_question ON /*_*/optin_survey (ois_user, ois_timestamp, ois_question);
Index: trunk/extensions/UsabilityInitiative/OptIn/OptIn.i18n.php
@@ -17,11 +17,14 @@
1818 'optin-title' => 'Usability Intitiative enhancements',
1919 'optin-needlogin' => 'You need to [$1 log in] to opt-in to the Usability Initiative\'s usability enhancements.',
2020 'optin-intro' => 'The Wikipedia Usability Initiative has developed a new skin and a new edit toolbar intended to enhance the usability of Wikipedia. These enhancements have not been enabled for all users yet, but you can opt-in to them by clicking the button below.',
21 - 'optin-success-in' => 'You have successfully opted in to the Usability Initiative\'s usability enhancements. You can opt back out at any time by clicking the button below.',
22 - 'optin-success-out' => 'You have successfully opted out of the Usability Initiative\'s usability enhancements. You can opt back in at any time by clicking the button below.',
 21+ 'optin-success-in' => 'You have successfully opted in to the Usability Initiative\'s usability enhancements.
 22+You can opt back out at any time by clicking the button below.',
 23+ 'optin-success-out' => 'You have successfully opted out of the Usability Initiative\'s usability enhancements.
 24+You can opt back in at any time by clicking the button below.',
2325 'optin-submit-in' => 'Opt in',
2426 'optin-submit-out' => 'Opt out',
25 - 'optin-survey-intro' => "Thank you for trying the Usability Initiative's usability enhancements. You can opt out by clicking the button at the bottom of this page.\n\nWe'd like to know what you think about our new interface, so we'd appreciate it if you filled out the optional survey below before clicking the Opt out button.",
 27+ 'optin-survey-intro' => "Thank you for trying the Usability Initiative's usability enhancements.
 28+You can opt out by clicking the button at the bottom of this page.\n\nWe'd like to know what you think about our new interface, so we'd appreciate it if you filled out the optional survey below before clicking the Opt out button.",
2629 'optin-survey-question-whyoptout' => 'Why are you opting out of this interface?',
2730 'optin-survey-answer-whyoptout-didntlike' => 'I do not like the design.',
2831 'optin-survey-answer-whyoptout-hard' => 'It was too hard to edit an article or a discussion page.',
Index: trunk/extensions/UsabilityInitiative/PrefStats/PrefStats.i18n.php
@@ -15,7 +15,8 @@
1616 'prefstats' => 'Preference statistics',
1717 'prefstats-desc' => 'Track statistics about how many users have certain preferences enabled',
1818 'prefstats-title' => 'Preference statistics',
19 - 'prefstats-list-intro' => 'Currently, the following preferences are being tracked. Click on one to view statistics about it.',
 19+ 'prefstats-list-intro' => 'Currently, the following preferences are being tracked.
 20+Click on one to view statistics about it.',
2021 'prefstats-list-elem' => '$1 = $2',
2122 );
2223
Index: trunk/extensions/UsabilityInitiative/PrefStats/PrefStats.php
@@ -29,7 +29,7 @@
3030 $wgPrefStatsChartDimensions = '1000x300';
3131
3232 // Time unit to use for the graph on Special:PrefStats
33 -$wgPrefStatsTimeUnit = 60*60*24; // one day
 33+$wgPrefStatsTimeUnit = 60 * 60 * 24; // one day
3434
3535 /* Setup */
3636
@@ -47,7 +47,7 @@
4848 $wgAutoloadClasses['PrefStatsHooks'] =
4949 dirname( __FILE__ ) . '/PrefStats.hooks.php';
5050 $wgAutoloadClasses['SpecialPrefStats'] =
51 - dirname( __FILE__ ). '/SpecialPrefStats.php';
 51+ dirname( __FILE__ ) . '/SpecialPrefStats.php';
5252
5353 $wgSpecialPages['PrefStats'] = 'SpecialPrefStats';
5454
@@ -55,7 +55,7 @@
5656 $wgExtensionMessagesFiles['PrefStats'] =
5757 dirname( __FILE__ ) . '/PrefStats.i18n.php';
5858 $wgExtensionAliasesFiles['PrefStats'] =
59 - dirname( __FILE__ ). '/PrefStats.alias.php';
 59+ dirname( __FILE__ ) . '/PrefStats.alias.php';
6060
6161 // Registers Hooks
6262 $wgHooks['LoadExtensionSchemaUpdates'][] = 'PrefStatsHooks::schema';
Index: trunk/extensions/UsabilityInitiative/PrefStats/SpecialPrefStats.php
@@ -11,27 +11,27 @@
1212 parent::__construct( 'PrefStats', 'prefstats' );
1313 wfLoadExtensionMessages( 'PrefStats' );
1414 }
15 -
 15+
1616 function execute( $par ) {
1717 global $wgRequest, $wgOut, $wgUser, $wgPrefStatsTrackPrefs;
1818 $this->setHeaders();
19 -
 19+
2020 // Check permissions
2121 if ( !$this->userCanExecute( $wgUser ) ) {
2222 $this->displayRestrictionError();
2323 return;
2424 }
25 -
 25+
2626 $wgOut->setPageTitle( wfMsg( 'prefstats-title' ) );
27 -
28 - if( !isset( $wgPrefStatsTrackPrefs[$par] ) ) {
 27+
 28+ if ( !isset( $wgPrefStatsTrackPrefs[$par] ) ) {
2929 $this->displayTrackedPrefs();
3030 return;
3131 }
32 -
 32+
3333 $this->displayPrefStats( $par );
3434 }
35 -
 35+
3636 function displayTrackedPrefs() {
3737 global $wgOut, $wgUser, $wgPrefStatsTrackPrefs;
3838 $wgOut->addWikiMsg( 'prefstats-list-intro' );
@@ -45,7 +45,7 @@
4646 }
4747 $wgOut->addHTML( Xml::closeElement( 'ul' ) );
4848 }
49 -
 49+
5050 function displayPrefStats( $pref ) {
5151 global $wgOut, $wgRequest, $wgPrefStatsTrackPrefs;
5252 $max = $this->getMaxDuration( $pref );
@@ -54,10 +54,10 @@
5555 $wgOut->addHTML( Xml::element( 'img', array( 'src' =>
5656 $this->getGoogleChartParams( $stats ) ) ) );
5757 }
58 -
 58+
5959 function getGoogleChartParams( $stats ) {
6060 global $wgPrefStatsChartDimensions;
61 - return "http://chart.apis.google.com/chart?" . wfArrayToCGI(
 61+ return "http://chart.apis.google.com/chart?" . wfArrayToCGI(
6262 array(
6363 'chs' => $wgPrefStatsChartDimensions,
6464 'cht' => 'bvs',
@@ -65,18 +65,18 @@
6666 'chd' => 't:' . implode( ',', $stats ),
6767 'chxt' => 'x,y',
6868 'chxr' => '1,' . min( $stats ) . ',' . max( $stats ),
69 - 'chxl' => '0:|'. implode( '|', array_keys( $stats ) ),
70 - 'chm' => 'N*f0zy*,000000,0,-1,11'
 69+ 'chxl' => '0:|' . implode( '|', array_keys( $stats ) ),
 70+ 'chm' => 'N*f0zy*,000000,0,-1,11'
7171 ) );
7272 }
73 -
 73+
7474 function getPrefStats( $pref, $inc = null ) {
7575 global $wgPrefStatsTimeUnit;
7676 $max = ceil( $this->getMaxDuration( $pref ) /
7777 $wgPrefStatsTimeUnit );
7878 $inc = max( 1, ( is_null( $inc ) ? ceil( $max / 10 ) : $inc ) );
7979 $retval = array();
80 - for( $i = 0; $i <= $max; $i += $inc ) {
 80+ for ( $i = 0; $i <= $max; $i += $inc ) {
8181 $end = min( $max, $i + $inc );
8282 $key = $i . '-' . $end;
8383 $retval[$key] = $this->countBetween( $pref,
@@ -85,7 +85,7 @@
8686 }
8787 return $retval;
8888 }
89 -
 89+
9090 /**
9191 * Get the highest duration in the database
9292 */
@@ -99,7 +99,7 @@
100100 $max2 = wfTimestamp( TS_UNIX ) - wfTimestamp( TS_UNIX, $minTS );
101101 return max( $max1, $max2 );
102102 }
103 -
 103+
104104 /**
105105 * Count the number of users having $pref enabled between
106106 * $min and $max seconds
Index: trunk/extensions/UsabilityInitiative/PrefStats/PrefStats.hooks.php
@@ -29,7 +29,7 @@
3030 'ps_pref' => $pref,
3131 'ps_end IS NULL'
3232 ), __METHOD__ );
33 - if ( isset( $options[$pref] ) && $options[$pref] == $value && !$start)
 33+ if ( isset( $options[$pref] ) && $options[$pref] == $value && !$start )
3434 $dbw->insert( 'prefstats', array(
3535 'ps_user' => $user->getId(),
3636 'ps_pref' => $pref,
@@ -55,5 +55,4 @@
5656 }
5757 return true;
5858 }
59 -
6059 }
Index: trunk/extensions/UsabilityInitiative/PrefStats/PrefStats.alias.php
@@ -5,9 +5,9 @@
66 * @file
77 * @ingroup Extensions
88 */
9 -
 9+
1010 $aliases = array();
11 -
 11+
1212 $aliases['en'] = array(
1313 'PrefStats' => array( 'PrefStats' ),
1414 );
Index: trunk/extensions/UsabilityInitiative/PrefStats/PrefStats.sql
@@ -5,19 +5,19 @@
66 CREATE TABLE IF NOT EXISTS /*_*/prefstats (
77 -- User ID
88 ps_user int NOT NULL,
9 -
 9+
1010 -- Preference name
1111 ps_pref varbinary(32) NOT NULL,
12 -
 12+
1313 -- Preference value
1414 ps_value blob NOT NULL,
15 -
 15+
1616 -- Timestamp the user enabled the preference
1717 ps_start binary(14) NOT NULL,
18 -
 18+
1919 -- Timestamp the user disabled the preference, or NULL if still enabled
2020 ps_end binary(14) NULL,
21 -
 21+
2222 -- Number of seconds the user had the preference enabled,
2323 -- or 0 if still enabled
2424 ps_duration int unsigned
Index: trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.i18n.php
@@ -14,4 +14,4 @@
1515 $messages['en'] = array(
1616 'navigabletoc' => 'Navigable table of contents',
1717 'navigabletoc-desc' => 'Adds a table of contents to the edit form that scrolls the text box when a section is clicked.',
18 -);
\ No newline at end of file
 18+);
Index: trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.hooks.php
@@ -9,12 +9,12 @@
1010 class NavigableTOCHooks {
1111
1212 /* Static Functions */
13 -
 13+
1414 /**
1515 * EditPage::showEditForm::initial hook
1616 * Adds the TOC to the edit form
1717 */
18 - public static function addTOC(&$ep) {
 18+ public static function addTOC( &$ep ) {
1919 global $wgNavigableTOCStyleVersion, $wgParser, $wgUser;
2020 global $wgUseParserCache;
2121
@@ -22,34 +22,34 @@
2323 UsabilityInitiativeHooks::addScript(
2424 'NavigableTOC/NavigableTOC.js', $wgNavigableTOCStyleVersion
2525 );
26 -
 26+
2727 // Try the parser cache first
2828 $pcache = ParserCache::singleton();
2929 $articleObj = new Article( $ep->mTitle );
3030 $p_result = $pcache->get( $articleObj, $wgUser );
3131 if ( !$p_result )
3232 {
33 - $p_result = $wgParser->parse( $articleObj->getContent(), $ep->mTitle, new ParserOptions());
34 - if( $wgUseParserCache )
 33+ $p_result = $wgParser->parse( $articleObj->getContent(), $ep->mTitle, new ParserOptions() );
 34+ if ( $wgUseParserCache )
3535 $pcache->save( $p_result, $articleObj, $popts );
3636 } else {
3737 // The ParserOutput in cache could be too old to have
3838 // byte offsets. In that case, reparse
3939 $sections = $p_result->getSections();
4040 if ( isset( $sections[0] ) && !isset( $sections[0]['byteoffset'] ) ) {
41 - $p_result = $wgParser->parse( $articleObj->getContent(), $ep->mTitle, new ParserOptions());
42 - if( $wgUseParserCache )
 41+ $p_result = $wgParser->parse( $articleObj->getContent(), $ep->mTitle, new ParserOptions() );
 42+ if ( $wgUseParserCache )
4343 $pcache->save( $p_result, $articleObj, $popts );
4444 }
4545 }
46 -
 46+
4747 $js = "\$.sectionOffsets = [";
4848 foreach ( $p_result->getSections() as $section )
4949 if ( !is_null( $section['byteoffset'] ) )
5050 $js .= intval( $section['byteoffset'] ) . ',';
5151 $js .= '];';
5252 $jsTag = Xml::element( 'script', array(), $js );
53 -
 53+
5454 $ep->editFormTextTop .= $p_result->getTOCHTML() . $jsTag;
5555 return true;
5656 }
Index: trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.js
@@ -18,7 +18,7 @@
1919 var width = control.scrollWidth;
2020 return Math.floor(width/8);
2121 }
22 -
 22+
2323 function getCaret(control) {
2424 var caretPos = 0;
2525 // IE Support
@@ -38,16 +38,16 @@
3939 }
4040 return caretPos;
4141 }
42 -
 42+
4343 function getCaretPosition(control) {
4444 var text = control.value.replace(/\r/g, "");
4545 var caret = getCaret(control);
4646 var lineLength = getLineLength(control);
47 -
 47+
4848 var row = 0;
4949 var charInLine = 0;
5050 var lastSpaceInLine = 0;
51 -
 51+
5252 for(i = 0; i < caret; i++) {
5353 charInLine++;
5454 if(text.charAt(i) == " ") {
@@ -60,13 +60,13 @@
6161 if(charInLine > lineLength) {
6262 if(lastSpaceInLine > 0) {
6363 charInLine = charInLine - lastSpaceInLine;
64 -
 64+
6565 lastSpaceInLine = 0;
6666 row++;
6767 }
6868 }
6969 }
70 -
 70+
7171 var nextSpace = 0;
7272 for(j = caret; j < caret + lineLength; j++) {
7373 if(text.charAt(j) == " " || text.charAt(j) == "\n" || caret == text.length) {
@@ -74,16 +74,16 @@
7575 break;
7676 }
7777 }
78 -
 78+
7979 if(nextSpace > lineLength && caret <= lineLength) {
8080 charInLine = caret - lastSpaceInLine;
8181 row++;
8282 }
83 -
84 -
 83+
 84+
8585 return ($.os.name == 'mac' ? 13 : 16)*row;
8686 }
87 -
 87+
8888 // Put the cursor at the desired position
8989 this.focus();
9090 if ( this.selectionStart || this.selectionStart == '0' ) { // Mozilla
@@ -111,6 +111,5 @@
112112 $( '#wpTextbox1' ).scrollToPosition( $(this).data( 'offset' ) );
113113 e.preventDefault();
114114 });
115 -
116 -});
117115
 116+});

Status & tagging log