EditPage: Restore getSummaryInput(); deprecate it and getSummaryInputOOUI()
authorBartosz Dziewoński <matma.rex@gmail.com>
Wed, 30 Aug 2017 18:33:23 +0000 (20:33 +0200)
committerKunal Mehta <legoktm@member.fsf.org>
Fri, 1 Sep 2017 20:00:15 +0000 (13:00 -0700)
Follow-up to 478caa076f75fde935c66eb9334410d868c30818.
We can't just remove it without a deprecation.

Change-Id: I3286e8de12bacb50a6d080477adbecf09b3be71c

RELEASE-NOTES-1.30
includes/EditPage.php

index 7fff8ad..1075999 100644 (file)
@@ -183,6 +183,8 @@ changes to languages because of Phabricator reports.
 * MWMemcached and MemCachedClientforWiki classes (deprecated in 1.27) were removed.
   The MemcachedClient class should be used instead.
 * EditPage::isOouiEnabled() is deprecated and will always return true.
+* EditPage::getSummaryInput() and ::getSummaryInputOOUI() are deprecated. Please
+  use ::getSummaryInputWidget() instead.
 * Parser::getRandomString() (deprecated in 1.26) was removed.
 * Parser::uniqPrefix() (deprecated in 1.26) was removed.
 * Parser::extractTagsAndParams() now only accepts three arguments.  The fourth,
index 0e1438f..48e694c 100644 (file)
@@ -3065,9 +3065,51 @@ class EditPage {
                ];
        }
 
+       /**
+        * Standard summary input and label (wgSummary), abstracted so EditPage
+        * subclasses may reorganize the form.
+        * Note that you do not need to worry about the label's for=, it will be
+        * inferred by the id given to the input. You can remove them both by
+        * passing [ 'id' => false ] to $userInputAttrs.
+        *
+        * @deprecated since 1.30 Use getSummaryInputWidget() instead
+        * @param string $summary The value of the summary input
+        * @param string $labelText The html to place inside the label
+        * @param array $inputAttrs Array of attrs to use on the input
+        * @param array $spanLabelAttrs Array of attrs to use on the span inside the label
+        * @return array An array in the format [ $label, $input ]
+        */
+       public function getSummaryInput( $summary = "", $labelText = null,
+               $inputAttrs = null, $spanLabelAttrs = null
+       ) {
+               wfDeprecated( __METHOD__, '1.30' );
+               $inputAttrs = $this->getSummaryInputAttributes( $inputAttrs );
+               $inputAttrs += Linker::tooltipAndAccesskeyAttribs( 'summary' );
+
+               $spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? $spanLabelAttrs : [] ) + [
+                       'class' => $this->missingSummary ? 'mw-summarymissed' : 'mw-summary',
+                       'id' => "wpSummaryLabel"
+               ];
+
+               $label = null;
+               if ( $labelText ) {
+                       $label = Xml::tags(
+                               'label',
+                               $inputAttrs['id'] ? [ 'for' => $inputAttrs['id'] ] : null,
+                               $labelText
+                       );
+                       $label = Xml::tags( 'span', $spanLabelAttrs, $label );
+               }
+
+               $input = Html::input( 'wpSummary', $summary, 'text', $inputAttrs );
+
+               return [ $label, $input ];
+       }
+
        /**
         * Builds a standard summary input with a label.
         *
+        * @deprecated since 1.30 Use getSummaryInputWidget() instead
         * @param string $summary The value of the summary input
         * @param string $labelText The html to place inside the label
         * @param array $inputAttrs Array of attrs to use on the input
@@ -3075,6 +3117,20 @@ class EditPage {
         * @return OOUI\FieldLayout OOUI FieldLayout with Label and Input
         */
        function getSummaryInputOOUI( $summary = "", $labelText = null, $inputAttrs = null ) {
+               wfDeprecated( __METHOD__, '1.30' );
+               $this->getSummaryInputWidget( $summary, $labelText, $inputAttrs );
+       }
+
+       /**
+        * Builds a standard summary input with a label.
+        *
+        * @param string $summary The value of the summary input
+        * @param string $labelText The html to place inside the label
+        * @param array $inputAttrs Array of attrs to use on the input
+        *
+        * @return OOUI\FieldLayout OOUI FieldLayout with Label and Input
+        */
+       function getSummaryInputWidget( $summary = "", $labelText = null, $inputAttrs = null ) {
                $inputAttrs = OOUI\Element::configFromHtmlAttributes(
                        $this->getSummaryInputAttributes( $inputAttrs )
                );
@@ -3123,7 +3179,7 @@ class EditPage {
                }
 
                $labelText = $this->context->msg( $isSubjectPreview ? 'subject' : 'summary' )->parse();
-               $wgOut->addHTML( $this->getSummaryInputOOUI(
+               $wgOut->addHTML( $this->getSummaryInputWidget(
                                $summary,
                                $labelText,
                                [ 'class' => $summaryClass ]