r95887 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95886‎ | r95887 | r95888 >
Date:17:10, 31 August 2011
Author:catrope
Status:ok
Tags:
Comment:
1.17wmf1: MFT UploadWizard fixes r95691, r95726, r95727, r95793, r95815, r95829, r95876, r95880
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/UploadWizard/UploadWizard.config.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/UploadWizard/includes/UploadWizardCampaign.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/UploadWizard/includes/specials/SpecialUploadCampaigns.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/UploadWizard/resources/jquery/jquery.validate.wmCommonsBlacklist.js (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/UploadWizard/resources/mw.UploadWizardDetails.js (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/UploadWizard/resources/mw.UploadWizardLicenseInput.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -1170,31 +1170,44 @@
11711171
11721172 },
11731173
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 ) {
11781183 var deeds = [];
1179 - var hasChoice = mw.UploadWizard.config.ownWorkOption == 'choice';
11801184
1181 - if ( hasChoice ) {
 1185+ if ( mw.UploadWizard.config.ownWorkOption == 'choice' ) {
11821186 // 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 ) );
11851189 }
11861190 else {
11871191 if ( mw.UploadWizard.config.ownWorkOption == 'own' ) {
1188 - deeds.push( new mw.UploadWizardDeedOwnWork( _this.uploads.length ) );
 1192+ deeds.push( new mw.UploadWizardDeedOwnWork( uploadsLength ) );
11891193 }
11901194 else {
1191 - deeds.push( new mw.UploadWizardDeedThirdParty( _this.uploads.length ) );
 1195+ deeds.push( new mw.UploadWizardDeedThirdParty( uploadsLength ) );
11921196 }
11931197 }
 1198+
 1199+ return deeds;
 1200+ },
11941201
 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+
11951207 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' ) {
11991212 var ownWork = mw.UploadWizard.config.licensesOwnWork;
12001213 var licenseIsNotDefault = ( ownWork.licenses.length === 1 && ownWork.licenses[0] !== ownWork.defaults[0] );
12011214 return ownWork.licenses.length > 1 || licenseIsNotDefault;
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
@@ -269,23 +269,33 @@
270270 _this.addDescription( true, mw.config.get( 'wgUserLanguage' ) );
271271 $j( containerDiv ).append( _this.div );
272272
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+ }
290300 // make this a category picker
291301 var hiddenCats = mw.isDefined( mw.UploadWizard.config.autoCategories ) ? mw.UploadWizard.config.autoCategories : [];
292302 if ( mw.isDefined( mw.UploadWizard.config.autoCategory ) && mw.UploadWizard.config.autoCategory !== '' ) {
@@ -350,12 +360,14 @@
351361 var _this = this;
352362 _this.copyrightInfoFieldset.show();
353363 _this.upload.wizardDeedChooser = _this.upload.deedChooser;
 364+
354365 _this.upload.deedChooser = new mw.UploadWizardDeedChooser(
355366 _this.deedDiv,
356 - [ new mw.UploadWizardDeedOwnWork(),
357 - new mw.UploadWizardDeedThirdParty() ],
 367+ mw.UploadWizard.prototype.getLicensingDeeds(),
358368 [ _this.upload ]
359369 );
 370+
 371+ _this.upload.deedChooser.onLayoutReady();
360372 },
361373
362374 /**
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/resources/jquery/jquery.validate.wmCommonsBlacklist.js
@@ -1,7 +1,10 @@
22 /**
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.
55 *
 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+ *
69 * 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
710 * ignores cases that are irrelevant to uploading new media images.
811 * - all regexes are case INsensitive by default
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/resources/mw.UploadWizardLicenseInput.js
@@ -80,6 +80,7 @@
8181 $input.click( function() { _this.$selector.trigger( 'changeLicenses' ); } );
8282 // this is added so that setValues() can find one (or more) checkboxes to check - represent values without wikitext
8383 $input.data( 'templateString', origTemplateString );
 84+ $input.data( 'licenseName', name );
8485 _this.inputs.push( $input );
8586
8687 var messageKey = mw.isDefined( license.props['msg'] ) ? license.props.msg : '[missing msg for ' + license.name + ']';
@@ -152,9 +153,9 @@
153154 setValues: function( values ) {
154155 var _this = this;
155156 $j.each( _this.inputs, function( i, $input ) {
156 - var templateString = $input.data( 'templateString' );
 157+ var licenseName = $input.data( 'licenseName' );
157158 // !! to ensure boolean.
158 - $input.attr( 'checked', !!values[templateString] );
 159+ $input.attr( 'checked', !!values[licenseName] );
159160 } );
160161 // we use the selector because events can't be unbound unless they're in the DOM.
161162 _this.$selector.trigger( 'changeLicenses' );
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/UploadWizard.config.php
@@ -142,7 +142,7 @@
143143 'own-pd' => array(
144144 'msg' => 'mwe-upwiz-license-own-pd',
145145 'icons' => array( 'cc-zero' ),
146 - 'templates' => array( 'own-pd' )
 146+ 'templates' => array( 'cc-zero' )
147147 ),
148148 'cc-by-sa-2.5' => array(
149149 'msg' => 'mwe-upwiz-license-cc-by-sa-2.5',
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php
@@ -162,16 +162,21 @@
163163 *
164164 * @param string $pageName
165165 * @param boolean $parse
 166+ * @param string $langCode
166167 *
167168 * @return string|false
168169 */
169 - protected function getPageContent( $pageName, $parse = false ) {
 170+ protected function getPageContent( $pageName, $parse = false, $langCode = null ) {
170171 $content = false;
171172
172173 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+ }
175178
 179+ $page = Title::newFromText( str_replace( '$1', $langCode, $pageName ) );
 180+
176181 if ( !is_null( $page ) && $page->exists() ) {
177182 $article = new Article( $page, 0 );
178183 $content = $article->getContent();
@@ -183,6 +188,11 @@
184189 }
185190 }
186191
 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+
187197 return $content;
188198 }
189199
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/includes/specials/SpecialUploadCampaigns.php
@@ -53,7 +53,8 @@
5454 && $wgRequest->getCheck( 'newcampaign' ) ) {
5555 $wgOut->redirect( SpecialPage::getTitleFor( 'UploadCampaign', $wgRequest->getVal( 'newcampaign' ) )->getLocalURL() );
5656 }
57 - elseif ( count( $subPage ) == 2 && $subPage[0] == 'del' ) {
 57+ elseif ( count( $subPage ) == 2 && $subPage[0] == 'del'
 58+ && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
5859 $campaign = UploadWizardCampaign::newFromName( $subPage[1], false );
5960 $campaign->deleteFromDB();
6061 $wgOut->redirect( $this->getTitle()->getLocalURL() );
@@ -144,18 +145,23 @@
145146
146147 $out->addHTML( Xml::openElement(
147148 'table',
148 - array( 'class' => 'wikitable', 'style' => 'width:400px' )
 149+ array( 'class' => 'wikitable sortable', 'style' => 'width:400px' )
149150 ) );
150151
151152 $out->addHTML(
152 - '<tr>' .
 153+ '<thead><tr>' .
153154 Html::element( 'th', array(), wfMsg( 'mwe-upwiz-campaigns-name' ) ) .
154155 Html::element( 'th', array(), wfMsg( 'mwe-upwiz-campaigns-status' ) ) .
155156 Html::element( 'th', array(), wfMsg( 'mwe-upwiz-campaigns-edit' ) ) .
156157 Html::element( 'th', array(), wfMsg( 'mwe-upwiz-campaigns-delete' ) ) .
157 - '</tr>'
 158+ '</tr></thead>'
158159 );
159160
 161+ $out->addHTML( '<tbody>' );
 162+
 163+ global $wgUser;
 164+ $editToken = array( 'wpEditToken' => $wgUser->editToken() );
 165+
160166 foreach ( $campaigns as $campaign ) {
161167 $out->addHTML(
162168 '<tr>' .
@@ -182,7 +188,7 @@
183189 Html::element(
184190 'a',
185191 array(
186 - 'href' => SpecialPage::getTitleFor( 'UploadCampaigns', 'del/' . $campaign->campaign_name )->getLocalURL(),
 192+ 'href' => SpecialPage::getTitleFor( 'UploadCampaigns', 'del/' . $campaign->campaign_name )->getLocalURL( $editToken ),
187193 'onclick' => 'return confirm( "' . wfMsg( 'mwe-upwiz-campaigns-confdel' ) . '" )'
188194 ),
189195 wfMsg( 'mwe-upwiz-campaigns-delete' )
@@ -192,6 +198,7 @@
193199 );
194200 }
195201
 202+ $out->addHTML( '</tbody>' );
196203 $out->addHTML( '</table>' );
197204 }
198205
Index: branches/wmf/1.17wmf1/extensions/UploadWizard/includes/UploadWizardCampaign.php
@@ -480,6 +480,12 @@
481481 protected function writePropsToDB( DatabaseBase $dbw ) {
482482 $success = true;
483483
 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+
484490 $dbw->begin();
485491
486492 foreach ( $this->config as $prop => $value ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95691make campaign table sortablejeroendedauw19:53, 29 August 2011
r95726address point 2 from bug 30620jeroendedauw23:25, 29 August 2011
r95727compare license name to license name instead of license templatejeroendedauw23:34, 29 August 2011
r95793fix point 3 from bug 30620jeroendedauw16:41, 30 August 2011
r95815Disable internal regex checks when TitleBlacklist checking is enabled....raindrift21:06, 30 August 2011
r95829Revert r94923...erik02:23, 31 August 2011
r95876fallback to en when current lang not availablejeroendedauw15:26, 31 August 2011
r95880address bug 30644jeroendedauw16:14, 31 August 2011

Status & tagging log