New special page Special:NewbieContributions to replace Special:Contributions/newbies
authorIlmari Karonen <vyznev@users.mediawiki.org>
Sun, 3 Dec 2006 01:59:57 +0000 (01:59 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Sun, 3 Dec 2006 01:59:57 +0000 (01:59 +0000)
Also remove some obsolete contributions-related UI messages.

RELEASE-NOTES
includes/AutoLoader.php
includes/QueryPage.php
includes/SpecialContributions.php
includes/SpecialNewbieContributions.php [new file with mode: 0644]
includes/SpecialPage.php
languages/messages/MessagesEn.php
languages/messages/MessagesFi.php

index d721871..4aa999a 100644 (file)
@@ -243,7 +243,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   to ensure consistent behavior
 * {{REVISIONTIMESTAMP}} and friends should now work on non-MySQL backends
 * Special:Contributions has been rewritten to inherit from QueryPage
-* Special:Contributions/newbies now lists the user who made each edit
+* New special page Special:NewbieContributions, with a (deprecated)
+  redirect from Special:Contributions/newbies for backwards compatibility
 
 == Languages updated ==
 
index e72dcbc..8b0fb31 100644 (file)
@@ -186,6 +186,7 @@ function __autoload($className) {
                'MostlinkedCategoriesPage' => 'includes/SpecialMostlinkedcategories.php',
                'MostrevisionsPage' => 'includes/SpecialMostrevisions.php',
                'MovePageForm' => 'includes/SpecialMovepage.php',
+               'NewbieContributionsPage' => 'includes/SpecialNewbieContributions.php',
                'NewPagesPage' => 'includes/SpecialNewpages.php',
                'SpecialPage' => 'includes/SpecialPage.php',
                'UnlistedSpecialPage' => 'includes/SpecialPage.php',
index b4df3a0..b69277a 100644 (file)
@@ -28,6 +28,7 @@ $wgQueryPages = array(
        array( 'MostlinkedPage',                'Mostlinked'                    ),
        array( 'MostrevisionsPage',             'Mostrevisions'                 ),
        array( 'NewPagesPage',                  'Newpages'                      ),
+       array( 'NewbieContributionsPage',       'NewbieContributions'           ),
        array( 'ShortPagesPage',                'Shortpages'                    ),
        array( 'UncategorizedCategoriesPage',   'Uncategorizedcategories'       ),
        array( 'UncategorizedPagesPage',        'Uncategorizedpages'            ),
index 01a346f..34ab8c3 100644 (file)
@@ -10,7 +10,6 @@
 class ContributionsPage extends QueryPage {
        var $user = null;
        var $namespace = null;
-       var $newbies = false;
        var $botmode = false;
 
        /**
@@ -18,11 +17,7 @@ class ContributionsPage extends QueryPage {
         * @param $username username to list contribs for (or "newbies" for extra magic)
         */
        function __construct( $username ) {
-               // This is an ugly hack.  I don't know who came up with it.
-               if ( $username == 'newbies' && $this->newbiesModeEnabled() )
-                       $this->newbies = true;
-               else
-                       $this->user = User::newFromName( $username, false );
+               $this->user = User::newFromName( $username, false );
        }
 
        /**
@@ -43,15 +38,18 @@ class ContributionsPage extends QueryPage {
        function isSyndicated() { return false; }
 
        /**
-        * Special handling of "newbies" username.  May be disabled in subclasses.
+        * Get target user name.  May be overridden in subclasses.
+        * @return string username
         */
-       function newbiesModeEnabled() { return true; }
+       function getUsername() {
+               return $this->user->getName();
+       }
 
        /**
         * @return array Extra URL params for self-links.
         */
        function linkParameters() {
-               $params['target'] = ( $this->newbies ? "newbies" : $this->user->getName() );
+               $params['target'] = $this->getUsername();
 
                if ( isset($this->namespace) )
                        $params['namespace'] = $this->namespace;
@@ -71,7 +69,7 @@ class ContributionsPage extends QueryPage {
 
                $skin = $wgUser->getSkin();
 
-               $username = $this->user->getName();
+               $username = $this->getUsername();
                $userpage = $this->user->getUserPage();
                $userlink = $skin->makeLinkObj( $userpage, $username );
 
@@ -104,10 +102,7 @@ class ContributionsPage extends QueryPage {
         * @return string 
         */
        function getSubtitleForTarget() {
-               if ( $this->newbies )
-                       return wfMsgHtml( 'sp-contributions-newbies-sub' );
-               else
-                       return wfMsgHtml( 'contribsub', $this->getTargetUserLinks() );
+               return wfMsgHtml( 'contribsub', $this->getTargetUserLinks() );
        }
 
        /**
@@ -118,18 +113,18 @@ class ContributionsPage extends QueryPage {
        function getDeletedContributionsLink() {
                global $wgUser;
 
-               if( $this->newbies || !$wgUser->isAllowed( 'deletedhistory' ) )
+               if( !$wgUser->isAllowed( 'deletedhistory' ) )
                        return '';
 
                $dbr = wfGetDB( DB_SLAVE );
-               $n = $dbr->selectField( 'archive', 'count(*)', array( 'ar_user_text' => $this->user->getName() ), __METHOD__ );
+               $n = $dbr->selectField( 'archive', 'count(*)', array( 'ar_user_text' => $this->getUsername() ), __METHOD__ );
 
                if ( $n == 0 )
                        return '';
 
                $msg = wfMsg( ( $wgUser->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted' ),
                              $wgUser->getSkin()->makeKnownLinkObj(
-                                     SpecialPage::getTitleFor( 'DeletedContributions', $this->user->getName() ),
+                                     SpecialPage::getTitleFor( 'DeletedContributions', $this->getUsername() ),
                                      wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
 
                return "<p>$msg</p>";
@@ -162,7 +157,7 @@ class ContributionsPage extends QueryPage {
                $form .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );
                $form .= Xml::hidden( 'offset', $this->offset );
                $form .= Xml::hidden( 'limit',  $this->limit );
-               $form .= Xml::hidden( 'target', ( $this->newbies ? "newbies" : $this->user->getName() ) );
+               $form .= Xml::hidden( 'target', $this->getUsername() );
                if ( $this->botmode )
                        $form .= Xml::hidden( 'bot', 1 );
                $form .= '</form>';
@@ -186,14 +181,11 @@ class ContributionsPage extends QueryPage {
         */
        function makeSQLCond( $dbr ) {
                $cond = ' page_id = rev_page';
-               if ( $this->newbies ) {
-                       $max = $dbr->selectField( 'user', 'max(user_id)', false, 'make_sql' );
-                       $cond .= ' AND rev_user > ' . (int)($max - $max / 100);
-               } else {
-                       $cond .= ' AND rev_user_text = ' . $dbr->addQuotes( $this->user->getName() );
-               }
+               $cond .= ' AND rev_user_text = ' . $dbr->addQuotes( $this->getUsername() );
+
                if ( isset($this->namespace) )
                        $cond .= ' AND page_namespace = ' . (int)$this->namespace;
+
                return $cond;
        }
 
@@ -206,6 +198,9 @@ class ContributionsPage extends QueryPage {
 
                list( $page, $revision ) = $dbr->tableNamesN( 'page', 'revision' );
 
+               // XXX: the username and userid fields aren't used for much here,
+               // but some subclasses rely on them more than we do.
+
                return "SELECT 'Contributions' as type,
                                page_namespace AS namespace,
                                page_title     AS title,
@@ -222,25 +217,14 @@ class ContributionsPage extends QueryPage {
        }
 
        /**
-        * If in newbies mode, do a batch existence check for any user
-        * and user talk pages that will be shown in the list.
+        * Get user links for output row, for subclasses that may want
+        * such functionality.
+        *
+        * @param $skin Skin to use
+        * @param $row Result row
+        * @return string
         */
-       function preprocessResults( $dbr, $res ) {
-               if ( !$this->newbies )
-                       return;
-
-               // Do a batch existence check for user and talk pages
-               $linkBatch = new LinkBatch();
-               while( $row = $dbr->fetchObject( $res ) ) {
-                       $linkBatch->add( NS_USER, $row->username );
-                       $linkBatch->add( NS_USER_TALK, $row->username );
-               }
-               $linkBatch->execute();
-
-               // Seek to start
-               if( $dbr->numRows( $res ) > 0 )
-                       $dbr->dataSeek( $res, 0 );
-       }
+       function getRowUserLinks( $skin, $row ) { return ''; }
 
        /**
         * Format a row, providing the timestamp, links to the
@@ -297,12 +281,7 @@ class ContributionsPage extends QueryPage {
                $link    = $skin->makeKnownLinkObj( $page );
                $comment = $skin->revComment( $rev );
 
-               if ( $this->newbies ) {
-                       $user = ' . . ' . $skin->userLink( $row->userid, $row->username )
-                               . $skin->userToolLinks( $row->userid, $row->username );
-               } else {
-                       $user = '';
-               }
+               $user = $this->getRowUserLinks( $skin, $row );  // for subclasses
 
                $notes = '';
 
@@ -320,38 +299,29 @@ class ContributionsPage extends QueryPage {
                
                return "{$time} ({$hist}) ({$diff}) {$mflag} {$dm}{$link}{$user} {$comment}{$notes}";
        }
-
-       /**
-        * Called to actually output the page.  Override to do a basic
-        * input validity check before proceeding.
-        *
-        * @param $offset database query offset
-        * @param $limit database query limit
-        * @param $shownavigation show navigation like "next 200"?
-        */
-       function doQuery( $limit, $offset, $shownavigation = true ) {
-
-               // this needs to be checked before doing anything
-               if( !$this->user && !$this->newbies ) {
-                       global $wgOut;
-                       $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
-                       return;
-               }
-
-               return parent::doQuery( $limit, $offset, $shownavigation );
-       }
 }
 
 /**
  * Show the special page.
  */
 function wfSpecialContributions( $par = null ) {
-       global $wgRequest, $wgUser;
+       global $wgRequest, $wgUser, $wgOut;
 
        $username = ( isset($par) ? $par : $wgRequest->getVal( 'target' ) );
 
+       // compatibility hack
+       if ( $username == 'newbies' ) {
+               $wgOut->redirect( SpecialPage::getTitleFor( 'NewbieContributions' )->getFullURL() );
+               return;
+       }
+
        $page = new ContributionsPage( $username );
 
+       if( !$page->user ) {
+               $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
+               return;
+       }
+
        // hook for Contributionseditcount extension
        if ( $page->user && $page->user->isLoggedIn() )
                wfRunHooks( 'SpecialContributionsBeforeMainOutput', $page->user->getId() );
diff --git a/includes/SpecialNewbieContributions.php b/includes/SpecialNewbieContributions.php
new file mode 100644 (file)
index 0000000..7e8e948
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+
+/**
+ * Special page allowing users to view the contributions of new users.
+ *
+ * @package MediaWiki
+ * @subpackage Special pages
+ */
+class NewbieContributionsPage extends ContributionsPage {
+
+       /**
+        * Constructor.  No need for username.
+        */
+       function __construct() { }
+
+       /**
+        * @return string Name of this special page.
+        */
+       function getName() {
+               return 'NewbieContributions';
+       }
+
+       /**
+        * No target user here.
+        */
+       function getUsername() {
+               return '';
+       }
+
+       /**
+        * No target user => no subtitle.
+        */
+       function getSubtitleForTarget() {
+               return '';
+       }
+
+       /**
+        * No target user => no deleted contribs link.
+        */
+       function getDeletedContributionsLink() {
+               return '';
+       }
+
+       /**
+        * Construct the WHERE clause of the SQL SELECT statement for
+        * this query.
+        * @return string
+        */
+       function makeSQLCond( $dbr ) {
+               $cond = ' page_id = rev_page';
+
+               $max = $dbr->selectField( 'user', 'max(user_id)', false, 'make_sql' );
+               $cond .= ' AND rev_user > ' . (int)($max - $max / 100);
+
+               if ( isset($this->namespace) )
+                       $cond .= ' AND page_namespace = ' . (int)$this->namespace;
+
+               return $cond;
+       }
+
+       /**
+        * Do a batch existence check for any user and user talk pages
+        * that will be shown in the list.
+        */
+       function preprocessResults( $dbr, $res ) {
+               $linkBatch = new LinkBatch();
+               while( $row = $dbr->fetchObject( $res ) ) {
+                       $linkBatch->add( NS_USER, $row->username );
+                       $linkBatch->add( NS_USER_TALK, $row->username );
+               }
+               $linkBatch->execute();
+
+               // Seek to start
+               if( $dbr->numRows( $res ) > 0 )
+                       $dbr->dataSeek( $res, 0 );
+       }
+
+       /**
+        * Get user links for output row.
+        *
+        * @param $skin Skin to use
+        * @param $row Result row
+        * @return string User links
+        */
+       function getRowUserLinks( $skin, $row ) {
+               $user = ' . . ' . $skin->userLink( $row->userid, $row->username )
+                               . $skin->userToolLinks( $row->userid, $row->username );
+               return $user;
+       }
+}
+
+/**
+ * Show the special page.
+ */
+function wfSpecialNewbieContributions( $par = null ) {
+       global $wgRequest, $wgUser, $wgOut;
+
+       $page = new NewbieContributionsPage();
+
+       $page->namespace = $wgRequest->getIntOrNull( 'namespace' );
+       $page->botmode   = ( $wgUser->isAllowed( 'rollback' ) && $wgRequest->getBool( 'bot' ) );
+       
+       list( $limit, $offset ) = wfCheckLimits();
+       return $page->doQuery( $offset, $limit );
+}
+
+?>
index e8db18b..92aa4cb 100644 (file)
@@ -114,6 +114,7 @@ class SpecialPage
                'Ipblocklist'               => array( 'SpecialPage', 'Ipblocklist' ),
                'Specialpages'              => array( 'UnlistedSpecialPage', 'Specialpages' ),
                'Contributions'             => array( 'UnlistedSpecialPage', 'Contributions' ),
+               'NewbieContributions'       => array( 'SpecialPage', 'NewbieContributions' ),
                'Emailuser'                 => array( 'UnlistedSpecialPage', 'Emailuser' ),
                'Whatlinkshere'             => array( 'UnlistedSpecialPage', 'Whatlinkshere' ),
                'Recentchangeslinked'       => array( 'UnlistedSpecialPage', 'Recentchangeslinked' ),
index 5e7a573..f1860b2 100644 (file)
@@ -380,6 +380,7 @@ $specialPageAliases = array(
        'Ipblocklist'               => array( 'Ipblocklist' ),
        'Specialpages'              => array( 'Specialpages' ),
        'Contributions'             => array( 'Contributions' ),
+       'NewbieContributions'       => array( 'NewbieContributions' ),
        'Emailuser'                 => array( 'Emailuser' ),
        'Whatlinkshere'             => array( 'Whatlinkshere' ),
        'Recentchangeslinked'       => array( 'Recentchangeslinked' ),
@@ -1754,19 +1755,11 @@ Consult the [[Special:Log/delete|deletion log]] for a record of recent deletions
 'contributions' => 'User contributions',
 'mycontris'     => 'My contributions',
 'contribsub'    => "For $1",
-'nocontribs'    => 'No changes were found matching these criteria.',
-'ucnote'        => "Below are this user's last <b>$1</b> changes in the last <b>$2</b> days.",
-'uclinks'       => "View the last $1 changes; view the last $2 days.",
 'uctop'         => ' (top)' ,
-'newbies'       => 'newbies',
 
-'sp-newimages-showfrom' => 'Show new images starting from $1',
-
-'sp-contributions-newest' => 'Newest',
-'sp-contributions-oldest' => 'Oldest',
-'sp-contributions-newer'  => 'Newer $1',
-'sp-contributions-older'  => 'Older $1',
-'sp-contributions-newbies-sub' => 'For newbies',
+# Newbie contributions
+#
+'newbiecontributions' => 'Newbie contributions',
 
 
 # What links here
@@ -2168,6 +2161,7 @@ ta[\'ca-nstab-category\'] = new Array(\'c\',\'View the category page\');',
 'newimages-summary' => '',
 'showhidebots' => '($1 bots)',
 'noimages'  => 'Nothing to see.',
+'sp-newimages-showfrom' => 'Show new images starting from $1',
 
 # short names for language variants used for language conversion links.
 # to disable showing a particular link, set it to 'disable', e.g.
index da69814..b9bddc4 100644 (file)
@@ -1137,17 +1137,11 @@ Palaute ja lisäapu osoitteessa:
 'contributions'       => 'Käyttäjän muokkaukset',
 'mycontris'           => 'Muokkaukset',
 'contribsub'          => 'Käyttäjän $1 muokkaukset',
-'nocontribs'          => 'Näihin ehtoihin sopivia muokkauksia ei löytynyt.',
-'ucnote'              => 'Alla on \'\'\'$1\'\'\' viimeisintä tämän käyttäjän tekemää muokkausta viimeisten \'\'\'$2\'\'\' päivän aikana.',
-'uclinks'             => 'Katso $1 viimeisintä muokkausta; katso $2 viimeisintä päivää.',
 'uctop'               => ' (uusin)' ,
-'newbies'             => 'tulokkaat',
 
-'sp-contributions-newest' => 'Uusimmat',
-'sp-contributions-oldest' => 'Vanhimmat',
-'sp-contributions-newer'  => '← $1 uudempaa',
-'sp-contributions-older'  => '$1 vanhempaa →',
-'sp-contributions-newbies-sub' => 'Uusien tulokkaiden muokkaukset',
+# Newbie contributions
+#
+'newbiecontributions' => 'Uusien tulokkaiden muokkaukset',
 
 # What links here
 #