Also remove some obsolete contributions-related UI messages.
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 ==
'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',
array( 'MostlinkedPage', 'Mostlinked' ),
array( 'MostrevisionsPage', 'Mostrevisions' ),
array( 'NewPagesPage', 'Newpages' ),
+ array( 'NewbieContributionsPage', 'NewbieContributions' ),
array( 'ShortPagesPage', 'Shortpages' ),
array( 'UncategorizedCategoriesPage', 'Uncategorizedcategories' ),
array( 'UncategorizedPagesPage', 'Uncategorizedpages' ),
class ContributionsPage extends QueryPage {
var $user = null;
var $namespace = null;
- var $newbies = false;
var $botmode = false;
/**
* @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 );
}
/**
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;
$skin = $wgUser->getSkin();
- $username = $this->user->getName();
+ $username = $this->getUsername();
$userpage = $this->user->getUserPage();
$userlink = $skin->makeLinkObj( $userpage, $username );
* @return string
*/
function getSubtitleForTarget() {
- if ( $this->newbies )
- return wfMsgHtml( 'sp-contributions-newbies-sub' );
- else
- return wfMsgHtml( 'contribsub', $this->getTargetUserLinks() );
+ return wfMsgHtml( 'contribsub', $this->getTargetUserLinks() );
}
/**
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>";
$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>';
*/
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;
}
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,
}
/**
- * 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
$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 = '';
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() );
--- /dev/null
+<?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 );
+}
+
+?>
'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' ),
'Ipblocklist' => array( 'Ipblocklist' ),
'Specialpages' => array( 'Specialpages' ),
'Contributions' => array( 'Contributions' ),
+ 'NewbieContributions' => array( 'NewbieContributions' ),
'Emailuser' => array( 'Emailuser' ),
'Whatlinkshere' => array( 'Whatlinkshere' ),
'Recentchangeslinked' => array( 'Recentchangeslinked' ),
'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
'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.
'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
#