Use link() instead of deprecated makeLinkObj() where possible.
[lhc/web/wiklou.git] / includes / LogPage.php
index 945de9d..39869cb 100644 (file)
@@ -201,7 +201,8 @@ class LogPage {
                                } else {
                                        $details = '';
                                        array_unshift( $params, $titleLink );
-                                       if ( $key == 'block/block' || $key == 'suppress/block' || $key == 'block/reblock' ) {
+                                       // User suppression
+                                       if ( preg_match( '/^(block|suppress)\/(block|reblock)$/', $key ) ) {
                                                if ( $skin ) {
                                                        $params[1] = '<span title="' . htmlspecialchars( $params[1] ). '">' . 
                                                                $wgLang->translateBlockExpiry( $params[1] ) . '</span>';
@@ -210,6 +211,7 @@ class LogPage {
                                                }
                                                $params[2] = isset( $params[2] ) ? 
                                                        self::formatBlockFlags( $params[2], is_null( $skin ) ) : '';
+                                       // Page protections
                                        } else if ( $type == 'protect' && count($params) == 3 ) {
                                                $details .= " {$params[1]}"; // restrictions and expiries
                                                if( $params[2] ) {
@@ -219,6 +221,7 @@ class LogPage {
                                                                $details .= ' ['.wfMsgForContent('protect-summary-cascade').']';
                                                        }
                                                }
+                                       // Page moves
                                        } else if ( $type == 'move' && count( $params ) == 3 ) {
                                                if( $params[2] ) {
                                                        if ( $skin ) {
@@ -227,6 +230,18 @@ class LogPage {
                                                                $details .= ' [' . wfMsgForContent( 'move-redirect-suppressed' ) . ']';
                                                        }
                                                }
+                                       // Revision deletion
+                                       } else if ( preg_match( '/^(delete|suppress)\/revision$/', $key ) && count( $params ) == 5 ) {
+                                               $count = substr_count( $params[2], ',' ) + 1; // revisions
+                                               $ofield = intval( substr( $params[3], 7 ) ); // <ofield=x>
+                                               $nfield = intval( substr( $params[4], 7 ) ); // <nfield=x>
+                                               $details .= ': '.RevisionDeleter::getLogMessage( $count, $nfield, $ofield, false );
+                                       // Log deletion
+                                       } else if ( preg_match( '/^(delete|suppress)\/event$/', $key ) && count( $params ) == 4 ) {
+                                               $count = substr_count( $params[1], ',' ) + 1; // log items
+                                               $ofield = intval( substr( $params[2], 7 ) ); // <ofield=x>
+                                               $nfield = intval( substr( $params[3], 7 ) ); // <nfield=x>
+                                               $details .= ': '.RevisionDeleter::getLogMessage( $count, $nfield, $ofield, true );
                                        }
                                        $rv = wfMsgReal( $wgLogActions[$key], $params, true, !$skin ) . $details;
                                }
@@ -250,6 +265,8 @@ class LogPage {
                //  is that link in HTML form, and so this just gets rid of the ugly [[]].
                //  However, this is a horrible hack and it doesn't work like you expect if, say,
                //  you want to link to something OTHER than the title of the log entry.
+               //  The real problem, which Erik was trying to fix (and it sort-of works now) is
+               //  that the same messages are being treated as both wikitext *and* HTML.
                if( $filterWikilinks ) {
                        $rv = str_replace( "[[", "", $rv );
                        $rv = str_replace( "]]", "", $rv );
@@ -264,14 +281,21 @@ class LogPage {
                }
                switch( $type ) {
                        case 'move':
-                               $titleLink = $skin->makeLinkObj( $title, 
-                                       htmlspecialchars( $title->getPrefixedText() ), 'redirect=no' );
+                               $titleLink = $skin->link(
+                                       $title, 
+                                       htmlspecialchars( $title->getPrefixedText() ),
+                                       array(),
+                                       array( 'redirect' => 'no' )
+                               );
                                $targetTitle = Title::newFromText( $params[0] );
                                if ( !$targetTitle ) {
                                        # Workaround for broken database
                                        $params[0] = htmlspecialchars( $params[0] );
                                } else {
-                                       $params[0] = $skin->makeLinkObj( $targetTitle, htmlspecialchars( $params[0] ) );
+                                       $params[0] = $skin->link(
+                                               $targetTitle,
+                                               htmlspecialchars( $params[0] )
+                                       );
                                }
                                break;
                        case 'block':
@@ -287,11 +311,19 @@ class LogPage {
                                break;
                        case 'rights':
                                $text = $wgContLang->ucfirst( $title->getText() );
-                               $titleLink = $skin->makeLinkObj( Title::makeTitle( NS_USER, $text ) );
+                               $titleLink = $skin->link( Title::makeTitle( NS_USER, $text ) );
                                break;
                        case 'merge':
-                               $titleLink = $skin->makeLinkObj( $title, $title->getPrefixedText(), 'redirect=no' );
-                               $params[0] = $skin->makeLinkObj( Title::newFromText( $params[0] ), htmlspecialchars( $params[0] ) );
+                               $titleLink = $skin->link(
+                                       $title,
+                                       $title->getPrefixedText(),
+                                       array(),
+                                       array( 'redirect' => 'no' )
+                               );
+                               $params[0] = $skin->link(
+                                       Title::newFromText( $params[0] ),
+                                       htmlspecialchars( $params[0] )
+                               );
                                $params[1] = $wgLang->timeanddate( $params[1] );
                                break;
                        default:
@@ -299,12 +331,12 @@ class LogPage {
                                        list( $name, $par ) = SpecialPage::resolveAliasWithSubpage( $title->getDBKey() );
                                        # Use the language name for log titles, rather than Log/X
                                        if( $name == 'Log' ) {
-                                               $titleLink = '('.$skin->makeLinkObj( $title, LogPage::logName( $par ) ).')';
+                                               $titleLink = '('.$skin->link( $title, LogPage::logName( $par ) ).')';
                                        } else {
-                                               $titleLink = $skin->makeLinkObj( $title );
+                                               $titleLink = $skin->link( $title );
                                        }
                                } else {
-                                       $titleLink = $skin->makeLinkObj( $title );
+                                       $titleLink = $skin->link( $title );
                                }
                }
                return $titleLink;
@@ -372,11 +404,13 @@ class LogPage {
         * @return string
         */
        public static function formatBlockFlags( $flags, $forContent = false ) {
+               global $wgLang;
+
                $flags = explode( ',', trim( $flags ) );
                if( count( $flags ) > 0 ) {
                        for( $i = 0; $i < count( $flags ); $i++ )
                                $flags[$i] = self::formatBlockFlag( $flags[$i], $forContent );
-                       return '(' . implode( ', ', $flags ) . ')';
+                       return '(' . $wgLang->commaList( $flags ) . ')';
                } else {
                        return '';
                }