From: jenkins-bot Date: Mon, 7 Aug 2017 10:07:07 +0000 (+0000) Subject: Merge "Use HTML::hidden to create input fields" X-Git-Tag: 1.31.0-rc.0~2453 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=24ebca2251f94a20acee53e583d65aa7fac2c15d;hp=-c Merge "Use HTML::hidden to create input fields" --- 24ebca2251f94a20acee53e583d65aa7fac2c15d diff --combined includes/EditPage.php index 9d83fbd91d,e5fb4c5c10..cfb78cd78d --- a/includes/EditPage.php +++ b/includes/EditPage.php @@@ -1698,7 -1698,7 +1698,7 @@@ class EditPage global $wgParser; if ( $this->sectiontitle !== '' ) { - $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->sectiontitle ); + $sectionanchor = $this->guessSectionName( $this->sectiontitle ); // If no edit summary was specified, create one automatically from the section // title and have it link to the new section. Otherwise, respect the summary as // passed. @@@ -1708,7 -1708,7 +1708,7 @@@ ->rawParams( $cleanSectionTitle )->inContentLanguage()->text(); } } elseif ( $this->summary !== '' ) { - $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->summary ); + $sectionanchor = $this->guessSectionName( $this->summary ); # This is a new section, so create a link to the new section # in the revision summary. $cleanSummary = $wgParser->stripSectionName( $this->summary ); @@@ -1743,7 -1743,7 +1743,7 @@@ * time. */ public function internalAttemptSave( &$result, $bot = false ) { - global $wgUser, $wgRequest, $wgParser, $wgMaxArticleSize; + global $wgUser, $wgRequest, $wgMaxArticleSize; global $wgContentHandlerUseDB; $status = Status::newGood(); @@@ -2117,7 -2117,7 +2117,7 @@@ # We can't deal with anchors, includes, html etc in the header for now, # headline would need to be parsed to improve this. if ( $hasmatch && strlen( $matches[2] ) > 0 ) { - $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $matches[2] ); + $sectionanchor = $this->guessSectionName( $matches[2] ); } } $result['sectionanchor'] = $sectionanchor; @@@ -3076,7 -3076,7 +3076,7 @@@ 'tabindex' => 1, 'size' => 60, 'spellcheck' => 'true', - ] + Linker::tooltipAndAccesskeyAttribs( 'summary' ); + ]; } /** @@@ -3097,7 -3097,6 +3097,7 @@@ $inputAttrs = null, $spanLabelAttrs = null ) { $inputAttrs = $this->getSummaryInputAttributes( $inputAttrs ); + $inputAttrs += Linker::tooltipAndAccesskeyAttribs( 'summary' ); $spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? $spanLabelAttrs : [] ) + [ 'class' => $this->missingSummary ? 'mw-summarymissed' : 'mw-summary', @@@ -3133,10 -3132,6 +3133,10 @@@ $inputAttrs = OOUI\Element::configFromHtmlAttributes( $this->getSummaryInputAttributes( $inputAttrs ) ); + $inputAttrs += [ + 'title' => Linker::titleAttrib( 'summary' ), + 'accessKey' => Linker::accesskey( 'summary' ), + ]; // For compatibility with old scripts and extensions, we want the legacy 'id' on the `` $inputAttrs['inputId'] = $inputAttrs['id']; @@@ -3225,16 -3220,13 +3225,13 @@@ protected function showFormBeforeText() { global $wgOut; - $section = htmlspecialchars( $this->section ); - $wgOut->addHTML( << - - - - - - HTML - ); + + $wgOut->addHTML( Html::hidden( 'wpSection', htmlspecialchars( $this->section ) ) ); + $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 ) ); + if ( !$this->checkUnicodeCompliantBrowser() ) { $wgOut->addHTML( Html::hidden( 'safemode', '1' ) ); } @@@ -3498,8 -3490,8 +3495,8 @@@ } /** - * Inserts optional text shown below edit and upload forms. Can be used to offer special characters not present on - * most keyboards for copying/pasting. + * Inserts optional text shown below edit and upload forms. Can be used to offer special + * characters not present on most keyboards for copying/pasting. */ protected function showEditTools() { global $wgOut; @@@ -4282,7 -4274,7 +4279,7 @@@ $accesskey = null; if ( isset( $options['tooltip'] ) ) { $accesskey = $this->context->msg( "accesskey-{$options['tooltip']}" )->text(); - $title = Linker::titleAttrib( $options['tooltip'], 'withaccess' ); + $title = Linker::titleAttrib( $options['tooltip'] ); } if ( isset( $options['title-message'] ) ) { $title = $this->context->msg( $options['title-message'] )->text(); @@@ -4360,7 -4352,8 +4357,7 @@@ $attribs = [ 'name' => 'wpSave', 'tabindex' => ++$tabindex, - ] + Linker::tooltipAndAccesskeyAttribs( 'save' ); - + ]; if ( $this->oouiEnabled ) { $saveConfig = OOUI\Element::configFromHtmlAttributes( $attribs ); $buttons['save'] = new OOUI\ButtonInputWidget( [ @@@ -4372,13 -4365,11 +4369,13 @@@ 'label' => $buttonLabel, 'infusable' => true, 'type' => 'submit', + 'title' => Linker::titleAttrib( 'save' ), + 'accessKey' => Linker::accesskey( 'save' ), ] + $saveConfig ); } else { $buttons['save'] = Html::submitButton( $buttonLabel, - $attribs + [ 'id' => 'wpSave' ], + $attribs + Linker::tooltipAndAccesskeyAttribs( 'save' ) + [ 'id' => 'wpSave' ], [ 'mw-ui-progressive' ] ); } @@@ -4386,7 -4377,7 +4383,7 @@@ $attribs = [ 'name' => 'wpPreview', 'tabindex' => ++$tabindex, - ] + Linker::tooltipAndAccesskeyAttribs( 'preview' ); + ]; if ( $this->oouiEnabled ) { $previewConfig = OOUI\Element::configFromHtmlAttributes( $attribs ); $buttons['preview'] = new OOUI\ButtonInputWidget( [ @@@ -4396,20 -4387,18 +4393,20 @@@ 'useInputTag' => true, 'label' => $this->context->msg( 'showpreview' )->text(), 'infusable' => true, - 'type' => 'submit' + 'type' => 'submit', + 'title' => Linker::titleAttrib( 'preview' ), + 'accessKey' => Linker::accesskey( 'preview' ), ] + $previewConfig ); } else { $buttons['preview'] = Html::submitButton( $this->context->msg( 'showpreview' )->text(), - $attribs + [ 'id' => 'wpPreview' ] + $attribs + Linker::tooltipAndAccesskeyAttribs( 'preview' ) + [ 'id' => 'wpPreview' ] ); } $attribs = [ 'name' => 'wpDiff', 'tabindex' => ++$tabindex, - ] + Linker::tooltipAndAccesskeyAttribs( 'diff' ); + ]; if ( $this->oouiEnabled ) { $diffConfig = OOUI\Element::configFromHtmlAttributes( $attribs ); $buttons['diff'] = new OOUI\ButtonInputWidget( [ @@@ -4420,13 -4409,11 +4417,13 @@@ 'label' => $this->context->msg( 'showdiff' )->text(), 'infusable' => true, 'type' => 'submit', + 'title' => Linker::titleAttrib( 'diff' ), + 'accessKey' => Linker::accesskey( 'diff' ), ] + $diffConfig ); } else { $buttons['diff'] = Html::submitButton( $this->context->msg( 'showdiff' )->text(), - $attribs + [ 'id' => 'wpDiff' ] + $attribs + Linker::tooltipAndAccesskeyAttribs( 'diff' ) + [ 'id' => 'wpDiff' ] ); } @@@ -4795,27 -4782,4 +4792,27 @@@ } return $wikitext; } + + /** + * Turns section name wikitext into anchors for use in HTTP redirects. Various + * versions of Microsoft browsers misinterpret fragment encoding of Location: headers + * resulting in mojibake in address bar. Redirect them to legacy section IDs, + * if possible. All the other browsers get HTML5 if the wiki is configured for it, to + * spread the new style links more efficiently. + * + * @param string $text + * @return string + */ + private function guessSectionName( $text ) { + global $wgParser; + + // Detect Microsoft browsers + $userAgent = $this->context->getRequest()->getHeader( 'User-Agent' ); + if ( $userAgent && preg_match( '/MSIE|Edge/', $userAgent ) ) { + // ...and redirect them to legacy encoding, if available + return $wgParser->guessLegacySectionNameFromWikiText( $text ); + } + // Meanwhile, real browsers get real anchors + return $wgParser->guessSectionNameFromWikiText( $text ); + } }