Add blanket support for mediawiki ui via globals
authorjdlrobson <jdlrobson@gmail.com>
Wed, 30 Jul 2014 17:56:25 +0000 (10:56 -0700)
committerjdlrobson <jdlrobson@gmail.com>
Fri, 15 Aug 2014 21:48:00 +0000 (14:48 -0700)
This provides better mobile experiences on various pages
and a more consistent UI across both mobile and desktop.

It does this in two ways.

1) Forces HTMLForms to not use table based layouts so as
not to interfere with responsive nature of mediawiki ui elements

2) Applies MediaWiki.UI classes to most pages
If a page is created via Xml or Html classes it will use mediawiki ui
Where possible I've added classes unconditionally, but for cases of buttons
this is behind the $wgUseMediaWikiUIEverywhere global since button styling is
enabled on pages by default and for checkboxes since it is changes HTML markup.

3) Adds all MediaWiki.UI styles to pages which can use it
When enabled:
* Apply these styles to all pages which use HTMLForms
* Apply to EditPage
* Apply to anything that uses certain elements outputted by the
Xml or HTML helper classes
* Apply to History page
* Apply to protection page
* Apply to move page
* Apply to deletion page

Currently kept behind a global to allow us time to finetune
existing elements. After further testing we will look to kill the
globals and make mediawiki.ui the default

See: I430c0fbb79d2a33bb828b2427bda0ee01115d73f
Change-Id: I47db5eab4569514d039261d11b6dedb0eeae17b5

17 files changed:
includes/DefaultSettings.php
includes/EditPage.php
includes/Html.php
includes/Xml.php
includes/actions/DeleteAction.php
includes/actions/EditAction.php
includes/actions/HistoryAction.php
includes/actions/ProtectAction.php
includes/htmlform/HTMLCheckField.php
includes/htmlform/HTMLCheckMatrix.php
includes/htmlform/HTMLForm.php
includes/htmlform/HTMLMultiSelectField.php
includes/htmlform/HTMLTextAreaField.php
includes/htmlform/HTMLTextField.php
includes/specialpage/SpecialPage.php
tests/phpunit/includes/HtmlTest.php
tests/phpunit/includes/XmlTest.php

index 304a75f..cf00701 100644 (file)
@@ -2851,6 +2851,23 @@ $wgHtml5 = true;
  */
 $wgHtml5Version = null;
 
+/**
+ * Temporary variable that allows HTMLForms to be rendered as tables.
+ * Table based layouts cause various issues when designing for mobile.
+ * This global allows skins or extensions a means to force non-table based rendering.
+ * Setting to false forces form components to always render as div elements.
+ * @since 1.24
+ */
+$wgHTMLFormAllowTableFormat = true;
+
+/**
+ * Temporary variable that applies MediaWiki UI wherever it can be supported.
+ * Temporary variable that should be removed when mediawiki ui is more
+ * stable and change has been communicated.
+ * @since 1.24
+ */
+$wgUseMediaWikiUIEverywhere = false;
+
 /**
  * Enabled RDFa attributes for use in wikitext.
  * NOTE: Interaction with HTML5 is somewhat underspecified.
index f97e3f8..145eae2 100644 (file)
@@ -3183,7 +3183,7 @@ HTML
        }
 
        protected function showStandardInputs( &$tabindex = 2 ) {
-               global $wgOut;
+               global $wgOut, $wgUseMediaWikiUIEverywhere;
                $wgOut->addHTML( "<div class='editOptions'>\n" );
 
                if ( $this->section != 'new' ) {
@@ -3211,8 +3211,14 @@ HTML
 
                $message = wfMessage( 'edithelppage' )->inContentLanguage()->text();
                $edithelpurl = Skin::makeInternalOrExternalUrl( $message );
-               $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' .
-                       wfMessage( 'edithelp' )->escaped() . '</a> ' .
+               $attrs = array(
+                       'target' => 'helpwindow',
+                       'href' => $edithelpurl,
+               );
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $attrs['class'] = 'mw-ui-button mw-ui-quiet';
+               }
+               $edithelp = Html::element( 'a', $attrs, wfMessage( 'edithelp' )->text() ) .
                        wfMessage( 'newwindow' )->parse();
 
                $wgOut->addHTML( "      <span class='cancelLink'>{$cancel}</span>\n" );
@@ -3254,15 +3260,20 @@ HTML
         * @return string
         */
        public function getCancelLink() {
+               global $wgUseMediaWikiUIEverywhere;
                $cancelParams = array();
                if ( !$this->isConflict && $this->oldid > 0 ) {
                        $cancelParams['oldid'] = $this->oldid;
                }
+               $attrs = array( 'id' => 'mw-editform-cancel' );
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $attrs['class'] = 'mw-ui-button mw-ui-quiet';
+               }
 
                return Linker::linkKnown(
                        $this->getContextTitle(),
                        wfMessage( 'cancel' )->parse(),
-                       array( 'id' => 'mw-editform-cancel' ),
+                       $attrs,
                        $cancelParams
                );
        }
@@ -3690,7 +3701,7 @@ HTML
         * @return array
         */
        public function getCheckboxes( &$tabindex, $checked ) {
-               global $wgUser;
+               global $wgUser, $wgUseMediaWikiUIEverywhere;
 
                $checkboxes = array();
 
@@ -3704,11 +3715,19 @@ HTML
                                        'accesskey' => wfMessage( 'accesskey-minoredit' )->text(),
                                        'id' => 'wpMinoredit',
                                );
-                               $checkboxes['minor'] =
+                               $minorEditHtml =
                                        Xml::check( 'wpMinoredit', $checked['minor'], $attribs ) .
                                        "&#160;<label for='wpMinoredit' id='mw-editpage-minoredit'" .
                                        Xml::expandAttributes( array( 'title' => Linker::titleAttrib( 'minoredit', 'withaccess' ) ) ) .
                                        ">{$minorLabel}</label>";
+
+                               if ( $wgUseMediaWikiUIEverywhere ) {
+                                       $checkboxes['minor'] = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
+                                               $minorEditHtml .
+                                       Html::closeElement( 'div' );
+                               } else {
+                                       $checkboxes['minor'] = $minorEditHtml;
+                               }
                        }
                }
 
@@ -3720,11 +3739,18 @@ HTML
                                'accesskey' => wfMessage( 'accesskey-watch' )->text(),
                                'id' => 'wpWatchthis',
                        );
-                       $checkboxes['watch'] =
+                       $watchThisHtml =
                                Xml::check( 'wpWatchthis', $checked['watch'], $attribs ) .
                                "&#160;<label for='wpWatchthis' id='mw-editpage-watch'" .
                                Xml::expandAttributes( array( 'title' => Linker::titleAttrib( 'watch', 'withaccess' ) ) ) .
                                ">{$watchLabel}</label>";
+                       if ( $wgUseMediaWikiUIEverywhere ) {
+                               $checkboxes['watch'] = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
+                                       $watchThisHtml .
+                                       Html::closeElement( 'div' );
+                       } else {
+                               $checkboxes['watch'] = $watchThisHtml;
+                       }
                }
                wfRunHooks( 'EditPageBeforeEditChecks', array( &$this, &$checkboxes, &$tabindex ) );
                return $checkboxes;
@@ -3739,6 +3765,8 @@ HTML
         * @return array
         */
        public function getEditButtons( &$tabindex ) {
+               global $wgUseMediaWikiUIEverywhere;
+
                $buttons = array();
 
                $attribs = array(
@@ -3748,6 +3776,9 @@ HTML
                        'tabindex' => ++$tabindex,
                        'value' => wfMessage( 'savearticle' )->text(),
                ) + Linker::tooltipAndAccesskeyAttribs( 'save' );
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $attribs['class'] = 'mw-ui-button mw-ui-constructive';
+               }
                $buttons['save'] = Xml::element( 'input', $attribs, '' );
 
                ++$tabindex; // use the same for preview and live preview
@@ -3758,6 +3789,9 @@ HTML
                        'tabindex' => $tabindex,
                        'value' => wfMessage( 'showpreview' )->text(),
                ) + Linker::tooltipAndAccesskeyAttribs( 'preview' );
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $attribs['class'] = 'mw-ui-button mw-ui-progressive';
+               }
                $buttons['preview'] = Xml::element( 'input', $attribs, '' );
                $buttons['live'] = '';
 
@@ -3768,6 +3802,9 @@ HTML
                        'tabindex' => ++$tabindex,
                        'value' => wfMessage( 'showdiff' )->text(),
                ) + Linker::tooltipAndAccesskeyAttribs( 'diff' );
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $attribs['class'] = 'mw-ui-button mw-ui-progressive';
+               }
                $buttons['diff'] = Xml::element( 'input', $attribs, '' );
 
                wfRunHooks( 'EditPageBeforeEditButtons', array( &$this, &$buttons, &$tabindex ) );
index 4192507..9e7f5c4 100644 (file)
@@ -101,6 +101,35 @@ class Html {
                'itemscope',
        );
 
+       /**
+        * Modifies a set of attributes meant for text input elements
+        * and apply a set of default attributes.
+        * Removes size attribute when $wgUseMediaWikiUIEverywhere enabled.
+        * @param array $attrs An attribute array.
+        * @return array $attrs A modified attribute array
+        */
+       public static function getTextInputAttributes( $attrs ) {
+               global $wgUseMediaWikiUIEverywhere;
+               if ( !$attrs ) {
+                       $attrs = array();
+               }
+               if ( isset( $attrs['class'] ) ) {
+                       if ( is_array( $attrs['class'] ) ) {
+                               $attrs['class'][] = 'mw-ui-input';
+                       } else {
+                               $attrs['class'] .= ' mw-ui-input';
+                       }
+               } else {
+                       $attrs['class'] = 'mw-ui-input';
+               }
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       // Note that size can effect the desired width rendering of mw-ui-input elements
+                       // so it is removed. Left intact when mediawiki ui not enabled.
+                       unset( $attrs['size'] );
+               }
+               return $attrs;
+       }
+
        /**
         * Returns an HTML element in a string.  The major advantage here over
         * manually typing out the HTML is that it will escape all attribute
@@ -632,7 +661,9 @@ class Html {
                $attribs['type'] = $type;
                $attribs['value'] = $value;
                $attribs['name'] = $name;
-
+               if ( in_array( $type, array( 'text', 'search', 'email', 'password', 'number' ) ) ) {
+                       $attribs = Html::getTextInputAttributes( $attribs );
+               }
                return self::element( 'input', $attribs );
        }
 
@@ -731,7 +762,7 @@ class Html {
                } else {
                        $spacedValue = $value;
                }
-               return self::element( 'textarea', $attribs, $spacedValue );
+               return self::element( 'textarea', Html::getTextInputAttributes( $attribs ), $spacedValue );
        }
 
        /**
index 7761ecc..6df6258 100644 (file)
@@ -317,7 +317,8 @@ class Xml {
                        $attributes['value'] = $value;
                }
 
-               return self::element( 'input', $attributes + $attribs );
+               return self::element( 'input',
+                       Html::getTextInputAttributes( $attributes + $attribs ) );
        }
 
        /**
@@ -453,9 +454,16 @@ class Xml {
         * @return string HTML
         */
        public static function checkLabel( $label, $name, $id, $checked = false, $attribs = array() ) {
-               return self::check( $name, $checked, array( 'id' => $id ) + $attribs ) .
+               global $wgUseMediaWikiUIEverywhere;
+               $chkLabel = self::check( $name, $checked, array( 'id' => $id ) + $attribs ) .
                        '&#160;' .
                        self::label( $label, $id, $attribs );
+
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $chkLabel = self::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
+                               $chkLabel . self::closeElement( 'div' );
+               }
+               return $chkLabel;
        }
 
        /**
@@ -480,12 +488,26 @@ class Xml {
 
        /**
         * Convenience function to build an HTML submit button
+        * When $wgUseMediaWikiUIEverywhere is true it will default to a constructive button
         * @param string $value Label text for the button
         * @param array $attribs Optional custom attributes
         * @return string HTML
         */
        public static function submitButton( $value, $attribs = array() ) {
-               return Html::element( 'input', array( 'type' => 'submit', 'value' => $value ) + $attribs );
+               global $wgUseMediaWikiUIEverywhere;
+               $baseAttrs = array(
+                       'type' => 'submit',
+                       'value' => $value,
+               );
+               // Done conditionally for time being as it is possible
+               // some submit forms
+               // might need to be mw-ui-destructive (e.g. delete a page)
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $baseAttrs['class'] = 'mw-ui-button mw-ui-constructive';
+               }
+               // Any custom attributes will take precendence of anything in baseAttrs e.g. override the class
+               $attribs = $attribs + $baseAttrs;
+               return Html::element( 'input', $attribs );
        }
 
        /**
@@ -617,12 +639,14 @@ class Xml {
         */
        public static function textarea( $name, $content, $cols = 40, $rows = 5, $attribs = array() ) {
                return self::element( 'textarea',
-                                       array(
-                                               'name' => $name,
-                                               'id' => $name,
-                                               'cols' => $cols,
-                                               'rows' => $rows
-                                       ) + $attribs,
+                                       Html::getTextInputAttributes(
+                                               array(
+                                                       'name' => $name,
+                                                       'id' => $name,
+                                                       'cols' => $cols,
+                                                       'rows' => $rows
+                                               ) + $attribs
+                                       ),
                                        $content, false );
        }
 
index 069d570..9dc1049 100644 (file)
@@ -41,7 +41,14 @@ class DeleteAction extends FormlessAction {
        }
 
        public function show() {
-
+               global $wgUseMediaWikiUIEverywhere;
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $out = $this->getOutput();
+                       $out->addModuleStyles( array(
+                               'mediawiki.ui.input',
+                               'mediawiki.ui.checkbox',
+                       ) );
+               }
                $this->page->delete();
        }
 }
index 5a1e2c1..aaf4526 100644 (file)
@@ -41,6 +41,14 @@ class EditAction extends FormlessAction {
        }
 
        public function show() {
+               global $wgUseMediaWikiUIEverywhere;
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $out = $this->getOutput();
+                       $out->addModuleStyles( array(
+                               'mediawiki.ui.input',
+                               'mediawiki.ui.checkbox',
+                       ) );
+               }
                $page = $this->page;
                $user = $this->getUser();
 
index 7ca8f3a..66ea245 100644 (file)
@@ -105,9 +105,10 @@ class HistoryAction extends FormlessAction {
                wfProfileIn( __METHOD__ );
 
                $this->preCacheMessages();
+               $config = $this->context->getConfig();
 
                # Fill in the file cache if not set already
-               $useFileCache = $this->context->getConfig()->get( 'UseFileCache' );
+               $useFileCache = $config->get( 'UseFileCache' );
                if ( $useFileCache && HTMLFileCache::useFileCache( $this->getContext() ) ) {
                        $cache = HTMLFileCache::newFromTitle( $this->getTitle(), 'history' );
                        if ( !$cache->isCacheGood( /* Assume up to date */ ) ) {
@@ -118,6 +119,13 @@ class HistoryAction extends FormlessAction {
                // Setup page variables.
                $out->setFeedAppendQuery( 'action=history' );
                $out->addModules( 'mediawiki.action.history' );
+               if ( $config->get( 'UseMediaWikiUIEverywhere' ) ) {
+                       $out = $this->getOutput();
+                       $out->addModuleStyles( array(
+                               'mediawiki.ui.input',
+                               'mediawiki.ui.checkbox',
+                       ) );
+               }
 
                // Handle atom/RSS feeds.
                $feedType = $request->getVal( 'feed' );
@@ -464,6 +472,7 @@ class HistoryPager extends ReverseChronologicalPager {
         * @return string HTML output
         */
        function getStartBody() {
+               global $wgUseMediaWikiUIEverywhere;
                $this->lastRow = false;
                $this->counter = 1;
                $this->oldIdChecked = 0;
@@ -476,8 +485,12 @@ class HistoryPager extends ReverseChronologicalPager {
 
                // Button container stored in $this->buttons for re-use in getEndBody()
                $this->buttons = '<div>';
+               $className = 'historysubmit mw-history-compareselectedversions-button';
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $className .= ' mw-ui-button mw-ui-constructive';
+               }
                $this->buttons .= $this->submitButton( $this->msg( 'compareselectedversions' )->text(),
-                       array( 'class' => 'historysubmit mw-history-compareselectedversions-button' )
+                       array( 'class' => $className )
                                + Linker::tooltipAndAccesskeyAttribs( 'compareselectedversions' )
                ) . "\n";
 
index 2c2b470..443660b 100644 (file)
@@ -41,6 +41,14 @@ class ProtectAction extends FormlessAction {
        }
 
        public function show() {
+               global $wgUseMediaWikiUIEverywhere;
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $out = $this->getOutput();
+                       $out->addModuleStyles( array(
+                               'mediawiki.ui.input',
+                               'mediawiki.ui.checkbox',
+                       ) );
+               }
 
                $this->page->protect();
        }
index a0dd370..4eb7e6e 100644 (file)
@@ -26,9 +26,7 @@ class HTMLCheckField extends HTMLFormField {
                                ),
                                Xml::check( $this->mName, $value, $attr ) . $this->mLabel );
                } else {
-                       return Xml::check( $this->mName, $value, $attr )
-                       . '&#160;'
-                       . Html::rawElement( 'label', array( 'for' => $this->mID ), $this->mLabel );
+                       return Xml::checkLabel( $this->mLabel, $this->mName, $this->mID, $value, $attr );
                }
        }
 
index 606523b..8255526 100644 (file)
@@ -80,6 +80,8 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
         * @return string
         */
        function getInputHTML( $value ) {
+               global $wgUseMediaWikiUIEverywhere;
+
                $html = '';
                $tableContents = '';
                $rows = $this->mParams['rows'];
@@ -113,8 +115,9 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
                        foreach ( $columns as $columnTag ) {
                                $thisTag = "$columnTag-$rowTag";
                                // Construct the checkbox
+                               $thisId = "{$this->mID}-$thisTag";
                                $thisAttribs = array(
-                                       'id' => "{$this->mID}-$thisTag",
+                                       'id' => $thisId,
                                        'value' => $thisTag,
                                );
                                $checked = in_array( $thisTag, (array)$value, true );
@@ -125,10 +128,17 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
                                        $checked = true;
                                        $thisAttribs['disabled'] = 1;
                                }
+                               $chkBox = Xml::check( "{$this->mName}[]", $checked, $attribs + $thisAttribs );
+                               if ( $wgUseMediaWikiUIEverywhere ) {
+                                       $chkBox = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
+                                               $chkBox .
+                                               Html::element( 'label', array( 'for' => $thisId ) ) .
+                                               Html::closeElement( 'div' );
+                               }
                                $rowContents .= Html::rawElement(
                                        'td',
                                        array(),
-                                       Xml::check( "{$this->mName}[]", $checked, $attribs + $thisAttribs )
+                                       $chkBox
                                );
                        }
                        $tableContents .= Html::rawElement( 'tr', array(), "\n$rowContents\n" );
index 6cf8d0a..885bcd7 100644 (file)
@@ -299,7 +299,12 @@ class HTMLForm extends ContextSource {
         * @return string
         */
        public function getDisplayFormat() {
-               return $this->displayFormat;
+               global $wgHTMLFormAllowTableFormat;
+               $format = $this->displayFormat;
+               if ( !$wgHTMLFormAllowTableFormat && $format === 'table' ) {
+                       $format = 'div';
+               }
+               return $format;
        }
 
        /**
@@ -868,6 +873,7 @@ class HTMLForm extends ContextSource {
         * @return string HTML.
         */
        function getButtons() {
+               global $wgUseMediaWikiUIEverywhere;
                $buttons = '';
 
                if ( $this->mShowSubmit ) {
@@ -887,15 +893,17 @@ class HTMLForm extends ContextSource {
 
                        $attribs['class'] = array( 'mw-htmlform-submit' );
 
+                       if ( $this->isVForm() || $wgUseMediaWikiUIEverywhere ) {
+                               array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-constructive' );
+                       }
+
                        if ( $this->isVForm() ) {
                                // mw-ui-block is necessary because the buttons aren't necessarily in an
                                // immediate child div of the vform.
                                // @todo Let client specify if the primary submit button is progressive or destructive
                                array_push(
                                        $attribs['class'],
-                                       'mw-ui-button',
                                        'mw-ui-big',
-                                       'mw-ui-constructive',
                                        'mw-ui-block'
                                );
                        }
@@ -928,6 +936,14 @@ class HTMLForm extends ContextSource {
                                $attrs['id'] = $button['id'];
                        }
 
+                       if ( $wgUseMediaWikiUIEverywhere ) {
+                               if ( isset( $attrs['class' ] ) ) {
+                                       $attrs['class'] .= ' mw-ui-button';
+                               } else {
+                                       $attrs['class'] = 'mw-ui-button';
+                               }
+                       }
+
                        $buttons .= Html::element( 'input', $attrs ) . "\n";
                }
 
@@ -1245,6 +1261,9 @@ class HTMLForm extends ContextSource {
                                // Close enough to a div.
                                $getFieldHtmlMethod = 'getDiv';
                                break;
+                       case 'div':
+                               $getFieldHtmlMethod = 'getDiv';
+                               break;
                        default:
                                $getFieldHtmlMethod = 'get' . ucfirst( $displayFormat );
                }
index 576f5cd..1b71ab9 100644 (file)
@@ -47,6 +47,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
                        } else {
                                $thisAttribs = array( 'id' => "{$this->mID}-$info", 'value' => $info );
 
+                               // @todo: Make this use checkLabel for consistency purposes
                                $checkbox = Xml::check(
                                        $this->mName . '[]',
                                        in_array( $info, $value, true ),
index 4fd1989..21173d2 100644 (file)
@@ -15,7 +15,6 @@ class HTMLTextAreaField extends HTMLFormField {
        function getInputHTML( $value ) {
                $attribs = array(
                                'id' => $this->mID,
-                               'name' => $this->mName,
                                'cols' => $this->getCols(),
                                'rows' => $this->getRows(),
                        ) + $this->getTooltipAndAccessKey();
@@ -34,7 +33,6 @@ class HTMLTextAreaField extends HTMLFormField {
                );
 
                $attribs += $this->getAttributes( $allowedParams );
-
-               return Html::element( 'textarea', $attribs, $value );
+               return Html::textarea( $this->mName, $value, $attribs );
        }
 }
index e584d88..10bc67f 100644 (file)
@@ -41,13 +41,14 @@ class HTMLTextField extends HTMLFormField {
                # Implement tiny differences between some field variants
                # here, rather than creating a new class for each one which
                # is essentially just a clone of this one.
+               $type = 'text';
                if ( isset( $this->mParams['type'] ) ) {
                        switch ( $this->mParams['type'] ) {
                                case 'int':
-                                       $attribs['type'] = 'number';
+                                       $type = 'number';
                                        break;
                                case 'float':
-                                       $attribs['type'] = 'number';
+                                       $type = 'number';
                                        $attribs['step'] = 'any';
                                        break;
                                # Pass through
@@ -55,11 +56,10 @@ class HTMLTextField extends HTMLFormField {
                                case 'password':
                                case 'file':
                                case 'url':
-                                       $attribs['type'] = $this->mParams['type'];
+                                       $type = $this->mParams['type'];
                                        break;
                        }
                }
-
-               return Html::element( 'input', $attribs );
+               return Html::input( $this->mName, $value, $type, $attribs );
        }
 }
index 4edd87a..8fc28f8 100644 (file)
@@ -333,6 +333,12 @@ class SpecialPage {
                $out->setArticleRelated( false );
                $out->setRobotPolicy( $this->getRobotPolicy() );
                $out->setPageTitle( $this->getDescription() );
+               if ( $this->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
+                       $out->addModuleStyles( array(
+                               'mediawiki.ui.input',
+                               'mediawiki.ui.checkbox',
+                       ) );
+               }
        }
 
        /**
index d4d9551..a8829cd 100644 (file)
@@ -715,7 +715,7 @@ class HtmlTest extends MediaWikiTestCase {
                        'Input wrapper with type and value.'
                );
                $this->assertEquals(
-                       '<input name=testname>',
+                       '<input name=testname class=mw-ui-input>',
                        Html::input( 'testname' ),
                        'Input wrapper with all default values.'
                );
index 382e3d8..e655881 100644 (file)
@@ -81,7 +81,7 @@ class XmlTest extends MediaWikiTestCase {
         */
        public function testElementInputCanHaveAValueOfZero() {
                $this->assertEquals(
-                       '<input name="name" value="0" />',
+                       '<input name="name" value="0" class="mw-ui-input" />',
                        Xml::input( 'name', false, 0 ),
                        'Input with a value of 0 (bug 23797)'
                );
@@ -152,7 +152,7 @@ class XmlTest extends MediaWikiTestCase {
 
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> ' .
-                               '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year" /> ' .
+                               '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year" class="mw-ui-input" /> ' .
                                '<label for="month">From month (and earlier):</label> ' .
                                '<select id="month" name="month" class="mw-month-selector">' .
                                '<option value="-1">all</option>' . "\n" .
@@ -173,7 +173,7 @@ class XmlTest extends MediaWikiTestCase {
                );
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> ' .
-                               '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year" /> ' .
+                               '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year" class="mw-ui-input" /> ' .
                                '<label for="month">From month (and earlier):</label> ' .
                                '<select id="month" name="month" class="mw-month-selector">' .
                                '<option value="-1">all</option>' . "\n" .
@@ -207,7 +207,7 @@ class XmlTest extends MediaWikiTestCase {
 
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> ' .
-                               '<input id="year" maxlength="4" size="7" type="number" name="year" /> ' .
+                               '<input id="year" maxlength="4" size="7" type="number" name="year" class="mw-ui-input" /> ' .
                                '<label for="month">From month (and earlier):</label> ' .
                                '<select id="month" name="month" class="mw-month-selector">' .
                                '<option value="-1">all</option>' . "\n" .
@@ -233,7 +233,7 @@ class XmlTest extends MediaWikiTestCase {
         */
        public function testTextareaNoContent() {
                $this->assertEquals(
-                       '<textarea name="name" id="name" cols="40" rows="5"></textarea>',
+                       '<textarea name="name" id="name" cols="40" rows="5" class="mw-ui-input"></textarea>',
                        Xml::textarea( 'name', '' ),
                        'textarea() with not content'
                );
@@ -244,7 +244,7 @@ class XmlTest extends MediaWikiTestCase {
         */
        public function testTextareaAttribs() {
                $this->assertEquals(
-                       '<textarea name="name" id="name" cols="20" rows="10">&lt;txt&gt;</textarea>',
+                       '<textarea name="name" id="name" cols="20" rows="10" class="mw-ui-input">&lt;txt&gt;</textarea>',
                        Xml::textarea( 'name', '<txt>', 20, 10 ),
                        'textarea() with custom attribs'
                );