SuchABot has uploaded a new change for review. https://gerrit.wikimedia.org/r/72869
Change subject: Enable use of wikitext in field labels ...................................................................... Enable use of wikitext in field labels Bug: 39911 Change-Id: I6b5b274aa3b61c3b584a3d4b3305717587148122 GitHub: https://github.com/wikimedia/mediawiki-extensions-UploadWizard/pull/5 --- M UploadWizard.config.php M includes/CampaignSchema.php M includes/specials/SpecialUploadWizard.php M maintenance/migrateCampaigns.php M resources/mw.UploadWizardDetails.js 5 files changed, 17 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard refs/changes/69/72869/1 diff --git a/UploadWizard.config.php b/UploadWizard.config.php index ed1bd80..2233c1e 100644 --- a/UploadWizard.config.php +++ b/UploadWizard.config.php @@ -124,12 +124,8 @@ // When non empty, this field will be shown, and $1 will be replaced by it's value. 'wikitext' => '', - // Label text to display with the field. + // Label text to display with the field. Is parsed as wikitext. 'label' => '', - - // Page on which the text to display with the id field is stored. - // Overrides label when set. $1 is replaced by the language code. - 'lagelPage' => '', // The maximum length of the id field. 'maxLength' => 25, diff --git a/includes/CampaignSchema.php b/includes/CampaignSchema.php index 36997cb..ff95791 100644 --- a/includes/CampaignSchema.php +++ b/includes/CampaignSchema.php @@ -36,9 +36,6 @@ "label" => array( "type" => "string" ), - "labelPage" => array( - "type" => "string" - ), "maxLength" => array( "type" => "integer" ), diff --git a/includes/specials/SpecialUploadWizard.php b/includes/specials/SpecialUploadWizard.php index aee579d..a733857 100644 --- a/includes/specials/SpecialUploadWizard.php +++ b/includes/specials/SpecialUploadWizard.php @@ -173,16 +173,16 @@ * @param subpage, e.g. the "foo" in Special:UploadWizard/foo */ public function addJsVars( $subPage ) { - global $wgSitename; + global $wgSitename, $wgParser; $config = UploadWizardConfig::getConfig( $this->campaign ); if ( array_key_exists( 'fields', $config ) ) { foreach ( $config['fields'] as &$field ) { - if ( array_key_exists( 'labelPage', $field ) ) { - $labelPageContent = $this->getPageContent( $field['labelPage'] ); - if ( $labelPageContent !== false ) { - $field['label'] = $labelPageContent; + if ( array_key_exists( 'label', $field ) ) { + $labelContent = $this->getOutput()->parse( $field['label'] ); + if ( $labelContent !== false ) { + $field['label'] = $labelContent; } } } diff --git a/maintenance/migrateCampaigns.php b/maintenance/migrateCampaigns.php index a77f2c1..fb7ba77 100644 --- a/maintenance/migrateCampaigns.php +++ b/maintenance/migrateCampaigns.php @@ -190,6 +190,8 @@ array( 'wikitext' => $oldConfig['idField'], 'label' => $oldConfig['idFieldLabel'], + # Migrated even though this is a nop. + # People will have to migrate this manually 'labelPage' => $oldConfig['idFieldLabelPage'], 'maxLength' => $oldConfig['idFieldMaxLength'], 'initialValue' => $oldConfig['idFieldInitialValue'] diff --git a/resources/mw.UploadWizardDetails.js b/resources/mw.UploadWizardDetails.js index de642b3..d591261 100644 --- a/resources/mw.UploadWizardDetails.js +++ b/resources/mw.UploadWizardDetails.js @@ -212,10 +212,18 @@ .val( field.initialValue ) .data( 'field', field ); + // Strip out extra <p> added by the parser + // This is added everytime, and is a known issue that has absolutely + // no hope of being fixed anytime soon. Roan apparently wept + // over this, so I'm not even going to try. + // This is also meant to be html that has been pre-sanitized + // by the wikitext parser, and so free of any elements that can + // cause XSS + var fieldLabelHtml = $j( field.label ).html(); _this.$form.append( $j( '<div>' ).attr( 'class', 'mwe-upwiz-details-input-error' ) .append( $j( '<label>' ).attr( { 'class': 'mwe-validator-error', 'for': fieldInputId, 'generated': 'true' } ) ), - $j( '<div>' ).attr( 'class', 'mwe-upwiz-details-fieldname' ).text( field.label ).requiredFieldLabel(), + $j( '<div>' ).attr( 'class', 'mwe-upwiz-details-fieldname' ).html( fieldLabelHtml ).requiredFieldLabel(), $j( '<div>' ).attr( 'class', 'mwe-id-field' ) .append( $fieldInput ) ); -- To view, visit https://gerrit.wikimedia.org/r/72869 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6b5b274aa3b61c3b584a3d4b3305717587148122 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/UploadWizard Gerrit-Branch: master Gerrit-Owner: SuchABot <[email protected]> Gerrit-Reviewer: Yuvipanda <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
