X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FEditPage.php;h=098ffbf791015ea7f69cb7cb3a65681b5b3959fe;hb=0be08c438f92095fbdcb45b870615c4e7eef4e01;hp=f97f16469a1c818323e0a7fb06e197c3fc5c03e2;hpb=8ca0afde953e905762d549c0b289f7954262e535;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/EditPage.php b/includes/EditPage.php index f97f16469a..098ffbf791 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1452,10 +1452,8 @@ class EditPage { * This uses a temporary cookie for each revision ID so separate saves will never * interfere with each other. * - * The cookie is deleted in the mediawiki.action.view.postEdit JS module after - * the redirect. It must be clearable by JavaScript code, so it must not be - * marked HttpOnly. The JavaScript code converts the cookie to a wgPostEdit config - * variable. + * Article::view deletes the cookie on server-side after the redirect and + * converts the value to the global JavaScript variable wgPostEdit. * * If the variable were set on the server, it would be cached, which is unwanted * since the post-edit state should only apply to the load right after the save. @@ -1474,9 +1472,7 @@ class EditPage { } $response = RequestContext::getMain()->getRequest()->response(); - $response->setCookie( $postEditKey, $val, time() + self::POST_EDIT_COOKIE_DURATION, [ - 'httpOnly' => false, - ] ); + $response->setCookie( $postEditKey, $val, time() + self::POST_EDIT_COOKIE_DURATION ); } /** @@ -2757,6 +2753,9 @@ class EditPage { $wgOut->addHTML( Html::hidden( 'format', $this->contentFormat ) ); $wgOut->addHTML( Html::hidden( 'model', $this->contentModel ) ); + // Preserve &ooui=1 / &ooui=0 from URL parameters after submitting the page for preview + $wgOut->addHTML( Html::hidden( 'ooui', $this->oouiEnabled ? '1' : '0' ) ); + // following functions will need OOUI, enable it only once; here. if ( $this->oouiEnabled ) { $wgOut->enableOOUI(); @@ -2909,24 +2908,38 @@ class EditPage { } } + $buttonLabelKey = $this->getSaveButtonLabel(); + if ( $this->missingComment ) { $wgOut->wrapWikiMsg( "
\n$1\n
", 'missingcommenttext' ); } if ( $this->missingSummary && $this->section != 'new' ) { - $wgOut->wrapWikiMsg( "
\n$1\n
", 'missingsummary' ); + $wgOut->wrapWikiMsg( + "
\n$1\n
", + [ 'missingsummary', $buttonLabelKey ] + ); } if ( $this->missingSummary && $this->section == 'new' ) { - $wgOut->wrapWikiMsg( "
\n$1\n
", 'missingcommentheader' ); + $wgOut->wrapWikiMsg( + "
\n$1\n
", + [ 'missingcommentheader', $buttonLabelKey ] + ); } if ( $this->blankArticle ) { - $wgOut->wrapWikiMsg( "
\n$1\n
", 'blankarticle' ); + $wgOut->wrapWikiMsg( + "
\n$1\n
", + [ 'blankarticle', $buttonLabelKey ] + ); } if ( $this->selfRedirect ) { - $wgOut->wrapWikiMsg( "
\n$1\n
", 'selfredirect' ); + $wgOut->wrapWikiMsg( + "
\n$1\n
", + [ 'selfredirect', $buttonLabelKey ] + ); } if ( $this->hookError !== '' ) { @@ -3044,6 +3057,7 @@ class EditPage { // Note: the maxlength is overridden in JS to 255 and to make it use UTF-8 bytes, not characters. return ( is_array( $inputAttrs ) ? $inputAttrs : [] ) + [ 'id' => 'wpSummary', + 'name' => 'wpSummary', 'maxlength' => '200', 'tabindex' => '1', 'size' => 60, @@ -3155,7 +3169,6 @@ class EditPage { ); $wgOut->addHTML( "{$label} {$input}" ); } - } /** @@ -4096,11 +4109,14 @@ HTML } $script .= '});'; - $wgOut->addScript( ResourceLoader::makeInlineScript( $script ) ); $toolbar = '
'; - Hooks::run( 'EditPageBeforeEditToolbar', [ &$toolbar ] ); + if ( Hooks::run( 'EditPageBeforeEditToolbar', [ &$toolbar ] ) ) { + // Only add the old toolbar cruft to the page payload if the toolbar has not + // been over-written by a hook caller + $wgOut->addScript( ResourceLoader::makeInlineScript( $script ) ); + }; return $toolbar; } @@ -4279,6 +4295,27 @@ HTML return $checkboxes; } + /** + * Get the message key of the label for the button to save the page + * + * @return string + */ + private function getSaveButtonLabel() { + $labelAsPublish = + $this->mArticle->getContext()->getConfig()->get( 'EditSubmitButtonLabelPublish' ); + + // Can't use $this->isNew as that's also true if we're adding a new section to an extant page + $newPage = !$this->mTitle->exists(); + + if ( $labelAsPublish ) { + $buttonLabelKey = $newPage ? 'publishpage' : 'publishchanges'; + } else { + $buttonLabelKey = $newPage ? 'savearticle' : 'savechanges'; + } + + return $buttonLabelKey; + } + /** * Returns an array of html code of the following buttons: * save, diff and preview @@ -4290,15 +4327,8 @@ HTML public function getEditButtons( &$tabindex ) { $buttons = []; - $labelAsPublish = - $this->mArticle->getContext()->getConfig()->get( 'EditSubmitButtonLabelPublish' ); + $buttonLabelKey = $this->getSaveButtonLabel(); - // Can't use $this->isNew as that's also true if we're adding a new section to an extant page - if ( $labelAsPublish ) { - $buttonLabelKey = !$this->mTitle->exists() ? 'publishpage' : 'publishchanges'; - } else { - $buttonLabelKey = !$this->mTitle->exists() ? 'savearticle' : 'savechanges'; - } $attribs = [ 'id' => 'wpSave', 'name' => 'wpSave', @@ -4308,6 +4338,8 @@ HTML if ( $this->oouiEnabled ) { $saveConfig = OOUI\Element::configFromHtmlAttributes( $attribs ); $buttons['save'] = new OOUI\ButtonInputWidget( [ + // Support: IE 6 – Use , otherwise it can't distinguish which button was clicked + 'useInputTag' => true, 'flags' => [ 'constructive', 'primary' ], 'label' => $this->context->msg( $buttonLabelKey )->text(), 'infusable' => true, @@ -4329,6 +4361,8 @@ HTML if ( $this->oouiEnabled ) { $previewConfig = OOUI\Element::configFromHtmlAttributes( $attribs ); $buttons['preview'] = new OOUI\ButtonInputWidget( [ + // Support: IE 6 – Use , otherwise it can't distinguish which button was clicked + 'useInputTag' => true, 'label' => $this->context->msg( 'showpreview' )->text(), 'infusable' => true, 'type' => 'submit' @@ -4347,6 +4381,8 @@ HTML if ( $this->oouiEnabled ) { $diffConfig = OOUI\Element::configFromHtmlAttributes( $attribs ); $buttons['diff'] = new OOUI\ButtonInputWidget( [ + // Support: IE 6 – Use , otherwise it can't distinguish which button was clicked + 'useInputTag' => true, 'label' => $this->context->msg( 'showdiff' )->text(), 'infusable' => true, 'type' => 'submit', @@ -4659,7 +4695,10 @@ HTML * @since 1.29 */ protected function addExplainConflictHeader( OutputPage $out ) { - $out->wrapWikiMsg( "
\n$1\n
", 'explainconflict' ); + $out->wrapWikiMsg( + "
\n$1\n
", + [ 'explainconflict', $this->getSaveButtonLabel() ] + ); } /**