Index: trunk/extensions/Reviews/includes/ReviewsTag.php |
— | — | @@ -67,12 +67,18 @@ |
68 | 68 | } |
69 | 69 | |
70 | 70 | $reviews = $this->getReviews( $parser ); |
71 | | - return $this->getList( $reviews ); |
| 71 | + |
| 72 | + if ( count( $reviews ) > 0 ) { |
| 73 | + return $this->getList( $reviews ); |
| 74 | + } |
| 75 | + else { |
| 76 | + return is_null( $this->contents['default'] ) ? '' : $this->contents['default']; |
| 77 | + } |
72 | 78 | } |
73 | 79 | |
74 | 80 | /** |
| 81 | + * Get the reviews to display based on the provided arguments that are selection criteria. |
75 | 82 | * |
76 | | - * |
77 | 83 | * @since 0.1 |
78 | 84 | * |
79 | 85 | * @param Parser $parser |
— | — | @@ -111,8 +117,8 @@ |
112 | 118 | } |
113 | 119 | |
114 | 120 | /** |
| 121 | + * Get the HTML for a list of reviews. |
115 | 122 | * |
116 | | - * |
117 | 123 | * @since 0.1 |
118 | 124 | * |
119 | 125 | * @param array $reviews |
— | — | @@ -130,8 +136,8 @@ |
131 | 137 | } |
132 | 138 | |
133 | 139 | /** |
| 140 | + * Gets the parameters accepted by this tag extension. |
134 | 141 | * |
135 | | - * |
136 | 142 | * @since 0.1 |
137 | 143 | * |
138 | 144 | * @param array $args |
— | — | @@ -143,6 +149,7 @@ |
144 | 150 | 'id' => array( 'filter' => FILTER_VALIDATE_INT, 'options' => array( 'min_range' => 1 ) ), |
145 | 151 | 'page' => array(), |
146 | 152 | 'user' => array(), |
| 153 | + 'default' => array(), |
147 | 154 | ); |
148 | 155 | } |
149 | 156 | |
Index: trunk/extensions/Reviews/includes/Review.php |
— | — | @@ -345,16 +345,30 @@ |
346 | 346 | public function getHTML() { |
347 | 347 | $html = '<table class="review-table">'; |
348 | 348 | |
349 | | - $html .= '<tr><th colspan="2">' . htmlspecialchars( $this->getField( 'title' ) ) . '</th></tr>'; |
| 349 | + $html .= '<tr><th colspan="2" class="review-table-title">' . htmlspecialchars( $this->getField( 'title' ) ) . '</th></tr>'; |
350 | 350 | |
351 | 351 | $html .= '<tr>'; |
352 | 352 | |
353 | | - $html .= '<td>...</td>'; |
| 353 | + $html .= '<td rowspan="2">author stuff be here</td>'; |
354 | 354 | |
355 | 355 | $html .= Html::element( 'td', array(), $this->getField( 'text' ) ); |
356 | 356 | |
357 | 357 | $html .= '</tr>'; |
358 | 358 | |
| 359 | + $html .= '<tr colspan="2">'; |
| 360 | + |
| 361 | + $html .= Html::rawElement( 'td', array(), |
| 362 | + array_reduce( $this->getRatings(), function( $html, /* ReviewRating */ $rating ) { |
| 363 | + return $html . Html::element( 'div', array( |
| 364 | + 'class' => 'review-rating-display', |
| 365 | + 'data-type' => $rating->getField( 'type' ), |
| 366 | + 'data-value' => $rating->getField( 'value' ), |
| 367 | + ) ); |
| 368 | + }, '' ) |
| 369 | + ); |
| 370 | + |
| 371 | + $html .= '</tr>'; |
| 372 | + |
359 | 373 | $html .= '</table>'; |
360 | 374 | |
361 | 375 | return Html::openElement( |
Index: trunk/extensions/Reviews/Reviews.php |
— | — | @@ -174,6 +174,15 @@ |
175 | 175 | ), |
176 | 176 | ); |
177 | 177 | |
| 178 | +$wgResourceModules['jquery.reviewRating'] = $moduleTemplate + array( |
| 179 | + 'scripts' => array( |
| 180 | + 'jquery.reviewRating.js', |
| 181 | + ), |
| 182 | + 'dependencies' => array( |
| 183 | + 'ext.reviews', 'jquery.ui.stars', |
| 184 | + ), |
| 185 | +); |
| 186 | + |
178 | 187 | $wgResourceModules['jquery.ui.stars'] = $moduleTemplate + array( |
179 | 188 | 'scripts' => array( |
180 | 189 | 'jquery.ui.stars/jquery.ui.stars.js', |
— | — | @@ -193,6 +202,9 @@ |
194 | 203 | 'styles' => array( |
195 | 204 | 'reviews.tag.css', |
196 | 205 | ), |
| 206 | + 'dependencies' => array( |
| 207 | + 'jquery.reviewRating', |
| 208 | + ), |
197 | 209 | ); |
198 | 210 | |
199 | 211 | $wgResourceModules['ext.reviews.pager'] = $moduleTemplate + array( |
Index: trunk/extensions/Reviews/resources/jquery.reviewRating.js |
— | — | @@ -0,0 +1,39 @@ |
| 2 | +/** |
| 3 | + * JavasSript for the Reviews MediaWiki extension. |
| 4 | + * @see https://www.mediawiki.org/wiki/Extension:Reviews |
| 5 | + * |
| 6 | + * @licence GNU GPL v3 or later |
| 7 | + * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
| 8 | + */ |
| 9 | + |
| 10 | +(function( $, mw, reviews ) { $.fn.reviewRating = function( options ) { |
| 11 | + |
| 12 | + var settings = $.extend( { |
| 13 | + |
| 14 | + } ); |
| 15 | + |
| 16 | + return this.each( function() { |
| 17 | + |
| 18 | + var _this = this; |
| 19 | + var $this = $( _this ); |
| 20 | + |
| 21 | + this.setup = function() { |
| 22 | + $this.html( $( '<p>' ).text( $this.attr( 'data-type' ) + ': ' ) ); |
| 23 | + |
| 24 | + $this.append( reviews.htmlSelect( |
| 25 | + { 1: 1, 2: 2, 3: 3, 4: 4, 5: 5 }, // TODO |
| 26 | + parseInt( $this.attr( 'data-value' ) ), { } |
| 27 | + ) ); |
| 28 | + |
| 29 | + $this.stars( { |
| 30 | + inputType: 'select', |
| 31 | + cancelShow: false, |
| 32 | + disabled: true |
| 33 | + } ); |
| 34 | + }; |
| 35 | + |
| 36 | + this.setup(); |
| 37 | + |
| 38 | + }); |
| 39 | + |
| 40 | +}; })( window.jQuery, window.mediaWiki, window.reviews ); |
Property changes on: trunk/extensions/Reviews/resources/jquery.reviewRating.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 41 | + native |
Index: trunk/extensions/Reviews/resources/reviews.tag.css |
— | — | @@ -8,4 +8,26 @@ |
9 | 9 | |
10 | 10 | .review-table { |
11 | 11 | width: 100%; |
12 | | -} |
\ No newline at end of file |
| 12 | +} |
| 13 | + |
| 14 | +table.review-table, table.review-table td, table.review-table th { |
| 15 | + border: 1px solid gray; |
| 16 | +} |
| 17 | + |
| 18 | +.review-table-title { |
| 19 | + text-align: left; |
| 20 | + padding-left: 5px; |
| 21 | +} |
| 22 | + |
| 23 | +.review-rating-display { |
| 24 | + display: block; |
| 25 | + clear: both; |
| 26 | +} |
| 27 | + |
| 28 | +.review-rating-display > * { |
| 29 | + float: left; |
| 30 | +} |
| 31 | + |
| 32 | +.review-rating-display > p { |
| 33 | + line-height: 1.4em; |
| 34 | +} |
Index: trunk/extensions/Reviews/resources/reviews.tag.js |
— | — | @@ -6,8 +6,14 @@ |
7 | 7 | * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
8 | 8 | */ |
9 | 9 | |
10 | | -(function( $, mw ) { $( document ).ready( function() { |
| 10 | +(function( $, mw ) { |
11 | 11 | |
12 | 12 | var _this = this; |
| 13 | + |
| 14 | + $( document ).ready( function() { |
13 | 15 | |
14 | | -} ); })( window.jQuery, window.mediaWiki ); |
| 16 | + $( '.review-rating-display' ).reviewRating(); |
| 17 | + |
| 18 | + } ); |
| 19 | + |
| 20 | +})( window.jQuery, window.mediaWiki ); |