Merge "postEdit: Show a different success messsage on publish vs. save wikis"
[lhc/web/wiklou.git] / includes / EditPage.php
index 69744f6..6bf3c89 100644 (file)
@@ -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 <<<ERROR
+<div class="errorbox">
+{$errmsg}
+</div>
+<br clear="all" />
+ERROR;
+       }
+
        /**
         * Return the summary to be used for a new section.
         *
@@ -3737,7 +3757,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,