BryanDavis has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/207794

Change subject: Allow selection of HTMLForm display format
......................................................................

Allow selection of HTMLForm display format

Add a 'DisplayFormat' configuration value that tells HTMLForm which output
styling should be used. This can be used for example to change the form
to the 'vform' style which uses the Mediawiki.ui css styles.

Change-Id: I04d2959b80a44e31f1e04324b26e6dff5ea5b4a6
---
M ContactPage.php
M ContactPage_body.php
M extension.json
3 files changed, 15 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContactPage 
refs/changes/94/207794/1

diff --git a/ContactPage.php b/ContactPage.php
index e2ae761..072c9d9 100644
--- a/ContactPage.php
+++ b/ContactPage.php
@@ -80,6 +80,10 @@
        // address of the submitter in the subject line
        'IncludeIP' => false,
 
+       // Display format for the form. See HTMLForm documentation for available
+       // values.
+       'DisplayFormat' => 'table',
+
        // Any additional fields to display on the contact form.
        // Uses https://www.mediawiki.org/wiki/HTMLForm notation
        // Using any of your own "AdditionalFields" will replce the large text 
box
diff --git a/ContactPage_body.php b/ContactPage_body.php
index 72c4a3b..ba3f533 100644
--- a/ContactPage_body.php
+++ b/ContactPage_body.php
@@ -201,7 +201,9 @@
                        );
                }
 
-               $form = new HTMLForm( $formItems, $this->getContext(), 
"contactpage-{$this->formType}" );
+               $form = HTMLForm::factory( $config['DisplayFormat'],
+                       $formItems, $this->getContext(), 
"contactpage-{$this->formType}"
+               );
                $form->setWrapperLegendMsg( 'contactpage-legend' );
                $form->setSubmitTextMsg( 'emailsend' );
                if ( $this->formType != '' ) {
@@ -245,6 +247,13 @@
 
                        $out->returnToMain( false );
                } else {
+                       if ( $config['DisplayFormat'] === 'vform' ) {
+                               $this->getOutput()->addModuleStyles( array(
+                                       'mediawiki.ui',
+                                       'mediawiki.ui.button',
+                                       'mediawiki.ui.input',
+                               ) );
+                       }
                        $this->getOutput()->prependHTML( trim( $formText ) );
                }
        }
diff --git a/extension.json b/extension.json
index cc3c58a..f220b12 100644
--- a/extension.json
+++ b/extension.json
@@ -25,6 +25,7 @@
                                "SenderName": null,
                                "RequireDetails": false,
                                "IncludeIP": false,
+                               "DisplayFormat": "table",
                                "AdditionalFields": {
                                        "Text": {
                                                "label-message": "emailmessage",

-- 
To view, visit https://gerrit.wikimedia.org/r/207794
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I04d2959b80a44e31f1e04324b26e6dff5ea5b4a6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContactPage
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <bda...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to