X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FEditPage.php;h=373f6d9bf6fe592d14c4cdaefbc29d0f312e5963;hb=049ae64857c620ffa3f79d70dc13190418b05744;hp=7143c3f3246f7dd958e6249cffa2d38312ce7981;hpb=1658759d42a5d802e29a71c3fd70ae127afd3e46;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/EditPage.php b/includes/EditPage.php
index 7143c3f324..373f6d9bf6 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -794,7 +794,7 @@ class EditPage {
$out->addHTML( $this->editFormTextTop );
if ( $errorMessage !== '' ) {
- $out->addWikiText( $errorMessage );
+ $out->addWikiTextAsInterface( $errorMessage );
$out->addHTML( "
" .
- $this->context->msg( 'undo-' . $undoMsg )->plain() . '
', true, /* interface */true );
+ $this->editFormPageTop .= Html::rawElement(
+ 'div', [ 'class' => $class ],
+ $out->parseAsInterface(
+ $this->context->msg( 'undo-' . $undoMsg )->plain()
+ )
+ );
}
if ( $content === false ) {
@@ -1640,7 +1644,7 @@ class EditPage {
case self::AS_CANNOT_USE_CUSTOM_MODEL:
case self::AS_PARSE_ERROR:
case self::AS_UNICODE_NOT_SUPPORTED:
- $out->addWikiText( '' . "\n" . $status->getWikiText() . '
' );
+ $out->wrapWikiTextAsInterface( 'error', $status->getWikiText() );
return true;
case self::AS_SUCCESS_NEW_ARTICLE:
@@ -2479,13 +2483,6 @@ ERROR;
$out->addModuleStyles( 'mediawiki.editfont.styles' );
$user = $this->context->getUser();
- if ( $user->getOption( 'showtoolbar' ) ) {
- // The addition of default buttons is handled by getEditToolbar() which
- // has its own dependency on this module. The call here ensures the module
- // is loaded in time (it has position "top") for other modules to register
- // buttons (e.g. extensions, gadgets, user scripts).
- $out->addModules( 'mediawiki.toolbar' );
- }
if ( $user->getOption( 'uselivepreview' ) ) {
$out->addModules( 'mediawiki.action.edit.preview' );
@@ -2788,13 +2785,8 @@ ERROR;
$out->addHTML( $this->editFormTextTop );
- $showToolbar = true;
if ( $this->wasDeletedSinceLastEdit() ) {
- if ( $this->formtype == 'save' ) {
- // Hide the toolbar and edit area, user can click preview to get it back
- // Add an confirmation checkbox and explanation.
- $showToolbar = false;
- } else {
+ if ( $this->formtype !== 'save' ) {
$out->wrapWikiMsg( "' . $msg->plain() . '
' );
+ $out->wrapWikiTextAsInterface( 'error', $msg->plain() );
}
}
@@ -3109,7 +3101,7 @@ ERROR;
}
if ( $this->hookError !== '' ) {
- $out->addWikiText( $this->hookError );
+ $out->addWikiTextAsInterface( $this->hookError );
}
if ( $this->section != 'new' ) {
@@ -3131,7 +3123,10 @@ ERROR;
if ( !$revision->isCurrent() ) {
$this->mArticle->setOldSubtitle( $revision->getId() );
- $out->addWikiMsg( 'editingold' );
+ $out->wrapWikiMsg(
+ Html::warningBox( "\n$1\n" ),
+ 'editingold'
+ );
$this->isOldRev = true;
}
} elseif ( $this->mTitle->exists() ) {
@@ -3466,7 +3461,7 @@ ERROR;
$this->contentFormat,
$ex->getMessage()
);
- $out->addWikiText( '' . $msg->plain() . '
' );
+ $out->wrapWikiTextAsInterface( 'error', $msg->plain() );
}
}
}
@@ -3707,7 +3702,7 @@ ERROR;
$out->addHTML( "" . $checkboxesHTML . "
\n" );
// Show copyright warning.
- $out->addWikiText( $this->getCopywarn() );
+ $out->addWikiTextAsInterface( $this->getCopywarn() );
$out->addHTML( $this->editFormTextAfterWarn );
$out->addHTML( "\n" );
@@ -3880,9 +3875,10 @@ ERROR;
// Do not put big scary notice, if previewing the empty
// string, which happens when you initially edit
// a category page, due to automatic preview-on-open.
- $parsedNote = $out->parse( "
" .
- $this->context->msg( 'session_fail_preview_html' )->text() . "
",
- true, /* interface */true );
+ $parsedNote = Html::rawElement( 'div', [ 'class' => 'previewnote' ],
+ $out->parseAsInterface(
+ $this->context->msg( 'session_fail_preview_html' )->plain()
+ ) );
}
$this->incrementEditFailureStats( 'session_loss' );
return $parsedNote;
@@ -3957,7 +3953,7 @@ ERROR;
# sitecsspreview, sitejsonpreview, sitejspreview
if ( $level && $format ) {
$note = "
" .
- $this->context->msg( "{$level}{$format}preview" )->text() .
+ $this->context->msg( "{$level}{$format}preview" )->plain() .
' ' . $continueEditing . "
";
}
}
@@ -3991,20 +3987,27 @@ ERROR;
$this->contentFormat,
$ex->getMessage()
);
- $note .= "\n\n" . $m->parse();
+ $note .= "\n\n" . $m->plain(); # gets parsed down below
$previewHTML = '';
}
if ( $this->isConflict ) {
- $conflict = '
'
- . $this->context->msg( 'previewconflict' )->escaped() . "
\n";
+ $conflict = Html::rawElement(
+ 'h2', [ 'id' => 'mw-previewconflict' ],
+ $this->context->msg( 'previewconflict' )->escaped()
+ );
} else {
$conflict = '
';
}
- $previewhead = "
\n" .
- '" .
- $out->parse( $note, true, /* interface */true ) . $conflict . "
\n";
+ $previewhead = Html::rawElement(
+ 'div', [ 'class' => 'previewnote' ],
+ Html::rawElement(
+ 'h2', [ 'id' => 'mw-previewheader' ],
+ $this->context->msg( 'preview' )->escaped()
+ ) .
+ $out->parseAsInterface( $note ) . $conflict
+ );
$pageViewLang = $this->mTitle->getPageViewLanguage();
$attribs = [ 'lang' => $pageViewLang->getHtmlCode(), 'dir' => $pageViewLang->getDir(),
@@ -4088,145 +4091,20 @@ ERROR;
}
/**
- * Shows a bulletin board style toolbar for common editing functions.
- * It can be disabled in the user preferences.
+ * Allow extensions to provide a toolbar.
*
* @param Title|null $title Title object for the page being edited (optional)
- * @return string
+ * @return string|null
*/
public static function getEditToolbar( $title = null ) {
- global $wgOut, $wgEnableUploads, $wgForeignFileRepos;
-
- $imagesAvailable = $wgEnableUploads || count( $wgForeignFileRepos );
- $showSignature = true;
- if ( $title ) {
- $showSignature = MWNamespace::wantSignatures( $title->getNamespace() );
- }
-
- $contLang = MediaWikiServices::getInstance()->getContentLanguage();
-
- /**
- * $toolarray is an array of arrays each of which includes the
- * opening tag, the closing tag, optionally a sample text that is
- * inserted between the two when no selection is highlighted
- * and. The tip text is shown when the user moves the mouse
- * over the button.
- *
- * Images are defined in ResourceLoaderEditToolbarModule.
- */
- $toolarray = [
- [
- 'id' => 'mw-editbutton-bold',
- 'open' => '\'\'\'',
- 'close' => '\'\'\'',
- 'sample' => wfMessage( 'bold_sample' )->text(),
- 'tip' => wfMessage( 'bold_tip' )->text(),
- ],
- [
- 'id' => 'mw-editbutton-italic',
- 'open' => '\'\'',
- 'close' => '\'\'',
- 'sample' => wfMessage( 'italic_sample' )->text(),
- 'tip' => wfMessage( 'italic_tip' )->text(),
- ],
- [
- 'id' => 'mw-editbutton-link',
- 'open' => '[[',
- 'close' => ']]',
- 'sample' => wfMessage( 'link_sample' )->text(),
- 'tip' => wfMessage( 'link_tip' )->text(),
- ],
- [
- 'id' => 'mw-editbutton-extlink',
- 'open' => '[',
- 'close' => ']',
- 'sample' => wfMessage( 'extlink_sample' )->text(),
- 'tip' => wfMessage( 'extlink_tip' )->text(),
- ],
- [
- 'id' => 'mw-editbutton-headline',
- 'open' => "\n== ",
- 'close' => " ==\n",
- 'sample' => wfMessage( 'headline_sample' )->text(),
- 'tip' => wfMessage( 'headline_tip' )->text(),
- ],
- $imagesAvailable ? [
- 'id' => 'mw-editbutton-image',
- 'open' => '[[' . $contLang->getNsText( NS_FILE ) . ':',
- 'close' => ']]',
- 'sample' => wfMessage( 'image_sample' )->text(),
- 'tip' => wfMessage( 'image_tip' )->text(),
- ] : false,
- $imagesAvailable ? [
- 'id' => 'mw-editbutton-media',
- 'open' => '[[' . $contLang->getNsText( NS_MEDIA ) . ':',
- 'close' => ']]',
- 'sample' => wfMessage( 'media_sample' )->text(),
- 'tip' => wfMessage( 'media_tip' )->text(),
- ] : false,
- [
- 'id' => 'mw-editbutton-nowiki',
- 'open' => "
",
- 'close' => "",
- 'sample' => wfMessage( 'nowiki_sample' )->text(),
- 'tip' => wfMessage( 'nowiki_tip' )->text(),
- ],
- $showSignature ? [
- 'id' => 'mw-editbutton-signature',
- 'open' => wfMessage( 'sig-text', '~~~~' )->inContentLanguage()->text(),
- 'close' => '',
- 'sample' => '',
- 'tip' => wfMessage( 'sig_tip' )->text(),
- ] : false,
- [
- 'id' => 'mw-editbutton-hr',
- 'open' => "\n----\n",
- 'close' => '',
- 'sample' => '',
- 'tip' => wfMessage( 'hr_tip' )->text(),
- ]
- ];
+ $startingToolbar = '
';
+ $toolbar = $startingToolbar;
- $script = '';
- foreach ( $toolarray as $tool ) {
- if ( !$tool ) {
- continue;
- }
-
- $params = [
- // Images are defined in ResourceLoaderEditToolbarModule
- false,
- // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
- // Older browsers show a "speedtip" type message only for ALT.
- // Ideally these should be different, realistically they
- // probably don't need to be.
- $tool['tip'],
- $tool['open'],
- $tool['close'],
- $tool['sample'],
- $tool['id'],
- ];
-
- $script .= Xml::encodeJsCall(
- 'mw.toolbar.addButton',
- $params,
- ResourceLoader::inDebugMode()
- );
- }
-
- $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
- $nonce = $wgOut->getCSPNonce();
- $wgOut->addScript( Html::inlineScript(
- ResourceLoader::makeInlineCodeWithModule( 'mediawiki.toolbar', $script ),
- $nonce
- ) );
+ if ( !Hooks::run( 'EditPageBeforeEditToolbar', [ &$toolbar ] ) ) {
+ return null;
};
-
- return $toolbar;
+ // Don't add a pointless `
` to the page unless a hook caller populated it
+ return ( $toolbar === $startingToolbar ) ? null : $toolbar;
}
/**