Index: trunk/extensions/Contest/Contest.i18n.php |
— | — | @@ -50,6 +50,9 @@ |
51 | 51 | 'contest-special-edit' => 'Edit', |
52 | 52 | 'contest-special-delete' => 'Delete', |
53 | 53 | |
| 54 | + 'contest-special-confirm-delete' => 'Are you sure you want to delete this contest?', |
| 55 | + 'contest-special-delete-failed' => 'Failed to delete the contest.', |
| 56 | + |
54 | 57 | // Special:EditContest |
55 | 58 | 'editcontest-text' => 'You are editing a contest.', |
56 | 59 | 'editcontest-legend' => 'Contest', |
Index: trunk/extensions/Contest/specials/SpecialContests.php |
— | — | @@ -201,6 +201,8 @@ |
202 | 202 | |
203 | 203 | $out->addHTML( '</tbody>' ); |
204 | 204 | $out->addHTML( '</table>' ); |
| 205 | + |
| 206 | + $out->addModules( 'contest.special.contests' ); |
205 | 207 | } |
206 | 208 | |
207 | 209 | } |
Index: trunk/extensions/Contest/Contest.php |
— | — | @@ -114,10 +114,14 @@ |
115 | 115 | 'remoteExtPath' => 'Contest/resources' |
116 | 116 | ); |
117 | 117 | |
118 | | -$wgResourceModules[''] = $moduleTemplate + array( |
| 118 | +$wgResourceModules['contest.special.contests'] = $moduleTemplate + array( |
119 | 119 | 'scripts' => array( |
120 | | - '' |
| 120 | + 'contest.special.contests.js' |
121 | 121 | ), |
| 122 | + 'messages' => array( |
| 123 | + 'contest-special-confirm-delete', |
| 124 | + 'contest-special-delete-failed', |
| 125 | + ) |
122 | 126 | ); |
123 | 127 | |
124 | 128 | unset( $moduleTemplate ); |
Index: trunk/extensions/Contest/includes/ContestDBObject.php |
— | — | @@ -276,13 +276,8 @@ |
277 | 277 | * @return boolean Success indicator |
278 | 278 | */ |
279 | 279 | public function removeFromDB() { |
280 | | - $dbw = wfGetDB( DB_MASTER ); |
| 280 | + $sucecss = $this->delete( array( 'id' => $this->getId() ) ); |
281 | 281 | |
282 | | - $sucecss = $dbw->delete( |
283 | | - $this->getDBTable(), |
284 | | - array( $this->getFieldPrefix() . 'id' => $this->getId() ) |
285 | | - ); |
286 | | - |
287 | 282 | if ( $sucecss ) { |
288 | 283 | $this->setField( 'id', null ); |
289 | 284 | } |
— | — | @@ -481,6 +476,22 @@ |
482 | 477 | } |
483 | 478 | |
484 | 479 | /** |
| 480 | + * Removes the object from the database. |
| 481 | + * |
| 482 | + * @since 0.1 |
| 483 | + * |
| 484 | + * @param array $conditions |
| 485 | + * |
| 486 | + * @return boolean Success indicator |
| 487 | + */ |
| 488 | + public function delete( array $conditions ) { |
| 489 | + return wfGetDB( DB_MASTER )->delete( |
| 490 | + $this->getDBTable(), |
| 491 | + $this->getPrefixedValues( $conditions ) |
| 492 | + ); |
| 493 | + } |
| 494 | + |
| 495 | + /** |
485 | 496 | * Selects the the specified fields of the records matching the provided |
486 | 497 | * conditions. Field names get prefixed. |
487 | 498 | * |
Index: trunk/extensions/Contest/resources/contest.special.contests.js |
— | — | @@ -0,0 +1,50 @@ |
| 2 | +/** |
| 3 | + * JavasSript for the Contest MediaWiki extension. |
| 4 | + * @see https://secure.wikimedia.org/wikipedia/mediawiki/wiki/Extension:Contest |
| 5 | + * |
| 6 | + * @licence GNU GPL v3 or later |
| 7 | + * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
| 8 | + */ |
| 9 | + |
| 10 | +(function( $, mw ) { $( document ).ready( function() { |
| 11 | + |
| 12 | + function deleteSurvey( options, successCallback, failCallback ) { |
| 13 | + $.post( |
| 14 | + wgScriptPath + '/api.php', |
| 15 | + { |
| 16 | + 'action': 'deletecontest', |
| 17 | + 'format': 'json', |
| 18 | + 'ids': options.id, |
| 19 | + 'token': options.token |
| 20 | + }, |
| 21 | + function( data ) { |
| 22 | + if ( data.success ) { |
| 23 | + successCallback(); |
| 24 | + } else { |
| 25 | + failCallback( mw.msg( 'contest-special-delete-failed' ) ); |
| 26 | + } |
| 27 | + } |
| 28 | + ); |
| 29 | + } |
| 30 | + |
| 31 | + $( '.contest-delete' ).click( function() { |
| 32 | + $this = $( this ); |
| 33 | + |
| 34 | + if ( confirm( mw.msg( 'contest-special-confirm-delete' ) ) ) { |
| 35 | + deleteSurvey( |
| 36 | + { |
| 37 | + id: $this.attr( 'data-contest-id' ), |
| 38 | + token: $this.attr( 'data-contest-token' ) |
| 39 | + }, |
| 40 | + function() { |
| 41 | + $this.closest( 'tr' ).slideUp( 'slow', function() { $( this ).remove(); } ); |
| 42 | + }, |
| 43 | + function( error ) { |
| 44 | + alert( error ); |
| 45 | + } |
| 46 | + ); |
| 47 | + } |
| 48 | + return false; |
| 49 | + } ); |
| 50 | + |
| 51 | +} ); })( window.jQuery, window.mediaWiki ); |
\ No newline at end of file |
Property changes on: trunk/extensions/Contest/resources/contest.special.contests.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 52 | + native |