Merge "EditPage: Remove unused variable in getCheckboxesOOUI()"
[lhc/web/wiklou.git] / includes / EditPage.php
index 664e9b8..9d2d402 100644 (file)
@@ -3064,9 +3064,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
@@ -3074,6 +3116,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 )
                );
@@ -3122,7 +3178,7 @@ class EditPage {
                }
 
                $labelText = $this->context->msg( $isSubjectPreview ? 'subject' : 'summary' )->parse();
-               $wgOut->addHTML( $this->getSummaryInputOOUI(
+               $wgOut->addHTML( $this->getSummaryInputWidget(
                                $summary,
                                $labelText,
                                [ 'class' => $summaryClass ]
@@ -3165,7 +3221,7 @@ class EditPage {
                $wgOut->addHTML( Html::hidden( 'wpStarttime', $this->starttime ) );
                $wgOut->addHTML( Html::hidden( 'wpEdittime', $this->edittime ) );
                $wgOut->addHTML( Html::hidden( 'editRevId', $this->editRevId ) );
-               $wgOut->addHTML( Html::hidden( 'wpScrolltop', $this->scrolltop ) );
+               $wgOut->addHTML( Html::hidden( 'wpScrolltop', $this->scrolltop, [ 'id' => 'wpScrolltop' ] ) );
 
                if ( !$this->checkUnicodeCompliantBrowser() ) {
                        $wgOut->addHTML( Html::hidden( 'safemode', '1' ) );
@@ -4086,7 +4142,7 @@ class EditPage {
         *   where bool indicates the checked status of the checkbox
         * @return array
         */
-       protected function getCheckboxesDefinition( $checked ) {
+       public function getCheckboxesDefinition( $checked ) {
                global $wgUser;
                $checkboxes = [];