3 * Provide functions to generate a special page
5 * @subpackage SpecialPage
11 function wfSpecialAllmessages() {
12 global $wgOut, $wgAllMessagesEn, $wgRequest, $wgMessageCache, $wgTitle;
14 $fname = "wfSpecialAllMessages";
15 wfProfileIn( $fname );
17 wfProfileIn( "$fname-setup");
18 $ot = $wgRequest->getText( 'ot' );
19 $mwMsg =& MagicWord
::get( MAG_MSG
);
21 $navText = wfMsg( 'allmessagestext', $mwMsg->getSynonym( 0 ) );
23 $sortedArray = $wgAllMessagesEn;
24 ksort( $sortedArray );
26 $wgMessageCache->disableTransform();
27 foreach ( $sortedArray as $key => $enMsg ) {
28 $messages[$key]['enmsg'] = $enMsg;
29 $messages[$key]['statmsg'] = wfMsgNoDb( $key );
30 $messages[$key]['msg'] = wfMsg ( $key );
32 wfProfileOut( "$fname-setup" );
34 wfProfileIn( "$fname-output" );
36 $navText .= makePhp($messages);
37 $wgOut->addHTML('PHP | <a href="'.$wgTitle->escapeLocalUrl('ot=html').'">HTML</a><pre>'.htmlspecialchars($navText).'</pre>');
39 $wgOut->addHTML( '<a href="'.$wgTitle->escapeLocalUrl('ot=php').'">PHP</a> | HTML' );
40 $wgOut->addWikiText( $navText );
41 $wgOut->addHTML( makeHTMLText( $messages ) );
43 wfProfileOut( "$fname-output" );
45 wfProfileOut( $fname );
51 function makePhp($messages) {
52 global $wgLanguageCode;
53 $txt = "\n\n".'$wgAllMessages'.ucfirst($wgLanguageCode).' = array('."\n";
54 foreach( $messages as $key => $m ) {
55 if(strtolower($wgLanguageCode) != 'en' and $m['msg'] == $m['enmsg'] ) {
56 if (strstr($m['msg'],"\n")) {
63 } elseif ($m['msg'] == '<'.$key.'>'){
69 $txt .= "'".$key."' => \"".str_replace('"','\"',$m['msg'])."\",$comment\n";
78 function makeHTMLText( $messages ) {
79 global $wgLang, $wgUser;
80 $fname = "makeHTMLText";
81 wfProfileIn( $fname );
83 $sk =& $wgUser->getSkin();
84 $talk = $wgLang->getNsText( NS_TALK
);
85 $mwnspace = $wgLang->getNsText( NS_MEDIAWIKI
);
86 $mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK
);
89 <table border='1' cellspacing='0' width='100%'>
90 <tr bgcolor='#b2b2ff'>
96 wfProfileIn( "$fname-check" );
97 # This is a nasty hack to avoid doing independent existence checks
98 # without sending the links and table through the slow wiki parser.
100 NS_MEDIAWIKI
=> array(),
101 NS_MEDIAWIKI_TALK
=> array()
103 $sql = "SELECT cur_namespace,cur_title FROM cur WHERE cur_namespace IN (" . NS_MEDIAWIKI
. ", " . NS_MEDIAWIKI_TALK
. ")";
104 $dbr =& wfGetDB( DB_SLAVE
);
105 $res = $dbr->query( $sql );
106 while( $s = $dbr->fetchObject( $res ) ) {
107 $pageExists[$s->cur_namespace
][$s->cur_title
] = true;
109 $dbr->freeResult( $res );
110 wfProfileOut( "$fname-check" );
112 wfProfileIn( "$fname-output" );
113 foreach( $messages as $key => $m ) {
114 $title = $wgLang->ucfirst( $key );
115 $titleObj =& Title
::makeTitle( NS_MEDIAWIKI
, $title );
116 $talkPage =& Title
::makeTitle( NS_MEDIAWIKI_TALK
, $title );
118 $colorIt = ($m['statmsg'] == $m['msg']) ?
" bgcolor=\"#f0f0ff\"" : " bgcolor=\"#ffe2e2\"";
119 $message = htmlspecialchars( $m['statmsg'] );
120 $mw = htmlspecialchars( $m['msg'] );
122 #$pageLink = $sk->makeLinkObj( $titleObj, htmlspecialchars( $key ) );
123 #$talkLink = $sk->makeLinkObj( $talkPage, htmlspecialchars( $talk ) );
124 if( isset( $pageExists[NS_MEDIAWIKI
][$title] ) ) {
125 $pageLink = $sk->makeKnownLinkObj( $titleObj, htmlspecialchars( $key ) );
127 $pageLink = $sk->makeBrokenLinkObj( $titleObj, htmlspecialchars( $key ) );
129 if( isset( $pageExists[NS_MEDIAWIKI_TALK
][$title] ) ) {
130 $talkLink = $sk->makeKnownLinkObj( $talkPage, htmlspecialchars( $talk ) );
132 $talkLink = $sk->makeBrokenLinkObj( $talkPage, htmlspecialchars( $talk ) );
146 wfProfileOut( "$fname-output" );
148 wfProfileOut( $fname );