r39423 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39422‎ | r39423 | r39424 >
Date:18:48, 15 August 2008
Author:siebrand
Status:old
Tags:
Comment:
* remove dependency on ExtensionFunctions.php
* add $wgExtensionAliasesFiles
* minor changes for consistency with other extensions
* delayed message loading (and wfBoardVoteInitMessages())
* remove some obsolete, commented out code
* EOL whitespace fixes
Modified paths:
  • /trunk/extensions/BoardVote/BoardVote.php (modified) (history)
  • /trunk/extensions/BoardVote/BoardVote_body.php (modified) (history)
  • /trunk/extensions/BoardVote/GoToBoardVote_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/BoardVote/GoToBoardVote_body.php
@@ -1,7 +1,8 @@
22 <?php
 3+if (!defined('MEDIAWIKI')) {
 4+ die( "Not a valid entry point\n" );
 5+}
36
4 -wfBoardVoteInitMessages();
5 -
67 class GoToBoardVotePage extends SpecialPage {
78 function __construct() {
89 parent::__construct( "Boardvote" );
@@ -12,12 +13,14 @@
1314 global $wgBoardVoteEditCount, $wgBoardVoteRecentEditCount, $wgBoardVoteCountDate;
1415 global $wgBoardVoteRecentFirstCountDate, $wgBoardVoteRecentCountDate;
1516
 17+ wfLoadExtensionMessages( 'BoardVote' );
 18+
1619 $this->setHeaders();
1720
1821 $centralSessionId = '';
1922 if ( class_exists( 'CentralAuthUser' ) ) {
2023 global $wgCentralAuthCookiePrefix;
21 - if ( isset( $wgCentralAuthCookiePrefix )
 24+ if ( isset( $wgCentralAuthCookiePrefix )
2225 && isset( $_COOKIE[$wgCentralAuthCookiePrefix . 'Session'] ) )
2326 {
2427 $centralSessionId = $_COOKIE[$wgCentralAuthCookiePrefix . 'Session'];
@@ -48,6 +51,5 @@
4952 $wgLang->timeanddate( $wgBoardVoteRecentCountDate )
5053 ) );
5154 }
52 -
5355 }
5456 }
Index: trunk/extensions/BoardVote/BoardVote_body.php
@@ -1,17 +1,14 @@
22 <?php
3 -
43 if (!defined('MEDIAWIKI')) {
54 die( "Not a valid entry point\n" );
65 }
76
8 -wfBoardVoteInitMessages();
9 -
107 class BoardVotePage extends UnlistedSpecialPage {
118 var $mPosted, $mVotedFor, $mUserDays, $mUserEdits;
129 var $mHasVoted, $mAction, $mUserKey, $mId, $mFinished;
1310 var $mDb;
1411
15 - function BoardVotePage() {
 12+ function __construct() {
1613 parent::__construct( "Boardvote" );
1714 }
1815
@@ -38,8 +35,8 @@
3936 // Necessary on some versions of cURL, others do this by default
4037 curl_setopt( $c, CURLOPT_CAINFO, '/etc/ssl/certs/ca-certificates.crt' );
4138 curl_setopt( $c, CURLOPT_RETURNTRANSFER, true );
42 - curl_setopt( $c, CURLOPT_COOKIE,
43 - "{$db}_session=" . urlencode( $sid ) . ';' .
 39+ curl_setopt( $c, CURLOPT_COOKIE,
 40+ "{$db}_session=" . urlencode( $sid ) . ';' .
4441 "centralauth_Session=" . urlencode( $casid )
4542 );
4643 curl_setopt( $c, CURLOPT_FOLLOWLOCATION, true );
@@ -136,6 +133,8 @@
137134 function execute( $par ) {
138135 global $wgOut, $wgBoardVoteStartDate, $wgBoardVoteEndDate;
139136
 137+ wfLoadExtensionMessages( 'BoardVote' );
 138+
140139 $this->init( $par );
141140 $this->setHeaders();
142141
@@ -157,7 +156,7 @@
158157 $wgOut->addWikiText( wfMsg( 'boardvote_blocked' ) );
159158 return;
160159 }
161 -
 160+
162161 if ( $this->mBot ) {
163162 $wgOut->addWikiText( wfMsg( 'boardvote_bot' ) );
164163 return;
@@ -165,7 +164,7 @@
166165
167166 if ( wfTimestampNow() > $wgBoardVoteEndDate ) {
168167 $this->mFinished = true;
169 -
 168+
170169 $wgOut->addWikiText( wfMsg( 'boardvote_closed' ) );
171170 } else {
172171 $this->mFinished = false;
@@ -341,7 +340,7 @@
342341 $wgLang->timeanddate( $wgBoardVoteRecentCountDate )
343342 ) );
344343 }
345 -
 344+
346345 function displayInvalidVoteError() {
347346 global $wgOut;
348347 $wgOut->addWikiText( wfMsg( "boardvote_invalidentered" ) );
@@ -355,7 +354,7 @@
356355 $cnt = 0;
357356 foreach ( $this->mVotedFor as $i => $rank ) {
358357 $cnt++;
359 -
 358+
360359 $record .= $wgBoardCandidates[ $i ] . "[";
361360 $record .= ( $rank == '' ) ? 100 : $rank;
362361 $record .= "]";
@@ -546,7 +545,7 @@
547546 $title = Title::makeTitle( NS_SPECIAL, "Boardvote" );
548547 $wgOut->redirect( $title->getFullURL( "action=list" ) );
549548 }
550 -
 549+
551550 function validVote() {
552551 foreach ( $this->mVotedFor as $rank ) {
553552 if ( $rank != '' ) {
@@ -555,7 +554,7 @@
556555 }
557556 }
558557 }
559 -
 558+
560559 return true;
561560 }
562561 }
Index: trunk/extensions/BoardVote/BoardVote.php
@@ -42,16 +42,13 @@
4343 $wgExtensionMessagesFiles['BoardVote'] = $dir . 'BoardVote.i18n.php';
4444 $wgExtensionAliasesFiles['BoardVote'] = $dir . 'BoardVote.alias.php';
4545
46 -# Register special page
47 -if ( !function_exists( 'extAddSpecialPage' ) ) {
48 - require( dirname(__FILE__) . '/../ExtensionFunctions.php' );
49 -}
50 -
5146 if ( !defined( 'BOARDVOTE_REDIRECT_ONLY' ) ) {
52 - extAddSpecialPage( dirname(__FILE__) . '/BoardVote_body.php', 'Boardvote', 'BoardVotePage' );
 47+ $wgAutoloadClasses['BoardVotePage'] = $dir . 'BoardVote_body.php';
 48+ $wgSpecialPages['Boardvote'] = 'BoardVotePage';
5349 $wgExtensionFunctions[] = 'wfSetupBoardVote';
5450 } else {
55 - extAddSpecialPage( dirname(__FILE__) . '/GoToBoardVote_body.php', 'Boardvote', 'GoToBoardVotePage' );
 51+ $wgAutoloadClasses['GoToBoardVotePage'] = $dir . 'GoToBoardVote_body.php';
 52+ $wgSpecialPages['Boardvote'] = 'GoToBoardVotePage';
5653 }
5754
5855 function wfSetupBoardVote() {
@@ -63,13 +60,3 @@
6461 $wgLang = Language::factory( $_SESSION['bvLang'] );
6562 }
6663 }
67 -
68 -function wfBoardVoteInitMessages() {
69 - static $done = false;
70 - if ( $done ) return true;
71 -
72 - $done = true;
73 - wfLoadExtensionMessages( 'BoardVote' );
74 -
75 - return true;
76 -}

Status & tagging log