3 * Provide functions to generate a special page
9 function wfSpecialAllmessages() {
10 global $wgOut, $wgAllMessagesEn, $wgRequest, $wgMessageCache, $wgTitle;
12 $fname = "wfSpecialAllMessages";
13 wfProfileIn( $fname );
15 wfProfileIn( "$fname-setup");
16 $ot = $wgRequest->getText( 'ot' );
17 $mwMsg =& MagicWord
::get( MAG_MSG
);
19 $navText = wfMsg( 'allmessagestext', $mwMsg->getSynonym( 0 ) );
21 $sortedArray = $wgAllMessagesEn;
22 ksort( $sortedArray );
24 $wgMessageCache->disableTransform();
25 foreach ( $sortedArray as $key => $enMsg ) {
26 $messages[$key]['enmsg'] = $enMsg;
27 $messages[$key]['statmsg'] = wfMsgNoDb( $key );
28 $messages[$key]['msg'] = wfMsg ( $key );
30 wfProfileOut( "$fname-setup" );
32 wfProfileIn( "$fname-output" );
34 $navText .= makePhp($messages);
35 $wgOut->addHTML('PHP | <a href="'.$wgTitle->escapeLocalUrl('ot=html').'">HTML</a><pre>'.htmlspecialchars($navText).'</pre>');
37 $wgOut->addHTML( '<a href="'.$wgTitle->escapeLocalUrl('ot=php').'">PHP</a> | HTML' );
38 $wgOut->addWikiText( $navText );
39 $wgOut->addHTML( makeHTMLText( $messages ) );
41 wfProfileOut( "$fname-output" );
43 wfProfileOut( $fname );
49 function makePhp($messages) {
50 global $wgLanguageCode;
51 $txt = "\n\n".'$wgAllMessages'.ucfirst($wgLanguageCode).' = array('."\n";
52 foreach( $messages as $key => $m ) {
53 if(strtolower($wgLanguageCode) != 'en' and $m['msg'] == $m['enmsg'] ) {
54 if (strstr($m['msg'],"\n")) {
61 } elseif ($m['msg'] == '<'.$key.'>'){
67 $txt .= "'".$key."' => \"".str_replace('"','\"',$m['msg'])."\",$comment\n";
76 function makeHTMLText( $messages ) {
77 global $wgLang, $wgUser;
78 $fname = "makeHTMLText";
79 wfProfileIn( $fname );
81 $sk =& $wgUser->getSkin();
82 $talk = $wgLang->getNsText( NS_TALK
);
83 $mwnspace = $wgLang->getNsText( NS_MEDIAWIKI
);
84 $mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK
);
87 <table border='1' cellspacing='0' width='100%'>
88 <tr bgcolor='#b2b2ff'>
94 wfProfileIn( "$fname-check" );
95 # This is a nasty hack to avoid doing independent existence checks
96 # without sending the links and table through the slow wiki parser.
98 NS_MEDIAWIKI
=> array(),
99 NS_MEDIAWIKI_TALK
=> array()
101 $sql = "SELECT cur_namespace,cur_title FROM cur WHERE cur_namespace IN (" . NS_MEDIAWIKI
. ", " . NS_MEDIAWIKI_TALK
. ")";
102 $dbr =& wfGetDB( DB_SLAVE
);
103 $res = $dbr->query( $sql );
104 while( $s = $dbr->fetchObject( $res ) ) {
105 $pageExists[$s->cur_namespace
][$s->cur_title
] = true;
107 $dbr->freeResult( $res );
108 wfProfileOut( "$fname-check" );
110 wfProfileIn( "$fname-output" );
111 foreach( $messages as $key => $m ) {
112 $title = $wgLang->ucfirst( $key );
113 $titleObj =& Title
::makeTitle( NS_MEDIAWIKI
, $title );
114 $talkPage =& Title
::makeTitle( NS_MEDIAWIKI_TALK
, $title );
116 $colorIt = ($m['statmsg'] == $m['msg']) ?
" bgcolor=\"#f0f0ff\"" : " bgcolor=\"#ffe2e2\"";
117 $message = htmlspecialchars( $m['statmsg'] );
118 $mw = htmlspecialchars( $m['msg'] );
120 #$pageLink = $sk->makeLinkObj( $titleObj, htmlspecialchars( $key ) );
121 #$talkLink = $sk->makeLinkObj( $talkPage, htmlspecialchars( $talk ) );
122 if( isset( $pageExists[NS_MEDIAWIKI
][$title] ) ) {
123 $pageLink = $sk->makeKnownLinkObj( $titleObj, htmlspecialchars( $key ) );
125 $pageLink = $sk->makeBrokenLinkObj( $titleObj, htmlspecialchars( $key ) );
127 if( isset( $pageExists[NS_MEDIAWIKI_TALK
][$title] ) ) {
128 $talkLink = $sk->makeKnownLinkObj( $talkPage, htmlspecialchars( $talk ) );
130 $talkLink = $sk->makeBrokenLinkObj( $talkPage, htmlspecialchars( $talk ) );
144 wfProfileOut( "$fname-output" );
146 wfProfileOut( $fname );