r104246 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104245‎ | r104246 | r104247 >
Date:17:16, 25 November 2011
Author:jeroendedauw
Status:reverted
Tags:
Comment:
work on special:reviews
Modified paths:
  • /trunk/extensions/Reviews/Reviews.i18n.php (modified) (history)
  • /trunk/extensions/Reviews/Reviews.php (modified) (history)
  • /trunk/extensions/Reviews/api/ApiDeleteReviews.php (modified) (history)
  • /trunk/extensions/Reviews/resources/reviews.review.js (modified) (history)
  • /trunk/extensions/Reviews/resources/reviews.special.js (modified) (history)
  • /trunk/extensions/Reviews/specials/SpecialReviews.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Reviews/specials/SpecialReviews.php
@@ -54,25 +54,38 @@
5555 return false;
5656 }
5757
 58+ $out = $this->getOutput();
 59+
 60+ if ( $this->getRequest()->getInt( 'deleted' ) === 1 ) {
 61+ $out->addHTML(
 62+ '<div class="successbox"><strong><p>'
 63+ . wfMsgExt( 'reviews-reviews-deleted', array( 'parseinline' ) )
 64+ . '</p></strong></div><hr style="display: block; clear: both; visibility: hidden;" />'
 65+ );
 66+ }
 67+
5868 if ( $subPage === '' ) {
59 - $this->getOutput()->addWikiMsg( 'reviews-reviews-header' );
 69+ $out->addWikiMsg( 'reviews-reviews-header' );
6070 $this->displayReviewList();
6171 }
6272 else {
6373 $review = Review::selectRow( null, array( 'id' => $subPage ) );
6474
6575 if ( $review === false ) {
66 - $this->getOutput()->addWikiMsg( 'reviews-reviews-nosuchreview' );
 76+ $out->addWikiMsg( 'reviews-reviews-nosuchreview' );
6777 $this->displayReviewList();
6878 }
6979 else {
70 - $this->getOutput()->addModules( 'ext.reviews.special.reviews' );
 80+ $out->addModules( 'ext.reviews.special.reviews' );
7181
72 - $this->getOutput()->addWikiMsg( 'reviews-reviews-editheader' );
 82+ $out->addWikiMsg( 'reviews-reviews-editheader' );
7383
7484 $this->displaySummary( $review );
7585
76 - $this->getOutput()->addHTML( $review->getHTML() );
 86+ $out->addHTML(
 87+ Html::element( 'h3', array(), wfMsg( 'reviews-reviews-reviewtext' ) ) .
 88+ '<div class="review-text-content"><p>' . htmlspecialchars( $review->getField( 'text' ) ) . '</p></div>'
 89+ );
7790
7891 $this->displayAdminControls( $review );
7992 }
@@ -170,6 +183,22 @@
171184 * @param Review $review
172185 */
173186 protected function displayAdminControls( Review $review ) {
 187+ $out = $this->getOutput();
 188+
 189+ $out->addHTML( Html::element( 'h3', array(), wfMsg( 'reviews-reviews-controls' ) ) );
 190+
 191+ if ( ReviewsSettings::get( 'reviewDeletionEnabled' ) ) {
 192+ $out->addHTML( Html::element(
 193+ 'button',
 194+ array(
 195+ 'class' => 'reviews-delete-button',
 196+ 'data-review-id' => $review->getId(),
 197+ // TODO: might want to add invalidation sign here so master db can be used on target page and we don't get rep lag ghosts.
 198+ 'data-completion-url' => $this->getTitle()->getLocalURL( array( 'deleted' => 1 ) )
 199+ ),
 200+ wfMsg( 'reviews-reviews-delete' )
 201+ ) );
 202+ }
174203 }
175204
176205 }
Index: trunk/extensions/Reviews/Reviews.i18n.php
@@ -75,6 +75,11 @@
7676 'reviews-reviews-header' => 'This page lists all reviews posted on this wiki',
7777 'reviews-reviews-nosuchreview' => 'You do not have a review with the provided ID, it might have been deleted. All reviews are listed below.',
7878 'reviews-reviews-editheader' => 'On this page you can manage this review. You can also view a list of [[Special:Reviews|all reviews]].',
 79+ 'reviews-reviews-deleted' => 'The review was deleted successfully',
 80+ 'reviews-reviews-reviewtext' => 'Review text',
 81+ 'reviews-reviews-controls' => 'Administration controls',
 82+ 'reviews-reviews-delete' => 'Remove this review',
 83+ 'reviews-reviews-delete-confirm' => 'Are you sure you want to delete this review?',
7984
8085 'reviews-reviews-header-title' => 'Review title',
8186 'reviews-reviews-header-page' => 'For page',
@@ -144,6 +149,11 @@
145150 'reviews-reviews-header' => "Line on top of a page explaining it's function",
146151 'reviews-reviews-nosuchreview' => "Line on top of a page explaining it's function",
147152 'reviews-reviews-editheader' => "Line on top of a page explaining it's function",
 153+ 'reviews-reviews-deleted' => 'Message indicating that a review was succesfully deleted.',
 154+ 'reviews-reviews-reviewtext' => 'Level 3 header',
 155+ 'reviews-reviews-controls' => 'Level 3 header',
 156+ 'reviews-reviews-delete' => 'Delete button text',
 157+ 'reviews-reviews-delete-confirm' => 'Message asking for confirmation of deletion shown in a confirmation dialog',
148158
149159 'reviews-pager-no-results' => 'Informs the user that there are no results',
150160 'reviews-pager-post-time' => 'Tabele column header',
Index: trunk/extensions/Reviews/api/ApiDeleteReviews.php
@@ -19,7 +19,7 @@
2020 $this->dieUsage( 'Review deletion is disabled', 'reviewdeletiondisabled' );
2121 }
2222
23 - if ( !$this->getUser()->isAllowed( 'reviewadmin' ) || $this->getUser()->isBlocked() ) {
 23+ if ( !$this->getUser()->isAllowed( 'reviewsadmin' ) || $this->getUser()->isBlocked() ) {
2424 $this->dieUsageMsg( array( 'badaccess-groups' ) );
2525 }
2626
@@ -43,11 +43,6 @@
4444 return true;
4545 }
4646
47 - public function getTokenSalt() {
48 - $params = $this->extractRequestParams();
49 - return 'deletereview' . implode( '|', $params['ids'] );
50 - }
51 -
5247 public function mustBePosted() {
5348 return true;
5449 }
@@ -66,7 +61,7 @@
6762 public function getParamDescription() {
6863 return array(
6964 'ids' => 'The IDs of the reviews to delete',
70 - 'token' => 'Edit token, salted with the review ids',
 65+ 'token' => 'Edit token. You can get one of these through prop=info.',
7166 );
7267 }
7368
Index: trunk/extensions/Reviews/Reviews.php
@@ -227,8 +227,11 @@
228228 'reviews.special.js',
229229 ),
230230 'dependencies' => array(
231 - 'jquery.reviewState'
 231+ 'jquery.reviewState', 'jquery.ui.button', 'ext.reviews'
232232 ),
 233+ 'messages' => array(
 234+ 'reviews-reviews-delete-confirm'
 235+ ),
233236 );
234237
235238 unset( $moduleTemplate );
Index: trunk/extensions/Reviews/resources/reviews.review.js
@@ -18,7 +18,7 @@
1919 };
2020
2121 this.save = function( callback ) {
22 - requestArgs = {
 22+ var requestArgs = {
2323 'action': 'submitreview',
2424 'format': 'json',
2525 'token': mw.user.tokens.get( 'editToken' ),
@@ -47,6 +47,23 @@
4848
4949 reviews.Review.prototype = {
5050
 51+ remove: function( callback ) {
 52+ var requestArgs = {
 53+ 'action': 'deletereviews',
 54+ 'format': 'json',
 55+ 'token': mw.user.tokens.get( 'editToken' ),
 56+ 'ids': this.fields.id
 57+ };
 58+
 59+ $.post(
 60+ wgScriptPath + '/api.php',
 61+ requestArgs,
 62+ function( data ) {
 63+ callback( data.hasOwnProperty( 'success' ) && data.success );
 64+ }
 65+ );
 66+ }
 67+
5168 };
5269
5370 })( window.jQuery, window.mediaWiki, window.reviews );
\ No newline at end of file
Index: trunk/extensions/Reviews/resources/reviews.special.js
@@ -6,7 +6,7 @@
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
99
10 -(function( $, mw ) {
 10+(function( $, mw, reviews ) {
1111
1212 $( document ).ready( function() {
1313
@@ -14,6 +14,25 @@
1515 $( e ).reviewState();
1616 } );
1717
 18+ $( '.reviews-delete-button' ).button().click( function() {
 19+ if ( confirm( mw.msg( 'reviews-reviews-delete-confirm' ) ) ) {
 20+ var $this = $( this );
 21+ var review = new reviews.Review( { 'id': $this.attr( 'data-review-id' ) } );
 22+ $this.button( 'disable' );
 23+
 24+ review.remove( function( success ) {
 25+ if ( success ) {
 26+ window.location = $this.attr( 'data-completion-url' );
 27+ }
 28+ else {
 29+ // TODO
 30+ alert( 'The review could not be removed.' );
 31+ $this.button( 'enable' );
 32+ }
 33+ } );
 34+ }
 35+ } );
 36+
1837 } );
1938
20 -})( window.jQuery, window.mediaWiki );
 39+})( window.jQuery, window.mediaWiki, window.reviews );

Status & tagging log