a58f9f0d4dddc01a4b3da55209d97faec7a6853f
3 * Provide functions to generate a special page
5 * @subpackage SpecialPage
11 function wfSpecialAllmessages() {
12 global $wgOut, $wgAllMessagesEn, $wgRequest, $wgMessageCache, $wgTitle;
13 global $wgLanguageCode, $wgContLanguageCode, $wgContLang;
14 global $wgUseDatabaseMessages;
16 if(!$wgUseDatabaseMessages) {
17 $wgOut->addHTML(wfMsg('allmessagesnotsupportedDB'));
21 $fname = "wfSpecialAllMessages";
22 wfProfileIn( $fname );
24 wfProfileIn( "$fname-setup");
25 $ot = $wgRequest->getText( 'ot' );
26 $mwMsg =& MagicWord
::get( MAG_MSG
);
28 $navText = wfMsg( 'allmessagestext', $mwMsg->getSynonym( 0 ) );
32 $sortedArray = $wgAllMessagesEn;
33 ksort( $sortedArray );
35 $wgMessageCache->disableTransform();
37 foreach ( $sortedArray as $key => $enMsg ) {
38 $messages[$key]['enmsg'] = $enMsg;
39 $messages[$key]['statmsg'] = wfMsgNoDb( $key );
40 $messages[$key]['msg'] = wfMsg ( $key );
43 $wgMessageCache->enableTransform();
44 wfProfileOut( "$fname-setup" );
46 wfProfileIn( "$fname-output" );
48 $navText .= makePhp($messages);
49 $wgOut->addHTML('PHP | <a href="'.$wgTitle->escapeLocalUrl('ot=html').'">HTML</a><pre>'.htmlspecialchars($navText).'</pre>');
51 $wgOut->addHTML( '<a href="'.$wgTitle->escapeLocalUrl('ot=php').'">PHP</a> | HTML' );
52 $wgOut->addWikiText( $navText );
53 $wgOut->addHTML( makeHTMLText( $messages ) );
55 wfProfileOut( "$fname-output" );
57 wfProfileOut( $fname );
63 function makePhp($messages) {
64 global $wgLanguageCode;
65 $txt = "\n\n".'$wgAllMessages'.ucfirst($wgLanguageCode).' = array('."\n";
66 foreach( $messages as $key => $m ) {
67 if(strtolower($wgLanguageCode) != 'en' and $m['msg'] == $m['enmsg'] ) {
68 if (strstr($m['msg'],"\n")) {
75 } elseif ($m['msg'] == '<'.$key.'>'){
81 $txt .= "'".$key."' => \"".str_replace('"','\"',$m['msg'])."\",$comment\n";
90 function makeHTMLText( $messages ) {
91 global $wgLang, $wgUser, $wgLanguageCode, $wgContLanguageCode, $wgContLang;
92 $fname = "makeHTMLText";
93 wfProfileIn( $fname );
95 $sk =& $wgUser->getSkin();
96 $talk = $wgLang->getNsText( NS_TALK
);
97 $mwnspace = $wgLang->getNsText( NS_MEDIAWIKI
);
98 $mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK
);
101 <table border='1' cellspacing='0' width='100%'>
102 <tr bgcolor='#b2b2ff'>
104 <th>Default text</th>
105 <th>Current text</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 $sql = "SELECT cur_namespace,cur_title FROM cur WHERE cur_namespace IN (" . NS_MEDIAWIKI
. ", " . NS_MEDIAWIKI_TALK
. ")";
116 $dbr =& wfGetDB( DB_SLAVE
);
117 $res = $dbr->query( $sql );
118 while( $s = $dbr->fetchObject( $res ) ) {
119 $pageExists[$s->cur_namespace
][$s->cur_title
] = true;
121 $dbr->freeResult( $res );
122 wfProfileOut( "$fname-check" );
124 wfProfileIn( "$fname-output" );
126 foreach( $messages as $key => $m ) {
128 $title = $wgLang->ucfirst( $key );
129 if($wgLanguageCode != $wgContLanguageCode)
130 $title.="/$wgLanguageCode";
132 $titleObj =& Title
::makeTitle( NS_MEDIAWIKI
, $title );
133 $talkPage =& Title
::makeTitle( NS_MEDIAWIKI_TALK
, $title );
135 $colorIt = ($m['statmsg'] == $m['msg']) ?
" bgcolor=\"#f0f0ff\"" : " bgcolor=\"#ffe2e2\"";
136 $message = htmlspecialchars( $m['statmsg'] );
137 $mw = htmlspecialchars( $m['msg'] );
139 #$pageLink = $sk->makeLinkObj( $titleObj, htmlspecialchars( $key ) );
140 #$talkLink = $sk->makeLinkObj( $talkPage, htmlspecialchars( $talk ) );
141 if( isset( $pageExists[NS_MEDIAWIKI
][$title] ) ) {
142 $pageLink = $sk->makeKnownLinkObj( $titleObj, htmlspecialchars( $key ) );
144 $pageLink = $sk->makeBrokenLinkObj( $titleObj, htmlspecialchars( $key ) );
146 if( isset( $pageExists[NS_MEDIAWIKI_TALK
][$title] ) ) {
147 $talkLink = $sk->makeKnownLinkObj( $talkPage, htmlspecialchars( $talk ) );
149 $talkLink = $sk->makeBrokenLinkObj( $talkPage, htmlspecialchars( $talk ) );
163 wfProfileOut( "$fname-output" );
165 wfProfileOut( $fname );