Merge "resources: Extract ForeignResourceManager from manageForeignResources.php"
[lhc/web/wiklou.git] / includes / EditPage.php
index bb4243a..0f7d9a7 100644 (file)
@@ -794,7 +794,7 @@ class EditPage {
                $out->addHTML( $this->editFormTextTop );
 
                if ( $errorMessage !== '' ) {
-                       $out->addWikiText( $errorMessage );
+                       $out->addWikiTextAsInterface( $errorMessage );
                        $out->addHTML( "<hr />\n" );
                }
 
@@ -1302,8 +1302,12 @@ class EditPage {
                                        // Messages: undo-success, undo-failure, undo-main-slot-only, undo-norev,
                                        // undo-nochange.
                                        $class = ( $undoMsg == 'success' ? '' : 'error ' ) . "mw-undo-{$undoMsg}";
-                                       $this->editFormPageTop .= $out->parse( "<div class=\"{$class}\">" .
-                                               $this->context->msg( 'undo-' . $undoMsg )->plain() . '</div>', 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( '<div class="error">' . "\n" . $status->getWikiText() . '</div>' );
+                               $out->wrapWikiTextAsInterface( 'error', $status->getWikiText() );
                                return true;
 
                        case self::AS_SUCCESS_NEW_ARTICLE:
@@ -2979,7 +2983,7 @@ ERROR;
                                        $this->contentFormat,
                                        $ex->getMessage()
                                );
-                               $out->addWikiText( '<div class="error">' . $msg->plain() . '</div>' );
+                               $out->wrapWikiTextAsInterface( 'error', $msg->plain() );
                        }
                }
 
@@ -3097,7 +3101,7 @@ ERROR;
                        }
 
                        if ( $this->hookError !== '' ) {
-                               $out->addWikiText( $this->hookError );
+                               $out->addWikiTextAsInterface( $this->hookError );
                        }
 
                        if ( $this->section != 'new' ) {
@@ -3454,7 +3458,7 @@ ERROR;
                                        $this->contentFormat,
                                        $ex->getMessage()
                                );
-                               $out->addWikiText( '<div class="error">' . $msg->plain() . '</div>' );
+                               $out->wrapWikiTextAsInterface( 'error', $msg->plain() );
                        }
                }
        }
@@ -3695,7 +3699,7 @@ ERROR;
                $out->addHTML( "<div class='editCheckboxes'>" . $checkboxesHTML . "</div>\n" );
 
                // Show copyright warning.
-               $out->addWikiText( $this->getCopywarn() );
+               $out->addWikiTextAsInterface( $this->getCopywarn() );
                $out->addHTML( $this->editFormTextAfterWarn );
 
                $out->addHTML( "<div class='editButtons'>\n" );
@@ -3868,9 +3872,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( "<div class='previewnote'>" .
-                                       $this->context->msg( 'session_fail_preview_html' )->text() . "</div>",
-                                       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;
@@ -3945,7 +3950,7 @@ ERROR;
                                #   sitecsspreview, sitejsonpreview, sitejspreview
                                if ( $level && $format ) {
                                        $note = "<div id='mw-{$level}{$format}preview'>" .
-                                               $this->context->msg( "{$level}{$format}preview" )->text() .
+                                               $this->context->msg( "{$level}{$format}preview" )->plain() .
                                                ' ' . $continueEditing . "</div>";
                                }
                        }
@@ -3979,20 +3984,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 = '<h2 id="mw-previewconflict">'
-                               . $this->context->msg( 'previewconflict' )->escaped() . "</h2>\n";
+                       $conflict = Html::rawElement(
+                               'h2', [ 'id' => 'mw-previewconflict' ],
+                               $this->context->msg( 'previewconflict' )->escaped()
+                       );
                } else {
                        $conflict = '<hr />';
                }
 
-               $previewhead = "<div class='previewnote'>\n" .
-                       '<h2 id="mw-previewheader">' . $this->context->msg( 'preview' )->escaped() . "</h2>" .
-                       $out->parse( $note, true, /* interface */true ) . $conflict . "</div>\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(),