Index: branches/wmf/1.17wmf1/extensions/UploadWizard/resources/mw.UploadWizard.js |
— | — | @@ -1170,31 +1170,44 @@ |
1171 | 1171 | |
1172 | 1172 | }, |
1173 | 1173 | |
1174 | | - |
1175 | | - // do some last minute prep before advancing to the DEEDS page |
1176 | | - prepareAndMoveToDeeds: function() { |
1177 | | - var _this = this; |
| 1174 | + |
| 1175 | + /** |
| 1176 | + * Get the own work and third party licensing deeds if they are needed. |
| 1177 | + * |
| 1178 | + * @since 1.2 |
| 1179 | + * @param {int|false} uploadsLength |
| 1180 | + * @return {Array} |
| 1181 | + */ |
| 1182 | + getLicensingDeeds: function( uploadsLength ) { |
1178 | 1183 | var deeds = []; |
1179 | | - var hasChoice = mw.UploadWizard.config.ownWorkOption == 'choice'; |
1180 | 1184 | |
1181 | | - if ( hasChoice ) { |
| 1185 | + if ( mw.UploadWizard.config.ownWorkOption == 'choice' ) { |
1182 | 1186 | // these deeds are standard |
1183 | | - deeds.push( new mw.UploadWizardDeedOwnWork( _this.uploads.length ) ); |
1184 | | - deeds.push( new mw.UploadWizardDeedThirdParty( _this.uploads.length ) ); |
| 1187 | + deeds.push( new mw.UploadWizardDeedOwnWork( uploadsLength ) ); |
| 1188 | + deeds.push( new mw.UploadWizardDeedThirdParty( uploadsLength ) ); |
1185 | 1189 | } |
1186 | 1190 | else { |
1187 | 1191 | if ( mw.UploadWizard.config.ownWorkOption == 'own' ) { |
1188 | | - deeds.push( new mw.UploadWizardDeedOwnWork( _this.uploads.length ) ); |
| 1192 | + deeds.push( new mw.UploadWizardDeedOwnWork( uploadsLength ) ); |
1189 | 1193 | } |
1190 | 1194 | else { |
1191 | | - deeds.push( new mw.UploadWizardDeedThirdParty( _this.uploads.length ) ); |
| 1195 | + deeds.push( new mw.UploadWizardDeedThirdParty( uploadsLength ) ); |
1192 | 1196 | } |
1193 | 1197 | } |
| 1198 | + |
| 1199 | + return deeds; |
| 1200 | + }, |
1194 | 1201 | |
| 1202 | + // do some last minute prep before advancing to the DEEDS page |
| 1203 | + prepareAndMoveToDeeds: function() { |
| 1204 | + var _this = this; |
| 1205 | + var deeds = _this.getLicensingDeeds( _this.uploads.length ); |
| 1206 | + |
1195 | 1207 | this.shouldShowIndividualDeed = function() { |
1196 | | - if ( hasChoice ) return true; |
1197 | | - |
1198 | | - if ( mw.UploadWizard.config.ownWorkOption == 'own' ) { |
| 1208 | + if ( mw.UploadWizard.config.ownWorkOption == 'choice' ) { |
| 1209 | + return true; |
| 1210 | + } |
| 1211 | + else if ( mw.UploadWizard.config.ownWorkOption == 'own' ) { |
1199 | 1212 | var ownWork = mw.UploadWizard.config.licensesOwnWork; |
1200 | 1213 | var licenseIsNotDefault = ( ownWork.licenses.length === 1 && ownWork.licenses[0] !== ownWork.defaults[0] ); |
1201 | 1214 | return ownWork.licenses.length > 1 || licenseIsNotDefault; |
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/resources/mw.UploadWizardDetails.js |
— | — | @@ -269,23 +269,33 @@ |
270 | 270 | _this.addDescription( true, mw.config.get( 'wgUserLanguage' ) ); |
271 | 271 | $j( containerDiv ).append( _this.div ); |
272 | 272 | |
273 | | - // make the title field required, and non-blacklisted |
274 | | - _this.$form.find( '.mwe-title' ) |
275 | | - .rules( "add", { |
276 | | - required: true, |
277 | | - titleBadchars: true, |
278 | | - titleSenselessimagename: true, |
279 | | - titleThumbnail: true, |
280 | | - titleExtension: true, |
281 | | - messages: { |
282 | | - required: gM( 'mwe-upwiz-error-blank' ), |
283 | | - titleBadchars: gM( 'mwe-upwiz-error-title-badchars' ), |
284 | | - titleSenselessimagename: gM( 'mwe-upwiz-error-title-senselessimagename' ), |
285 | | - titleThumbnail: gM( 'mwe-upwiz-error-title-thumbnail' ), |
286 | | - titleExtension: gM( 'mwe-upwiz-error-title-extension' ) |
287 | | - } |
288 | | - } ); |
289 | | - |
| 273 | + if( UploadWizardConfig.useTitleBlacklistApi ) { |
| 274 | + // less strict checking, since TitleBlacklist checks should catch most errors. |
| 275 | + _this.$form.find( '.mwe-title' ) |
| 276 | + .rules( "add", { |
| 277 | + required: true, |
| 278 | + messages: { |
| 279 | + required: gM( 'mwe-upwiz-error-blank' ), |
| 280 | + } |
| 281 | + } ); |
| 282 | + } else { |
| 283 | + // make the title field required, and non-blacklisted |
| 284 | + _this.$form.find( '.mwe-title' ) |
| 285 | + .rules( "add", { |
| 286 | + required: true, |
| 287 | + titleBadchars: true, |
| 288 | + titleSenselessimagename: true, |
| 289 | + titleThumbnail: true, |
| 290 | + titleExtension: true, |
| 291 | + messages: { |
| 292 | + required: gM( 'mwe-upwiz-error-blank' ), |
| 293 | + titleBadchars: gM( 'mwe-upwiz-error-title-badchars' ), |
| 294 | + titleSenselessimagename: gM( 'mwe-upwiz-error-title-senselessimagename' ), |
| 295 | + titleThumbnail: gM( 'mwe-upwiz-error-title-thumbnail' ), |
| 296 | + titleExtension: gM( 'mwe-upwiz-error-title-extension' ) |
| 297 | + } |
| 298 | + } ); |
| 299 | + } |
290 | 300 | // make this a category picker |
291 | 301 | var hiddenCats = mw.isDefined( mw.UploadWizard.config.autoCategories ) ? mw.UploadWizard.config.autoCategories : []; |
292 | 302 | if ( mw.isDefined( mw.UploadWizard.config.autoCategory ) && mw.UploadWizard.config.autoCategory !== '' ) { |
— | — | @@ -350,12 +360,14 @@ |
351 | 361 | var _this = this; |
352 | 362 | _this.copyrightInfoFieldset.show(); |
353 | 363 | _this.upload.wizardDeedChooser = _this.upload.deedChooser; |
| 364 | + |
354 | 365 | _this.upload.deedChooser = new mw.UploadWizardDeedChooser( |
355 | 366 | _this.deedDiv, |
356 | | - [ new mw.UploadWizardDeedOwnWork(), |
357 | | - new mw.UploadWizardDeedThirdParty() ], |
| 367 | + mw.UploadWizard.prototype.getLicensingDeeds(), |
358 | 368 | [ _this.upload ] |
359 | 369 | ); |
| 370 | + |
| 371 | + _this.upload.deedChooser.onLayoutReady(); |
360 | 372 | }, |
361 | 373 | |
362 | 374 | /** |
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/resources/jquery/jquery.validate.wmCommonsBlacklist.js |
— | — | @@ -1,7 +1,10 @@ |
2 | 2 | /** |
3 | | - * Does some local checking of a file. For more specific filenames (such as bad words, other blacklisted stuff) use |
4 | | - * the Blacklist API. |
| 3 | + * Does some local checking of a filename. |
| 4 | + * If you want more specific filename checks (such as bad words, other blacklisted stuff) use the TitleBlacklist API. |
5 | 5 | * |
| 6 | + * These checks are ignored when the TitleBlacklist API is available, since presumably they should be configured there instead, where it's |
| 7 | + * possible to update them easily and higher-quality error messages are available. |
| 8 | + * |
6 | 9 | * This is an incomplete rendering of some of the meta.wikimedia.org and commons.wikimedia.org blacklist as they existed on 2011-05-05, and |
7 | 10 | * ignores cases that are irrelevant to uploading new media images. |
8 | 11 | * - all regexes are case INsensitive by default |
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/resources/mw.UploadWizardLicenseInput.js |
— | — | @@ -80,6 +80,7 @@ |
81 | 81 | $input.click( function() { _this.$selector.trigger( 'changeLicenses' ); } ); |
82 | 82 | // this is added so that setValues() can find one (or more) checkboxes to check - represent values without wikitext |
83 | 83 | $input.data( 'templateString', origTemplateString ); |
| 84 | + $input.data( 'licenseName', name ); |
84 | 85 | _this.inputs.push( $input ); |
85 | 86 | |
86 | 87 | var messageKey = mw.isDefined( license.props['msg'] ) ? license.props.msg : '[missing msg for ' + license.name + ']'; |
— | — | @@ -152,9 +153,9 @@ |
153 | 154 | setValues: function( values ) { |
154 | 155 | var _this = this; |
155 | 156 | $j.each( _this.inputs, function( i, $input ) { |
156 | | - var templateString = $input.data( 'templateString' ); |
| 157 | + var licenseName = $input.data( 'licenseName' ); |
157 | 158 | // !! to ensure boolean. |
158 | | - $input.attr( 'checked', !!values[templateString] ); |
| 159 | + $input.attr( 'checked', !!values[licenseName] ); |
159 | 160 | } ); |
160 | 161 | // we use the selector because events can't be unbound unless they're in the DOM. |
161 | 162 | _this.$selector.trigger( 'changeLicenses' ); |
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/UploadWizard.config.php |
— | — | @@ -142,7 +142,7 @@ |
143 | 143 | 'own-pd' => array( |
144 | 144 | 'msg' => 'mwe-upwiz-license-own-pd', |
145 | 145 | 'icons' => array( 'cc-zero' ), |
146 | | - 'templates' => array( 'own-pd' ) |
| 146 | + 'templates' => array( 'cc-zero' ) |
147 | 147 | ), |
148 | 148 | 'cc-by-sa-2.5' => array( |
149 | 149 | 'msg' => 'mwe-upwiz-license-cc-by-sa-2.5', |
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php |
— | — | @@ -162,16 +162,21 @@ |
163 | 163 | * |
164 | 164 | * @param string $pageName |
165 | 165 | * @param boolean $parse |
| 166 | + * @param string $langCode |
166 | 167 | * |
167 | 168 | * @return string|false |
168 | 169 | */ |
169 | | - protected function getPageContent( $pageName, $parse = false ) { |
| 170 | + protected function getPageContent( $pageName, $parse = false, $langCode = null ) { |
170 | 171 | $content = false; |
171 | 172 | |
172 | 173 | if ( trim( $pageName ) != '' ) { |
173 | | - global $wgLang; |
174 | | - $page = Title::newFromText( str_replace( '$1', $wgLang->getCode(), $pageName ) ); |
| 174 | + if ( is_null( $langCode ) ) { |
| 175 | + global $wgLang; |
| 176 | + $langCode = $wgLang->getCode(); |
| 177 | + } |
175 | 178 | |
| 179 | + $page = Title::newFromText( str_replace( '$1', $langCode, $pageName ) ); |
| 180 | + |
176 | 181 | if ( !is_null( $page ) && $page->exists() ) { |
177 | 182 | $article = new Article( $page, 0 ); |
178 | 183 | $content = $article->getContent(); |
— | — | @@ -183,6 +188,11 @@ |
184 | 189 | } |
185 | 190 | } |
186 | 191 | |
| 192 | + // If no page was found, and the lang is not en, then see if there in an en version. |
| 193 | + if ( $content === false && $langCode != 'en' ) { |
| 194 | + $content = $this->getPageContent( $pageName, $parse, 'en' ); |
| 195 | + } |
| 196 | + |
187 | 197 | return $content; |
188 | 198 | } |
189 | 199 | |
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/includes/specials/SpecialUploadCampaigns.php |
— | — | @@ -53,7 +53,8 @@ |
54 | 54 | && $wgRequest->getCheck( 'newcampaign' ) ) { |
55 | 55 | $wgOut->redirect( SpecialPage::getTitleFor( 'UploadCampaign', $wgRequest->getVal( 'newcampaign' ) )->getLocalURL() ); |
56 | 56 | } |
57 | | - elseif ( count( $subPage ) == 2 && $subPage[0] == 'del' ) { |
| 57 | + elseif ( count( $subPage ) == 2 && $subPage[0] == 'del' |
| 58 | + && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
58 | 59 | $campaign = UploadWizardCampaign::newFromName( $subPage[1], false ); |
59 | 60 | $campaign->deleteFromDB(); |
60 | 61 | $wgOut->redirect( $this->getTitle()->getLocalURL() ); |
— | — | @@ -144,18 +145,23 @@ |
145 | 146 | |
146 | 147 | $out->addHTML( Xml::openElement( |
147 | 148 | 'table', |
148 | | - array( 'class' => 'wikitable', 'style' => 'width:400px' ) |
| 149 | + array( 'class' => 'wikitable sortable', 'style' => 'width:400px' ) |
149 | 150 | ) ); |
150 | 151 | |
151 | 152 | $out->addHTML( |
152 | | - '<tr>' . |
| 153 | + '<thead><tr>' . |
153 | 154 | Html::element( 'th', array(), wfMsg( 'mwe-upwiz-campaigns-name' ) ) . |
154 | 155 | Html::element( 'th', array(), wfMsg( 'mwe-upwiz-campaigns-status' ) ) . |
155 | 156 | Html::element( 'th', array(), wfMsg( 'mwe-upwiz-campaigns-edit' ) ) . |
156 | 157 | Html::element( 'th', array(), wfMsg( 'mwe-upwiz-campaigns-delete' ) ) . |
157 | | - '</tr>' |
| 158 | + '</tr></thead>' |
158 | 159 | ); |
159 | 160 | |
| 161 | + $out->addHTML( '<tbody>' ); |
| 162 | + |
| 163 | + global $wgUser; |
| 164 | + $editToken = array( 'wpEditToken' => $wgUser->editToken() ); |
| 165 | + |
160 | 166 | foreach ( $campaigns as $campaign ) { |
161 | 167 | $out->addHTML( |
162 | 168 | '<tr>' . |
— | — | @@ -182,7 +188,7 @@ |
183 | 189 | Html::element( |
184 | 190 | 'a', |
185 | 191 | array( |
186 | | - 'href' => SpecialPage::getTitleFor( 'UploadCampaigns', 'del/' . $campaign->campaign_name )->getLocalURL(), |
| 192 | + 'href' => SpecialPage::getTitleFor( 'UploadCampaigns', 'del/' . $campaign->campaign_name )->getLocalURL( $editToken ), |
187 | 193 | 'onclick' => 'return confirm( "' . wfMsg( 'mwe-upwiz-campaigns-confdel' ) . '" )' |
188 | 194 | ), |
189 | 195 | wfMsg( 'mwe-upwiz-campaigns-delete' ) |
— | — | @@ -192,6 +198,7 @@ |
193 | 199 | ); |
194 | 200 | } |
195 | 201 | |
| 202 | + $out->addHTML( '</tbody>' ); |
196 | 203 | $out->addHTML( '</table>' ); |
197 | 204 | } |
198 | 205 | |
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/includes/UploadWizardCampaign.php |
— | — | @@ -480,6 +480,12 @@ |
481 | 481 | protected function writePropsToDB( DatabaseBase $dbw ) { |
482 | 482 | $success = true; |
483 | 483 | |
| 484 | + if ( array_key_exists( 'defaultOwnWorkLicence', $this->config ) |
| 485 | + && array_key_exists( 'licensesOwnWork', $this->config ) |
| 486 | + && !in_array( $this->config['defaultOwnWorkLicence'], $this->config['licensesOwnWork'] ) ) { |
| 487 | + $this->config['licensesOwnWork'][] = $this->config['defaultOwnWorkLicence']; |
| 488 | + } |
| 489 | + |
484 | 490 | $dbw->begin(); |
485 | 491 | |
486 | 492 | foreach ( $this->config as $prop => $value ) { |