Index: trunk/extensions/Reviews/includes/ReviewControl.php |
— | — | @@ -1,12 +1,25 @@ |
2 | 2 | <?php |
3 | 3 | |
| 4 | +/** |
| 5 | + * Review control. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file ReviewsControl.php |
| 10 | + * @ingroup Reviews |
| 11 | + * |
| 12 | + * @licence GNU GPL v3+ |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
4 | 15 | class ReviewControl { |
5 | 16 | |
6 | 17 | protected $review; |
7 | 18 | protected $context; |
| 19 | + protected $reload; |
8 | 20 | |
9 | | - public function __construct( Review $review = null ) { |
| 21 | + public function __construct( Review $review = null, $reload = false ) { |
10 | 22 | $this->review = $review; |
| 23 | + $this->reload = $reload; |
11 | 24 | } |
12 | 25 | |
13 | 26 | public function addToContext( ContextSource &$context = null ) { |
— | — | @@ -38,7 +51,7 @@ |
39 | 52 | 'rating' => 0, |
40 | 53 | 'ratings' => $ratings |
41 | 54 | ); |
42 | | - } |
| 55 | + } |
43 | 56 | else { |
44 | 57 | $out->addHTML( Html::element( 'h2', array( 'id' => 'reviews-edit' ), wfMsg( 'reviews-submission-edit-title' ) ) ); |
45 | 58 | |
— | — | @@ -46,8 +59,11 @@ |
47 | 60 | } |
48 | 61 | |
49 | 62 | $attribs['data-review'] = FormatJson::encode( $review ); |
50 | | - $attribs['data-reload-target'] = $context->getTitle()->getLocalURL( array( 'action' => 'refresh' ) ); |
51 | 63 | |
| 64 | + if ( $this->reload ) { |
| 65 | + $attribs['data-reload-target'] = $context->getTitle()->getLocalURL( array( 'action' => 'purge' ) ); |
| 66 | + } |
| 67 | + |
52 | 68 | $out->addHTML( Html::element( 'div', $attribs ) ); |
53 | 69 | } |
54 | 70 | |
Index: trunk/extensions/Reviews/resources/jquery.reviewControl.js |
— | — | @@ -178,7 +178,10 @@ |
179 | 179 | // _this.successMessage.fadeOut( 'slow' ); |
180 | 180 | // }, 60000 ); |
181 | 181 | } ); |
182 | | - window.location = _this.reloadTarget; |
| 182 | + |
| 183 | + if ( _this.reloadTarget !== undefined ) { |
| 184 | + window.location = _this.reloadTarget; |
| 185 | + } |
183 | 186 | } |
184 | 187 | else { |
185 | 188 | alert( 'Review could not be saved' ); // TODO |
Index: trunk/extensions/Reviews/Reviews.hooks.php |
— | — | @@ -191,7 +191,8 @@ |
192 | 192 | ) ); |
193 | 193 | |
194 | 194 | if ( $review === false || $user->getOption( 'reviews_showedit' ) ) { |
195 | | - $control = new ReviewControl( $review === false ? null : $review ); |
| 195 | + $review = $review === false ? null : $review; |
| 196 | + $control = new ReviewControl( $review, true ); |
196 | 197 | $control->addToContext( $out ); |
197 | 198 | } |
198 | 199 | } |