Revert r113650 and reapply r113619 and r113649 with one modification: User::createNew...
[lhc/web/wiklou.git] / includes / ChangesList.php
index c8e136d..e0183c4 100644 (file)
@@ -63,7 +63,7 @@ class ChangesList extends ContextSource {
         * This first argument used to be an User object.
         *
         * @deprecated in 1.18; use newFromContext() instead
-        * @param $unused Unused
+        * @param $unused string|User Unused
         * @return ChangesList|EnhancedChangesList|OldChangesList derivative
         */
        public static function newFromUser( $unused ) {
@@ -217,7 +217,7 @@ class ChangesList extends ContextSource {
                        $formattedSizeClass = 'mw-plusminus-neg';
                }
 
-               $formattedTotalSize = wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $new ) );
+               $formattedTotalSize = wfMsgExt( 'rc-change-size-new', 'parsemag', $wgLang->formatNum( $new ) );
 
                return Html::element( $tag,
                        array( 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ),
@@ -252,14 +252,13 @@ class ChangesList extends ContextSource {
        public function insertLog( &$s, $title, $logtype ) {
                $page = new LogPage( $logtype );
                $logname = $page->getName()->escaped();
-               $s .= '(' . Linker::linkKnown( $title, $logname ) . ')';
+               $s .= $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $title, $logname ) )->escaped();
        }
 
        /**
         * @param $s
         * @param $rc RecentChange
         * @param $unpatrolled
-        * @return void
         */
        public function insertDiffHist( &$s, &$rc, $unpatrolled ) {
                # Diff link
@@ -285,9 +284,9 @@ class ChangesList extends ContextSource {
                                $query
                        );
                }
-               $s .= '(' . $diffLink . $this->message['pipe-separator'];
+               $diffhist = $diffLink . $this->message['pipe-separator'];
                # History link
-               $s .= Linker::linkKnown(
+               $diffhist .= Linker::linkKnown(
                        $rc->getTitle(),
                        $this->message['hist'],
                        array(),
@@ -296,7 +295,7 @@ class ChangesList extends ContextSource {
                                'action' => 'history'
                        )
                );
-               $s .= ') . . ';
+               $s .= $this->msg( 'parentheses' )->rawParams( $diffhist )->escaped() . ' . . ';
        }
 
        /**
@@ -304,7 +303,6 @@ class ChangesList extends ContextSource {
         * @param $rc RecentChange
         * @param $unpatrolled
         * @param $watched
-        * @return void
         */
        public function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) {
                # If it's a new article, there is no diff link, but if it hasn't been
@@ -340,29 +338,33 @@ class ChangesList extends ContextSource {
        /**
         * @param $s
         * @param $rc RecentChange
-        * @return void
         */
        public function insertTimestamp( &$s, $rc ) {
                $s .= $this->message['semicolon-separator'] .
                        $this->getLanguage()->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
        }
 
-       /** Insert links to user page, user talk page and eventually a blocking link
+       /**
+        * Insert links to user page, user talk page and eventually a blocking link
         *
-        * @param $rc RecentChange
+        * @param &$s String HTML to update
+        * @param &$rc RecentChange
         */
        public function insertUserRelatedLinks( &$s, &$rc ) {
                if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
                        $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
                } else {
-                       $s .= $this->getLanguage()->getDirMark() . 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'] );
                }
        }
 
-       /** insert a formatted action
+       /**
+        * Insert a formatted action
         *
         * @param $rc RecentChange
+        * @return string
         */
        public function insertLogEntry( $rc ) {
                $formatter = LogFormatter::newFromRow( $rc->mAttribs );
@@ -374,6 +376,7 @@ class ChangesList extends ContextSource {
        /** 
         * Insert a formatted comment
         * @param $rc RecentChange
+        * @return string
         */
        public function insertComment( $rc ) {
                if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) {
@@ -396,6 +399,7 @@ class ChangesList extends ContextSource {
 
        /**
         * Returns the string which indicates the number of watching users
+        * @return string
         */
        protected function numberofWatchingusers( $count ) {
                static $cache = array();
@@ -436,6 +440,11 @@ class ChangesList extends ContextSource {
                }
        }
 
+       /**
+        * @param $link string
+        * @param $watched bool
+        * @return string
+        */
        protected function maybeWatchedLink( $link, $watched = false ) {
                if( $watched ) {
                        return '<strong class="mw-watched">' . $link . '</strong>';
@@ -508,6 +517,7 @@ class OldChangesList extends ChangesList {
         * Format a line using the old system (aka without any javascript).
         *
         * @param $rc RecentChange
+        * @return string
         */
        public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
                global $wgRCShowChangedSize;
@@ -607,6 +617,9 @@ class OldChangesList extends ChangesList {
  * Generate a list of changes using an Enhanced system (uses javascript).
  */
 class EnhancedChangesList extends ChangesList {
+
+       protected $rc_cache;
+
        /**
         * Add the JavaScript file for enhanced changeslist
         * @return String
@@ -666,7 +679,7 @@ class EnhancedChangesList extends ChangesList {
                                $logtitle = SpecialPage::getTitleFor( 'Log', $logType );
                                $logpage = new LogPage( $logType );
                                $logname = $logpage->getName()->escaped();
-                               $clink = '(' . Linker::linkKnown( $logtitle, $logname ) . ')';
+                               $clink = $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $logtitle, $logname ) )->escaped();
                        } else {
                                $clink = Linker::link( $rc->getTitle() );
                        }
@@ -770,6 +783,7 @@ class EnhancedChangesList extends ChangesList {
 
        /**
         * Enhanced RC group
+        * @return string
         */
        protected function recentChangesBlockGroup( $block ) {
                global $wgRCShowChangedSize;
@@ -779,9 +793,11 @@ class EnhancedChangesList extends ChangesList {
                # Add the namespace and title of the block as part of the class
                if ( $block[0]->mAttribs['rc_log_type'] ) {
                        # Log entry
-                       $classes = 'mw-collapsible mw-collapsed mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-log-' . $block[0]->mAttribs['rc_log_type'] . '-' . $block[0]->mAttribs['rc_title'] );
+                       $classes = 'mw-collapsible mw-collapsed mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-log-'
+                                       . $block[0]->mAttribs['rc_log_type'] . '-' . $block[0]->mAttribs['rc_title'] );
                } else {
-                       $classes = 'mw-collapsible mw-collapsed mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-ns' . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
+                       $classes = 'mw-collapsible mw-collapsed mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-ns'
+                                       . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
                }
                $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
                        Html::openElement( 'tr' );
@@ -836,7 +852,7 @@ class EnhancedChangesList extends ChangesList {
                        $text = $userlink;
                        $text .= $this->getLanguage()->getDirMark();
                        if( $count > 1 ) {
-                               $text .= ' (' . $this->getLanguage()->formatNum( $count ) . '×)';
+                               $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->formatNum( $count ) . '×' )->escaped();
                        }
                        array_push( $users, $text );
                }
@@ -844,16 +860,7 @@ class EnhancedChangesList extends ChangesList {
                $users = ' <span class="changedby">[' .
                        implode( $this->message['semicolon-separator'], $users ) . ']</span>';
 
-               # Title for <a> tags
-               $expandTitle = htmlspecialchars( wfMsg( 'rc-enhanced-expand' ) );
-               $closeTitle = htmlspecialchars( wfMsg( 'rc-enhanced-hide' ) );
-
-               $tl = "<span class='mw-collapsible-toggle'>"
-                       . "<span class='mw-rc-openarrow'>"
-                       . "<a href='#' title='$expandTitle'>{$this->sideArrow()}</a>"
-                       . "</span><span class='mw-rc-closearrow'>"
-                       . "<a href='#' title='$closeTitle'>{$this->downArrow()}</a>"
-                       . "</span></span>";
+               $tl = '<span class="mw-collapsible-toggle mw-enhancedchanges-arrow"></span>';
                $r .= "<td>$tl</td>";
 
                # Main line
@@ -887,18 +894,18 @@ class EnhancedChangesList extends ChangesList {
                }
                # Total change link
                $r .= ' ';
+               $logtext = '';
                if( !$allLogs ) {
-                       $r .= '(';
                        if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
-                               $r .= $nchanges[$n];
+                               $logtext .= $nchanges[$n];
                        } elseif( $isnew ) {
-                               $r .= $nchanges[$n];
+                               $logtext .= $nchanges[$n];
                        } else {
                                $params = $queryParams;
                                $params['diff'] = $currentRevision;
                                $params['oldid'] = $oldid;
 
-                               $r .= Linker::link(
+                               $logtext .= Linker::link(
                                        $block[0]->getTitle(),
                                        $nchanges[$n],
                                        array(),
@@ -912,19 +919,24 @@ class EnhancedChangesList extends ChangesList {
                if( $allLogs ) {
                        // don't show history link for logs
                } elseif( $namehidden || !$block[0]->getTitle()->exists() ) {
-                       $r .= $this->message['pipe-separator'] . $this->message['hist'] . ')';
+                       $logtext .= $this->message['pipe-separator'] . $this->message['hist'];
                } else {
                        $params = $queryParams;
                        $params['action'] = 'history';
 
-                       $r .= $this->message['pipe-separator'] .
+                       $logtext .= $this->message['pipe-separator'] .
                                Linker::linkKnown(
                                        $block[0]->getTitle(),
                                        $this->message['hist'],
                                        array(),
                                        $params
-                               ) . ')';
+                               );
+               }
+
+               if( $logtext !== '' ) {
+                       $r .= $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
                }
+
                $r .= ' . . ';
 
                # Character difference (does not apply if only log items)
@@ -958,7 +970,6 @@ class EnhancedChangesList extends ChangesList {
                        $classes = array();
                        $type = $rcObj->mAttribs['rc_type'];
 
-                       #$r .= '<tr><td valign="top">'.$this->spacerArrow();
                        $r .= '<tr><td></td><td class="mw-enhanced-rc">';
                        $r .= $this->recentChangesFlags( array(
                                'newpage' => $rcObj->mAttribs['rc_new'],
@@ -997,11 +1008,7 @@ class EnhancedChangesList extends ChangesList {
                        $r .= $link . '</span>';
 
                        if ( !$type == RC_LOG || $type == RC_NEW ) {
-                               $r .= ' (';
-                               $r .= $rcObj->curlink;
-                               $r .= $this->message['pipe-separator'];
-                               $r .= $rcObj->lastlink;
-                               $r .= ')';
+                               $r .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->curlink . $this->message['pipe-separator'] . $rcObj->lastlink )->escaped();
                        }
                        $r .= ' . . ';
 
@@ -1094,14 +1101,16 @@ class EnhancedChangesList extends ChangesList {
                $logType = $rcObj->mAttribs['rc_log_type'];
                if( $logType ) {
                        # Log entry
-                       $classes = 'mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-log-' . $logType . '-' . $rcObj->mAttribs['rc_title'] );
+                       $classes = 'mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-log-'
+                                       . $logType . '-' . $rcObj->mAttribs['rc_title'] );
                } else {
-                       $classes = 'mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-ns' . $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
+                       $classes = 'mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-ns' .
+                                       $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
                }
                $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
                        Html::openElement( 'tr' );
 
-               $r .= '<td class="mw-enhanced-rc">' . $this->spacerArrow();
+               $r .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow mw-enhancedchanges-arrow-space"></span>';
                # Flag and Timestamp
                if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
                        $r .= '&#160;&#160;&#160;&#160;'; // 4 flags -> 4 spaces
@@ -1118,20 +1127,19 @@ class EnhancedChangesList extends ChangesList {
                if( $logType ) {
                        $logtitle = SpecialPage::getTitleFor( 'Log', $logType );
                        $logname = LogPage::logName( $logType );
-                       $r .= '(' . Linker::linkKnown( $logtitle, htmlspecialchars( $logname ) ) . ')';
+                       $r .= $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $logtitle, htmlspecialchars( $logname ) ) )->escaped();
                } else {
                        $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched );
                }
                # Diff and hist links
                if ( $type != RC_LOG ) {
-                       $r .= ' ('. $rcObj->difflink . $this->message['pipe-separator'];
                        $query['action'] = 'history';
-                       $r .= Linker::linkKnown(
+                       $r .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown(
                                $rcObj->getTitle(),
                                $this->message['hist'],
                                array(),
                                $query
-                       ) . ')';
+                       ) )->escaped();
                }
                $r .= ' . . ';
                # Character diff
@@ -1190,6 +1198,7 @@ class EnhancedChangesList extends ChangesList {
        /**
         * Returns text for the end of RC
         * If enhanced RC is in use, returns pretty much all the text
+        * @return string
         */
        public function endRecentChangesList() {
                return $this->recentChangesBlock() . parent::endRecentChangesList();