Use accessor method, ping r110179
[lhc/web/wiklou.git] / includes / ChangesList.php
index d8eab43..119c7a2 100644 (file)
@@ -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() );
        }
 
@@ -216,8 +217,10 @@ class ChangesList extends ContextSource {
                        $formattedSizeClass = 'mw-plusminus-neg';
                }
 
+               $formattedTotalSize = wfMsgExt( 'rc-change-size-new', 'parsemag', $wgLang->formatNum( $new ) );
+
                return Html::element( $tag,
-                       array( 'dir' => 'ltr', 'class' => $formattedSizeClass ),
+                       array( 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ),
                        wfMessage( 'parentheses', $formattedSize )->plain() ) . $wgLang->getDirMark();
        }
 
@@ -235,7 +238,7 @@ class ChangesList extends ContextSource {
 
        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";
@@ -256,7 +259,6 @@ class ChangesList extends ContextSource {
         * @param $s
         * @param $rc RecentChange
         * @param $unpatrolled
-        * @return void
         */
        public function insertDiffHist( &$s, &$rc, $unpatrolled ) {
                # Diff link
@@ -301,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
@@ -326,7 +327,7 @@ class ChangesList extends ContextSource {
                        $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) );
@@ -337,11 +338,10 @@ class ChangesList extends ContextSource {
        /**
         * @param $s
         * @param $rc RecentChange
-        * @return void
         */
        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
@@ -352,19 +352,21 @@ class ChangesList extends ContextSource {
                if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
                        $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
                } else {
-                       $s .= $this->getLang()->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
         */
        public function insertLogEntry( $rc ) {
                $formatter = LogFormatter::newFromRow( $rc->mAttribs );
                $formatter->setShowUserToolLinks( true );
-               $mark = $this->getLang()->getDirMark();
+               $mark = $this->getLanguage()->getDirMark();
                return $formatter->getActionText() . " $mark" . $formatter->getComment();
        }
 
@@ -399,7 +401,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 {
@@ -433,6 +435,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>';
@@ -443,7 +450,7 @@ class ChangesList extends ContextSource {
 
        /** Inserts a rollback link
         *
-        * @param $s
+        * @param $s string
         * @param $rc RecentChange
         */
        public function insertRollback( &$s, &$rc ) {
@@ -466,10 +473,9 @@ class ChangesList extends ContextSource {
        }
 
        /**
-        * @param $s
+        * @param $s string
         * @param $rc RecentChange
         * @param $classes
-        * @return
         */
        public function insertTags( &$s, &$rc, &$classes ) {
                if ( empty($rc->mAttribs['ts_tags']) )
@@ -572,7 +578,7 @@ class OldChangesList extends ChangesList {
                        # User tool links
                        $this->insertUserRelatedLinks( $s, $rc );
                        # LTR/RTL direction mark
-                       $s .= $this->getLang()->getDirMark();
+                       $s .= $this->getLanguage()->getDirMark();
                        $s .= $this->insertComment( $rc );
                }
 
@@ -586,7 +592,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 ) {
@@ -605,6 +611,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
@@ -635,7 +644,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
@@ -662,23 +671,17 @@ class EnhancedChangesList extends ChangesList {
                } elseif( $type == RC_LOG ) {
                        if( $logType ) {
                                $logtitle = SpecialPage::getTitleFor( 'Log', $logType );
-                               $clink = '(' . Linker::linkKnown( $logtitle,
-                                       LogPage::logName( $logType ) ) . ')';
+                               $logpage = new LogPage( $logType );
+                               $logname = $logpage->getName()->escaped();
+                               $clink = '(' . Linker::linkKnown( $logtitle, $logname ) . ')';
                        } else {
                                $clink = Linker::link( $rc->getTitle() );
                        }
                        $watched = false;
                // Log entries (old format) and special pages
                } elseif( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
-                       list( $specialName, $logtype ) = SpecialPageFactory::resolveAlias( $rc->mAttribs['rc_title'] );
-                       if ( $specialName == 'Log' ) {
-                               # Log updates, etc
-                               $logname = LogPage::logName( $logtype );
-                               $clink = '(' . Linker::linkKnown( $rc->getTitle(), $logname ) . ')';
-                       } else {
-                               wfDebug( "Unexpected special page in recentchanges\n" );
-                               $clink = '';
-                       }
+                       wfDebug( "Unexpected special page in recentchanges\n" );
+                       $clink = '';
                // Edits
                } else {
                        $clink = Linker::linkKnown( $rc->getTitle() );
@@ -689,7 +692,7 @@ class EnhancedChangesList extends ChangesList {
                        $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;
@@ -783,9 +786,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' );
@@ -838,9 +843,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 );
                }
@@ -880,14 +885,14 @@ 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 .= ' ';
@@ -1098,9 +1103,11 @@ 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' );
@@ -1194,6 +1201,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();