From 53defc09a7b3a3f5b77678cc9adc8e412c512136 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 30 Aug 2017 20:33:23 +0200 Subject: [PATCH] EditPage: Restore getSummaryInput(); deprecate it and getSummaryInputOOUI() Follow-up to 478caa076f75fde935c66eb9334410d868c30818. We can't just remove it without a deprecation. Change-Id: I3286e8de12bacb50a6d080477adbecf09b3be71c --- RELEASE-NOTES-1.30 | 2 ++ includes/EditPage.php | 58 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.30 b/RELEASE-NOTES-1.30 index 7fff8adf2e..10759995fc 100644 --- a/RELEASE-NOTES-1.30 +++ b/RELEASE-NOTES-1.30 @@ -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, diff --git a/includes/EditPage.php b/includes/EditPage.php index 0e1438f8f7..48e694c5c7 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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 ] -- 2.20.1