Don't add empty title attributes to anchor links
[lhc/web/wiklou.git] / includes / LogPage.php
index 1950b02..0d57238 100644 (file)
@@ -45,9 +45,9 @@ class LogPage {
          * @param string $type One of '', 'block', 'protect', 'rights', 'delete',
          *               'upload', 'move'
          * @param bool $rc Whether to update recent changes as well as the logging table
-         * @param bool $udp Whether to send to the UDP feed if not to RC
+         * @param bool $udp Whether to send to the UDP feed if NOT sent to RC
          */
-       public function __construct( $type, $rc = true, $udp = 'UDP' ) {
+       public function __construct( $type, $rc = true, $udp = 'skipUDP' ) {
                $this->type = $type;
                $this->updateRecentChanges = $rc;
                $this->sendToUDP = ($udp == 'UDP');
@@ -86,13 +86,10 @@ class LogPage {
                        }
                        # Notify external application via UDP.
                        # We send this to IRC but do not want to add it the RC table.
-                       global $wgRC2UDPAddress, $wgRC2UDPOmitBots;
                        $titleObj = SpecialPage::getTitleFor( 'Log', $this->type );
                        $rc = RecentChange::newLogEntry( $now, $titleObj, $this->doer, $this->getRcComment(), '',
                                $this->type, $this->action, $this->target, $this->comment, $this->params, $newId );
-                       if( $wgRC2UDPAddress && ( !$rc->getAttribute('rc_bot') || !$wgRC2UDPOmitBots ) ) {
-                               RecentChange::sendToUDP( $rc->getIRCLine() );
-                       }
+                       $rc->notifyRC2UDP();
                }
                return true;
        }
@@ -204,7 +201,7 @@ class LogPage {
                                } else {
                                        $details = '';
                                        array_unshift( $params, $titleLink );
-                                       if ( $key == 'block/block' || $key == 'suppress/block' || $key == 'block/reblock' ) {
+                                       if ( preg_match( '/^(block|suppress)\/(block|reblock)$/', $key ) ) {
                                                if ( $skin ) {
                                                        $params[1] = '<span title="' . htmlspecialchars( $params[1] ). '">' . 
                                                                $wgLang->translateBlockExpiry( $params[1] ) . '</span>';
@@ -216,11 +213,19 @@ class LogPage {
                                        } else if ( $type == 'protect' && count($params) == 3 ) {
                                                $details .= " {$params[1]}"; // restrictions and expiries
                                                if( $params[2] ) {
-                                                       $details .= ' ['.wfMsg('protect-summary-cascade').']';
+                                                       if ( $skin ) {
+                                                               $details .= ' ['.wfMsg('protect-summary-cascade').']';
+                                                       } else {
+                                                               $details .= ' ['.wfMsgForContent('protect-summary-cascade').']';
+                                                       }
                                                }
                                        } else if ( $type == 'move' && count( $params ) == 3 ) {
                                                if( $params[2] ) {
-                                                       $details .= ' [' . wfMsg( 'move-redirect-suppressed' ) . ']';
+                                                       if ( $skin ) {
+                                                               $details .= ' [' . wfMsg( 'move-redirect-suppressed' ) . ']';
+                                                       } else {
+                                                               $details .= ' [' . wfMsgForContent( 'move-redirect-suppressed' ) . ']';
+                                                       }
                                                }
                                        }
                                        $rv = wfMsgReal( $wgLogActions[$key], $params, true, !$skin ) . $details;
@@ -236,6 +241,17 @@ class LogPage {
                                $rv = "$action";
                        }
                }
+               
+               // For the perplexed, this feature was added in r7855 by Erik.
+               //  The feature was added because we liked adding [[$1]] in our log entries
+               //  but the log entries are parsed as Wikitext on RecentChanges but as HTML
+               //  on Special:Log. The hack is essentially that [[$1]] represented a link
+               //  to the title in question. The first parameter to the HTML version (Special:Log)
+               //  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 );
@@ -358,11 +374,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 '';
                }