X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FStatus.php;h=10dfb516b8542bbb831e6be2d24f6ac58b86fc58;hb=3a39bb2560f15584d0fdec630a7652b2171fe5b4;hp=30cbb851792130313949ac3aee7923ac4d5f6f28;hpb=0a21e2de1242a08dda5d6d16cb1913ae7bc6b7ed;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Status.php b/includes/Status.php index 30cbb85179..10dfb516b8 100644 --- a/includes/Status.php +++ b/includes/Status.php @@ -1,4 +1,24 @@ cleanCallback = false; } + /** + * @param $params array + * @return array + */ protected function cleanParams( $params ) { if ( !$this->cleanCallback ) { return $params; @@ -138,30 +164,6 @@ class Status { return $cleanParams; } - protected function getItemXML( $item ) { - $params = $this->cleanParams( $item['params'] ); - $xml = "<{$item['type']}>\n" . - Xml::element( 'message', null, $item['message'] ) . "\n" . - Xml::element( 'text', null, wfMsgReal( $item['message'], $params ) ) ."\n"; - foreach ( $params as $param ) { - $xml .= Xml::element( 'param', null, $param ); - } - $xml .= "type}>\n"; - return $xml; - } - - /** - * Get the error list as XML - */ - function getXML() { - $xml = "\n"; - foreach ( $this->errors as $error ) { - $xml .= $this->getItemXML( $error ); - } - $xml .= "\n"; - return $xml; - } - /** * Get the error list as a wikitext formatted list * @@ -183,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; @@ -211,17 +213,15 @@ class Status { protected function getWikiTextForError( $error ) { if ( is_array( $error ) ) { if ( isset( $error['message'] ) && isset( $error['params'] ) ) { - return wfMsgReal( $error['message'], - array_map( 'wfEscapeWikiText', $this->cleanParams( $error['params'] ) ), - true, false, false ); + return wfMessage( $error['message'], + array_map( 'wfEscapeWikiText', $this->cleanParams( $error['params'] ) ) )->plain(); } else { $message = array_shift($error); - return wfMsgReal( $message, - array_map( 'wfEscapeWikiText', $this->cleanParams( $error ) ), - true, false, false ); + return wfMessage( $message, + array_map( 'wfEscapeWikiText', $this->cleanParams( $error ) ) )->plain(); } } else { - return wfMsgReal( $error, array(), true, false, false); + return wfMessage( $error )->plain(); } } @@ -287,6 +287,25 @@ class Status { } return $result; } + + /** + * Returns a list of status messages of the given type, with message and + * params left untouched, like a sane version of getStatusArray + * + * @param $type String + * + * @return Array + */ + public function getErrorsByType( $type ) { + $result = array(); + foreach ( $this->errors as $error ) { + if ( $error['type'] === $type ) { + $result[] = $error; + } + } + return $result; + } + /** * Returns true if the specified message is present as a warning or error * @@ -303,10 +322,12 @@ class Status { } /** - * If the specified source message exists, replace it with the specified + * If the specified source message exists, replace it with the specified * destination message, but keep the same parameters as in the original error. * * Return true if the replacement was done, false otherwise. + * + * @return bool */ function replaceMessage( $source, $dest ) { $replaced = false; @@ -327,4 +348,11 @@ class Status { public function getMessage() { return $this->getWikiText(); } + + /** + * @return mixed + */ + public function getValue() { + return $this->value; + } }