2004-03-01 13:40:58 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Provide functions to generate a special page
|
2004-09-03 23:00:01 +00:00
|
|
|
* @package MediaWiki
|
|
|
|
|
* @subpackage SpecialPage
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2004-03-01 13:40:58 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function wfSpecialAllmessages() {
|
|
|
|
|
global $wgOut, $wgAllMessagesEn, $wgRequest, $wgMessageCache, $wgTitle;
|
2004-09-25 04:15:47 +00:00
|
|
|
global $wgLanguageCode, $wgContLanguageCode, $wgContLang;
|
2004-10-05 16:13:40 +00:00
|
|
|
global $wgUseDatabaseMessages;
|
|
|
|
|
|
|
|
|
|
if(!$wgUseDatabaseMessages) {
|
|
|
|
|
$wgOut->addHTML(wfMsg('allmessagesnotsupportedDB'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
$fname = "wfSpecialAllMessages";
|
|
|
|
|
wfProfileIn( $fname );
|
|
|
|
|
|
|
|
|
|
wfProfileIn( "$fname-setup");
|
|
|
|
|
$ot = $wgRequest->getText( 'ot' );
|
|
|
|
|
|
2005-05-13 10:28:54 +00:00
|
|
|
$navText = wfMsg( 'allmessagestext' );
|
2004-09-25 04:15:47 +00:00
|
|
|
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
$first = true;
|
|
|
|
|
$sortedArray = $wgAllMessagesEn;
|
|
|
|
|
ksort( $sortedArray );
|
|
|
|
|
$messages = array();
|
|
|
|
|
$wgMessageCache->disableTransform();
|
2004-09-17 04:49:39 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
foreach ( $sortedArray as $key => $enMsg ) {
|
|
|
|
|
$messages[$key]['enmsg'] = $enMsg;
|
2004-09-25 04:15:47 +00:00
|
|
|
$messages[$key]['statmsg'] = wfMsgNoDb( $key );
|
|
|
|
|
$messages[$key]['msg'] = wfMsg ( $key );
|
2004-09-02 23:28:24 +00:00
|
|
|
}
|
2004-09-17 04:49:39 +00:00
|
|
|
|
2004-09-09 22:22:17 +00:00
|
|
|
$wgMessageCache->enableTransform();
|
2004-09-02 23:28:24 +00:00
|
|
|
wfProfileOut( "$fname-setup" );
|
|
|
|
|
|
|
|
|
|
wfProfileIn( "$fname-output" );
|
|
|
|
|
if ($ot == 'php') {
|
|
|
|
|
$navText .= makePhp($messages);
|
|
|
|
|
$wgOut->addHTML('PHP | <a href="'.$wgTitle->escapeLocalUrl('ot=html').'">HTML</a><pre>'.htmlspecialchars($navText).'</pre>');
|
|
|
|
|
} else {
|
|
|
|
|
$wgOut->addHTML( '<a href="'.$wgTitle->escapeLocalUrl('ot=php').'">PHP</a> | HTML' );
|
|
|
|
|
$wgOut->addWikiText( $navText );
|
|
|
|
|
$wgOut->addHTML( makeHTMLText( $messages ) );
|
2004-03-01 13:40:58 +00:00
|
|
|
}
|
2004-09-02 23:28:24 +00:00
|
|
|
wfProfileOut( "$fname-output" );
|
2004-08-22 23:19:12 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
wfProfileOut( $fname );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function makePhp($messages) {
|
|
|
|
|
global $wgLanguageCode;
|
|
|
|
|
$txt = "\n\n".'$wgAllMessages'.ucfirst($wgLanguageCode).' = array('."\n";
|
|
|
|
|
foreach( $messages as $key => $m ) {
|
|
|
|
|
if(strtolower($wgLanguageCode) != 'en' and $m['msg'] == $m['enmsg'] ) {
|
|
|
|
|
if (strstr($m['msg'],"\n")) {
|
|
|
|
|
$txt.='/* ';
|
|
|
|
|
$comment=' */';
|
2004-05-01 15:42:11 +00:00
|
|
|
} else {
|
2004-09-02 23:28:24 +00:00
|
|
|
$txt .= '#';
|
2004-05-01 15:42:11 +00:00
|
|
|
$comment = '';
|
|
|
|
|
}
|
2004-09-02 23:28:24 +00:00
|
|
|
} elseif ($m['msg'] == '<'.$key.'>'){
|
|
|
|
|
$m['msg'] = '';
|
|
|
|
|
$comment = ' #empty';
|
|
|
|
|
} else {
|
|
|
|
|
$comment = '';
|
2004-05-01 15:42:11 +00:00
|
|
|
}
|
2005-05-13 10:28:54 +00:00
|
|
|
$txt .= "'$key' => '" . preg_replace( "/(?<!\\\\)'/", "\'", $m['msg']) . "',$comment\n";
|
2004-05-01 15:42:11 +00:00
|
|
|
}
|
2004-09-02 23:28:24 +00:00
|
|
|
$txt .= ');';
|
|
|
|
|
return $txt;
|
|
|
|
|
}
|
2004-05-01 15:42:11 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function makeHTMLText( $messages ) {
|
2004-12-07 20:22:22 +00:00
|
|
|
global $wgLang, $wgUser, $wgLanguageCode, $wgContLanguageCode, $wgContLang;
|
2004-09-02 23:28:24 +00:00
|
|
|
$fname = "makeHTMLText";
|
|
|
|
|
wfProfileIn( $fname );
|
|
|
|
|
|
|
|
|
|
$sk =& $wgUser->getSkin();
|
|
|
|
|
$talk = $wgLang->getNsText( NS_TALK );
|
|
|
|
|
$mwnspace = $wgLang->getNsText( NS_MEDIAWIKI );
|
|
|
|
|
$mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK );
|
|
|
|
|
$txt = "
|
2004-03-01 13:40:58 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
<table border='1' cellspacing='0' width='100%'>
|
|
|
|
|
<tr bgcolor='#b2b2ff'>
|
2005-03-13 09:03:58 +00:00
|
|
|
<th>" . wfMsg('allmessagesname') . "</th>
|
|
|
|
|
<th>" . wfMsg('allmessagesdefault') . "</th>
|
|
|
|
|
<th>" . wfMsg('allmessagescurrent') . "</th>
|
2004-09-02 23:28:24 +00:00
|
|
|
</tr>";
|
|
|
|
|
|
|
|
|
|
wfProfileIn( "$fname-check" );
|
|
|
|
|
# This is a nasty hack to avoid doing independent existence checks
|
|
|
|
|
# without sending the links and table through the slow wiki parser.
|
|
|
|
|
$pageExists = array(
|
|
|
|
|
NS_MEDIAWIKI => array(),
|
|
|
|
|
NS_MEDIAWIKI_TALK => array()
|
|
|
|
|
);
|
|
|
|
|
$dbr =& wfGetDB( DB_SLAVE );
|
2004-12-19 08:00:50 +00:00
|
|
|
$page = $dbr->tableName( 'page' );
|
|
|
|
|
$sql = "SELECT page_namespace,page_title FROM $page WHERE page_namespace IN (" . NS_MEDIAWIKI . ", " . NS_MEDIAWIKI_TALK . ")";
|
|
|
|
|
$res = $dbr->query( $sql );
|
2004-09-02 23:28:24 +00:00
|
|
|
while( $s = $dbr->fetchObject( $res ) ) {
|
2004-12-19 08:00:50 +00:00
|
|
|
$pageExists[$s->page_namespace][$s->page_title] = true;
|
2004-09-02 23:28:24 +00:00
|
|
|
}
|
|
|
|
|
$dbr->freeResult( $res );
|
|
|
|
|
wfProfileOut( "$fname-check" );
|
2004-08-22 22:22:54 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
wfProfileIn( "$fname-output" );
|
2004-12-07 20:22:22 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
foreach( $messages as $key => $m ) {
|
2004-09-25 04:15:47 +00:00
|
|
|
|
2004-10-11 02:15:55 +00:00
|
|
|
$title = $wgLang->ucfirst( $key );
|
|
|
|
|
if($wgLanguageCode != $wgContLanguageCode)
|
|
|
|
|
$title.="/$wgLanguageCode";
|
2004-12-07 20:22:22 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
$titleObj =& Title::makeTitle( NS_MEDIAWIKI, $title );
|
|
|
|
|
$talkPage =& Title::makeTitle( NS_MEDIAWIKI_TALK, $title );
|
2004-03-01 13:40:58 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
$colorIt = ($m['statmsg'] == $m['msg']) ? " bgcolor=\"#f0f0ff\"" : " bgcolor=\"#ffe2e2\"";
|
|
|
|
|
$message = htmlspecialchars( $m['statmsg'] );
|
|
|
|
|
$mw = htmlspecialchars( $m['msg'] );
|
|
|
|
|
|
|
|
|
|
#$pageLink = $sk->makeLinkObj( $titleObj, htmlspecialchars( $key ) );
|
|
|
|
|
#$talkLink = $sk->makeLinkObj( $talkPage, htmlspecialchars( $talk ) );
|
|
|
|
|
if( isset( $pageExists[NS_MEDIAWIKI][$title] ) ) {
|
|
|
|
|
$pageLink = $sk->makeKnownLinkObj( $titleObj, htmlspecialchars( $key ) );
|
|
|
|
|
} else {
|
|
|
|
|
$pageLink = $sk->makeBrokenLinkObj( $titleObj, htmlspecialchars( $key ) );
|
|
|
|
|
}
|
|
|
|
|
if( isset( $pageExists[NS_MEDIAWIKI_TALK][$title] ) ) {
|
|
|
|
|
$talkLink = $sk->makeKnownLinkObj( $talkPage, htmlspecialchars( $talk ) );
|
|
|
|
|
} else {
|
|
|
|
|
$talkLink = $sk->makeBrokenLinkObj( $talkPage, htmlspecialchars( $talk ) );
|
2004-05-01 15:42:11 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
$txt .=
|
|
|
|
|
"<tr$colorIt><td>
|
|
|
|
|
$pageLink<br />
|
|
|
|
|
$talkLink
|
|
|
|
|
</td><td>
|
|
|
|
|
$message
|
|
|
|
|
</td><td>
|
|
|
|
|
$mw
|
|
|
|
|
</td></tr>";
|
2004-05-01 15:42:11 +00:00
|
|
|
}
|
2004-09-02 23:28:24 +00:00
|
|
|
$txt .= "</table>";
|
|
|
|
|
wfProfileOut( "$fname-output" );
|
|
|
|
|
|
|
|
|
|
wfProfileOut( $fname );
|
|
|
|
|
return $txt;
|
|
|
|
|
}
|
2004-03-01 13:40:58 +00:00
|
|
|
|
2004-08-22 22:22:54 +00:00
|
|
|
?>
|