Allow the submit callback function to return a Status object (will use this later...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Fri, 3 Dec 2010 11:29:55 +0000 (11:29 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Fri, 3 Dec 2010 11:29:55 +0000 (11:29 +0000)
includes/HTMLForm.php
includes/Preferences.php

index c51a9a8..fff1b40 100644 (file)
@@ -209,7 +209,9 @@ class HTMLForm {
                        $result = $this->trySubmit();
                }
 
-               if ( $result === true ) {
+               if ( $result === true ||
+                       ( $result instanceof Status && $result->isGood() ) )
+               {
                        return $result;
                }
 
@@ -460,7 +462,10 @@ class HTMLForm {
         * @return String
         */
        function getErrors( $errors ) {
-               if ( is_array( $errors ) ) {
+               if ( $errors instanceof Status ) {
+                       global $wgOut;
+                       $errorstr = $wgOut->parse( $errors->getWikiText() );
+               } elseif ( is_array( $errors ) ) {
                        $errorstr = $this->formatErrors( $errors );
                } else {
                        $errorstr = $errors;
index b9b120c..deb17d0 100644 (file)
@@ -1328,7 +1328,7 @@ class Preferences {
                        $wgOut->redirect( $url );
                }
 
-               return true;
+               return Status::newGood();
        }
 
        public static function loadOldSearchNs( $user ) {