X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialAllmessages.php;h=017bbda66e62a7c7a1eb51fe0ddb099b722942a5;hb=d466cf6e86b929b17e3a9938e16a4e97d9448cdb;hp=923e3ec3f928a3f5638ecf17ef4b4bd295120a66;hpb=40dc5960971fe0de53dcd7623b31c95738140607;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/SpecialAllmessages.php b/includes/SpecialAllmessages.php
index 923e3ec3f9..017bbda66e 100644
--- a/includes/SpecialAllmessages.php
+++ b/includes/SpecialAllmessages.php
@@ -1,58 +1,199 @@
getNsText( NS_TALK );
- $mwnspace = $wgLang->getNsText( NS_MEDIAWIKI );
- $mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK );
- $mwMsg =& MagicWord::get( MAG_MSG );
- $navText = str_replace( "$1", "allmessagestext", $mwMsg->getSynonym( 0 ) );
- $navText .= "
-
-
- '''Name'''
- |
- '''Default text'''
- |
- '''Current text'''
- |
";
-
- $first = true;
- $sortedArray = $wgAllMessagesEn;
+/**
+ * Constructor.
+ */
+function wfSpecialAllmessages() {
+ global $wgOut, $wgRequest, $wgMessageCache, $wgTitle;
+ global $wgUseDatabaseMessages;
+
+ # The page isn't much use if the MediaWiki namespace is not being used
+ if( !$wgUseDatabaseMessages ) {
+ $wgOut->addWikiText( wfMsg( 'allmessagesnotsupportedDB' ) );
+ return;
+ }
+
+ wfProfileIn( __METHOD__ );
+
+ wfProfileIn( __METHOD__ . '-setup' );
+ $ot = $wgRequest->getText( 'ot' );
+
+ $navText = wfMsg( 'allmessagestext' );
+
+ # Make sure all extension messages are available
+ MessageCache::loadAllMessages();
+
+ $sortedArray = array_merge( Language::getMessagesFor( 'en' ), $wgMessageCache->getExtensionMessagesFor( 'en' ) );
ksort( $sortedArray );
-
- foreach ( $sortedArray as $key => $enMsg ) {
-
- $titleObj = Title::newFromText( $key );
- $title = $titleObj->getDBkey();
-
- $message = wfMsgNoDB( $key );
- $mw = wfMsg ( $key );
+ $messages = array();
+ $wgMessageCache->disableTransform();
- $colorIt = ($message == $mw) ? " bgcolor=\"#f0f0ff\"" : " bgcolor=\"#ffe2e2\"";
-
- $message = wfEscapeWikiText( $message );
- $mw = wfEscapeWikiText( $mw );
-
-# [$wgServer$wgScript?title=$mwnspace:$title&action=edit $key]
- $navText .=
-"
- [[$mwnspace:$title|$key]]
- [[$mwtalk:$title|$talk]]
- |
- $message
- |
- $mw
- |
";
+ foreach ( $sortedArray as $key => $value ) {
+ $messages[$key]['enmsg'] = $value;
+ $messages[$key]['statmsg'] = wfMsgNoDb( $key );
+ $messages[$key]['msg'] = wfMsg ( $key );
}
- $navText .= "
";
+ $wgMessageCache->enableTransform();
+ wfProfileOut( __METHOD__ . '-setup' );
- $wgOut->addWikiText( $navText );
+ wfProfileIn( __METHOD__ . '-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( __METHOD__ . '-output' );
- return;
+ wfProfileOut( __METHOD__ );
}
-?>
+/**
+ * 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 $wgLang;
+ $txt = "\n\n\$messages = array(\n";
+ foreach( $messages as $key => $m ) {
+ if( $wgLang->getCode() != 'en' && $m['msg'] == $m['enmsg'] ) {
+ continue;
+ } else if ( wfEmptyMsg( $key, $m['msg'] ) ) {
+ $m['msg'] = '';
+ $comment = ' #empty';
+ } else {
+ $comment = '';
+ }
+ $txt .= "'$key' => '" . preg_replace( '/(?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()
+ );
+ $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->page_namespace][$s->page_title] = true;
+ }
+ $dbr->freeResult( $res );
+ wfProfileOut( __METHOD__ . "-check" );
+
+ wfProfileIn( __METHOD__ . "-output" );
+
+ $i = 0;
+
+ foreach( $messages as $key => $m ) {
+ $title = $wgLang->ucfirst( $key );
+ if( $wgLang->getCode() != $wgContLang->getCode() ) {
+ $title .= '/' . $wgLang->getCode();
+ }
+
+ $titleObj =& Title::makeTitle( NS_MEDIAWIKI, $title );
+ $talkPage =& Title::makeTitle( NS_MEDIAWIKI_TALK, $title );
+
+ $changed = ( $m['statmsg'] != $m['msg'] );
+ $message = htmlspecialchars( $m['statmsg'] );
+ $mw = htmlspecialchars( $m['msg'] );
+
+ 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 ) );
+ }
+
+ $anchor = 'msg_' . htmlspecialchars( strtolower( $title ) );
+ $anchor = "";
+
+ if( $changed ) {
+ $txt .= "
+
+
+ $anchor$pageLink $talkLink
+ |
+$message
+ |
+
+
+$mw
+ |
+
";
+ } else {
+ $txt .= "
+
+
+ $anchor$pageLink $talkLink
+ |
+$mw
+ |
+
";
+ }
+ $i++;
+ }
+ $txt .= '
';
+ wfProfileOut( __METHOD__ . '-output' );
+
+ wfProfileOut( __METHOD__ );
+ return $txt;
+}
+
+