Index: trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.php |
— | — | @@ -1,7 +1,19 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * Article Assessment Pilot extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * |
| 9 | + * @author Trevor Parscal <trevor@wikimedia.org> |
| 10 | + * @license GPL v2 or later |
| 11 | + * @version 0.1.0 |
| 12 | + */ |
3 | 13 | |
4 | | -// If the number of page revisions (since users last rating) is greater than this |
5 | | -// then consider the last rating "stale" |
| 14 | +/* Configuration */ |
| 15 | + |
| 16 | +// If the number of page revisions (since users last rating) is greater than this then consider the |
| 17 | +// last rating "stale" |
6 | 18 | $wgArticleAssessmentStaleCount = 5; |
7 | 19 | |
8 | 20 | // Array of the "ratings" id's to store. Allows it to be a bit more dynamic |
— | — | @@ -9,54 +21,8 @@ |
10 | 22 | |
11 | 23 | // Which categories the pages must belong to have the rating widget added (with _ in text) |
12 | 24 | // Extension is "disabled" if this field is an empty array (as per default configuration) |
13 | | -$wgArticleAssessmentCategories = array( ); |
| 25 | +$wgArticleAssessmentCategories = array(); |
14 | 26 | |
15 | | -// Set to 'combined' or 'raw' if you need to debug this extension's JS |
16 | | -$wgArticleAssessmentResourceMode = 'minified'; |
17 | | - |
18 | | -// Path to jQuery UI's JS |
19 | | -$wgArticleAssessmentJUIJSPath = null; // Defaults to "$wgExtensionAssetsPath/ArticleAssessmentPilot/js/jui.combined.min.js" |
20 | | - |
21 | | -// Path to jQuery UI's CSS |
22 | | -$wgArticleAssessmentJUICSSPath = null; // Defaults to "$wgExtensionAssetsPath/ArticleAssessmentPilot/css/jquery-ui-1.7.2.css" |
23 | | - |
24 | | -// Auto-load files |
25 | | -$dir = dirname( __FILE__ ) . '/'; |
26 | | -$wgAutoloadClasses['ApiQueryArticleAssessment'] = $dir . 'api/ApiQueryArticleAssessment.php'; |
27 | | -$wgAutoloadClasses['ApiArticleAssessment'] = $dir . 'api/ApiArticleAssessment.php'; |
28 | | -$wgAutoloadClasses['ArticleAssessmentPilotHooks'] = $dir . 'ArticleAssessmentPilot.hooks.php'; |
29 | | - |
30 | | -// Schema and tables |
31 | | -$wgHooks['LoadExtensionSchemaUpdates'][] = 'ArticleAssessmentPilotHooks::schema'; |
32 | | -$wgHooks['ParserTestTables'][] = 'ArticleAssessmentPilotHooks::parserTestTables'; |
33 | | - |
34 | | -// Hooks |
35 | | -$wgHooks['BeforePageDisplay'][] = 'ArticleAssessmentPilotHooks::addResources'; |
36 | | -$wgHooks['MakeGlobalVariablesScript'][] = 'ArticleAssessmentPilotHooks::addVariables'; |
37 | | - |
38 | | -// API modules |
39 | | -$wgAPIListModules['articleassessment'] = 'ApiQueryArticleAssessment'; |
40 | | -$wgAPIModules['articleassessment'] = 'ApiArticleAssessment'; |
41 | | - |
42 | | -// i18n and aliases |
43 | | -// Adds Internationalized Messages |
44 | | -$wgExtensionMessagesFiles['ArticleAssessmentPilot'] = $dir . 'ArticleAssessmentPilot.i18n.php'; |
45 | | - |
46 | | -// Credits |
47 | | -$wgExtensionCredits['other'][] = array( |
48 | | - 'path' => __FILE__, |
49 | | - 'name' => 'Article Assessment Pilot', |
50 | | - 'author' => array( 'Nimish Gautam', 'Sam Reed', 'Adam Miller' ), |
51 | | - 'version' => '1.0.0', |
52 | | - 'descriptionmsg' => 'articleassessment-desc', |
53 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:ArticleAssessmentPilot' |
54 | | -); |
55 | | - |
56 | | -// Survey setup |
57 | | -// This is totally a hack, but it's easy and had to be done fast |
58 | | -// Should be used with SimpleSurvey 0.1 |
59 | | -require_once( $dir . '../SimpleSurvey/SimpleSurvey.php' ); |
60 | | - |
61 | 27 | // Would ordinarily call this articleassessment but survey names are 16 chars max |
62 | 28 | $wgPrefSwitchSurveys['articlerating'] = array( |
63 | 29 | 'updatable' => false, |
— | — | @@ -91,3 +57,39 @@ |
92 | 58 | ), |
93 | 59 | ); |
94 | 60 | $wgValidSurveys[] = 'articlerating'; |
| 61 | + |
| 62 | +/* Setup */ |
| 63 | + |
| 64 | +$wgExtensionCredits['other'][] = array( |
| 65 | + 'path' => __FILE__, |
| 66 | + 'name' => 'Article Assessment Pilot', |
| 67 | + 'author' => array( |
| 68 | + 'Sam Reed', |
| 69 | + 'Roan Kattouw', |
| 70 | + 'Trevor Parscal', |
| 71 | + 'Brandon Harris', |
| 72 | + 'Adam Miller', |
| 73 | + 'Nimish Gautam', |
| 74 | + ), |
| 75 | + 'version' => '0.2.0', |
| 76 | + 'descriptionmsg' => 'articleassessment-desc', |
| 77 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:ArticleAssessmentPilot' |
| 78 | +); |
| 79 | +$dir = dirname( __FILE__ ) . '/'; |
| 80 | +// Autoloading |
| 81 | +$wgAutoloadClasses['ApiQueryArticleAssessment'] = $dir . 'api/ApiQueryArticleAssessment.php'; |
| 82 | +$wgAutoloadClasses['ApiArticleAssessment'] = $dir . 'api/ApiArticleAssessment.php'; |
| 83 | +$wgAutoloadClasses['ArticleAssessmentPilotHooks'] = $dir . 'ArticleAssessmentPilot.hooks.php'; |
| 84 | +$wgExtensionMessagesFiles['ArticleAssessmentPilot'] = $dir . 'ArticleAssessmentPilot.i18n.php'; |
| 85 | +// Hooks |
| 86 | +$wgHooks['LoadExtensionSchemaUpdates'][] = 'ArticleAssessmentPilotHooks::loadExtensionSchemaUpdates'; |
| 87 | +$wgHooks['ParserTestTables'][] = 'ArticleAssessmentPilotHooks::parserTestTables'; |
| 88 | +$wgHooks['BeforePageDisplay'][] = 'ArticleAssessmentPilotHooks::beforePageDisplay'; |
| 89 | +$wgHooks['ResourceLoaderRegisterModules'][] = 'ArticleAssessmentPilotHooks::resourceLoaderRegisterModules'; |
| 90 | +// API Registration |
| 91 | +$wgAPIListModules['articleassessment'] = 'ApiQueryArticleAssessment'; |
| 92 | +$wgAPIModules['articleassessment'] = 'ApiArticleAssessment'; |
| 93 | + |
| 94 | +/* XXX: Survey setup */ |
| 95 | + |
| 96 | +require_once( $dir . '../SimpleSurvey/SimpleSurvey.php' ); |
Index: trunk/extensions/ArticleAssessmentPilot/modules/ext.articleAssessment/ext.articleAssessment.css |
— | — | @@ -1,63 +1,7 @@ |
2 | | -/*! |
3 | | - * jQuery UI Stars v3.0.1 |
4 | | - * http://plugins.jquery.com/project/Star_Rating_widget |
5 | | - * |
6 | | - * Copyright (c) 2010 Marek "Orkan" Zajac (orkans@gmail.com) |
7 | | - * Dual licensed under the MIT and GPL licenses. |
8 | | - * http://docs.jquery.com/License |
9 | | - * |
10 | | - * $Rev: 164 $ |
11 | | - * $Date:: 2010-05-01 #$ |
12 | | - * $Build: 35 (2010-05-01) |
13 | | - * |
| 2 | +/* |
| 3 | + * Styles for Article Assessment |
14 | 4 | */ |
15 | | -.article-assessment-wrapper .ui-stars-star { |
16 | | - float: left; |
17 | | - display: block; |
18 | | - overflow: hidden; |
19 | | - text-indent: -999em; |
20 | | - cursor: pointer; |
21 | | - padding-right: 4px; |
22 | | -} |
23 | | -.article-assessment-wrapper .ui-stars-star a { |
24 | | - width: 21px; |
25 | | - height: 21px; |
26 | | - line-height: 0; |
27 | | - display: block; |
28 | | - background: url(../images/stars.gif) no-repeat 0 0; |
29 | | -} |
30 | | -.article-assessment-wrapper .ui-stars-star a { |
31 | | - background-position: 0 0px; |
32 | | -} |
33 | 5 | |
34 | | -.article-assessment-wrapper .ui-stars-star-on a { |
35 | | - background-position: 0 -21px; |
36 | | -} |
37 | | -.article-assessment-wrapper .ui-stars-star-rated a { |
38 | | - background-position: 0 -42px; |
39 | | -} |
40 | | -.article-assessment-wrapper .ui-stars-star-stale a { |
41 | | - background-position: 0 -63px; |
42 | | -} |
43 | | -.article-assessment-wrapper .ui-stars-star-hover a { |
44 | | - background-position: 0 -21px; |
45 | | -} |
46 | | -.article-assessment-wrapper .ui-stars-star-disabled, |
47 | | -.article-assessment-wrapper .ui-stars-star-disabled a { |
48 | | - cursor: default !important; |
49 | | -} |
50 | | -.article-assessment-wrapper .ui-stars-cancel { |
51 | | - display: none; |
52 | | -} |
53 | | -/* End ui-stars styles */ |
54 | | - |
55 | | -/* Tipsy Styles */ |
56 | | -.tipsy { padding: 5px 5px 10px; font-size: 12px; position: absolute; z-index: 100000; overflow: visible; } |
57 | | -.tipsy-inner { padding: 5px 8px 4px 8px; background-color: #d6f3ff; color: black; border: 1px solid #5dc9f4; max-width: 300px; text-align: left; } |
58 | | -.tipsy-arrow { position: absolute; background: url( '../images/arrow.gif' ) no-repeat top left; width: 13px; height: 13px; } |
59 | | -.tipsy-se .tipsy-arrow { bottom: -2px; right: 10px; background-position: 0% 100%; } |
60 | | - |
61 | | -/* End Tipsy styles */ |
62 | 6 | .article-assessment-wrapper #article-assessment-rate, |
63 | 7 | .article-assessment-wrapper #article-assessment-ratings { |
64 | 8 | background: #f7f7f7; |
— | — | @@ -95,10 +39,10 @@ |
96 | 40 | height: 24px; |
97 | 41 | display: block; |
98 | 42 | float: right; |
99 | | - background: url(../images/question.gif) 0 50% no-repeat; |
| 43 | + background: url(images/question.gif) 0 50% no-repeat; |
100 | 44 | } |
101 | 45 | .article-assessment-wrapper .rating-field-hint:hover { |
102 | | - background: url(../images/question-hover.gif) 0 50% no-repeat; |
| 46 | + background: url(images/question-hover.gif) 0 50% no-repeat; |
103 | 47 | } |
104 | 48 | |
105 | 49 | .article-assessment-wrapper .article-assessment-flash { |
— | — | @@ -128,7 +72,7 @@ |
129 | 73 | font-size: 11px; |
130 | 74 | } |
131 | 75 | .article-assessment-wrapper .article-assessment-rating-field-value-wrapper { |
132 | | - background: url( ../images/rating_bg.gif ) 0 0 no-repeat; |
| 76 | + background: url(images/rating_bg.gif) 0 0 no-repeat; |
133 | 77 | width: 120px; |
134 | 78 | height: 13px; |
135 | 79 | display: block; |
— | — | @@ -151,7 +95,7 @@ |
152 | 96 | float: right; |
153 | 97 | } |
154 | 98 | .article-assessment-wrapper .article-assessment-rating-field-value-wrapper .article-assessment-rating-field-value { |
155 | | - background: url( ../images/rating_bar.gif ) 0 0 no-repeat; |
| 99 | + background: url(images/rating_bar.gif) 0 0 no-repeat; |
156 | 100 | height: 9px; |
157 | 101 | float: right; |
158 | 102 | display: block; |
— | — | @@ -172,7 +116,7 @@ |
173 | 117 | float: right; |
174 | 118 | } |
175 | 119 | .article-assessment-wrapper .article-assessment-ratings-disabled .article-assessment-rating-field-value-wrapper { |
176 | | - background: url( ../images/rating_disabled_bg.gif ) 0 0 no-repeat; |
| 120 | + background: urlimages/rating_disabled_bg.gif) 0 0 no-repeat; |
177 | 121 | } |
178 | 122 | .article-assessment-wrapper .article-assessment-ratings-disabled .article-assessment-rating-field-value { |
179 | 123 | display: none; |
— | — | @@ -190,7 +134,7 @@ |
191 | 135 | display: block; |
192 | 136 | height: 24px; |
193 | 137 | width: 24px; |
194 | | - background: url( ../images/loading.gif ) center no-repeat; |
| 138 | + background: url(images/loading.gif) center no-repeat; |
195 | 139 | text-indent: -9999px; |
196 | 140 | margin: 0 auto; |
197 | 141 | } |
Index: trunk/extensions/ArticleAssessmentPilot/modules/ext.articleAssessment/ext.articleAssessment.js |
— | — | @@ -77,20 +77,24 @@ |
78 | 78 | return randomstring; |
79 | 79 | } |
80 | 80 | userToken = randomString( 32 ); |
81 | | - $.cookie( 'mwArticleAssessmentUserToken', userToken, { 'expires': 30, 'path': '/' } ); |
| 81 | + $.cookie( |
| 82 | + 'mwArticleAssessmentUserToken', |
| 83 | + userToken, |
| 84 | + { 'expires': 30, 'path': '/' } |
| 85 | + ); |
82 | 86 | } |
83 | 87 | if ( !wgUserName ) { |
84 | 88 | config.userID = userToken; |
85 | 89 | } |
86 | 90 | // setup our markup using the template variables in settings |
87 | 91 | var $structure = $( settings.structureHTML ), |
88 | | - instructions = $.ArticleAssessment.fn.getMsg( 'articleassessment-pleaserate' ), |
89 | | - feedback = $.ArticleAssessment.fn.getMsg( 'articleassessment-featurefeedback' ), |
90 | | - yourfeedback = $.ArticleAssessment.fn.getMsg( 'articleassessment-yourfeedback'), |
91 | | - articlerating = $.ArticleAssessment.fn.getMsg( 'articleassessment-articlerating' ), |
92 | | - resultshide = $.ArticleAssessment.fn.getMsg( 'articleassessment-results-hide' ), |
93 | | - resultsshow = $.ArticleAssessment.fn.getMsg( 'articleassessment-results-show' ); |
94 | | - submitbutton = $.ArticleAssessment.fn.getMsg( 'articleassessment-submit' ); |
| 92 | + instructions = mediaWiki.msg( 'articleassessment-pleaserate' ), |
| 93 | + feedback = mediaWiki.msg( 'articleassessment-featurefeedback' ), |
| 94 | + yourfeedback = mediaWiki.msg( 'articleassessment-yourfeedback'), |
| 95 | + articlerating = mediaWiki.msg( 'articleassessment-articlerating' ), |
| 96 | + resultshide = mediaWiki.msg( 'articleassessment-results-hide' ), |
| 97 | + resultsshow = mediaWiki.msg( 'articleassessment-results-show' ); |
| 98 | + submitbutton = mediaWiki.msg( 'articleassessment-submit' ); |
95 | 99 | $structure |
96 | 100 | .find( '#article-assessment-rate legend' ) |
97 | 101 | .html( yourfeedback ) |
— | — | @@ -140,10 +144,13 @@ |
141 | 145 | for ( var i = 0; i < settings.fieldMessages.length; i++ ) { |
142 | 146 | var $field = $( settings.fieldHTML ), |
143 | 147 | $rating = $( settings.ratingHTML ), |
144 | | - label = $.ArticleAssessment.fn.getMsg( settings.fieldPrefix + settings.fieldMessages[i] ), |
| 148 | + label = mediaWiki.msg( settings.fieldPrefix + settings.fieldMessages[i] ), |
145 | 149 | field = settings.fieldMessages[i], |
146 | | - hint = $.ArticleAssessment.fn.getMsg( settings.fieldPrefix + settings.fieldMessages[i] + settings.fieldHintSuffix ), |
147 | | - count = $.ArticleAssessment.fn.getMsg( 'articleassessment-noratings', [0, 0] ); |
| 150 | + hint = mediaWiki.msg( |
| 151 | + settings.fieldPrefix + settings.fieldMessages[i] + |
| 152 | + settings.fieldHintSuffix |
| 153 | + ), |
| 154 | + count = mediaWiki.msg( 'articleassessment-noratings', 0, 0 ); |
148 | 155 | // initialize the field html |
149 | 156 | $field |
150 | 157 | .attr( 'id', 'articleassessment-rate-' + field ) |
— | — | @@ -172,24 +179,32 @@ |
173 | 180 | .append( $rating ); |
174 | 181 | } |
175 | 182 | // store our settings and configuration for later |
176 | | - $structure.find( '#article-assessment' ).data( 'articleAssessment-context', { 'settings': settings, 'config': config } ); |
| 183 | + $structure.find( '#article-assessment' ) |
| 184 | + .data( |
| 185 | + 'articleAssessment-context', |
| 186 | + { 'settings': settings, 'config': config } |
| 187 | + ); |
177 | 188 | $( '#catlinks' ).before( $structure ); |
178 | 189 | // Hide the ratings initially |
179 | 190 | $.ArticleAssessment.fn.hideRatings(); |
180 | 191 | |
181 | 192 | |
182 | 193 | // set the height of our smaller fieldset to match the taller |
183 | | - if ( $( '#article-assessment-rate' ).height() > $( '#article-assessment-ratings' ).height() ) { |
184 | | - $( '#article-assessment-ratings' ).css( 'minHeight', $( '#article-assessment-rate' ).height() ); |
| 194 | + if ( |
| 195 | + $( '#article-assessment-rate' ).height() > |
| 196 | + $( '#article-assessment-ratings' ).height() ) { |
| 197 | + $( '#article-assessment-ratings' ) |
| 198 | + .css( 'minHeight', $( '#article-assessment-rate' ).height() ); |
185 | 199 | } else { |
186 | | - $( '#article-assessment-rate' ).css( 'minHeight', $( '#article-assessment-ratings' ).height() ); |
| 200 | + $( '#article-assessment-rate' ) |
| 201 | + .css( 'minHeight', $( '#article-assessment-ratings' ).height() ); |
187 | 202 | } |
188 | 203 | // attempt to fetch the ratings |
189 | 204 | $.ArticleAssessment.fn.getRatingData(); |
190 | 205 | |
191 | 206 | // initialize the star plugin |
192 | 207 | $( '.rating-field' ).each( function() { |
193 | | - $( this ) |
| 208 | + $(this) |
194 | 209 | .wrapAll( '<div class="rating-field"></div>' ) |
195 | 210 | .parent() |
196 | 211 | .stars( { |
— | — | @@ -197,20 +212,21 @@ |
198 | 213 | callback: function( value, link ) { |
199 | 214 | // remove any stale or rated classes |
200 | 215 | value.$stars.each( function() { |
201 | | - $( this ) |
| 216 | + $(this) |
202 | 217 | .removeClass( 'ui-stars-star-stale' ) |
203 | 218 | .removeClass( 'ui-stars-star-rated' ); |
204 | 219 | // enable our submit button if it's still disabled |
205 | | - $( '#article-assessment input:disabled' ).removeAttr( 'disabled' ); |
| 220 | + $( '#article-assessment input:disabled' ) |
| 221 | + .removeAttr( 'disabled' ); |
206 | 222 | } ); |
207 | 223 | } |
208 | 224 | } ); |
209 | | - }); |
| 225 | + } ); |
210 | 226 | // intialize the tooltips |
211 | 227 | $( '.field-wrapper label[original-title]' ).each( function() { |
212 | | - $( this ) |
| 228 | + $(this) |
213 | 229 | .after( $( '<span class="rating-field-hint" />' ) |
214 | | - .attr( 'original-title', $( this ).attr( 'original-title' ) ) |
| 230 | + .attr( 'original-title', $(this).attr( 'original-title' ) ) |
215 | 231 | .tipsy( { gravity : 'se', opacity: '0.9' } ) ); |
216 | 232 | } ); |
217 | 233 | // bind submit event to the form |
— | — | @@ -262,7 +278,7 @@ |
263 | 279 | dataType: 'json', |
264 | 280 | success: $.ArticleAssessment.fn.afterGetRatingData, |
265 | 281 | error: function( XMLHttpRequest, textStatus, errorThrown ) { |
266 | | - $.ArticleAssessment.fn.flashNotice( $.ArticleAssessment.fn.getMsg( 'articleassessment-error' ), |
| 282 | + $.ArticleAssessment.fn.flashNotice( mediaWiki.msg( 'articleassessment-error' ), |
267 | 283 | { 'class': 'article-assessment-error-msg' } ); |
268 | 284 | } |
269 | 285 | } ); |
— | — | @@ -278,7 +294,7 @@ |
279 | 295 | $rating = $( '#' + rating.ratingdesc ), |
280 | 296 | count = rating.count, |
281 | 297 | total = ( rating.total / count ).toFixed( 1 ), |
282 | | - label = $.ArticleAssessment.fn.getMsg( 'articleassessment-noratings', [total, count] ); |
| 298 | + label = mediaWiki.msg( 'articleassessment-noratings', total, count ); |
283 | 299 | $rating |
284 | 300 | .find( '.article-assessment-rating-field-value' ) |
285 | 301 | .text( total ) |
— | — | @@ -302,7 +318,7 @@ |
303 | 319 | $( '.ui-stars-star-on' ) |
304 | 320 | .addClass( 'ui-stars-star-stale' ); |
305 | 321 | // add the stale message |
306 | | - var msg = $.ArticleAssessment.fn.getMsg( 'articleassessment-stalemessage-norevisioncount' ); |
| 322 | + var msg = mediaWiki.msg( 'articleassessment-stalemessage-norevisioncount' ); |
307 | 323 | $.ArticleAssessment.fn.flashNotice( msg, { 'class': 'article-assessment-stale-msg' } ); |
308 | 324 | } else { |
309 | 325 | // if it's not a stale rating, we want to make the stars blue |
— | — | @@ -311,9 +327,9 @@ |
312 | 328 | } |
313 | 329 | // initialize the ratings |
314 | 330 | $( '.article-assessment-rating-field-value' ).each( function() { |
315 | | - $( this ) |
| 331 | + $(this) |
316 | 332 | .css( { |
317 | | - 'width': 120 - ( 120 * ( parseFloat( $( this ).text() ) / 5 ) ) + 'px' |
| 333 | + 'width': 120 - ( 120 * ( parseFloat( $(this).text() ) / 5 ) ) + 'px' |
318 | 334 | } ) |
319 | 335 | } ); |
320 | 336 | }, |
— | — | @@ -330,8 +346,8 @@ |
331 | 347 | $( '.rating-field input' ).each( function() { |
332 | 348 | // expects the hidden inputs to have names like 'rating[field-name]' which we use to |
333 | 349 | // be transparent about what values we're sending to the server |
334 | | - var fieldName = $( this ).attr( 'name' ).match( /\[([a-zA-Z0-9\-]*)\]/ )[1]; |
335 | | - results[ fieldName ] = $( this ).val(); |
| 350 | + var fieldName = $(this).attr( 'name' ).match( /\[([a-zA-Z0-9\-]*)\]/ )[1]; |
| 351 | + results[ fieldName ] = $(this).val(); |
336 | 352 | } ); |
337 | 353 | var request = $.ajax( { |
338 | 354 | url: wgScriptPath + '/api.php', |
— | — | @@ -350,7 +366,7 @@ |
351 | 367 | dataType: 'json', |
352 | 368 | success: $.ArticleAssessment.fn.afterSubmitRating, |
353 | 369 | error: function( XMLHttpRequest, textStatus, errorThrown ) { |
354 | | - $.ArticleAssessment.fn.flashNotice( $.ArticleAssessment.fn.getMsg( 'articleassessment-error' ), |
| 370 | + $.ArticleAssessment.fn.flashNotice( mediaWiki.msg( 'articleassessment-error' ), |
355 | 371 | { 'class': 'article-assessment-error-msg' } ); |
356 | 372 | } |
357 | 373 | } ); |
— | — | @@ -368,7 +384,7 @@ |
369 | 385 | // show the results |
370 | 386 | $.ArticleAssessment.fn.showRatings(); |
371 | 387 | // say thank you |
372 | | - $.ArticleAssessment.fn.flashNotice( $.ArticleAssessment.fn.getMsg( 'articleassessment-thanks' ), |
| 388 | + $.ArticleAssessment.fn.flashNotice( mediaWiki.msg( 'articleassessment-thanks' ), |
373 | 389 | { 'class': 'article-assessment-success-msg' } ); |
374 | 390 | }, |
375 | 391 | // places a message on the interface |
— | — | @@ -394,37 +410,35 @@ |
395 | 411 | } |
396 | 412 | }, |
397 | 413 | 'showFeedback': function() { |
398 | | - $.ArticleAssessment.fn.withJUI( function() { |
399 | | - var $dialogDiv = $( '#article-assessment-dialog' ); |
400 | | - if ( $dialogDiv.size() == 0 ) { |
401 | | - $dialogDiv = $( '<div id="article-assessment-dialog" class="loading" />' ) |
402 | | - .dialog( { |
403 | | - width: 600, |
404 | | - height: 400, |
405 | | - bgiframe: true, |
406 | | - autoOpen: true, |
407 | | - modal: true, |
408 | | - title: $.ArticleAssessment.fn.getMsg( 'articleassessment-survey-title' ), |
409 | | - close: function() { |
410 | | - $( this ) |
411 | | - .dialog( 'option', 'height', 400 ) |
412 | | - .find( '.article-assessment-success-msg, .article-assessment-error-msg' ) |
413 | | - .remove() |
414 | | - .end() |
415 | | - .find( 'form' ) |
416 | | - .show(); |
417 | | - } |
418 | | - } ); |
419 | | - $dialogDiv.load( |
420 | | - wgScript + '?title=Special:SimpleSurvey&survey=articlerating&raw=1', |
421 | | - function() { |
422 | | - $( this ).find( 'form' ).bind( 'submit', $.ArticleAssessment.fn.submitFeedback ); |
423 | | - $( this ).removeClass( 'loading' ); |
| 414 | + var $dialogDiv = $( '#article-assessment-dialog' ); |
| 415 | + if ( $dialogDiv.size() == 0 ) { |
| 416 | + $dialogDiv = $( '<div id="article-assessment-dialog" class="loading" />' ) |
| 417 | + .dialog( { |
| 418 | + width: 600, |
| 419 | + height: 400, |
| 420 | + bgiframe: true, |
| 421 | + autoOpen: true, |
| 422 | + modal: true, |
| 423 | + title: mediaWiki.msg( 'articleassessment-survey-title' ), |
| 424 | + close: function() { |
| 425 | + $(this) |
| 426 | + .dialog( 'option', 'height', 400 ) |
| 427 | + .find( '.article-assessment-success-msg, .article-assessment-error-msg' ) |
| 428 | + .remove() |
| 429 | + .end() |
| 430 | + .find( 'form' ) |
| 431 | + .show(); |
424 | 432 | } |
425 | | - ); |
426 | | - } |
427 | | - $dialogDiv.dialog( 'open' ); |
428 | | - } ); |
| 433 | + } ); |
| 434 | + $dialogDiv.load( |
| 435 | + wgScript + '?title=Special:SimpleSurvey&survey=articlerating&raw=1', |
| 436 | + function() { |
| 437 | + $(this).find( 'form' ).bind( 'submit', $.ArticleAssessment.fn.submitFeedback ); |
| 438 | + $(this).removeClass( 'loading' ); |
| 439 | + } |
| 440 | + ); |
| 441 | + } |
| 442 | + $dialogDiv.dialog( 'open' ); |
429 | 443 | return false; |
430 | 444 | }, |
431 | 445 | 'submitFeedback': function() { |
— | — | @@ -439,16 +453,16 @@ |
440 | 454 | var formData = {}; |
441 | 455 | $dialogDiv.find( 'input[type=text], input[type=radio]:checked, input[type=checkbox]:checked, ' + |
442 | 456 | 'input[type=hidden], textarea' ).each( function() { |
443 | | - var name = $( this ).attr( 'name' ); |
| 457 | + var name = $(this).attr( 'name' ); |
444 | 458 | if ( name !== '' ) { |
445 | 459 | if ( name.substr( -2 ) == '[]' ) { |
446 | 460 | var trimmedName = name.substr( 0, name.length - 2 ); |
447 | 461 | if ( typeof formData[trimmedName] == 'undefined' ) { |
448 | 462 | formData[trimmedName] = []; |
449 | 463 | } |
450 | | - formData[trimmedName].push( $( this ).val() ); |
| 464 | + formData[trimmedName].push( $(this).val() ); |
451 | 465 | } else { |
452 | | - formData[name] = $( this ).val(); |
| 466 | + formData[name] = $(this).val(); |
453 | 467 | } |
454 | 468 | } |
455 | 469 | } ); |
— | — | @@ -466,15 +480,13 @@ |
467 | 481 | // TODO: Style success-msg, error-msg |
468 | 482 | var $msgDiv = $( '<div />' ) |
469 | 483 | .addClass( success ? 'article-assessment-success-msg' : 'article-assessment-error-msg' ) |
470 | | - .html( $.ArticleAssessment.fn.getMsg( success? 'articleassessment-survey-thanks' : 'articleassessment-error' ) ) |
| 484 | + .html( mediaWiki.msg( success? 'articleassessment-survey-thanks' : 'articleassessment-error' ) ) |
471 | 485 | .appendTo( $dialogDiv ); |
472 | 486 | $dialogDiv.removeClass( 'loading' ); |
473 | 487 | |
474 | 488 | // This is absurdly unnecessary from the looks of it, but it seems this is somehow |
475 | 489 | // needed in certain cases. |
476 | | - $.ArticleAssessment.fn.withJUI( function() { |
477 | | - $dialogDiv.dialog( 'option', 'height', $msgDiv.height() + 100 ) |
478 | | - } ); |
| 490 | + $dialogDiv.dialog( 'option', 'height', $msgDiv.height() + 100 ); |
479 | 491 | |
480 | 492 | if ( success ) { |
481 | 493 | // Hide the dialog link |
— | — | @@ -488,45 +500,13 @@ |
489 | 501 | // TODO: Duplicates code, factor out, maybe |
490 | 502 | var $msgDiv = $( '<div />' ) |
491 | 503 | .addClass( 'article-assessment-error-msg' ) |
492 | | - .html( $.ArticleAssessment.fn.getMsg( 'articleassessment-error' ) ) |
| 504 | + .html( mediaWiki.msg( 'articleassessment-error' ) ) |
493 | 505 | .appendTo( $dialogDiv ); |
494 | 506 | $dialogDiv.removeClass( 'loading' ); |
495 | | - $.ArticleAssessment.fn.withJUI( function() { |
496 | | - $dialogDiv.dialog( 'option', 'height', $msgDiv.height() + 100 ) |
497 | | - } ); |
| 507 | + $dialogDiv.dialog( 'option', 'height', $msgDiv.height() + 100 ); |
498 | 508 | } |
499 | 509 | } ); |
500 | 510 | return false; |
501 | | - }, |
502 | | - 'addMessages': function( messages ) { |
503 | | - for ( var key in messages ) { |
504 | | - $.ArticleAssessment.messages[key] = messages[key]; |
505 | | - } |
506 | | - }, |
507 | | - /** |
508 | | - * Get a message |
509 | | - * FIXME: Parameter expansion is broken in all sorts of edge cases |
510 | | - */ |
511 | | - 'getMsg': function( key, args ) { |
512 | | - if ( !( key in $.ArticleAssessment.messages ) ) { |
513 | | - return '[' + key + ']'; |
514 | | - } |
515 | | - var msg = $.ArticleAssessment.messages[key]; |
516 | | - if ( typeof args == 'object' || typeof args == 'array' ) { |
517 | | - for ( var i = 0; i < args.length; i++ ) { |
518 | | - msg = msg.replace( new RegExp( '\\$' + ( parseInt( i ) + 1 ), 'g' ), args[i] ); |
519 | | - } |
520 | | - } else if ( typeof args == 'string' || typeof args == 'number' ) { |
521 | | - msg = msg.replace( /\$1/g, args ); |
522 | | - } |
523 | | - return msg; |
524 | | - }, |
525 | | - 'withJUI': function( callback ) { |
526 | | - if ( typeof $.ui == 'undefined' ) { |
527 | | - $.getScript( wgArticleAssessmentJUIPath, callback ); |
528 | | - } else { |
529 | | - callback(); |
530 | | - } |
531 | 511 | } |
532 | 512 | } |
533 | 513 | }; |
Index: trunk/extensions/ArticleAssessmentPilot/modules/jquery.stars/jquery.stars.css |
— | — | @@ -0,0 +1,51 @@ |
| 2 | +/*! |
| 3 | + * jQuery UI Stars v3.0.1 |
| 4 | + * http://plugins.jquery.com/project/Star_Rating_widget |
| 5 | + * |
| 6 | + * Copyright (c) 2010 Marek "Orkan" Zajac (orkans@gmail.com) |
| 7 | + * Dual licensed under the MIT and GPL licenses. |
| 8 | + * http://docs.jquery.com/License |
| 9 | + * |
| 10 | + * $Rev: 164 $ |
| 11 | + * $Date:: 2010-05-01 #$ |
| 12 | + * $Build: 35 (2010-05-01) |
| 13 | + * |
| 14 | + */ |
| 15 | +.ui-stars-star { |
| 16 | + float: left; |
| 17 | + display: block; |
| 18 | + overflow: hidden; |
| 19 | + text-indent: -999em; |
| 20 | + cursor: pointer; |
| 21 | + padding-right: 4px; |
| 22 | +} |
| 23 | +.ui-stars-star a { |
| 24 | + width: 21px; |
| 25 | + height: 21px; |
| 26 | + line-height: 0; |
| 27 | + display: block; |
| 28 | + background: url(images/stars.gif) no-repeat 0 0; |
| 29 | +} |
| 30 | +.ui-stars-star a { |
| 31 | + background-position: 0 0px; |
| 32 | +} |
| 33 | + |
| 34 | +.ui-stars-star-on a { |
| 35 | + background-position: 0 -21px; |
| 36 | +} |
| 37 | +.ui-stars-star-rated a { |
| 38 | + background-position: 0 -42px; |
| 39 | +} |
| 40 | +.ui-stars-star-stale a { |
| 41 | + background-position: 0 -63px; |
| 42 | +} |
| 43 | +.ui-stars-star-hover a { |
| 44 | + background-position: 0 -21px; |
| 45 | +} |
| 46 | +.ui-stars-star-disabled, |
| 47 | +.ui-stars-star-disabled a { |
| 48 | + cursor: default !important; |
| 49 | +} |
| 50 | +.ui-stars-cancel { |
| 51 | + display: none; |
| 52 | +} |
Property changes on: trunk/extensions/ArticleAssessmentPilot/modules/jquery.stars/jquery.stars.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 53 | + native |
Added: svn:mime-type |
2 | 54 | + text/plain |
Index: trunk/extensions/ArticleAssessmentPilot/modules/jquery.stars/images/jquery.ui.stars.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = image/gif |
Index: trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.hooks.php |
— | — | @@ -1,43 +1,57 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | 4 | * Hooks for ArticleAssessmentPilot |
6 | 5 | * |
7 | 6 | * @file |
8 | 7 | * @ingroup Extensions |
9 | 8 | */ |
| 9 | + |
10 | 10 | class ArticleAssessmentPilotHooks { |
11 | | - private static $styleFiles = array( |
12 | | - 'raw' => array( |
13 | | - array( 'src' => 'css/ArticleAssessment.css', 'version' => 1 ), |
| 11 | + |
| 12 | + protected static $modules = array( |
| 13 | + 'ext.articleAssessment' => array( |
| 14 | + 'scripts' => 'ext.articleAssessment/ext.articleAssessment.js', |
| 15 | + 'styles' => 'ext.articleAssessment/ext.articleAssessment.css', |
| 16 | + 'messages' => array( |
| 17 | + 'articleassessment', |
| 18 | + 'articleassessment-desc', |
| 19 | + 'articleassessment-yourfeedback', |
| 20 | + 'articleassessment-pleaserate', |
| 21 | + 'articleassessment-submit', |
| 22 | + 'articleassessment-rating-wellsourced', |
| 23 | + 'articleassessment-rating-neutrality', |
| 24 | + 'articleassessment-rating-completeness', |
| 25 | + 'articleassessment-rating-readability', |
| 26 | + 'articleassessment-rating-wellsourced-tooltip', |
| 27 | + 'articleassessment-rating-neutrality-tooltip', |
| 28 | + 'articleassessment-rating-completeness-tooltip', |
| 29 | + 'articleassessment-rating-readability-tooltip', |
| 30 | + 'articleassessment-error', |
| 31 | + 'articleassessment-thanks', |
| 32 | + 'articleassessment-articlerating', |
| 33 | + 'articleassessment-featurefeedback', |
| 34 | + 'articleassessment-noratings', |
| 35 | + 'articleassessment-stalemessage-revisioncount', |
| 36 | + 'articleassessment-stalemessage-norevisioncount', |
| 37 | + 'articleassessment-results-show', |
| 38 | + 'articleassessment-results-hide', |
| 39 | + 'articleassessment-survey-title', |
| 40 | + 'articleassessment-survey-thanks', |
| 41 | + ), |
| 42 | + 'dependencies' => array( 'jquery.ui.dialog', 'jquery.tipsy', 'jquery.stars' ), |
14 | 43 | ), |
15 | | - 'combined' => array( |
16 | | - array( 'src' => 'css/ArticleAssessment.css', 'version' => 1 ), |
| 44 | + 'jquery.stars' => array( |
| 45 | + 'scripts' => 'jquery.stars/jquery.stars.js', |
| 46 | + 'styles' => 'jquery.stars/jquery.stars.css', |
17 | 47 | ), |
18 | | - 'minified' => array( |
19 | | - array( 'src' => 'css/ArticleAssessment.css', 'version' => 1 ), |
20 | | - ), |
21 | 48 | ); |
22 | | - |
23 | | - private static $scriptFiles = array( |
24 | | - 'raw' => array( |
25 | | - array( 'src' => 'js/ArticleAssessment.js', 'version' => 5 ), |
26 | | - array( 'src' => 'js/jquery.cookie.js', 'version' => 1 ), |
27 | | - array( 'src' => 'js/jquery.tipsy.js', 'version' => 1 ), |
28 | | - array( 'src' => 'js/jquery.stars.js', 'version' => 2 ), |
29 | | - ), |
30 | | - 'combined' => array( |
31 | | - array( 'src' => 'js/ArticleAssessment.combined.js', 'version' => 5 ) |
32 | | - ), |
33 | | - 'minified' => array( |
34 | | - array( 'src' => 'js/ArticleAssessment.combined.min.js', 'version' => 5 ) |
35 | | - ), |
36 | | - ); |
37 | | - |
38 | | - private static $messages = array(); |
39 | | - |
40 | | - /* Static Functions */ |
41 | | - public static function schema( $updater = null ) { |
| 49 | + |
| 50 | + /* Static Methods */ |
| 51 | + |
| 52 | + /** |
| 53 | + * LoadExtensionSchemaUpdates hook |
| 54 | + */ |
| 55 | + public static function loadExtensionSchemaUpdates( $updater = null ) { |
42 | 56 | if ( $updater === null ) { |
43 | 57 | global $wgExtNewTables; |
44 | 58 | $wgExtNewTables[] = array( |
— | — | @@ -48,21 +62,11 @@ |
49 | 63 | $updater->addExtensionUpdate( array( 'addTable', 'article_assessment', |
50 | 64 | dirname( __FILE__ ) . '/ArticleAssessmentPilot.sql', true ) ); |
51 | 65 | } |
52 | | - |
53 | 66 | return true; |
54 | 67 | } |
55 | 68 | |
56 | | - public static function addVariables( &$vars ) { |
57 | | - global $wgArticleAssessmentJUIJSPath, $wgExtensionAssetsPath; |
58 | | - $vars['wgArticleAssessmentJUIPath'] = $wgArticleAssessmentJUIJSPath ? $wgArticleAssessmentJUIJSPath : |
59 | | - "$wgExtensionAssetsPath/ArticleAssessmentPilot/js/jui.combined.min.js"; |
60 | | - return true; |
61 | | - } |
62 | | - |
63 | 69 | /** |
64 | | - * Make sure the tables exist for parser tests |
65 | | - * @param $tables |
66 | | - * @return bool |
| 70 | + * ParserTestTables hook |
67 | 71 | */ |
68 | 72 | public static function parserTestTables( &$tables ) { |
69 | 73 | $tables[] = 'article_assessment'; |
— | — | @@ -70,106 +74,59 @@ |
71 | 75 | $tables[] = 'article_assessment_ratings'; |
72 | 76 | return true; |
73 | 77 | } |
74 | | - |
75 | | - public static function addResources( $out ) { |
| 78 | + |
| 79 | + /** |
| 80 | + * BeforePageDisplay hook |
| 81 | + */ |
| 82 | + public static function beforePageDisplay( $out ) { |
| 83 | + global $wgRequest, $wgArticleAssessmentCategories; |
76 | 84 | |
77 | 85 | $title = $out->getTitle(); |
78 | | - |
79 | | - // Chances are we only want to be rating Mainspace, right? |
80 | | - if ( $title->getNamespace() !== NS_MAIN ) { |
81 | | - return true; |
| 86 | + |
| 87 | + // Restrict ratings to... |
| 88 | + if ( |
| 89 | + // Main namespace articles |
| 90 | + $title->getNamespace() == NS_MAIN |
| 91 | + // View pages |
| 92 | + && $wgRequest->getVal( 'action', 'view' ) == 'view' |
| 93 | + // Current revision |
| 94 | + && !$wgRequest->getCheck( 'diff' ) |
| 95 | + && !$wgRequest->getCheck( 'oldid' ) |
| 96 | + // Articles in valid categories |
| 97 | + && count( $wgArticleAssessmentCategories ) |
| 98 | + && self::isInCategories( $title->getArticleId(), $wgArticleAssessmentCategories ) |
| 99 | + ) { |
| 100 | + $out->addModules( 'ext.articleAssessment' ); |
82 | 101 | } |
83 | | - |
84 | | - global $wgRequest; |
85 | | - |
86 | | - // Only show for view actions. |
87 | | - if ( $wgRequest->getVal( 'action', 'view' ) !== 'view' || $wgRequest->getCheck( 'diff' ) || |
88 | | - $wgRequest->getCheck( 'oldid' ) ) { |
89 | | - return true; |
90 | | - } |
91 | | - |
92 | | - global $wgArticleAssessmentCategories; |
93 | | - |
94 | | - // check if this page should have the form |
95 | | - if ( !count( $wgArticleAssessmentCategories ) |
96 | | - || !self::isInCategories( $title->getArticleId(), $wgArticleAssessmentCategories ) ) { |
97 | | - return true; |
98 | | - } |
99 | | - |
100 | | - global $wgExtensionAssetsPath, $wgArticleAssessmentResourceMode; |
101 | | - $mode = isset( self::$scriptFiles[$wgArticleAssessmentResourceMode] ) ? $wgArticleAssessmentResourceMode : 'minified'; |
102 | | - foreach ( self::$scriptFiles[$mode] as $script ) { |
103 | | - $out->addScriptFile( $wgExtensionAssetsPath . |
104 | | - "/ArticleAssessmentPilot/{$script['src']}", $script['version'] |
| 102 | + return true; |
| 103 | + } |
| 104 | + |
| 105 | + /* |
| 106 | + * ResourceLoaderRegisterModules hook |
| 107 | + */ |
| 108 | + public static function resourceLoaderRegisterModules( &$resourceLoader ) { |
| 109 | + global $wgExtensionAssetsPath; |
| 110 | + $localpath = dirname( __FILE__ ) . '/modules'; |
| 111 | + $remotepath = "$wgExtensionAssetsPath/ArticleAssessmentPilot/modules"; |
| 112 | + foreach ( self::$modules as $name => $resources ) { |
| 113 | + $resourceLoader->register( |
| 114 | + $name, new ResourceLoaderFileModule( $resources, $localpath, $remotepath ) |
105 | 115 | ); |
106 | 116 | } |
107 | | - |
108 | | - global $wgArticleAssessmentJUICSSPath; |
109 | | - $out->addExtensionStyle( ( $wgArticleAssessmentJUICSSPath ? $wgArticleAssessmentJUICSSPath : |
110 | | - "$wgExtensionAssetsPath/ArticleAssessmentPilot/css/jquery-ui-1.7.2.css" ) . '?1.7.2y' |
111 | | - ); |
112 | | - foreach ( self::$styleFiles[$mode] as $style ) { |
113 | | - $out->addExtensionStyle( $wgExtensionAssetsPath . |
114 | | - "/ArticleAssessmentPilot/{$style['src']}?{$style['version']}" |
115 | | - ); |
116 | | - } |
117 | | - |
118 | | - // Transforms messages into javascript object members |
119 | | - self::$messages = array( |
120 | | - 'articleassessment', |
121 | | - 'articleassessment-desc', |
122 | | - 'articleassessment-yourfeedback', |
123 | | - 'articleassessment-pleaserate', |
124 | | - 'articleassessment-submit', |
125 | | - 'articleassessment-rating-wellsourced', |
126 | | - 'articleassessment-rating-neutrality', |
127 | | - 'articleassessment-rating-completeness', |
128 | | - 'articleassessment-rating-readability', |
129 | | - 'articleassessment-rating-wellsourced-tooltip', |
130 | | - 'articleassessment-rating-neutrality-tooltip', |
131 | | - 'articleassessment-rating-completeness-tooltip', |
132 | | - 'articleassessment-rating-readability-tooltip', |
133 | | - 'articleassessment-error', |
134 | | - 'articleassessment-thanks', |
135 | | - 'articleassessment-articlerating', |
136 | | - 'articleassessment-featurefeedback', |
137 | | - 'articleassessment-noratings', |
138 | | - 'articleassessment-stalemessage-revisioncount', |
139 | | - 'articleassessment-stalemessage-norevisioncount', |
140 | | - 'articleassessment-results-show', |
141 | | - 'articleassessment-results-hide', |
142 | | - 'articleassessment-survey-title', |
143 | | - 'articleassessment-survey-thanks', |
144 | | - ); |
145 | | - |
146 | | - foreach ( self::$messages as $i => $message ) { |
147 | | - // TODO: Not parsing or even preprocessing the messages would be more efficient, |
148 | | - // but we can't do that until we have such nice things as JS-side {{PLURAL}} |
149 | | - // Should be OK for now in a limited deployment scenario |
150 | | - $escapedMessageValue = Xml::escapeJsString( wfMsgExt( $message, array( 'parseinline' ) ) ); |
151 | | - $escapedMessageKey = Xml::escapeJsString( $message ); |
152 | | - self::$messages[$i] = |
153 | | - "'{$escapedMessageKey}':'{$escapedMessageValue}'"; |
154 | | - } |
155 | | - // Add javascript to document |
156 | | - if ( count( self::$messages ) > 0 ) { |
157 | | - $out->addScript( Html::inlineScript( |
158 | | - '$j.ArticleAssessment.fn.addMessages({' . implode( ',', self::$messages ) . '});' |
159 | | - ) ); |
160 | | - } |
161 | | - |
162 | 117 | return true; |
163 | 118 | } |
164 | | - |
| 119 | + |
| 120 | + /* Protected Static Methods */ |
| 121 | + |
165 | 122 | /** |
166 | 123 | * Returns whether an article is in the specified categories |
167 | | - * |
| 124 | + * |
168 | 125 | * @param $articleId Integer: Article ID |
169 | | - * @param $categories Array: Array of category names (without Category: prefix, with underscores) |
170 | | - * |
171 | | - * @return bool |
| 126 | + * @param $categories Array: List of category names (without Category: prefix, with underscores) |
| 127 | + * |
| 128 | + * @return Boolean: True if article is in one of the values of $categories |
172 | 129 | */ |
173 | | - private static function isInCategories( $articleId, $categories ) { |
| 130 | + protected static function isInCategories( $articleId, $categories ) { |
174 | 131 | $dbr = wfGetDB( DB_SLAVE ); |
175 | 132 | return (bool)$dbr->selectRow( 'categorylinks', '1', |
176 | 133 | array( |