X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialAllmessages.php;h=d44036f214d6b2f269c656d227a748369b34de35;hb=772b5eb07e95144ae38fdceb3c1e2afbd588a4b7;hp=2001c414c01877cdd399a0e91524bd5bb09dd73c;hpb=9aae1d5065cee553d93882c20a755e58efabe2d8;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/SpecialAllmessages.php b/includes/SpecialAllmessages.php
index 2001c414c0..d44036f214 100644
--- a/includes/SpecialAllmessages.php
+++ b/includes/SpecialAllmessages.php
@@ -1,173 +1,216 @@
getVariants())) {
- $err = wfMsg('allmessagesnotsupportedUI');
- $wgOut->addHTML( $err );
- return;
- }
- if(!$wgUseDatabaseMessages) {
- $wgOut->addHTML(wfMsg('allmessagesnotsupportedDB'));
+ # The page isn't much use if the MediaWiki namespace is not being used
+ if( !$wgUseDatabaseMessages ) {
+ $wgOut->addWikiText( wfMsg( 'allmessagesnotsupportedDB' ) );
return;
}
- $fname = "wfSpecialAllMessages";
- wfProfileIn( $fname );
-
- wfProfileIn( "$fname-setup");
+ wfProfileIn( __METHOD__ );
+
+ wfProfileIn( __METHOD__ . '-setup' );
$ot = $wgRequest->getText( 'ot' );
- $mwMsg =& MagicWord::get( MAG_MSG );
-
- $navText = wfMsg( 'allmessagestext', $mwMsg->getSynonym( 0 ) );
+ $navText = wfMsg( 'allmessagestext' );
- $first = true;
- $sortedArray = $wgAllMessagesEn;
+ # Make sure all extension messages are available
+
+ $wgMessageCache->loadAllMessages();
+
+ $sortedArray = array_merge( Language::getMessagesFor( 'en' ), $wgMessageCache->getExtensionMessagesFor( 'en' ) );
ksort( $sortedArray );
$messages = array();
$wgMessageCache->disableTransform();
- foreach ( $sortedArray as $key => $enMsg ) {
- $messages[$key]['enmsg'] = $enMsg;
+ foreach ( $sortedArray as $key => $value ) {
+ $messages[$key]['enmsg'] = $value;
$messages[$key]['statmsg'] = wfMsgNoDb( $key );
$messages[$key]['msg'] = wfMsg ( $key );
}
$wgMessageCache->enableTransform();
- wfProfileOut( "$fname-setup" );
-
- wfProfileIn( "$fname-output" );
- if ($ot == 'php') {
- $navText .= makePhp($messages);
- $wgOut->addHTML('PHP | HTML
'.htmlspecialchars($navText).'
');
+ wfProfileOut( __METHOD__ . '-setup' );
+
+ wfProfileIn( __METHOD__ . '-output' );
+ if ( $ot == 'php' ) {
+ $navText .= makePhp( $messages );
+ $wgOut->addHTML( 'PHP | HTML | XML' . htmlspecialchars( $navText ) . '
' );
+ } else if ( $ot == 'xml' ) {
+ $wgOut->disable();
+ header( 'Content-type: text/xml' );
+ echo makeXml( $messages );
} else {
- $wgOut->addHTML( 'PHP | HTML' );
+ $wgOut->addHTML( 'PHP | HTML | XML' );
$wgOut->addWikiText( $navText );
$wgOut->addHTML( makeHTMLText( $messages ) );
}
- wfProfileOut( "$fname-output" );
-
- wfProfileOut( $fname );
+ wfProfileOut( __METHOD__ . '-output' );
+
+ wfProfileOut( __METHOD__ );
+}
+
+function makeXml( $messages ) {
+ global $wgLang;
+ $lang = $wgLang->getCode();
+ $txt = "\n";
+ $txt .= "\n";
+ foreach( $messages as $key => $m ) {
+ $txt .= "\t" . Xml::element( 'message', array( 'name' => $key ), $m['msg'] ) . "\n";
+ }
+ $txt .= "";
+ return $txt;
}
/**
- *
+ * Create the messages array, formatted in PHP to copy to language files.
+ * @param $messages Messages array.
+ * @return The PHP messages array.
+ * @todo Make suitable for language files.
*/
-function makePhp($messages) {
- global $wgLanguageCode;
- $txt = "\n\n".'$wgAllMessages'.ucfirst($wgLanguageCode).' = array('."\n";
+function makePhp( $messages ) {
+ global $wgLang;
+ $txt = "\n\n\$messages = 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.'>'){
+ if( $wgLang->getCode() != 'en' && $m['msg'] == $m['enmsg'] ) {
+ continue;
+ } else if ( wfEmptyMsg( $key, $m['msg'] ) ) {
$m['msg'] = '';
$comment = ' #empty';
} else {
$comment = '';
}
- $txt .= "'".$key."' => \"".str_replace('"','\"',$m['msg'])."\",$comment\n";
+ $txt .= "'$key' => '" . preg_replace( '/(?getSkin();
- $talk = $wgLang->getNsText( NS_TALK );
- $mwnspace = $wgLang->getNsText( NS_MEDIAWIKI );
- $mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK );
- $txt = "
-
-
-
- Name |
- Default text |
- Current text |
-
";
-
- wfProfileIn( "$fname-check" );
+ global $wgLang, $wgContLang, $wgUser;
+ wfProfileIn( __METHOD__ );
+
+ $sk = $wgUser->getSkin();
+ $talk = wfMsg( 'talkpagelinktext' );
+
+ $input = wfElement( 'input', array(
+ 'type' => 'text',
+ 'id' => 'allmessagesinput',
+ 'onkeyup' => 'allmessagesfilter()'
+ ), '' );
+ $checkbox = wfElement( 'input', array(
+ 'type' => 'button',
+ 'value' => wfMsgHtml( 'allmessagesmodified' ),
+ 'id' => 'allmessagescheckbox',
+ 'onclick' => 'allmessagesmodified()'
+ ), '' );
+
+ $txt = '' . wfMsgHtml( 'allmessagesfilter' ) . " {$input}{$checkbox} " . '';
+
+ $txt .= '
+
+
+ ' . wfMsgHtml( 'allmessagesname' ) . ' |
+ ' . wfMsgHtml( 'allmessagesdefault' ) . ' |
+
+
+ ' . wfMsgHtml( 'allmessagescurrent' ) . ' |
+
';
+
+ wfProfileIn( __METHOD__ . "-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 );
+ $dbr = wfGetDB( DB_SLAVE );
+ $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 );
while( $s = $dbr->fetchObject( $res ) ) {
- $pageExists[$s->cur_namespace][$s->cur_title] = true;
+ $pageExists[$s->page_namespace][$s->page_title] = true;
}
$dbr->freeResult( $res );
- wfProfileOut( "$fname-check" );
+ wfProfileOut( __METHOD__ . "-check" );
- wfProfileIn( "$fname-output" );
- foreach( $messages as $key => $m ) {
+ wfProfileIn( __METHOD__ . "-output" );
+
+ $i = 0;
+ foreach( $messages as $key => $m ) {
$title = $wgLang->ucfirst( $key );
- if($wgLanguageCode != $wgContLanguageCode)
- $title.="/$wgLanguageCode";
+ if( $wgLang->getCode() != $wgContLang->getCode() ) {
+ $title .= '/' . $wgLang->getCode();
+ }
+
$titleObj =& Title::makeTitle( NS_MEDIAWIKI, $title );
$talkPage =& Title::makeTitle( NS_MEDIAWIKI_TALK, $title );
- $colorIt = ($m['statmsg'] == $m['msg']) ? " bgcolor=\"#f0f0ff\"" : " bgcolor=\"#ffe2e2\"";
+ $changed = ( $m['statmsg'] != $m['msg'] );
$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 ) );
+ $pageLink = $sk->makeKnownLinkObj( $titleObj, "" . htmlspecialchars( $key ) . '' );
} else {
- $pageLink = $sk->makeBrokenLinkObj( $titleObj, htmlspecialchars( $key ) );
+ $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
+
+ $anchor = 'msg_' . htmlspecialchars( strtolower( $title ) );
+ $anchor = "";
+
+ if( $changed ) {
+ $txt .= "
+ |
+
+ $anchor$pageLink $talkLink
|
- $message
+$message
+ |
+
+
+$mw
+ |
+
";
+ } else {
+ $txt .= "
+
+
+ $anchor$pageLink $talkLink
|
- $mw
- |
";
+$mw
+
+ ";
+ }
+ $i++;
}
- $txt .= "
";
- wfProfileOut( "$fname-output" );
+ $txt .= '
';
+ wfProfileOut( __METHOD__ . '-output' );
- wfProfileOut( $fname );
+ wfProfileOut( __METHOD__ );
return $txt;
}
-?>
+