diff options
Diffstat (limited to 'includes/Status.php')
-rw-r--r-- | includes/Status.php | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/includes/Status.php b/includes/Status.php index e9f3fb91..10dfb516 100644 --- a/includes/Status.php +++ b/includes/Status.php @@ -1,4 +1,24 @@ <?php +/** + * Generic operation result. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + */ /** * Generic operation result class @@ -28,6 +48,7 @@ class Status { * Factory function for fatal errors * * @param $message String: message name + * @return Status */ static function newFatal( $message /*, parameters...*/ ) { $params = func_get_args(); @@ -41,6 +62,7 @@ class Status { * Factory function for good results * * @param $value Mixed + * @return Status */ static function newGood( $value = null ) { $result = new self; @@ -143,35 +165,6 @@ class Status { } /** - * @param $item - * @return string - */ - protected function getItemXML( $item ) { - $params = $this->cleanParams( $item['params'] ); - $xml = "<{$item['type']}>\n" . - Xml::element( 'message', null, $item['message'] ) . "\n" . - Xml::element( 'text', null, wfMsg( $item['message'], $params ) ) ."\n"; - foreach ( $params as $param ) { - $xml .= Xml::element( 'param', null, $param ); - } - $xml .= "</{$item['type']}>\n"; - return $xml; - } - - /** - * Get the error list as XML - * @return string - */ - function getXML() { - $xml = "<errors>\n"; - foreach ( $this->errors as $error ) { - $xml .= $this->getItemXML( $error ); - } - $xml .= "</errors>\n"; - return $xml; - } - - /** * Get the error list as a wikitext formatted list * * @param $shortContext String: a short enclosing context message name, to @@ -192,17 +185,17 @@ class Status { if ( count( $this->errors ) == 1 ) { $s = $this->getWikiTextForError( $this->errors[0], $this->errors[0] ); if ( $shortContext ) { - $s = wfMsgNoTrans( $shortContext, $s ); + $s = wfMessage( $shortContext, $s )->plain(); } elseif ( $longContext ) { - $s = wfMsgNoTrans( $longContext, "* $s\n" ); + $s = wfMessage( $longContext, "* $s\n" )->plain(); } } else { $s = '* '. implode("\n* ", $this->getWikiTextArray( $this->errors ) ) . "\n"; if ( $longContext ) { - $s = wfMsgNoTrans( $longContext, $s ); + $s = wfMessage( $longContext, $s )->plain(); } elseif ( $shortContext ) { - $s = wfMsgNoTrans( $shortContext, "\n$s\n" ); + $s = wfMessage( $shortContext, "\n$s\n" )->plain(); } } return $s; @@ -220,15 +213,15 @@ class Status { protected function getWikiTextForError( $error ) { if ( is_array( $error ) ) { if ( isset( $error['message'] ) && isset( $error['params'] ) ) { - return wfMsgNoTrans( $error['message'], - array_map( 'wfEscapeWikiText', $this->cleanParams( $error['params'] ) ) ); + return wfMessage( $error['message'], + array_map( 'wfEscapeWikiText', $this->cleanParams( $error['params'] ) ) )->plain(); } else { $message = array_shift($error); - return wfMsgNoTrans( $message, - array_map( 'wfEscapeWikiText', $this->cleanParams( $error ) ) ); + return wfMessage( $message, + array_map( 'wfEscapeWikiText', $this->cleanParams( $error ) ) )->plain(); } } else { - return wfMsgNoTrans( $error ); + return wfMessage( $error )->plain(); } } @@ -355,4 +348,11 @@ class Status { public function getMessage() { return $this->getWikiText(); } + + /** + * @return mixed + */ + public function getValue() { + return $this->value; + } } |