Index: trunk/extensions/BoardVote/GoToBoardVote_body.php |
— | — | @@ -1,7 +1,8 @@ |
2 | 2 | <?php |
| 3 | +if (!defined('MEDIAWIKI')) { |
| 4 | + die( "Not a valid entry point\n" ); |
| 5 | +} |
3 | 6 | |
4 | | -wfBoardVoteInitMessages(); |
5 | | - |
6 | 7 | class GoToBoardVotePage extends SpecialPage { |
7 | 8 | function __construct() { |
8 | 9 | parent::__construct( "Boardvote" ); |
— | — | @@ -12,12 +13,14 @@ |
13 | 14 | global $wgBoardVoteEditCount, $wgBoardVoteRecentEditCount, $wgBoardVoteCountDate; |
14 | 15 | global $wgBoardVoteRecentFirstCountDate, $wgBoardVoteRecentCountDate; |
15 | 16 | |
| 17 | + wfLoadExtensionMessages( 'BoardVote' ); |
| 18 | + |
16 | 19 | $this->setHeaders(); |
17 | 20 | |
18 | 21 | $centralSessionId = ''; |
19 | 22 | if ( class_exists( 'CentralAuthUser' ) ) { |
20 | 23 | global $wgCentralAuthCookiePrefix; |
21 | | - if ( isset( $wgCentralAuthCookiePrefix ) |
| 24 | + if ( isset( $wgCentralAuthCookiePrefix ) |
22 | 25 | && isset( $_COOKIE[$wgCentralAuthCookiePrefix . 'Session'] ) ) |
23 | 26 | { |
24 | 27 | $centralSessionId = $_COOKIE[$wgCentralAuthCookiePrefix . 'Session']; |
— | — | @@ -48,6 +51,5 @@ |
49 | 52 | $wgLang->timeanddate( $wgBoardVoteRecentCountDate ) |
50 | 53 | ) ); |
51 | 54 | } |
52 | | - |
53 | 55 | } |
54 | 56 | } |
Index: trunk/extensions/BoardVote/BoardVote_body.php |
— | — | @@ -1,17 +1,14 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | if (!defined('MEDIAWIKI')) { |
5 | 4 | die( "Not a valid entry point\n" ); |
6 | 5 | } |
7 | 6 | |
8 | | -wfBoardVoteInitMessages(); |
9 | | - |
10 | 7 | class BoardVotePage extends UnlistedSpecialPage { |
11 | 8 | var $mPosted, $mVotedFor, $mUserDays, $mUserEdits; |
12 | 9 | var $mHasVoted, $mAction, $mUserKey, $mId, $mFinished; |
13 | 10 | var $mDb; |
14 | 11 | |
15 | | - function BoardVotePage() { |
| 12 | + function __construct() { |
16 | 13 | parent::__construct( "Boardvote" ); |
17 | 14 | } |
18 | 15 | |
— | — | @@ -38,8 +35,8 @@ |
39 | 36 | // Necessary on some versions of cURL, others do this by default |
40 | 37 | curl_setopt( $c, CURLOPT_CAINFO, '/etc/ssl/certs/ca-certificates.crt' ); |
41 | 38 | 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 ) . ';' . |
44 | 41 | "centralauth_Session=" . urlencode( $casid ) |
45 | 42 | ); |
46 | 43 | curl_setopt( $c, CURLOPT_FOLLOWLOCATION, true ); |
— | — | @@ -136,6 +133,8 @@ |
137 | 134 | function execute( $par ) { |
138 | 135 | global $wgOut, $wgBoardVoteStartDate, $wgBoardVoteEndDate; |
139 | 136 | |
| 137 | + wfLoadExtensionMessages( 'BoardVote' ); |
| 138 | + |
140 | 139 | $this->init( $par ); |
141 | 140 | $this->setHeaders(); |
142 | 141 | |
— | — | @@ -157,7 +156,7 @@ |
158 | 157 | $wgOut->addWikiText( wfMsg( 'boardvote_blocked' ) ); |
159 | 158 | return; |
160 | 159 | } |
161 | | - |
| 160 | + |
162 | 161 | if ( $this->mBot ) { |
163 | 162 | $wgOut->addWikiText( wfMsg( 'boardvote_bot' ) ); |
164 | 163 | return; |
— | — | @@ -165,7 +164,7 @@ |
166 | 165 | |
167 | 166 | if ( wfTimestampNow() > $wgBoardVoteEndDate ) { |
168 | 167 | $this->mFinished = true; |
169 | | - |
| 168 | + |
170 | 169 | $wgOut->addWikiText( wfMsg( 'boardvote_closed' ) ); |
171 | 170 | } else { |
172 | 171 | $this->mFinished = false; |
— | — | @@ -341,7 +340,7 @@ |
342 | 341 | $wgLang->timeanddate( $wgBoardVoteRecentCountDate ) |
343 | 342 | ) ); |
344 | 343 | } |
345 | | - |
| 344 | + |
346 | 345 | function displayInvalidVoteError() { |
347 | 346 | global $wgOut; |
348 | 347 | $wgOut->addWikiText( wfMsg( "boardvote_invalidentered" ) ); |
— | — | @@ -355,7 +354,7 @@ |
356 | 355 | $cnt = 0; |
357 | 356 | foreach ( $this->mVotedFor as $i => $rank ) { |
358 | 357 | $cnt++; |
359 | | - |
| 358 | + |
360 | 359 | $record .= $wgBoardCandidates[ $i ] . "["; |
361 | 360 | $record .= ( $rank == '' ) ? 100 : $rank; |
362 | 361 | $record .= "]"; |
— | — | @@ -546,7 +545,7 @@ |
547 | 546 | $title = Title::makeTitle( NS_SPECIAL, "Boardvote" ); |
548 | 547 | $wgOut->redirect( $title->getFullURL( "action=list" ) ); |
549 | 548 | } |
550 | | - |
| 549 | + |
551 | 550 | function validVote() { |
552 | 551 | foreach ( $this->mVotedFor as $rank ) { |
553 | 552 | if ( $rank != '' ) { |
— | — | @@ -555,7 +554,7 @@ |
556 | 555 | } |
557 | 556 | } |
558 | 557 | } |
559 | | - |
| 558 | + |
560 | 559 | return true; |
561 | 560 | } |
562 | 561 | } |
Index: trunk/extensions/BoardVote/BoardVote.php |
— | — | @@ -42,16 +42,13 @@ |
43 | 43 | $wgExtensionMessagesFiles['BoardVote'] = $dir . 'BoardVote.i18n.php'; |
44 | 44 | $wgExtensionAliasesFiles['BoardVote'] = $dir . 'BoardVote.alias.php'; |
45 | 45 | |
46 | | -# Register special page |
47 | | -if ( !function_exists( 'extAddSpecialPage' ) ) { |
48 | | - require( dirname(__FILE__) . '/../ExtensionFunctions.php' ); |
49 | | -} |
50 | | - |
51 | 46 | 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'; |
53 | 49 | $wgExtensionFunctions[] = 'wfSetupBoardVote'; |
54 | 50 | } else { |
55 | | - extAddSpecialPage( dirname(__FILE__) . '/GoToBoardVote_body.php', 'Boardvote', 'GoToBoardVotePage' ); |
| 51 | + $wgAutoloadClasses['GoToBoardVotePage'] = $dir . 'GoToBoardVote_body.php'; |
| 52 | + $wgSpecialPages['Boardvote'] = 'GoToBoardVotePage'; |
56 | 53 | } |
57 | 54 | |
58 | 55 | function wfSetupBoardVote() { |
— | — | @@ -63,13 +60,3 @@ |
64 | 61 | $wgLang = Language::factory( $_SESSION['bvLang'] ); |
65 | 62 | } |
66 | 63 | } |
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 | | -} |