X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialAllmessages.php;h=5ceb40bf589c871b69b07d79303eb02079cb264f;hb=539fc27b10ab37e229ae6b8b3326670607f899cc;hp=30b17411a4319d3518a29dcc3b8d1ae5ada755c6;hpb=28346910c6918d6666113c3d1ef451f183e1992e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialAllmessages.php b/includes/SpecialAllmessages.php index 30b17411a4..5ceb40bf58 100644 --- a/includes/SpecialAllmessages.php +++ b/includes/SpecialAllmessages.php @@ -1,86 +1,155 @@ getText('ot'); - $mwMsg =& MagicWord::get( MAG_MSG ); - set_time_limit(0); - $navText = wfMsg( 'allmessagestext', $mwMsg->getSynonym( 0 ) ); - $first = true; - $sortedArray = $wgAllMessagesEn; - ksort( $sortedArray ); - $messages = array(); - $wgMessageCache->disableTransform(); - foreach ( $sortedArray as $key => $enMsg ) { - $messages[$key]['enmsg'] = $enMsg; - $messages[$key]['statmsg'] = wfMsgNoDb( $key ); - $messages[$key]['msg'] = wfMsg ( $key ); - } - if ($ot == 'html') { - $navText .= makeWikiText($messages); - $wgOut->addHTML('PHP | HTML'); - $wgOut->addWikiText($navText); - } else { - $navText .= makePhp($messages); - $wgOut->addHTML('PHP | HTML
'.htmlspecialchars($navText).''); - } - return; +/** + * + */ +function wfSpecialAllmessages() { + global $wgOut, $wgAllMessagesEn, $wgRequest, $wgMessageCache, $wgTitle; + + $fname = "wfSpecialAllMessages"; + wfProfileIn( $fname ); + + wfProfileIn( "$fname-setup"); + $ot = $wgRequest->getText( 'ot' ); + $mwMsg =& MagicWord::get( MAG_MSG ); + + $navText = wfMsg( 'allmessagestext', $mwMsg->getSynonym( 0 ) ); + $first = true; + $sortedArray = $wgAllMessagesEn; + ksort( $sortedArray ); + $messages = array(); + $wgMessageCache->disableTransform(); + + foreach ( $sortedArray as $key => $enMsg ) { + $messages[$key]['enmsg'] = $enMsg; + $messages[$key]['statmsg'] = wfMsgNoDbNoConvert( $key ); + $messages[$key]['msg'] = wfMsgNoConvert ( $key ); } - 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'] ) { - $txt .= '#'; - } elseif ($m['msg'] == '<'.$key.'>'){ - $m['msg'] = ''; - $comment = ' #empty'; + + $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 = ''; } - $txt .= "'".$key."' => \"".str_replace('"','\"',$m['msg'])."\",$comment\n"; + } elseif ($m['msg'] == '<'.$key.'>'){ + $m['msg'] = ''; + $comment = ' #empty'; + } else { + $comment = ''; } - $txt .= ');'; - return $txt; + $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 = " - function makeWikiText($messages) { - global $wgLang; - $talk = $wgLang->getNsText( NS_TALK ); - $mwnspace = $wgLang->getNsText( NS_MEDIAWIKI ); - $mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK ); - $txt = " - -
- '''Name''' - | - '''Default text''' - | - '''Current text''' - |
Name | +Default text | +Current text | +
---|---|---|
- [[$mwnspace:$title|$key]] - [[$mwtalk:$title|$talk]] - | - $message - | - $mw - |