X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FEditPage.php;h=ddb4971db7436008a26a9afe354402aa49b13c4d;hp=a41e6d91778d895d210265fa44c3553c43876205;hb=6d4e15476c6ec12ecc671c1d3536eacede7211b2;hpb=58858df842f91d9ea1c9f9b6f3c767d8b204886b diff --git a/includes/EditPage.php b/includes/EditPage.php index a41e6d9177..ddb4971db7 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -239,19 +239,19 @@ class EditPage { public $isConflict = false; /** - * @deprecated since 1.30 use Title::isCssJsSubpage() + * @deprecated since 1.30 use Title::isUserConfigPage() * @var bool */ public $isCssJsSubpage = false; /** - * @deprecated since 1.30 use Title::isCssSubpage() + * @deprecated since 1.30 use Title::isUserCssConfigPage() * @var bool */ public $isCssSubpage = false; /** - * @deprecated since 1.30 use Title::isJsSubpage() + * @deprecated since 1.30 use Title::isUserJsConfigPage() * @var bool */ public $isJsSubpage = false; @@ -325,7 +325,7 @@ class EditPage { /** @var bool Has a summary been preset using GET parameter &summary= ? */ public $hasPresetSummary = false; - /** @var Revision|bool */ + /** @var Revision|bool|null */ public $mBaseRevision = false; /** @var bool */ @@ -663,10 +663,10 @@ class EditPage { // css / js subpages of user pages get a special treatment // The following member variables are deprecated since 1.30, // the functions should be used instead. - $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage(); - $this->isCssSubpage = $this->mTitle->isCssSubpage(); - $this->isJsSubpage = $this->mTitle->isJsSubpage(); - $this->isWrongCaseCssJsPage = $this->isWrongCaseCssJsPage(); + $this->isCssJsSubpage = $this->mTitle->isUserConfigPage(); + $this->isCssSubpage = $this->mTitle->isUserCssConfigPage(); + $this->isJsSubpage = $this->mTitle->isUserJsConfigPage(); + $this->isWrongCaseCssJsPage = $this->isWrongCaseUserConfigPage(); # Show applicable editing introductions if ( $this->formtype == 'initial' || $this->firsttime ) { @@ -877,9 +877,9 @@ class EditPage { * * @return bool */ - protected function isWrongCaseCssJsPage() { - if ( $this->mTitle->isCssJsSubpage() ) { - $name = $this->mTitle->getSkinFromCssJsSubpage(); + protected function isWrongCaseUserConfigPage() { + if ( $this->mTitle->isUserConfigPage() ) { + $name = $this->mTitle->getSkinFromConfigSubpage(); $skins = array_merge( array_keys( Skin::getSkinNames() ), [ 'common' ] @@ -1717,7 +1717,7 @@ class EditPage { // being set. This is used by ConfirmEdit to display a captcha // without any error message cruft. } else { - $this->hookError = $status->getWikiText(); + $this->hookError = $this->formatStatusErrors( $status ); } // Use the existing $status->value if the hook set it if ( !$status->value ) { @@ -1727,7 +1727,7 @@ class EditPage { } elseif ( !$status->isOK() ) { # ...or the hook could be expecting us to produce an error // FIXME this sucks, we should just use the Status object throughout - $this->hookError = $status->getWikiText(); + $this->hookError = $this->formatStatusErrors( $status ); $status->fatal( 'hookaborted' ); $status->value = self::AS_HOOK_ERROR_EXPECTED; return false; @@ -1736,6 +1736,26 @@ class EditPage { return true; } + /** + * Wrap status errors in an errorbox for increased visiblity + * + * @param Status $status + * @return string Wikitext + */ + private function formatStatusErrors( Status $status ) { + $errmsg = $status->getWikiText( + 'edit-error-short', + 'edit-error-long', + $this->context->getLanguage() + ); + return << +{$errmsg} + +
+ERROR; + } + /** * Return the summary to be used for a new section. * @@ -2349,7 +2369,7 @@ class EditPage { /** * @note: this method is very poorly named. If the user opened the form with ?oldid=X, * one might think of X as the "base revision", which is NOT what this returns. - * @return Revision Current version when the edit was started + * @return Revision|null Current version when the edit was started */ public function getBaseRevision() { if ( !$this->mBaseRevision ) { @@ -2452,12 +2472,22 @@ class EditPage { $displayTitle = $contextTitle->getPrefixedText(); } $out->setPageTitle( $this->context->msg( $msg, $displayTitle ) ); + + $config = $this->context->getConfig(); + # Transmit the name of the message to JavaScript for live preview # Keep Resources.php/mediawiki.action.edit.preview in sync with the possible keys $out->addJsConfigVars( [ 'wgEditMessage' => $msg, - 'wgAjaxEditStash' => $this->context->getConfig()->get( 'AjaxEditStash' ), + 'wgAjaxEditStash' => $config->get( 'AjaxEditStash' ), ] ); + + // Add whether to use 'save' or 'publish' messages to JavaScript for post-edit, other + // editors, etc. + $out->addJsConfigVars( + 'wgEditSubmitButtonLabelPublish', + $config->get( 'EditSubmitButtonLabelPublish' ) + ); } /** @@ -2768,7 +2798,8 @@ class EditPage { if ( $this->wasDeletedSinceLastEdit() && 'save' == $this->formtype ) { $username = $this->lastDelete->user_name; - $comment = CommentStore::newKey( 'log_comment' )->getComment( $this->lastDelete )->text; + $comment = CommentStore::getStore() + ->getComment( 'log_comment', $this->lastDelete )->text; // It is better to not parse the comment at all than to have templates expanded in the middle // TODO: can the checkLabel be moved outside of the div so that wrapWikiMsg could be used? @@ -2848,7 +2879,7 @@ class EditPage { $out->addHTML( $editConflictHelper->getEditFormHtmlBeforeContent() ); } - if ( !$this->mTitle->isCssJsSubpage() && $showToolbar && $user->getOption( 'showtoolbar' ) ) { + if ( !$this->mTitle->isUserConfigPage() && $showToolbar && $user->getOption( 'showtoolbar' ) ) { $out->addHTML( self::getEditToolbar( $this->mTitle ) ); } @@ -3085,22 +3116,26 @@ class EditPage { ); } } else { - if ( $this->mTitle->isCssJsSubpage() ) { + if ( $this->mTitle->isUserConfigPage() ) { # Check the skin exists - if ( $this->isWrongCaseCssJsPage() ) { + if ( $this->isWrongCaseUserConfigPage() ) { $out->wrapWikiMsg( - "
\n$1\n
", - [ 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ] + "
\n$1\n
", + [ 'userinvalidconfigtitle', $this->mTitle->getSkinFromConfigSubpage() ] ); } if ( $this->getTitle()->isSubpageOf( $user->getUserPage() ) ) { - $isCssSubpage = $this->mTitle->isCssSubpage(); - $out->wrapWikiMsg( '
$1
', - $isCssSubpage ? 'usercssispublic' : 'userjsispublic' - ); + $isUserCssConfig = $this->mTitle->isUserCssConfigPage(); + + $warning = $isUserCssConfig + ? 'usercssispublic' + : 'userjsispublic'; + + $out->wrapWikiMsg( '
$1
', $warning ); + if ( $this->formtype !== 'preview' ) { $config = $this->context->getConfig(); - if ( $isCssSubpage && $config->get( 'AllowUserCss' ) ) { + if ( $isUserCssConfig && $config->get( 'AllowUserCss' ) ) { $out->wrapWikiMsg( "
\n$1\n
", [ 'usercssyoucanpreview' ] @@ -3727,7 +3762,7 @@ class EditPage { return new OOUI\ButtonWidget( [ 'id' => 'mw-editform-cancel', - 'href' => $this->getContextTitle()->getLinkUrl( $cancelParams ), + 'href' => $this->getContextTitle()->getLinkURL( $cancelParams ), 'label' => new OOUI\HtmlSnippet( $this->context->msg( 'cancel' )->parse() ), 'framed' => false, 'infusable' => true, @@ -3780,7 +3815,7 @@ class EditPage { */ protected function getLastDelete() { $dbr = wfGetDB( DB_REPLICA ); - $commentQuery = CommentStore::newKey( 'log_comment' )->getJoin(); + $commentQuery = CommentStore::getStore()->getJoin( 'log_comment' ); $data = $dbr->selectRow( [ 'logging', 'user' ] + $commentQuery['tables'], [ @@ -3882,10 +3917,10 @@ class EditPage { } # don't parse non-wikitext pages, show message about preview - if ( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) { - if ( $this->mTitle->isCssJsSubpage() ) { + if ( $this->mTitle->isUserConfigPage() || $this->mTitle->isSiteConfigPage() ) { + if ( $this->mTitle->isUserConfigPage() ) { $level = 'user'; - } elseif ( $this->mTitle->isCssOrJsPage() ) { + } elseif ( $this->mTitle->isSiteConfigPage() ) { $level = 'site'; } else { $level = false; @@ -3997,7 +4032,6 @@ class EditPage { $this->mTitle, $pstContent, $user ); $parserOutput = $pstContent->getParserOutput( $this->mTitle, null, $parserOptions ); ScopedCallback::consume( $scopedCallback ); - $parserOutput->setEditSectionTokens( false ); // no section edit links return [ 'parserOutput' => $parserOutput, 'html' => $parserOutput->getText( [ @@ -4392,34 +4426,32 @@ class EditPage { public function getEditButtons( &$tabindex ) { $buttons = []; - $buttonLabel = $this->context->msg( $this->getSubmitButtonLabel() )->text(); + $labelAsPublish = + $this->context->getConfig()->get( 'EditSubmitButtonLabelPublish' ); - $attribs = [ - 'name' => 'wpSave', - 'tabindex' => ++$tabindex, - ]; + $buttonLabel = $this->context->msg( $this->getSubmitButtonLabel() )->text(); + $buttonTooltip = $labelAsPublish ? 'publish' : 'save'; - $saveConfig = OOUI\Element::configFromHtmlAttributes( $attribs ); $buttons['save'] = new OOUI\ButtonInputWidget( [ + 'name' => 'wpSave', + 'tabIndex' => ++$tabindex, 'id' => 'wpSaveWidget', 'inputId' => 'wpSave', // Support: IE 6 – Use , otherwise it can't distinguish which button was clicked 'useInputTag' => true, - 'flags' => [ 'constructive', 'primary' ], + 'flags' => [ 'progressive', 'primary' ], 'label' => $buttonLabel, 'infusable' => true, 'type' => 'submit', - 'title' => Linker::titleAttrib( 'save' ), - 'accessKey' => Linker::accesskey( 'save' ), - ] + $saveConfig ); - - $attribs = [ - 'name' => 'wpPreview', - 'tabindex' => ++$tabindex, - ]; + // Messages used: tooltip-save, tooltip-publish + 'title' => Linker::titleAttrib( $buttonTooltip ), + // Messages used: accesskey-save, accesskey-publish + 'accessKey' => Linker::accesskey( $buttonTooltip ), + ] ); - $previewConfig = OOUI\Element::configFromHtmlAttributes( $attribs ); $buttons['preview'] = new OOUI\ButtonInputWidget( [ + 'name' => 'wpPreview', + 'tabIndex' => ++$tabindex, 'id' => 'wpPreviewWidget', 'inputId' => 'wpPreview', // Support: IE 6 – Use , otherwise it can't distinguish which button was clicked @@ -4427,17 +4459,15 @@ class EditPage { 'label' => $this->context->msg( 'showpreview' )->text(), 'infusable' => true, 'type' => 'submit', + // Message used: tooltip-preview 'title' => Linker::titleAttrib( 'preview' ), + // Message used: accesskey-preview 'accessKey' => Linker::accesskey( 'preview' ), - ] + $previewConfig ); - - $attribs = [ - 'name' => 'wpDiff', - 'tabindex' => ++$tabindex, - ]; + ] ); - $diffConfig = OOUI\Element::configFromHtmlAttributes( $attribs ); $buttons['diff'] = new OOUI\ButtonInputWidget( [ + 'name' => 'wpDiff', + 'tabIndex' => ++$tabindex, 'id' => 'wpDiffWidget', 'inputId' => 'wpDiff', // Support: IE 6 – Use , otherwise it can't distinguish which button was clicked @@ -4445,9 +4475,11 @@ class EditPage { 'label' => $this->context->msg( 'showdiff' )->text(), 'infusable' => true, 'type' => 'submit', + // Message used: tooltip-diff 'title' => Linker::titleAttrib( 'diff' ), + // Message used: accesskey-diff 'accessKey' => Linker::accesskey( 'diff' ), - ] + $diffConfig ); + ] ); // Avoid PHP 7.1 warning of passing $this by reference $editPage = $this;