e38952e8433faefea3f489b43ee3a4a43d105094
3 * Use this special page to get a list of the MediaWiki system messages.
4 * @addtogroup SpecialPage
10 function wfSpecialAllmessages() {
11 global $wgOut, $wgRequest, $wgMessageCache, $wgTitle;
12 global $wgUseDatabaseMessages;
14 # The page isn't much use if the MediaWiki namespace is not being used
15 if( !$wgUseDatabaseMessages ) {
16 $wgOut->addWikiText( wfMsg( 'allmessagesnotsupportedDB' ) );
20 wfProfileIn( __METHOD__
);
22 wfProfileIn( __METHOD__
. '-setup' );
23 $ot = $wgRequest->getText( 'ot' );
25 $navText = wfMsg( 'allmessagestext' );
27 # Make sure all extension messages are available
28 MessageCache
::loadAllMessages();
30 $sortedArray = array_merge( Language
::getMessagesFor( 'en' ), $wgMessageCache->getExtensionMessagesFor( 'en' ) );
31 ksort( $sortedArray );
33 $wgMessageCache->disableTransform();
35 foreach ( $sortedArray as $key => $value ) {
36 $messages[$key]['enmsg'] = $value;
37 $messages[$key]['statmsg'] = wfMsgNoDb( $key );
38 $messages[$key]['msg'] = wfMsg ( $key );
41 $wgMessageCache->enableTransform();
42 wfProfileOut( __METHOD__
. '-setup' );
44 wfProfileIn( __METHOD__
. '-output' );
46 $navText .= makePhp( $messages );
47 $wgOut->addHTML( 'PHP | <a href="' . $wgTitle->escapeLocalUrl( 'ot=html' ) . '">HTML</a><pre>' . htmlspecialchars( $navText ) . '</pre>' );
49 $wgOut->addHTML( '<a href="' . $wgTitle->escapeLocalUrl( 'ot=php' ) . '">PHP</a> | HTML' );
50 $wgOut->addWikiText( $navText );
51 $wgOut->addHTML( makeHTMLText( $messages ) );
53 wfProfileOut( __METHOD__
. '-output' );
55 wfProfileOut( __METHOD__
);
59 * Create the messages array, formatted in PHP to copy to language files.
60 * @param $messages Messages array.
61 * @return The PHP messages array.
62 * @todo Make suitable for language files.
64 function makePhp( $messages ) {
66 $txt = "\n\n\$messages = array(\n";
67 foreach( $messages as $key => $m ) {
68 if( $wgLang->getCode() != 'en' && $m['msg'] == $m['enmsg'] ) {
70 } else if ( wfEmptyMsg( $key, $m['msg'] ) ) {
76 $txt .= "'$key' => '" . preg_replace( '/(?<!\\\\)\'/', "\'", $m['msg']) . "',$comment\n";
83 * Create a list of messages, formatted in HTML as a list of messages and values and showing differences between the default language file message and the message in MediaWiki: namespace.
84 * @param $messages Messages array.
85 * @return The HTML list of messages.
87 function makeHTMLText( $messages ) {
88 global $wgLang, $wgContLang, $wgUser;
89 wfProfileIn( __METHOD__
);
91 $sk = $wgUser->getSkin();
92 $talk = wfMsg( 'talkpagelinktext' );
94 $input = wfElement( 'input', array(
96 'id' => 'allmessagesinput',
97 'onkeyup' => 'allmessagesfilter()'
99 $checkbox = wfElement( 'input', array(
101 'value' => wfMsgHtml( 'allmessagesmodified' ),
102 'id' => 'allmessagescheckbox',
103 'onclick' => 'allmessagesmodified()'
106 $txt = '<span id="allmessagesfilter" style="display: none;">' . wfMsgHtml( 'allmessagesfilter' ) . " {$input}{$checkbox} " . '</span>';
109 <table border="1" cellspacing="0" width="100%" id="allmessagestable">
111 <th rowspan="2">' . wfMsgHtml( 'allmessagesname' ) . '</th>
112 <th>' . wfMsgHtml( 'allmessagesdefault' ) . '</th>
115 <th>' . wfMsgHtml( 'allmessagescurrent' ) . '</th>
118 wfProfileIn( __METHOD__
. "-check" );
120 # This is a nasty hack to avoid doing independent existence checks
121 # without sending the links and table through the slow wiki parser.
122 $talkPageExists = array();
123 $dbr = wfGetDB( DB_SLAVE
);
124 $page = $dbr->tableName( 'page' );
125 $sql = "SELECT page_title FROM $page WHERE page_namespace IN (" . NS_MEDIAWIKI_TALK
. ")";
126 $res = $dbr->query( $sql );
127 while( $s = $dbr->fetchObject( $res ) ) {
128 $talkPageExists[$s->page_title
] = true;
130 $dbr->freeResult( $res );
131 wfProfileOut( __METHOD__
. "-check" );
133 wfProfileIn( __METHOD__
. "-output" );
137 foreach( $messages as $key => $m ) {
138 $title = $wgLang->ucfirst( $key );
139 if( $wgLang->getCode() != $wgContLang->getCode() ) {
140 $title .= '/' . $wgLang->getCode();
143 $titleObj =& Title
::makeTitle( NS_MEDIAWIKI
, $title );
144 $talkPage =& Title
::makeTitle( NS_MEDIAWIKI_TALK
, $title );
146 $changed = ( $m['statmsg'] != $m['msg'] );
147 $message = htmlspecialchars( $m['statmsg'] );
148 $mw = htmlspecialchars( $m['msg'] );
150 $pageLink = $sk->makeKnownLinkObj( $titleObj, "<span id=\"sp-allmessages-i-$i\">" . htmlspecialchars( $key ) . '</span>' );
152 if( isset( $talkPageExists[$title] ) ) {
153 $talkLink = $sk->makeKnownLinkObj( $talkPage, htmlspecialchars( $talk ) );
155 $talkLink = $sk->makeBrokenLinkObj( $talkPage, htmlspecialchars( $talk ) );
158 $anchor = 'msg_' . htmlspecialchars( strtolower( $title ) );
159 $anchor = "<a id=\"$anchor\" name=\"$anchor\"></a>";
163 <tr class=\"orig\" id=\"sp-allmessages-r1-$i\">
165 $anchor$pageLink<br />$talkLink
169 </tr><tr class=\"new\" id=\"sp-allmessages-r2-$i\">
176 <tr class=\"def\" id=\"sp-allmessages-r1-$i\">
178 $anchor$pageLink<br />$talkLink
187 wfProfileOut( __METHOD__
. '-output' );
189 wfProfileOut( __METHOD__
);