X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2FEditPage.php;h=f9c7fb29e8d8459ee3bf5f5407da820033d6c3d7;hb=9f026c24ec2f1e2b4374c77b42b6547f55848872;hp=5dc07207504ef68efd959c2cc9b37ac10caa8d76;hpb=276e1296ac8f8e040b5f7676fd7870cae153c894;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/EditPage.php b/includes/EditPage.php index 5dc0720750..f9c7fb29e8 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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 */ @@ -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? @@ -3780,7 +3811,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'], [ @@ -3997,7 +4028,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( [