X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FSpecialAllmessages.php;h=dd506e77985952b5974f7b08d6fa4a8c1641ed6b;hb=60c94987aab3141a19d735fbc003d5cb646a8502;hp=923e3ec3f928a3f5638ecf17ef4b4bd295120a66;hpb=40dc5960971fe0de53dcd7623b31c95738140607;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialAllmessages.php b/includes/SpecialAllmessages.php index 923e3ec3f9..dd506e7798 100644 --- a/includes/SpecialAllmessages.php +++ b/includes/SpecialAllmessages.php @@ -1,58 +1,155 @@ getNsText( NS_TALK ); - $mwnspace = $wgLang->getNsText( NS_MEDIAWIKI ); - $mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK ); + wfProfileIn( "$fname-setup"); + $ot = $wgRequest->getText( 'ot' ); $mwMsg =& MagicWord::get( MAG_MSG ); - $navText = str_replace( "$1", "allmessagestext", $mwMsg->getSynonym( 0 ) ); - $navText .= " - -"; + $navText = wfMsg( 'allmessagestext', $mwMsg->getSynonym( 0 ) ); $first = true; $sortedArray = $wgAllMessagesEn; ksort( $sortedArray ); - + $messages = array(); + $wgMessageCache->disableTransform(); + foreach ( $sortedArray as $key => $enMsg ) { - - $titleObj = Title::newFromText( $key ); - $title = $titleObj->getDBkey(); - - $message = wfMsgNoDB( $key ); - $mw = wfMsg ( $key ); + $messages[$key]['enmsg'] = $enMsg; + $messages[$key]['statmsg'] = wfMsgNoDbForContent( $key ); + $messages[$key]['msg'] = wfMsgForContent ( $key ); + } - $colorIt = ($message == $mw) ? " bgcolor=\"#f0f0ff\"" : " bgcolor=\"#ffe2e2\""; - - $message = wfEscapeWikiText( $message ); - $mw = wfEscapeWikiText( $mw ); - -# [$wgServer$wgScript?title=$mwnspace:$title&action=edit $key]
- $navText .= -""; + $wgMessageCache->enableTransform(); + wfProfileOut( "$fname-setup" ); + + wfProfileIn( "$fname-output" ); + if ($ot == 'php') { + $navText .= makePhp($messages); + $wgOut->addHTML('PHP | HTML
'.htmlspecialchars($navText).'
'); + } else { + $wgOut->addHTML( 'PHP | HTML' ); + $wgOut->addWikiText( $navText ); + $wgOut->addHTML( makeHTMLText( $messages ) ); + } + wfProfileOut( "$fname-output" ); + + 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=' */'; + } else { + $txt .= '#'; + $comment = ''; + } + } elseif ($m['msg'] == '<'.$key.'>'){ + $m['msg'] = ''; + $comment = ' #empty'; + } else { + $comment = ''; + } + $txt .= "'".$key."' => \"".str_replace('"','\"',$m['msg'])."\",$comment\n"; + } + $txt .= ');'; + return $txt; +} + +/** + * + */ +function makeHTMLText( $messages ) { + global $wgLang, $wgUser; + $fname = "makeHTMLText"; + wfProfileIn( $fname ); + + $sk =& $wgUser->getSkin(); + $talk = $wgLang->getNsText( NS_TALK ); + $mwnspace = $wgLang->getNsText( NS_MEDIAWIKI ); + $mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK ); + $txt = " + +
- '''Name''' - - '''Default text''' - - '''Current text''' -
- [[$mwnspace:$title|$key]]
- [[$mwtalk:$title|$talk]] -
- $message - - $mw -
+ + + + + "; + + 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() + ); + $sql = "SELECT cur_namespace,cur_title FROM cur WHERE cur_namespace IN (" . NS_MEDIAWIKI . ", " . NS_MEDIAWIKI_TALK . ")"; + $dbr =& wfGetDB( DB_SLAVE ); + $res = $dbr->query( $sql ); + while( $s = $dbr->fetchObject( $res ) ) { + $pageExists[$s->cur_namespace][$s->cur_title] = true; } + $dbr->freeResult( $res ); + wfProfileOut( "$fname-check" ); - $navText .= "
NameDefault textCurrent text
"; + wfProfileIn( "$fname-output" ); + foreach( $messages as $key => $m ) { + $title = $wgLang->ucfirst( $key ); + $titleObj =& Title::makeTitle( NS_MEDIAWIKI, $title ); + $talkPage =& Title::makeTitle( NS_MEDIAWIKI_TALK, $title ); - $wgOut->addWikiText( $navText ); + $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 ) ); + } + + $txt .= + " + $pageLink
+ $talkLink + + $message + + $mw + "; + } + $txt .= ""; + wfProfileOut( "$fname-output" ); - return; + wfProfileOut( $fname ); + return $txt; } ?>