* added an option to toggle the display of diff size with a warning message.
authorJure Kajzer <freakolowsky@users.mediawiki.org>
Sat, 14 May 2011 17:05:25 +0000 (17:05 +0000)
committerJure Kajzer <freakolowsky@users.mediawiki.org>
Sat, 14 May 2011 17:05:25 +0000 (17:05 +0000)
* in misermode this option is disabled

includes/specials/SpecialContributions.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index be0aff3..7f515fc 100644 (file)
@@ -69,6 +69,7 @@ class SpecialContributions extends SpecialPage {
                $this->opts['limit'] = $wgRequest->getInt( 'limit', $wgUser->getOption('rclimit') );
                $this->opts['target'] = $target;
                $this->opts['topOnly'] = $wgRequest->getBool( 'topOnly' );
+               $this->opts['showSizeDiff'] = $wgRequest->getBool( 'showSizeDiff' );
 
                $nt = Title::makeTitleSafe( NS_USER, $target );
                if( !$nt ) {
@@ -132,6 +133,7 @@ class SpecialContributions extends SpecialPage {
                                'month' => $this->opts['month'],
                                'deletedOnly' => $this->opts['deletedOnly'],
                                'topOnly' => $this->opts['topOnly'],
+                               'showSizeDiff' => $this->opts['showSizeDiff'],
                        ) );
                        if( !$pager->getNumRows() ) {
                                $wgOut->addWikiMsg( 'nocontribs', $target );
@@ -317,7 +319,7 @@ class SpecialContributions extends SpecialPage {
         * @return String: HTML fragment
         */
        protected function getForm() {
-               global $wgScript, $wgMiserMode;
+               global $wgScript, $wgMiserMode, $wgRCMaxAge, $wgContLang;
 
                $this->opts['title'] = $this->getTitle()->getPrefixedText();
                if( !isset( $this->opts['target'] ) ) {
@@ -354,10 +356,14 @@ class SpecialContributions extends SpecialPage {
                        $this->opts['topOnly'] = false;
                }
 
+               if( !isset( $this->opts['showSizeDiff'] ) ) {
+                       $this->opts['showSizeDiff'] = !$wgMiserMode;
+               }
+
                $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form' ) );
 
                # Add hidden params for tracking except for parameters in $skipParameters
-               $skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly' );
+               $skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'showSizeDiff' );
                foreach ( $this->opts as $name => $value ) {
                        if( in_array( $name, $skipParameters ) ) {
                                continue;
@@ -366,12 +372,20 @@ class SpecialContributions extends SpecialPage {
                }
 
                $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagFilter'] );
-
-               $fNS = ( $wgMiserMode ) ? '' :
-                       Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
-                               Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' .
-                               Xml::namespaceSelector( $this->opts['namespace'], '' )
-                       );
+               
+               $fNS = '';
+               $fShowDiff = '';
+               if ( !$wgMiserMode ) {
+                       $fNS = Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
+                                       Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' .
+                                       Xml::namespaceSelector( $this->opts['namespace'], '' )
+                               );
+                       $fShowDiff = Xml::infoBox( 
+                                       Xml::checkLabel( wfMsg( 'sp-contributions-showsizediff' ), 'showSizeDiff', 'mw-show-size-diff', $this->opts['showSizeDiff'] ) . '<br />'.
+                                       wfMsgReplaceArgs ( wfMsg( 'sp-contributions-showsizediff-warn' ),  array( $wgContLang->formatTimePeriod( $wgRCMaxAge ) ) )
+                                       , 'warning-32.png', wfMsg( 'sp-contributions-showsizediff' )
+                               );
+               }
 
                $f .=   Xml::fieldset( wfMsg( 'sp-contributions-search' ) ) .
                        Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ),
@@ -387,6 +401,7 @@ class SpecialContributions extends SpecialPage {
                                'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'] ) . '<br />' .
                        Xml::tags( 'p', null, Xml::checkLabel( wfMsg( 'sp-contributions-toponly' ),
                                'topOnly', 'mw-show-top-only', $this->opts['topOnly'] ) ) .
+                       $fShowDiff.
                        ( $tagFilter ? Xml::tags( 'p', null, implode( '&#160;', $tagFilter ) ) : '' ) .
                        Html::rawElement( 'p', array( 'style' => 'white-space: nowrap' ),
                                Xml::dateMenu( $this->opts['year'], $this->opts['month'] ) . ' ' .
@@ -436,6 +451,7 @@ class SpecialContributions extends SpecialPage {
                        'tagFilter' => $this->opts['tagFilter'],
                        'deletedOnly' => $this->opts['deletedOnly'],
                        'topOnly' => $this->opts['topOnly'],
+                       'showSizeDiff' => $this->opts['showSizeDiff'],
                ) );
 
                $pager->mLimit = min( $this->opts['limit'], $wgFeedLimit );
@@ -523,6 +539,7 @@ class ContribsPager extends ReverseChronologicalPager {
 
                $this->deletedOnly = !empty( $options['deletedOnly'] );
                $this->topOnly = !empty( $options['topOnly'] );
+               $this->showSizeDiff = !empty( $options['showSizeDiff'] );
 
                $year = isset( $options['year'] ) ? $options['year'] : false;
                $month = isset( $options['month'] ) ? $options['month'] : false;
@@ -538,7 +555,7 @@ class ContribsPager extends ReverseChronologicalPager {
        }
 
        function getQueryInfo() {
-               global $wgUser;
+               global $wgUser, $wgMiserMode;
                list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
 
                $conds = array_merge( $userCond, $this->getNamespaceCond() );
@@ -550,20 +567,25 @@ class ContribsPager extends ReverseChronologicalPager {
                                ' != ' . Revision::SUPPRESSED_USER;
                }
                $join_cond['page'] = array( 'INNER JOIN', 'page_id=rev_page' );
+               
+               $fields = array(
+                       'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
+                       'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
+                       'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted'
+               );
+               if ( $this->showSizeDiff && !$wgMiserMode ) {
+                       $fields = array_merge( $fields,  array( 'rc_old_len', 'rc_new_len' ) );
+                       array_unshift( $tables, 'recentchanges' );
+                       $join_cond['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );
+               }
 
                $queryInfo = array(
                        'tables' => $tables,
-                       'fields' => array(
-                               'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
-                               'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
-                               'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted',
-                               'rc_old_len', 'rc_new_len'
-                       ),
+                       'fields' => $fields,
                        'conds' => $conds,
                        'options' => array( 'USE INDEX' => array('revision' => $index) ),
                        'join_conds' => $join_cond
                );
-
                ChangeTags::modifyDisplayQuery(
                        $queryInfo['tables'],
                        $queryInfo['fields'],
@@ -580,19 +602,18 @@ class ContribsPager extends ReverseChronologicalPager {
        function getUserCond() {
                $condition = array();
                $join_conds = array();
+
                if( $this->target == 'newbies' ) {
-                       $tables = array( 'recentchanges', 'user_groups', 'page', 'revision' );
+                       $tables = array( 'user_groups', 'page', 'revision' );
                        $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
                        $condition[] = 'rev_user >' . (int)($max - $max / 100);
                        $condition[] = 'ug_group IS NULL';
                        $index = 'user_timestamp';
                        # FIXME: other groups may have 'bot' rights
                        $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
-                       $join_conds['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );
                } else {
-                       $tables = array( 'recentchanges', 'page', 'revision' );
+                       $tables = array( 'page', 'revision' );
                        $condition['rev_user_text'] = $this->target;
-                       $join_conds['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );
                        $index = 'usertext_timestamp';
                }
                if( $this->deletedOnly ) {
@@ -739,7 +760,8 @@ class ContribsPager extends ReverseChronologicalPager {
 
                $diffHistLinks = '(' . $difftext . $this->messages['pipe-separator'] . $histlink . ')';
                
-               $diffOut = ' . . '.ChangesList::showCharacterDifference( $row->rc_old_len, $row->rc_new_len );
+               
+               $diffOut = ( $this->showSizeDiff ) ? ' . . '.ChangesList::showCharacterDifference( $row->rc_old_len, $row->rc_new_len ) : '';
 
                $ret = "{$del}{$d} {$diffHistLinks} {$nflag}{$mflag} {$link}{$diffOut}{$userlink} {$comment} {$topmarktext}";
 
index 751a0ab..3fcc672 100644 (file)
@@ -2992,6 +2992,8 @@ The latest block log entry is provided below for reference:',
 'sp-contributions-search'              => 'Search for contributions',
 'sp-contributions-username'            => 'IP address or username:',
 'sp-contributions-toponly'             => 'Only show edits that are latest revisions',
+'sp-contributions-showsizediff'        => 'Display difference in page size',
+'sp-contributions-showsizediff-warn'   => 'This instance has recent changes log limited to $1 . If you use this option, pages not in this log will not be displayed',
 'sp-contributions-submit'              => 'Search',
 'sp-contributions-explain'             => '', # only translate this message to other languages if you have to change it
 'sp-contributions-footer'              => '-', # do not translate or duplicate this message to other languages
index ec73078..46e0d39 100644 (file)
@@ -2014,6 +2014,8 @@ $wgMessageStructure = array(
                'sp-contributions-explain',
                'sp-contributions-footer',
                'sp-contributions-footer-anon',
+               'sp-contributions-showsizediff',
+               'sp-contributions-showsizediff-warn',
        ),
        'whatlinkshere' => array(
                'whatlinkshere',