Index: trunk/extensions/VoteNY/Vote_AjaxFunctions.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | */ |
6 | 6 | $wgAjaxExportList[] = 'wfVoteClick'; |
7 | 7 | |
8 | | -function wfVoteClick( $voteValue, $pageId, $mk ) { |
| 8 | +function wfVoteClick( $voteValue, $pageId ) { |
9 | 9 | global $wgUser; |
10 | 10 | |
11 | 11 | if ( !$wgUser->isAllowed( 'vote' ) ) { |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | } |
24 | 24 | |
25 | 25 | $wgAjaxExportList[] = 'wfVoteDelete'; |
26 | | -function wfVoteDelete( $pageId, $mk ) { |
| 26 | +function wfVoteDelete( $pageId ) { |
27 | 27 | global $wgUser; |
28 | 28 | |
29 | 29 | if ( !$wgUser->isAllowed( 'vote' ) ) { |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | } |
42 | 42 | |
43 | 43 | $wgAjaxExportList[] = 'wfVoteStars'; |
44 | | -function wfVoteStars( $voteValue, $pageId, $mk ) { |
| 44 | +function wfVoteStars( $voteValue, $pageId ) { |
45 | 45 | global $wgUser; |
46 | 46 | |
47 | 47 | if ( !$wgUser->isAllowed( 'vote' ) ) { |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | } |
59 | 59 | |
60 | 60 | $wgAjaxExportList[] = 'wfVoteStarsMulti'; |
61 | | -function wfVoteStarsMulti( $voteValue, $pageId, $mk ) { |
| 61 | +function wfVoteStarsMulti( $voteValue, $pageId ) { |
62 | 62 | global $wgUser; |
63 | 63 | |
64 | 64 | if ( !$wgUser->isAllowed( 'vote' ) ) { |
Index: trunk/extensions/VoteNY/SpecialTopRatings.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | * |
11 | 11 | * @file |
12 | 12 | * @ingroup Extensions |
13 | | - * @date 21 August 2011 |
| 13 | + * @date 11 December 2011 |
14 | 14 | * @license To the extent that it is possible, this code is in the public domain |
15 | 15 | */ |
16 | 16 | class SpecialTopRatings extends IncludableSpecialPage { |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | * @param $par Mixed: parameter passed to the special page or null |
29 | 29 | */ |
30 | 30 | public function execute( $par ) { |
31 | | - global $wgOut, $wgScriptPath, $wgUser; |
| 31 | + global $wgOut, $wgScriptPath; |
32 | 32 | |
33 | 33 | // Set the page title, robot policies, etc. |
34 | 34 | $this->setHeaders(); |
— | — | @@ -49,13 +49,12 @@ |
50 | 50 | $limit = 50; |
51 | 51 | } |
52 | 52 | |
53 | | - // Add JS -- needed so that users can vote on this page and so that |
54 | | - // their browsers' consoles won't be filled with JS errors ;-) |
55 | | - $wgOut->addScriptFile( $wgScriptPath . '/extensions/VoteNY/Vote.js' ); |
| 53 | + // Add JS (and CSS) -- needed so that users can vote on this page and |
| 54 | + // so that their browsers' consoles won't be filled with JS errors ;-) |
| 55 | + $wgOut->addModules( 'ext.voteNY' ); |
56 | 56 | |
57 | 57 | $ratings = array(); |
58 | 58 | $output = ''; |
59 | | - $sk = $wgUser->getSkin(); |
60 | 59 | |
61 | 60 | $dbr = wfGetDB( DB_SLAVE ); |
62 | 61 | $tables = $where = $joinConds = array(); |
— | — | @@ -124,7 +123,7 @@ |
125 | 124 | |
126 | 125 | $vote = new VoteStars( $pageId ); |
127 | 126 | $output .= '<div class="user-list-rating">' . |
128 | | - $sk->link( |
| 127 | + Linker::link( |
129 | 128 | $titleObj, |
130 | 129 | $titleObj->getPrefixedText() // prefixed, so that the namespace shows! |
131 | 130 | ) . wfMsg( 'word-separator' ) . // i18n overkill? ya betcha... |
Index: trunk/extensions/VoteNY/Vote.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * |
6 | 6 | * @file |
7 | 7 | * @ingroup Extensions |
8 | | - * @version 2.3.3 |
| 8 | + * @version 2.4 |
9 | 9 | * @author Aaron Wright <aaron.wright@gmail.com> |
10 | 10 | * @author David Pean <david.pean@gmail.com> |
11 | 11 | * @author Jack Phoenix <jack@countervandalism.net> |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | // Extension credits that show up on Special:Version |
25 | 25 | $wgExtensionCredits['parserhook'][] = array( |
26 | 26 | 'name' => 'Vote', |
27 | | - 'version' => '2.3.3', |
| 27 | + 'version' => '2.4', |
28 | 28 | 'author' => array( 'Aaron Wright', 'David Pean', 'Jack Phoenix' ), |
29 | 29 | 'description' => 'JavaScript-based voting with the <tt><vote></tt> tag', |
30 | 30 | 'url' => 'https://www.mediawiki.org/wiki/Extension:VoteNY' |
— | — | @@ -55,7 +55,6 @@ |
56 | 56 | $wgAutoloadClasses['VoteHooks'] = $dir . 'VoteHooks.php'; |
57 | 57 | |
58 | 58 | $wgHooks['ParserFirstCallInit'][] = 'VoteHooks::registerParserHook'; |
59 | | -$wgHooks['MakeGlobalVariablesScript'][] = 'VoteHooks::addJSGlobalVariables'; |
60 | 59 | $wgHooks['RenameUserSQL'][] = 'VoteHooks::onUserRename'; |
61 | 60 | // Translations for {{NUMBEROFVOTES}} |
62 | 61 | //$wgExtensionMessagesFiles['NumberOfVotes'] = $dir . 'Vote.i18n.magic.php'; |
Index: trunk/extensions/VoteNY/VoteHooks.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | * @return String: HTML |
29 | 29 | */ |
30 | 30 | public static function renderVote( $input, $args, $parser ) { |
31 | | - global $wgOut, $wgTitle, $wgScriptPath; |
| 31 | + global $wgOut; |
32 | 32 | |
33 | 33 | wfProfileIn( __METHOD__ ); |
34 | 34 | |
— | — | @@ -39,12 +39,7 @@ |
40 | 40 | // Add CSS & JS |
41 | 41 | // In order for us to do this *here* instead of having to do this in |
42 | 42 | // registerParserHook(), we must've disabled parser cache |
43 | | - if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { |
44 | | - $wgOut->addModules( 'ext.voteNY' ); |
45 | | - } else { |
46 | | - $wgOut->addScriptFile( $wgScriptPath . '/extensions/VoteNY/Vote.js' ); |
47 | | - $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/VoteNY/Vote.css' ); |
48 | | - } |
| 43 | + $wgOut->addModules( 'ext.voteNY' ); |
49 | 44 | |
50 | 45 | // Define variable - 0 means that we'll get that green voting box by default |
51 | 46 | $type = 0; |
— | — | @@ -56,7 +51,7 @@ |
57 | 52 | $type = intval( $args['type'] ); |
58 | 53 | } |
59 | 54 | |
60 | | - $articleID = $wgTitle->getArticleID(); |
| 55 | + $articleID = $wgOut->getTitle()->getArticleID(); |
61 | 56 | switch( $type ) { |
62 | 57 | case 0: |
63 | 58 | $vote = new Vote( $articleID ); |
— | — | @@ -76,18 +71,6 @@ |
77 | 72 | } |
78 | 73 | |
79 | 74 | /** |
80 | | - * Adds required JS variables to the HTML output. |
81 | | - * |
82 | | - * @param $vars Array: array of pre-existing JS globals |
83 | | - * @return Boolean: true |
84 | | - */ |
85 | | - public static function addJSGlobalVariables( $vars ) { |
86 | | - $vars['_VOTE_LINK'] = wfMsg( 'vote-link' ); |
87 | | - $vars['_UNVOTE_LINK'] = wfMsg( 'vote-unvote-link' ); |
88 | | - return true; |
89 | | - } |
90 | | - |
91 | | - /** |
92 | 75 | * For the Renameuser extension. |
93 | 76 | * |
94 | 77 | * @param $renameUserSQL |
— | — | @@ -172,18 +155,13 @@ |
173 | 156 | * Creates the necessary database table when the user runs |
174 | 157 | * maintenance/update.php. |
175 | 158 | * |
176 | | - * @param $updater Object: instance of DatabaseUpdater |
| 159 | + * @param $updater DatabaseUpdater |
177 | 160 | * @return Boolean: true |
178 | 161 | */ |
179 | | - public static function addTable( $updater = null ) { |
| 162 | + public static function addTable( $updater ) { |
180 | 163 | $dir = dirname( __FILE__ ); |
181 | 164 | $file = "$dir/vote.sql"; |
182 | | - if ( $updater === null ) { |
183 | | - global $wgExtNewTables; |
184 | | - $wgExtNewTables[] = array( 'Vote', $file ); |
185 | | - } else { |
186 | | - $updater->addExtensionUpdate( array( 'addTable', 'Vote', $file, true ) ); |
187 | | - } |
| 165 | + $updater->addExtensionUpdate( array( 'addTable', 'Vote', $file, true ) ); |
188 | 166 | return true; |
189 | 167 | } |
190 | 168 | } |
\ No newline at end of file |
Index: trunk/extensions/VoteNY/Vote.js |
— | — | @@ -4,11 +4,11 @@ |
5 | 5 | * @file |
6 | 6 | * @ingroup Extensions |
7 | 7 | * @author Jack Phoenix <jack@countervandalism.net> |
8 | | - * @date 19 June 2011 |
| 8 | + * @date 4 January 2012 |
9 | 9 | */ |
10 | 10 | var VoteNY = { |
11 | 11 | MaxRating: 5, |
12 | | - clearRatingTimer: '', |
| 12 | + clearRatingTimer: null, |
13 | 13 | voted_new: [], |
14 | 14 | id: 0, |
15 | 15 | last_id: 0, |
— | — | @@ -16,57 +16,46 @@ |
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Called when voting through the green square voting box |
| 20 | + * |
20 | 21 | * @param TheVote |
21 | 22 | * @param PageID Integer: internal ID number of the current article |
22 | | - * @param mk Mixed: random token |
23 | 23 | */ |
24 | | - clickVote: function( TheVote, PageID, mk ) { |
| 24 | + clickVote: function( TheVote, PageID ) { |
25 | 25 | sajax_request_type = 'POST'; |
26 | | - sajax_do_call( 'wfVoteClick', [ TheVote, PageID, mk ], function( request ) { |
| 26 | + sajax_do_call( 'wfVoteClick', [ TheVote, PageID ], function( request ) { |
27 | 27 | document.getElementById( 'votebox' ).style.cursor = 'default'; |
28 | 28 | document.getElementById( 'PollVotes' ).innerHTML = request.responseText; |
29 | | - var unvoteMessage; |
30 | | - if ( typeof( mediaWiki ) == 'undefined' ) { |
31 | | - unvoteMessage = _UNVOTE_LINK; |
32 | | - } else { |
33 | | - unvoteMessage = mediaWiki.msg( 'vote-unvote-link' ); |
34 | | - } |
35 | 29 | document.getElementById( 'Answer' ).innerHTML = |
36 | | - "<a href=javascript:VoteNY.unVote(" + PageID + ",'" + mk + |
37 | | - "')>" + unvoteMessage + '</a>'; |
| 30 | + '<a href="javascript:void(0);" class="vote-unvote-link">' + |
| 31 | + mediaWiki.msg( 'vote-unvote-link' ) + '</a>'; |
38 | 32 | } ); |
39 | 33 | }, |
40 | 34 | |
41 | 35 | /** |
42 | 36 | * Called when removing your vote through the green square voting box |
| 37 | + * |
43 | 38 | * @param PageID Integer: internal ID number of the current article |
44 | 39 | * @param mk Mixed: random token |
45 | 40 | */ |
46 | | - unVote: function( PageID, mk ) { |
| 41 | + unVote: function( PageID ) { |
47 | 42 | sajax_request_type = 'POST'; |
48 | | - sajax_do_call( 'wfVoteDelete', [ PageID, mk ], function( request ) { |
| 43 | + sajax_do_call( 'wfVoteDelete', [ PageID ], function( request ) { |
49 | 44 | document.getElementById( 'votebox' ).style.cursor = 'pointer'; |
50 | 45 | document.getElementById( 'PollVotes' ).innerHTML = request.responseText; |
51 | | - var voteMessage; |
52 | | - if ( typeof( mediaWiki ) == 'undefined' ) { |
53 | | - voteMessage = _VOTE_LINK; |
54 | | - } else { |
55 | | - voteMessage = mediaWiki.msg( 'vote-link' ); |
56 | | - } |
57 | 46 | document.getElementById( 'Answer' ).innerHTML = |
58 | | - '<a href=javascript:VoteNY.clickVote(1,' + PageID + ',"' + mk + |
59 | | - '")>' + voteMessage + '</a>'; |
| 47 | + '<a href="javascript:void(0);" class="vote-vote-link">' + |
| 48 | + mediaWiki.msg( 'vote-link' ) + '</a>'; |
60 | 49 | } ); |
61 | 50 | }, |
62 | 51 | |
63 | 52 | /** |
64 | 53 | * Called when adding a vote after a user has clicked the yellow voting stars |
| 54 | + * |
65 | 55 | * @param PageID Integer: internal ID number of the current article |
66 | | - * @param mk Mixed: random token |
67 | 56 | * @param id Integer: ID of the current rating star |
68 | 57 | * @param action Integer: controls which AJAX function will be called |
69 | 58 | */ |
70 | | - clickVoteStars: function( TheVote, PageID, mk, id, action ) { |
| 59 | + clickVoteStars: function( TheVote, PageID, id, action ) { |
71 | 60 | VoteNY.voted_new[id] = TheVote; |
72 | 61 | var rsfun; |
73 | 62 | if( action == 3 ) { |
— | — | @@ -78,26 +67,25 @@ |
79 | 68 | |
80 | 69 | var resultElement = document.getElementById( 'rating_' + id ); |
81 | 70 | sajax_request_type = 'POST'; |
82 | | - sajax_do_call( rsfun, [ TheVote, PageID, mk ], resultElement ); |
| 71 | + sajax_do_call( rsfun, [ TheVote, PageID ], resultElement ); |
83 | 72 | }, |
84 | 73 | |
85 | 74 | /** |
86 | 75 | * Called when removing your vote through the yellow voting stars |
| 76 | + * |
87 | 77 | * @param PageID Integer: internal ID number of the current article |
88 | | - * @param mk Mixed: random token |
89 | 78 | * @param id Integer: ID of the current rating star |
90 | 79 | */ |
91 | | - unVoteStars: function( PageID, mk, id ) { |
| 80 | + unVoteStars: function( PageID, id ) { |
92 | 81 | var resultElement = document.getElementById( 'rating_' + id ); |
93 | 82 | sajax_request_type = 'POST'; |
94 | | - sajax_do_call( 'wfVoteStarsDelete', [ PageID, mk ], resultElement ); |
| 83 | + sajax_do_call( 'wfVoteStarsDelete', [ PageID ], resultElement ); |
95 | 84 | }, |
96 | 85 | |
97 | 86 | startClearRating: function( id, rating, voted ) { |
98 | | - VoteNY.clearRatingTimer = setTimeout( |
99 | | - "VoteNY.clearRating('" + id + "',0," + rating + ',' + voted + ')', |
100 | | - 200 |
101 | | - ); |
| 87 | + VoteNY.clearRatingTimer = setTimeout( function() { |
| 88 | + VoteNY.clearRating( id, 0, rating, voted ); |
| 89 | + }, 200 ); |
102 | 90 | }, |
103 | 91 | |
104 | 92 | clearRating: function( id, num, prev_rating, voted ) { |
— | — | @@ -133,4 +121,48 @@ |
134 | 122 | } |
135 | 123 | VoteNY.last_id = id; |
136 | 124 | } |
137 | | -}; |
\ No newline at end of file |
| 125 | +}; |
| 126 | + |
| 127 | +jQuery( document ).ready( function() { |
| 128 | + // Green voting box |
| 129 | + jQuery( '#votebox, a.vote-vote-link' ).click( function() { |
| 130 | + VoteNY.clickVote( 1, mw.config.get( 'wgArticleId' ) ); |
| 131 | + } ); |
| 132 | + |
| 133 | + jQuery( 'a.vote-unvote-link' ).click( function() { |
| 134 | + VoteNY.unVote( mw.config.get( 'wgArticleId' ) ); |
| 135 | + } ); |
| 136 | + |
| 137 | + // Rating stars |
| 138 | + jQuery( 'img.vote-rating-star' ).click( function() { |
| 139 | + var that = jQuery( this ); |
| 140 | + VoteNY.clickVoteStars( |
| 141 | + that.data( 'vote-the-vote' ), |
| 142 | + mw.config.get( 'wgArticleId' ), |
| 143 | + that.data( 'vote-id' ), |
| 144 | + that.data( 'vote-action' ) |
| 145 | + ); |
| 146 | + } ).mouseover( function() { |
| 147 | + var that = jQuery( this ); |
| 148 | + VoteNY.updateRating( |
| 149 | + that.data( 'vote-id' ), |
| 150 | + that.data( 'vote-the-vote' ), |
| 151 | + that.data( 'vote-rating' ) |
| 152 | + ); |
| 153 | + } ).mouseout( function() { |
| 154 | + var that = jQuery( this ); |
| 155 | + VoteNY.startClearRating( |
| 156 | + that.data( 'vote-id' ), |
| 157 | + that.data( 'vote-rating' ), |
| 158 | + that.data( 'vote-voted' ) |
| 159 | + ); |
| 160 | + } ); |
| 161 | + |
| 162 | + // Remove vote (rating stars) |
| 163 | + jQuery( 'a.vote-remove-stars-link' ).click( function() { |
| 164 | + VoteNY.unVoteStars( |
| 165 | + mw.config.get( 'wgArticleId' ), |
| 166 | + jQuery( this ).data( 'vote-id' ) |
| 167 | + ); |
| 168 | + } ); |
| 169 | +} ); |
\ No newline at end of file |
Index: trunk/extensions/VoteNY/VoteClass.php |
— | — | @@ -13,6 +13,7 @@ |
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Constructor |
| 17 | + * |
17 | 18 | * @param $pageID Integer: article ID number |
18 | 19 | */ |
19 | 20 | public function __construct( $pageID ) { |
— | — | @@ -26,10 +27,12 @@ |
27 | 28 | /** |
28 | 29 | * Counts all votes, fetching the data from memcached if available |
29 | 30 | * or from the database if memcached isn't available |
| 31 | + * |
30 | 32 | * @return Integer: amount of votes |
31 | 33 | */ |
32 | 34 | function count() { |
33 | 35 | global $wgMemc; |
| 36 | + |
34 | 37 | $key = wfMemcKey( 'vote', 'count', $this->PageID ); |
35 | 38 | $data = $wgMemc->get( $key ); |
36 | 39 | |
— | — | @@ -52,6 +55,7 @@ |
53 | 56 | } |
54 | 57 | $wgMemc->set( $key, $vote_count ); |
55 | 58 | } |
| 59 | + |
56 | 60 | return $vote_count; |
57 | 61 | } |
58 | 62 | |
— | — | @@ -82,6 +86,7 @@ |
83 | 87 | } |
84 | 88 | $wgMemc->set( $key, $voteAvg ); |
85 | 89 | } |
| 90 | + |
86 | 91 | return number_format( $voteAvg, 2 ); |
87 | 92 | } |
88 | 93 | |
— | — | @@ -96,21 +101,22 @@ |
97 | 102 | $wgMemc->delete( wfMemcKey( 'vote', 'avg', $this->PageID ) ); |
98 | 103 | |
99 | 104 | // Purge squid |
100 | | - $page_title = Title::newFromID( $this->PageID ); |
101 | | - if( is_object( $page_title ) ) { |
102 | | - $page_title->invalidateCache(); |
103 | | - $page_title->purgeSquid(); |
| 105 | + $pageTitle = Title::newFromID( $this->PageID ); |
| 106 | + if( is_object( $pageTitle ) ) { |
| 107 | + $pageTitle->invalidateCache(); |
| 108 | + $pageTitle->purgeSquid(); |
104 | 109 | |
105 | 110 | // Kill parser cache |
106 | | - $article = new Article( $page_title ); |
| 111 | + $article = new Article( $pageTitle ); |
107 | 112 | $parserCache = ParserCache::singleton(); |
108 | | - $parser_key = $parserCache->getKey( $article, $wgUser ); |
109 | | - $wgMemc->delete( $parser_key ); |
| 113 | + $parserKey = $parserCache->getKey( $article, $wgUser ); |
| 114 | + $wgMemc->delete( $parserKey ); |
110 | 115 | } |
111 | 116 | } |
112 | 117 | |
113 | 118 | /** |
114 | | - * Delete the user's vote from the DB if s/he wants to remove his/her vote |
| 119 | + * Delete the user's vote from the database, purges normal caches and |
| 120 | + * updates SocialProfile's statistics, if SocialProfile is active. |
115 | 121 | */ |
116 | 122 | function delete() { |
117 | 123 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -169,8 +175,9 @@ |
170 | 176 | |
171 | 177 | /** |
172 | 178 | * Checks if a user has already voted |
173 | | - * @return Boolean: false if s/he hasn't, otherwise returns the value of |
174 | | - * 'vote_value' column from Vote DB table |
| 179 | + * |
| 180 | + * @return Boolean|Integer: false if s/he hasn't, otherwise returns the |
| 181 | + * value of 'vote_value' column from Vote DB table |
175 | 182 | */ |
176 | 183 | function UserAlreadyVoted() { |
177 | 184 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -197,7 +204,6 @@ |
198 | 205 | function display() { |
199 | 206 | global $wgUser; |
200 | 207 | |
201 | | - $this->votekey = md5( $this->PageID . 'pants' . $this->Username ); |
202 | 208 | $voted = $this->UserAlreadyVoted(); |
203 | 209 | |
204 | 210 | $make_vote_box_clickable = ''; |
— | — | @@ -205,7 +211,7 @@ |
206 | 212 | $make_vote_box_clickable = ' vote-clickable'; |
207 | 213 | } |
208 | 214 | |
209 | | - $output = "<div class=\"vote-box{$make_vote_box_clickable}\" id=\"votebox\" onclick=\"VoteNY.clickVote(1,{$this->PageID},'{$this->votekey}')\">"; |
| 215 | + $output = "<div class=\"vote-box{$make_vote_box_clickable}\" id=\"votebox\">"; |
210 | 216 | $output .= '<span id="PollVotes" class="vote-number">' . $this->count() . '</span>'; |
211 | 217 | $output .= '</div>'; |
212 | 218 | $output .= '<div id="Answer" class="vote-action">'; |
— | — | @@ -221,10 +227,10 @@ |
222 | 228 | } else { |
223 | 229 | if( !wfReadOnly() ) { |
224 | 230 | if( $voted == false ) { |
225 | | - $output .= "<a href=\"javascript:VoteNY.clickVote(1,{$this->PageID},'{$this->votekey}')\">" . |
| 231 | + $output .= '<a href="javascript:void(0);" class="vote-vote-link">' . |
226 | 232 | wfMsg( 'vote-link' ) . '</a>'; |
227 | 233 | } else { |
228 | | - $output .= "<a href=\"javascript:VoteNY.unVote('{$this->PageID}', '{$this->votekey}')\">" . |
| 234 | + $output .= '<a href="javascript:void(0);" class="vote-unvote-link">' . |
229 | 235 | wfMsg( 'vote-unvote-link' ) . '</a>'; |
230 | 236 | } |
231 | 237 | } |
— | — | @@ -244,7 +250,8 @@ |
245 | 251 | |
246 | 252 | /** |
247 | 253 | * Displays voting stars |
248 | | - * @param $voted Boolean: false by default |
| 254 | + * |
| 255 | + * @param $voted Boolean: has the user already voted? False by default |
249 | 256 | * @return Mixed: HTML output |
250 | 257 | */ |
251 | 258 | function display( $voted = false ) { |
— | — | @@ -258,7 +265,6 @@ |
259 | 266 | $display_stars_rating = $this->getAverageVote(); |
260 | 267 | } |
261 | 268 | |
262 | | - $this->votekey = md5( $this->PageID . 'pants' . $this->Username ); |
263 | 269 | $id = ''; |
264 | 270 | |
265 | 271 | // Should probably be $this->PageID or something? |
— | — | @@ -279,7 +285,7 @@ |
280 | 286 | $output .= '<div class="rating-voted">' . |
281 | 287 | wfMsgExt( 'vote-gave-this', 'parsemag', $already_voted ) . |
282 | 288 | " </div> |
283 | | - <a href=\"javascript:VoteNY.unVoteStars({$this->PageID},'{$this->votekey}','{$id}')\">(" |
| 289 | + <a href=\"javascript:void(0);\" class=\"vote-remove-stars-link\" data-vote-id=\"{$id}\">(" |
284 | 290 | . wfMsg( 'vote-remove' ) . |
285 | 291 | ')</a>'; |
286 | 292 | } |
— | — | @@ -304,7 +310,6 @@ |
305 | 311 | if( !$rating ) { |
306 | 312 | $rating = 0; |
307 | 313 | } |
308 | | - $this->votekey = md5( $this->PageID . 'pants' . $this->Username ); |
309 | 314 | if( !$voted ) { |
310 | 315 | $voted = 0; |
311 | 316 | } |
— | — | @@ -316,10 +321,10 @@ |
317 | 322 | } else { |
318 | 323 | $action = 5; |
319 | 324 | } |
320 | | - $onclick = "VoteNY.clickVoteStars({$x},{$this->PageID},'{$this->votekey}','{$id}',$action);"; |
321 | | - $onmouseover = "VoteNY.updateRating('{$id}',{$x},{$rating});"; |
322 | | - $onmouseout = "VoteNY.startClearRating('{$id}','{$rating}',{$voted});"; |
323 | | - $output .= "<img onclick=\"javascript:{$onclick}\" onmouseover=\"javascript:{$onmouseover}\" onmouseout=\"javascript:{$onmouseout}\" id=\"rating_{$id}_{$x}\" src=\"{$wgScriptPath}/extensions/VoteNY/images/star_"; |
| 325 | + $output .= "<img class=\"vote-rating-star\" data-vote-the-vote=\"{$x}\"" . |
| 326 | + " data-vote-id=\"{$id}\" data-vote-action=\"{$action}\" data-vote-rating=\"{$rating}\"" . |
| 327 | + " data-vote-voted=\"{$voted}\" id=\"rating_{$id}_{$x}\"" . |
| 328 | + " src=\"{$wgScriptPath}/extensions/VoteNY/images/star_"; |
324 | 329 | switch( true ) { |
325 | 330 | case $rating >= $x: |
326 | 331 | if( $voted ) { |