3 * Provide functions to generate a special page
5 * @subpackage SpecialPage
11 function wfSpecialAllmessages() {
12 global $wgOut, $wgAllMessagesEn, $wgRequest, $wgMessageCache, $wgTitle;
13 global $wgUseDatabaseMessages;
15 if(!$wgUseDatabaseMessages) {
16 $wgOut->addHTML(wfMsg('allmessagesnotsupportedDB'));
20 $fname = "wfSpecialAllMessages";
21 wfProfileIn( $fname );
23 wfProfileIn( "$fname-setup");
24 $ot = $wgRequest->getText( 'ot' );
26 $navText = wfMsg( 'allmessagestext' );
30 $sortedArray = array_merge( $wgAllMessagesEn, $wgMessageCache->mExtensionMessages
);
31 ksort( $sortedArray );
33 $wgMessageCache->disableTransform();
35 foreach ( $sortedArray as $key => $enMsg ) {
36 $messages[$key]['enmsg'] = $enMsg;
37 $messages[$key]['statmsg'] = wfMsgNoDb( $key );
38 $messages[$key]['msg'] = wfMsg ( $key );
41 $wgMessageCache->enableTransform();
42 wfProfileOut( "$fname-setup" );
44 wfProfileIn( "$fname-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( "$fname-output" );
55 wfProfileOut( $fname );
61 function makePhp($messages) {
62 global $wgLanguageCode;
63 $txt = "\n\n".'$wgAllMessages'.ucfirst($wgLanguageCode).' = array('."\n";
64 foreach( $messages as $key => $m ) {
65 if(strtolower($wgLanguageCode) != 'en' and $m['msg'] == $m['enmsg'] ) {
66 //if (strstr($m['msg'],"\n")) {
74 } elseif ($m['msg'] == '<'.$key.'>'){
80 $txt .= "'$key' => '" . preg_replace( "/(?<!\\\\)'/", "\'", $m['msg']) . "',$comment\n";
89 function makeHTMLText( $messages ) {
90 global $wgLang, $wgUser, $wgLanguageCode, $wgContLanguageCode;
91 $fname = "makeHTMLText";
92 wfProfileIn( $fname );
94 $sk =& $wgUser->getSkin();
95 $talk = $wgLang->getNsText( NS_TALK
);
96 $mwnspace = $wgLang->getNsText( NS_MEDIAWIKI
);
97 $mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK
);
99 <table border='1' cellspacing='0' width='100%' id='allmessagestable'>
101 <th rowspan='2'>" . wfMsgHtml('allmessagesname') . "</th>
102 <th>" . wfMsgHtml('allmessagesdefault') . "</th>
105 <th>" . wfMsgHtml('allmessagescurrent') . "</th>
108 wfProfileIn( "$fname-check" );
109 # This is a nasty hack to avoid doing independent existence checks
110 # without sending the links and table through the slow wiki parser.
112 NS_MEDIAWIKI
=> array(),
113 NS_MEDIAWIKI_TALK
=> array()
115 $dbr =& wfGetDB( DB_SLAVE
);
116 $page = $dbr->tableName( 'page' );
117 $sql = "SELECT page_namespace,page_title FROM $page WHERE page_namespace IN (" . NS_MEDIAWIKI
. ", " . NS_MEDIAWIKI_TALK
. ")";
118 $res = $dbr->query( $sql );
119 while( $s = $dbr->fetchObject( $res ) ) {
120 $pageExists[$s->page_namespace
][$s->page_title
] = true;
122 $dbr->freeResult( $res );
123 wfProfileOut( "$fname-check" );
125 wfProfileIn( "$fname-output" );
127 foreach( $messages as $key => $m ) {
129 $title = $wgLang->ucfirst( $key );
130 if($wgLanguageCode != $wgContLanguageCode)
131 $title.="/$wgLanguageCode";
133 $titleObj =& Title
::makeTitle( NS_MEDIAWIKI
, $title );
134 $talkPage =& Title
::makeTitle( NS_MEDIAWIKI_TALK
, $title );
136 $changed = ($m['statmsg'] != $m['msg']);
137 $message = htmlspecialchars( $m['statmsg'] );
138 $mw = htmlspecialchars( $m['msg'] );
140 #$pageLink = $sk->makeLinkObj( $titleObj, htmlspecialchars( $key ) );
141 #$talkLink = $sk->makeLinkObj( $talkPage, htmlspecialchars( $talk ) );
142 if( isset( $pageExists[NS_MEDIAWIKI
][$title] ) ) {
143 $pageLink = $sk->makeKnownLinkObj( $titleObj, htmlspecialchars( $key ) );
145 $pageLink = $sk->makeBrokenLinkObj( $titleObj, htmlspecialchars( $key ) );
147 if( isset( $pageExists[NS_MEDIAWIKI_TALK
][$title] ) ) {
148 $talkLink = $sk->makeKnownLinkObj( $talkPage, htmlspecialchars( $talk ) );
150 $talkLink = $sk->makeBrokenLinkObj( $talkPage, htmlspecialchars( $talk ) );
158 $pageLink<br />$talkLink
162 </tr><tr class='new'>
172 $pageLink<br />$talkLink
181 wfProfileOut( "$fname-output" );
183 wfProfileOut( $fname );