diff options
Diffstat (limited to 'includes/SpecialAllmessages.php')
-rw-r--r-- | includes/SpecialAllmessages.php | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/includes/SpecialAllmessages.php b/includes/SpecialAllmessages.php index 4ba01e29..ee97b48e 100644 --- a/includes/SpecialAllmessages.php +++ b/includes/SpecialAllmessages.php @@ -13,7 +13,7 @@ function wfSpecialAllmessages() { # The page isn't much use if the MediaWiki namespace is not being used if( !$wgUseDatabaseMessages ) { - $wgOut->addWikiText( wfMsg( 'allmessagesnotsupportedDB' ) ); + $wgOut->addWikiMsg( 'allmessagesnotsupportedDB' ); return; } @@ -44,25 +44,44 @@ function wfSpecialAllmessages() { wfProfileIn( __METHOD__ . '-output' ); if ( $ot == 'php' ) { - $navText .= makePhp( $messages ); - $wgOut->addHTML( 'PHP | <a href="' . $wgTitle->escapeLocalUrl( 'ot=html' ) . '">HTML</a><pre>' . htmlspecialchars( $navText ) . '</pre>' ); + $navText .= wfAllMessagesMakePhp( $messages ); + $wgOut->addHTML( 'PHP | <a href="' . $wgTitle->escapeLocalUrl( 'ot=html' ) . '">HTML</a> | ' . + '<a href="' . $wgTitle->escapeLocalUrl( 'ot=xml' ) . '">XML</a>' . + '<pre>' . htmlspecialchars( $navText ) . '</pre>' ); + } else if ( $ot == 'xml' ) { + $wgOut->disable(); + header( 'Content-type: text/xml' ); + echo wfAllMessagesMakeXml( $messages ); } else { - $wgOut->addHTML( '<a href="' . $wgTitle->escapeLocalUrl( 'ot=php' ) . '">PHP</a> | HTML' ); + $wgOut->addHTML( '<a href="' . $wgTitle->escapeLocalUrl( 'ot=php' ) . '">PHP</a> | ' . + 'HTML | <a href="' . $wgTitle->escapeLocalUrl( 'ot=xml' ) . '">XML</a>' ); $wgOut->addWikiText( $navText ); - $wgOut->addHTML( makeHTMLText( $messages ) ); + $wgOut->addHTML( wfAllMessagesMakeHTMLText( $messages ) ); } wfProfileOut( __METHOD__ . '-output' ); wfProfileOut( __METHOD__ ); } +function wfAllMessagesMakeXml( $messages ) { + global $wgLang; + $lang = $wgLang->getCode(); + $txt = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; + $txt .= "<messages lang=\"$lang\">\n"; + foreach( $messages as $key => $m ) { + $txt .= "\t" . Xml::element( 'message', array( 'name' => $key ), $m['msg'] ) . "\n"; + } + $txt .= "</messages>"; + return $txt; +} + /** * Create the messages array, formatted in PHP to copy to language files. * @param $messages Messages array. * @return The PHP messages array. * @todo Make suitable for language files. */ -function makePhp( $messages ) { +function wfAllMessagesMakePhp( $messages ) { global $wgLang; $txt = "\n\n\$messages = array(\n"; foreach( $messages as $key => $m ) { @@ -85,7 +104,7 @@ function makePhp( $messages ) { * @param $messages Messages array. * @return The HTML list of messages. */ -function makeHTMLText( $messages ) { +function wfAllMessagesMakeHTMLText( $messages ) { global $wgLang, $wgContLang, $wgUser; wfProfileIn( __METHOD__ ); |