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' );
27 $navText = wfMsg( 'allmessagestext' );
31 $sortedArray = $wgAllMessagesEn;
32 ksort( $sortedArray );
34 $wgMessageCache->disableTransform();
36 foreach ( $sortedArray as $key => $enMsg ) {
37 $messages[$key]['enmsg'] = $enMsg;
38 $messages[$key]['statmsg'] = wfMsgNoDb( $key );
39 $messages[$key]['msg'] = wfMsg ( $key );
42 $wgMessageCache->enableTransform();
43 wfProfileOut( "$fname-setup" );
45 wfProfileIn( "$fname-output" );
47 $navText .= makePhp($messages);
48 $wgOut->addHTML('PHP | <a href="'.$wgTitle->escapeLocalUrl('ot=html').'">HTML</a><pre>'.htmlspecialchars($navText).'</pre>');
50 $wgOut->addHTML( '<a href="'.$wgTitle->escapeLocalUrl('ot=php').'">PHP</a> | HTML' );
51 $wgOut->addWikiText( $navText );
52 $wgOut->addHTML( makeHTMLText( $messages ) );
54 wfProfileOut( "$fname-output" );
56 wfProfileOut( $fname );
62 function makePhp($messages) {
63 global $wgLanguageCode;
64 $txt = "\n\n".'$wgAllMessages'.ucfirst($wgLanguageCode).' = array('."\n";
65 foreach( $messages as $key => $m ) {
66 if(strtolower($wgLanguageCode) != 'en' and $m['msg'] == $m['enmsg'] ) {
67 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, $wgContLang;
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
);
100 <table border='1' cellspacing='0' width='100%'>
101 <tr bgcolor='#b2b2ff'>
102 <th>" . wfMsg('allmessagesname') . "</th>
103 <th>" . wfMsg('allmessagesdefault') . "</th>
104 <th>" . wfMsg('allmessagescurrent') . "</th>
107 wfProfileIn( "$fname-check" );
108 # This is a nasty hack to avoid doing independent existence checks
109 # without sending the links and table through the slow wiki parser.
111 NS_MEDIAWIKI
=> array(),
112 NS_MEDIAWIKI_TALK
=> array()
114 $dbr =& wfGetDB( DB_SLAVE
);
115 $page = $dbr->tableName( 'page' );
116 $sql = "SELECT page_namespace,page_title FROM $page WHERE page_namespace IN (" . NS_MEDIAWIKI
. ", " . NS_MEDIAWIKI_TALK
. ")";
117 $res = $dbr->query( $sql );
118 while( $s = $dbr->fetchObject( $res ) ) {
119 $pageExists[$s->page_namespace
][$s->page_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 );