Fix fixme on r107328, attempting to use $this in a static method
[lhc/web/wiklou.git] / includes / ChangesList.php
index f75c5d5..32a8d47 100644 (file)
@@ -45,10 +45,10 @@ class ChangesList extends ContextSource {
        /**
         * Changeslist contructor
         *
-        * @param $obj Skin or RequestContext
+        * @param $obj Skin or IContextSource
         */
        public function __construct( $obj ) {
-               if ( $obj instanceof RequestContext ) {
+               if ( $obj instanceof IContextSource ) {
                        $this->setContext( $obj );
                        $this->skin = $obj->getSkin();
                } else {
@@ -67,6 +67,7 @@ class ChangesList extends ContextSource {
         * @return ChangesList|EnhancedChangesList|OldChangesList derivative
         */
        public static function newFromUser( $unused ) {
+               wfDeprecated( __METHOD__, '1.18' );
                return self::newFromContext( RequestContext::getMain() );
        }
 
@@ -74,10 +75,10 @@ class ChangesList extends ContextSource {
         * Fetch an appropriate changes list class for the specified context
         * Some users might want to use an enhanced list format, for instance
         *
-        * @param $context RequestContext to use
+        * @param $context IContextSource to use
         * @return ChangesList|EnhancedChangesList|OldChangesList derivative
         */
-       public static function newFromContext( RequestContext $context ) {
+       public static function newFromContext( IContextSource $context ) {
                $user = $context->getUser();
                $sk = $context->getSkin();
                $list = null;
@@ -193,10 +194,10 @@ class ChangesList extends ContextSource {
                        $fastCharDiff[$code] = $wgMiserMode || wfMsgNoTrans( 'rc-change-size' ) === '$1';
                }
 
-               $formatedSize = $wgLang->formatNum($szdiff);
+               $formattedSize = $wgLang->formatNum($szdiff);
 
                if ( !$fastCharDiff[$code] ) {
-                       $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $formatedSize );
+                       $formattedSize = wfMsgExt( 'rc-change-size', array( 'parsemag' ), $formattedSize );
                }
 
                if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
@@ -204,13 +205,23 @@ class ChangesList extends ContextSource {
                } else {
                        $tag = 'span';
                }
-               if( $szdiff === 0 ) {
-                       return "<$tag class='mw-plusminus-null'>($formatedSize)</$tag>";
-               } elseif( $szdiff > 0 ) {
-                       return "<$tag class='mw-plusminus-pos'>(+$formatedSize)</$tag>";
-               } else {
-                       return "<$tag class='mw-plusminus-neg'>($formatedSize)</$tag>";
+
+               if ( $szdiff === 0 ) {
+                       $formattedSizeClass = 'mw-plusminus-null';
+               }
+               if ( $szdiff > 0 ) {
+                       $formattedSize = '+' . $formattedSize;
+                       $formattedSizeClass = 'mw-plusminus-pos';
+               }
+               if ( $szdiff < 0 ) {
+                       $formattedSizeClass = 'mw-plusminus-neg';
                }
+
+               $formattedTotalSize = wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $new ) );
+
+               return Html::element( $tag,
+                       array( 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ),
+                       wfMessage( 'parentheses', $formattedSize )->plain() ) . $wgLang->getDirMark();
        }
 
        /**
@@ -225,38 +236,9 @@ class ChangesList extends ContextSource {
                }
        }
 
-       /**
-        * @param $s
-        * @param $rc RecentChange
-        * @return void
-        */
-       public function insertMove( &$s, $rc ) {
-               # Diff
-               $s .= '(' . $this->message['diff'] . ') (';
-               # Hist
-               $s .= Linker::linkKnown(
-                       $rc->getMovedToTitle(),
-                       $this->message['hist'],
-                       array(),
-                       array( 'action' => 'history' )
-               ) . ') . . ';
-               # "[[x]] moved to [[y]]"
-               $msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir';
-               $s .= wfMsgHtml(
-                       $msg,
-                       Linker::linkKnown(
-                               $rc->getTitle(),
-                               null,
-                               array(),
-                               array( 'redirect' => 'no' )
-                       ),
-                       Linker::linkKnown( $rc->getMovedToTitle() )
-               );
-       }
-
        public function insertDateHeader( &$s, $rc_timestamp ) {
                # Make date header if necessary
-               $date = $this->getLang()->date( $rc_timestamp, true, true );
+               $date = $this->getLanguage()->date( $rc_timestamp, true, true );
                if( $date != $this->lastdate ) {
                        if( $this->lastdate != '' ) {
                                $s .= "</ul>\n";
@@ -268,8 +250,9 @@ class ChangesList extends ContextSource {
        }
 
        public function insertLog( &$s, $title, $logtype ) {
-               $logname = LogPage::logName( $logtype );
-               $s .= '(' . Linker::linkKnown( $title, htmlspecialchars( $logname ) ) . ')';
+               $page = new LogPage( $logtype );
+               $logname = $page->getName()->escaped();
+               $s .= '(' . Linker::linkKnown( $title, $logname ) . ')';
        }
 
        /**
@@ -282,7 +265,7 @@ class ChangesList extends ContextSource {
                # Diff link
                if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
                        $diffLink = $this->message['diff'];
-               } elseif( !self::userCan($rc,Revision::DELETED_TEXT) ) {
+               } elseif ( !self::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
                        $diffLink = $this->message['diff'];
                } else {
                        $query = array(
@@ -332,28 +315,21 @@ class ChangesList extends ContextSource {
                        $params['rcid'] = $rc->mAttribs['rc_id'];
                }
 
+               $articlelink = Linker::linkKnown(
+                       $rc->getTitle(),
+                       null,
+                       array(),
+                       $params
+               );
                if( $this->isDeleted($rc,Revision::DELETED_TEXT) ) {
-                       $articlelink = Linker::linkKnown(
-                               $rc->getTitle(),
-                               null,
-                               array(),
-                               $params
-                       );
                        $articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
-               } else {
-                       $articlelink = ' '. Linker::linkKnown(
-                               $rc->getTitle(),
-                               null,
-                               array(),
-                               $params
-                       );
                }
                # Bolden pages watched by this user
                if( $watched ) {
                        $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
                }
                # RTL/LTR marker
-               $articlelink .= $this->getLang()->getDirMark();
+               $articlelink .= $this->getLanguage()->getDirMark();
 
                wfRunHooks( 'ChangesListInsertArticleLink',
                        array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched) );
@@ -368,7 +344,7 @@ class ChangesList extends ContextSource {
         */
        public function insertTimestamp( &$s, $rc ) {
                $s .= $this->message['semicolon-separator'] .
-                       $this->getLang()->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
+                       $this->getLanguage()->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
        }
 
        /** Insert links to user page, user talk page and eventually a blocking link
@@ -379,7 +355,7 @@ class ChangesList extends ContextSource {
                if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
                        $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
                } else {
-                       $s .= Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
+                       $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
                        $s .= Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
                }
        }
@@ -388,27 +364,23 @@ class ChangesList extends ContextSource {
         *
         * @param $rc RecentChange
         */
-       public function insertAction( &$s, &$rc ) {
-               if( $rc->mAttribs['rc_type'] == RC_LOG ) {
-                       if( $this->isDeleted( $rc, LogPage::DELETED_ACTION ) ) {
-                               $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
-                       } else {
-                               $s .= ' '.LogPage::actionText( $rc->mAttribs['rc_log_type'], $rc->mAttribs['rc_log_action'],
-                                       $rc->getTitle(), $this->getSkin(), LogPage::extractParams( $rc->mAttribs['rc_params'] ), true, true );
-                       }
-               }
+       public function insertLogEntry( $rc ) {
+               $formatter = LogFormatter::newFromRow( $rc->mAttribs );
+               $formatter->setShowUserToolLinks( true );
+               $mark = $this->getLanguage()->getDirMark();
+               return $formatter->getActionText() . " $mark" . $formatter->getComment();
        }
 
-       /** insert a formatted comment
-        *
+       /** 
+        * Insert a formatted comment
         * @param $rc RecentChange
         */
-       public function insertComment( &$s, &$rc ) {
+       public function insertComment( $rc ) {
                if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) {
                        if( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
-                               $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
+                               return ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
                        } else {
-                               $s .= Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
+                               return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
                        }
                }
        }
@@ -430,7 +402,7 @@ class ChangesList extends ContextSource {
                if( $count > 0 ) {
                        if( !isset( $cache[$count] ) ) {
                                $cache[$count] = wfMsgExt( 'number_of_watching_users_RCview',
-                                       array('parsemag', 'escape' ), $this->getLang()->formatNum( $count ) );
+                                       array('parsemag', 'escape' ), $this->getLanguage()->formatNum( $count ) );
                        }
                        return $cache[$count];
                } else {
@@ -453,13 +425,14 @@ class ChangesList extends ContextSource {
         * field of this revision, if it's marked as deleted.
         * @param $rc RCCacheEntry
         * @param $field Integer
+        * @param $user User object to check, or null to use $wgUser
         * @return Boolean
         */
-       public static function userCan( $rc, $field ) {
+       public static function userCan( $rc, $field, User $user = null ) {
                if( $rc->mAttribs['rc_type'] == RC_LOG ) {
-                       return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field );
+                       return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
                } else {
-                       return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field );
+                       return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
                }
        }
 
@@ -513,6 +486,18 @@ class ChangesList extends ContextSource {
        public function insertExtra( &$s, &$rc, &$classes ) {
                ## Empty, used for subclassers to add anything special.
        }
+
+       protected function showAsUnpatrolled( RecentChange $rc ) {
+               $unpatrolled = false;
+               if ( !$rc->mAttribs['rc_patrolled'] ) {
+                       if ( $this->getUser()->useRCPatrol() ) {
+                               $unpatrolled = true;
+                       } elseif ( $this->getUser()->useNPPatrol() && $rc->mAttribs['rc_new'] ) {
+                               $unpatrolled = true;
+                       }
+               }
+               return $unpatrolled;
+       }
 }
 
 
@@ -528,8 +513,9 @@ class OldChangesList extends ChangesList {
        public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
                global $wgRCShowChangedSize;
                wfProfileIn( __METHOD__ );
+
                # Should patrol-related stuff be shown?
-               $unpatrolled = $this->getUser()->useRCPatrol() && !$rc->mAttribs['rc_patrolled'];
+               $unpatrolled = $this->showAsUnpatrolled( $rc );
 
                $dateheader = ''; // $s now contains only <li>...</li>, for hooks' convenience.
                $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
@@ -546,12 +532,11 @@ class OldChangesList extends ChangesList {
                        }
                }
 
-               // Moved pages
+               // Moved pages (very very old, not supported anymore)
                if( $rc->mAttribs['rc_type'] == RC_MOVE || $rc->mAttribs['rc_type'] == RC_MOVE_OVER_REDIRECT ) {
-                       $this->insertMove( $s, $rc );
                // Log entries
                } elseif( $rc->mAttribs['rc_log_type'] ) {
-                       $logtitle = Title::newFromText( 'Log/'.$rc->mAttribs['rc_log_type'], NS_SPECIAL );
+                       $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
                        $this->insertLog( $s, $logtitle, $rc->mAttribs['rc_log_type'] );
                // Log entries (old format) or log targets, and special pages
                } elseif( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
@@ -583,16 +568,17 @@ class OldChangesList extends ChangesList {
                                $s .= "$cd  . . ";
                        }
                }
-               # User tool links
-               $this->insertUserRelatedLinks( $s, $rc );
-               # LTR/RTL direction mark
-               $s .= $this->getLang()->getDirMark();
-               # Log action text (if any)
-               $this->insertAction( $s, $rc );
-               # LTR/RTL direction mark
-               $s .= $this->getLang()->getDirMark();
-               # Edit or log comment
-               $this->insertComment( $s, $rc );
+
+               if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
+                       $s .= $this->insertLogEntry( $rc );
+               } else {
+                       # User tool links
+                       $this->insertUserRelatedLinks( $s, $rc );
+                       # LTR/RTL direction mark
+                       $s .= $this->getLanguage()->getDirMark();
+                       $s .= $this->insertComment( $rc );
+               }
+
                # Tags
                $this->insertTags( $s, $rc, $classes );
                # Rollback
@@ -603,7 +589,7 @@ class OldChangesList extends ChangesList {
                # How many users watch this page
                if( $rc->numberofWatchingusers > 0 ) {
                        $s .= ' ' . wfMsgExt( 'number_of_watching_users_RCview',
-                               array( 'parsemag', 'escape' ), $this->getLang()->formatNum( $rc->numberofWatchingusers ) );
+                               array( 'parsemag', 'escape' ), $this->getLanguage()->formatNum( $rc->numberofWatchingusers ) );
                }
 
                if( $this->watchlist ) {
@@ -652,7 +638,7 @@ class EnhancedChangesList extends ChangesList {
                $curIdEq = array( 'curid' => $rc->mAttribs['rc_cur_id'] );
 
                # If it's a new day, add the headline and flush the cache
-               $date = $this->getLang()->date( $rc->mAttribs['rc_timestamp'], true );
+               $date = $this->getLanguage()->date( $rc->mAttribs['rc_timestamp'], true );
                $ret = '';
                if( $date != $this->lastdate ) {
                        # Process current cache
@@ -663,22 +649,14 @@ class EnhancedChangesList extends ChangesList {
                }
 
                # Should patrol-related stuff be shown?
-               if( $this->getUser()->useRCPatrol() ) {
-                       $rc->unpatrolled = !$rc->mAttribs['rc_patrolled'];
-               } else {
-                       $rc->unpatrolled = false;
-               }
+               $rc->unpatrolled = $this->showAsUnpatrolled( $rc );
 
                $showdifflinks = true;
                # Make article link
                $type = $rc->mAttribs['rc_type'];
                $logType = $rc->mAttribs['rc_log_type'];
-               // Page moves
+               // Page moves, very old style, not supported anymore
                if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
-                       $msg = ( $type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir";
-                       $clink = wfMsg( $msg, Linker::linkKnown( $rc->getTitle(), null,
-                               array(), array( 'redirect' => 'no' ) ),
-                               Linker::linkKnown( $rc->getMovedToTitle() ) );
                // New unpatrolled pages
                } elseif( $rc->unpatrolled && $type == RC_NEW ) {
                        $clink = Linker::linkKnown( $rc->getTitle(), null, array(),
@@ -710,11 +688,11 @@ class EnhancedChangesList extends ChangesList {
                }
 
                # Don't show unusable diff links
-               if ( !ChangesList::userCan($rc,Revision::DELETED_TEXT) ) {
+               if ( !ChangesList::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
                        $showdifflinks = false;
                }
 
-               $time = $this->getLang()->time( $rc->mAttribs['rc_timestamp'], true, true );
+               $time = $this->getLanguage()->time( $rc->mAttribs['rc_timestamp'], true, true );
                $rc->watched = $watched;
                $rc->link = $clink;
                $rc->timestamp = $time;
@@ -740,13 +718,13 @@ class EnhancedChangesList extends ChangesList {
                        if ( $type != RC_NEW ) {
                                $curLink = $this->message['cur'];
                        } else {
-                               $curUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querycur ) );
+                               $curUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querycur ) );
                                $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
                        }
                        $diffLink = $this->message['diff'];
                } else {
-                       $diffUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querydiff ) );
-                       $curUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querycur ) );
+                       $diffUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querydiff ) );
+                       $curUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querycur ) );
                        $diffLink = "<a href=\"$diffUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['diff']}</a>";
                        $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
                }
@@ -863,9 +841,9 @@ class EnhancedChangesList extends ChangesList {
                $users = array();
                foreach( $userlinks as $userlink => $count) {
                        $text = $userlink;
-                       $text .= $this->getLang()->getDirMark();
+                       $text .= $this->getLanguage()->getDirMark();
                        if( $count > 1 ) {
-                               $text .= ' (' . $this->getLang()->formatNum( $count ) . '×)';
+                               $text .= ' (' . $this->getLanguage()->formatNum( $count ) . '×)';
                        }
                        array_push( $users, $text );
                }
@@ -905,20 +883,20 @@ class EnhancedChangesList extends ChangesList {
                        $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
                }
 
-               $r .= $this->getLang()->getDirMark();
+               $r .= $this->getLanguage()->getDirMark();
 
                $queryParams['curid'] = $curId;
                # Changes message
                $n = count($block);
                static $nchanges = array();
                if ( !isset( $nchanges[$n] ) ) {
-                       $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $this->getLang()->formatNum( $n ) );
+                       $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $this->getLanguage()->formatNum( $n ) );
                }
                # Total change link
                $r .= ' ';
                if( !$allLogs ) {
                        $r .= '(';
-                       if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT ) ) {
+                       if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
                                $r .= $nchanges[$n];
                        } elseif( $isnew ) {
                                $r .= $nchanges[$n];
@@ -1007,7 +985,7 @@ class EnhancedChangesList extends ChangesList {
                        if( $type == RC_LOG ) {
                                $link = $rcObj->timestamp;
                        # Revision link
-                       } elseif( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) {
+                       } elseif( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
                                $link = '<span class="history-deleted">'.$rcObj->timestamp.'</span> ';
                        } else {
                                if ( $rcObj->unpatrolled && $type == RC_NEW) {
@@ -1039,13 +1017,15 @@ class EnhancedChangesList extends ChangesList {
                                $r .= $rcObj->getCharacterDifference() . ' . . ' ;
                        }
 
-                       # User links
-                       $r .= $rcObj->userlink;
-                       $r .= $rcObj->usertalklink;
-                       // log action
-                       $this->insertAction( $r, $rcObj );
-                       // log comment
-                       $this->insertComment( $r, $rcObj );
+                       if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) {
+                               $r .= $this->insertLogEntry( $rcObj );
+                       } else {
+                               # User links
+                               $r .= $rcObj->userlink;
+                               $r .= $rcObj->usertalklink;
+                               $r .= $this->insertComment( $rcObj );
+                       }
+
                        # Rollback
                        $this->insertRollback( $r, $rcObj );
                        # Tags
@@ -1083,8 +1063,8 @@ class EnhancedChangesList extends ChangesList {
         * @return String: HTML <img> tag
         */
        protected function sideArrow() {
-               global $wgContLang;
-               $dir = $wgContLang->isRTL() ? 'l' : 'r';
+               global $wgLang;
+               $dir = $wgLang->isRTL() ? 'l' : 'r';
                return $this->arrow( $dir, '+', wfMsg( 'rc-enhanced-expand' ) );
        }
 
@@ -1109,7 +1089,7 @@ class EnhancedChangesList extends ChangesList {
         * Enhanced RC ungrouped line.
         *
         * @param $rcObj RecentChange
-        * @return String: a HTML formated line (generated using $r)
+        * @return String: a HTML formatted line (generated using $r)
         */
        protected function recentChangesBlockLine( $rcObj ) {
                global $wgRCShowChangedSize;
@@ -1135,7 +1115,7 @@ class EnhancedChangesList extends ChangesList {
                } else {
                        $r .= $this->recentChangesFlags( array(
                                'newpage' => $type == RC_NEW,
-                               'mino' => $rcObj->mAttribs['rc_minor'],
+                               'minor' => $rcObj->mAttribs['rc_minor'],
                                'unpatrolled' => $rcObj->unpatrolled,
                                'bot' => $rcObj->mAttribs['rc_bot'],
                        ) );
@@ -1165,19 +1145,15 @@ class EnhancedChangesList extends ChangesList {
                if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
                        $r .= "$cd . . ";
                }
-               # User/talk
-               $r .= ' '.$rcObj->userlink . $rcObj->usertalklink;
-               # Log action (if any)
-               if( $logType ) {
-                       if( $this->isDeleted($rcObj,LogPage::DELETED_ACTION) ) {
-                               $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
-                       } else {
-                               $r .= ' ' . LogPage::actionText( $logType, $rcObj->mAttribs['rc_log_action'], $rcObj->getTitle(),
-                                       $this->getSkin(), LogPage::extractParams( $rcObj->mAttribs['rc_params'] ), true, true );
-                       }
+
+               if ( $type == RC_LOG ) {
+                       $r .= $this->insertLogEntry( $rcObj );
+               } else { 
+                       $r .= ' '.$rcObj->userlink . $rcObj->usertalklink;
+                       $r .= $this->insertComment( $rcObj );
+                       $r .= $this->insertRollback( $r, $rcObj );
                }
-               $this->insertComment( $r, $rcObj );
-               $this->insertRollback( $r, $rcObj );
+
                # Tags
                $classes = explode( ' ', $classes );
                $this->insertTags( $r, $rcObj, $classes );