r24483 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24482‎ | r24483 | r24484 >
Date:11:46, 31 July 2007
Author:robchurch
Status:old
Tags:
Comment:
File cosmetics; kill some whitespace, update some doc blocks, comment some SQL; move along, nothing to see here...
Modified paths:
  • /trunk/extensions/Vote/Vote.css (modified) (history)
  • /trunk/extensions/Vote/Vote.page.php (modified) (history)
  • /trunk/extensions/Vote/Vote.php (modified) (history)
  • /trunk/extensions/Vote/vote.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/Vote/Vote.php
@@ -57,5 +57,4 @@
5858 } else {
5959 echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
6060 exit( 1 ) ;
61 -}
62 -
 61+}
\ No newline at end of file
Index: trunk/extensions/Vote/Vote.css
@@ -1,12 +1,11 @@
22 /**
33 * CSS file for the Vote extension
44 *
5 - * @package MediaWiki
6 - * @subpackage Extensions
 5+ * @addtogroup Extensions
76 * @author Rob Church <robchur@gmail.com>
 7+ *
88 * Please see the LICENCE file for terms of use and redistribution
99 */
10 -
1110 table.mw-votedata td, th {
1211 padding: 2px;
1312 }
Index: trunk/extensions/Vote/vote.sql
@@ -1,3 +1,4 @@
 2+-- Table for the Vote extension; holds individual votes
23 CREATE TABLE /*wgDBprefix*/vote (
34 vote_id int(11) NOT NULL auto_increment,
45 vote_user int(11) NOT NULL,
Index: trunk/extensions/Vote/Vote.page.php
@@ -5,6 +5,7 @@
66 *
77 * @addtogroup Extensions
88 * @author Rob Church <robchur@gmail.com>
 9+ *
910 * Please see the LICENCE file for terms of use and redistribution
1011 */
1112
@@ -19,13 +20,13 @@
2021 public function execute( $mode = false ) {
2122 global $wgOut, $wgUser;
2223 $this->setHeaders();
23 - $this->user =& $wgUser;
 24+ $this->user = $wgUser;
2425 if( strtolower( $mode ) == 'results' ) {
2526 if( $wgUser->isAllowed( 'voteadmin' ) )
2627 $this->showResults();
2728 } else {
2829 if( $wgUser->isAnon() ) {
29 - $skin =& $wgUser->getSkin();
 30+ $skin = $wgUser->getSkin();
3031 $self = SpecialPage::getTitleFor( 'Vote' );
3132 $login = SpecialPage::getTitleFor( 'Userlogin' );
3233 $link = $skin->makeKnownLinkObj( $login, wfMsgHtml( 'vote-login-link' ), 'returnto=' . $self->getPrefixedUrl() );
@@ -45,7 +46,7 @@
4647 $self = SpecialPage::getTitleFor( 'Vote' );
4748 $token = $wgRequest->getText( 'token' );
4849 if( $wgUser->isAllowed( 'voteadmin' ) ) {
49 - $skin =& $wgUser->getSkin();
 50+ $skin = $wgUser->getSkin();
5051 $rtitle = Title::makeTitle( NS_SPECIAL, $self->getText() . '/results' );
5152 $rlink = $skin->makeKnownLinkObj( $rtitle, wfMsgHtml( 'vote-view-results' ) );
5253 $wgOut->addHtml( '<p class="mw-voteresultslink">' . $rlink . '</p>' );
@@ -69,14 +70,14 @@
7071 }
7172 }
7273
73 - private static function getExistingVote( &$user ) {
74 - $dbr =& wfGetDB( DB_SLAVE );
 74+ private static function getExistingVote( $user ) {
 75+ $dbr = wfGetDB( DB_SLAVE );
7576 $choice = $dbr->selectField( 'vote', 'vote_choice', array( 'vote_user' => $user->getId() ), __METHOD__ );
7677 return $choice;
7778 }
7879
79 - private static function updateVote( &$user, $choice ) {
80 - $dbw =& wfGetDB( DB_MASTER );
 80+ private static function updateVote( $user, $choice ) {
 81+ $dbw = wfGetDB( DB_MASTER );
8182 $dbw->begin();
8283 $dbw->delete( 'vote', array( 'vote_user' => $user->getId() ), __METHOD__ );
8384 $dbw->insert( 'vote', array( 'vote_user' => $user->getId(), 'vote_choice' => $choice ), __METHOD__ );
@@ -86,7 +87,7 @@
8788 private function showResults() {
8889 global $wgOut, $wgLang;
8990 $wgOut->setPageTitle( wfMsg( 'vote-results' ) );
90 - $dbr =& wfGetDB( DB_SLAVE );
 91+ $dbr = wfGetDB( DB_SLAVE );
9192 $vote = $dbr->tableName( 'vote' );
9293 $res = $dbr->query( "SELECT vote_choice, COUNT(*) as count FROM {$vote} GROUP BY vote_choice ORDER BY count DESC", __METHOD__ );
9394 if( $res && $dbr->numRows( $res ) > 0 ) {
@@ -147,5 +148,4 @@
148149 return Xml::openElement( 'option', $attribs ) . htmlspecialchars( $label ) . Xml::closeElement( 'option' );
149150 }
150151
151 -}
152 -
 152+}
\ No newline at end of file

Status & tagging log