(bug 1331) Add "next page" link to bottom of Special:Allpages in chunk mode
[lhc/web/wiklou.git] / includes / SpecialContributions.php
index d077b76..ba6b280 100644 (file)
@@ -31,7 +31,7 @@ class ContribsFinder {
                list( $index, $usercond ) = $this->getUserCond();
                $nscond = $this->getNamespaceCond();
                $use_index = $this->dbr->useIndexClause( $index );
-               extract( $this->dbr->tableNames( 'revision', 'page' ) );
+               list( $revision, $page) = $this->dbr->tableNamesN( 'revision', 'page' );
                $sql =  "SELECT rev_timestamp " .
                        " FROM $page,$revision $use_index " .
                        " WHERE rev_page=page_id AND $usercond $nscond" .
@@ -82,7 +82,7 @@ class ContribsFinder {
                $nscond = $this->getNamespaceCond();
 
                $use_index = $this->dbr->useIndexClause( $index );
-               extract( $this->dbr->tableNames( 'page', 'revision' ) );
+               list( $page, $revision ) = $this->dbr->tableNamesN( 'page', 'revision' );
 
                $sql =  "SELECT rev_timestamp FROM $page, $revision $use_index " .
                        "WHERE page_id = rev_page AND rev_timestamp > '" . $this->offset . "' AND " .
@@ -106,7 +106,7 @@ class ContribsFinder {
        function getFirstOffsetForPaging() {
                list( $index, $usercond ) = $this->getUserCond();
                $use_index = $this->dbr->useIndexClause( $index );
-               extract( $this->dbr->tableNames( 'page', 'revision' ) );
+               list( $page, $revision ) = $this->dbr->tableNamesN( 'page', 'revision' );
                $nscond = $this->getNamespaceCond();
                $sql =  "SELECT rev_timestamp FROM $page, $revision $use_index " .
                        "WHERE page_id = rev_page AND " .
@@ -128,9 +128,9 @@ class ContribsFinder {
        }
 
        /* private */ function makeSql() {
-               $userCond = $condition = $index = $offsetQuery = '';
+               $offsetQuery = '';
 
-               extract( $this->dbr->tableNames( 'page', 'revision' ) );
+               list( $page, $revision ) = $this->dbr->tableNamesN( 'page', 'revision' );
                list( $index, $userCond ) = $this->getUserCond();
 
                if ( $this->offset )
@@ -168,7 +168,6 @@ class ContribsFinder {
  */
 function wfSpecialContributions( $par = null ) {
        global $wgUser, $wgOut, $wgLang, $wgRequest;
-       $fname = 'wfSpecialContributions';
 
        $target = isset( $par ) ? $par : $wgRequest->getVal( 'target' );
        if ( !strlen( $target ) ) {
@@ -186,9 +185,18 @@ function wfSpecialContributions( $par = null ) {
 
        list( $options['limit'], $options['offset']) = wfCheckLimits();
        $options['offset'] = $wgRequest->getVal( 'offset' );
-       /* Offset must be an integral. */
-       if ( !strlen( $options['offset'] ) || !preg_match( '/^[0-9]+$/', $options['offset'] ) )
+       /* Check that the offset is valid (e.g. integer or timestamp) */
+       if ( !strlen( $options['offset'] ) )
                $options['offset'] = '';
+       else {
+               $dbr =& wfGetDB( DB_SLAVE );
+               if ( !$dbr->realTimestamps() ) {
+                       if (!preg_match( '/^[0-9]+$/', $options['offset'] ) )
+                               $options['offset'] = '';
+               }
+               else if ( !preg_match( '/^[0-9\-\+: ]+$/', $options['offset'] ) )
+                       $options['offset'] = '';
+       }
 
        $title = SpecialPage::getTitleFor( 'Contributions' );
        $options['target'] = $target;
@@ -291,8 +299,9 @@ function wfSpecialContributions( $par = null ) {
 
        $wgOut->addHTML( "<ul>\n" );
 
+       $sk = $wgUser->getSkin();
        foreach ( $contribs as $contrib )
-               $wgOut->addHTML( ucListEdit( $contrib ) );
+               $wgOut->addHTML( ucListEdit( $sk, $contrib ) );
 
        $wgOut->addHTML( "</ul>\n" );
        $wgOut->addHTML( "<p>{$prevnextbits}</p>\n" );
@@ -305,26 +314,27 @@ function wfSpecialContributions( $par = null ) {
 function contributionsSub( $nt ) {
        global $wgSysopUserBans, $wgLang, $wgUser;
 
+       $sk = $wgUser->getSkin();
        $id = User::idFromName( $nt->getText() );
 
        if ( 0 == $id ) {
                $ul = $nt->getText();
        } else {
-               $ul = Linker::makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) );
+               $ul = $sk->makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) );
        }
        $talk = $nt->getTalkPage();
        if( $talk ) {
                # Talk page link        
-               $tools[] = Linker::makeLinkObj( $talk, $wgLang->getNsText( NS_TALK ) );
+               $tools[] = $sk->makeLinkObj( $talk, $wgLang->getNsText( NS_TALK ) );
                if( ( $id != 0 && $wgSysopUserBans ) || ( $id == 0 && User::isIP( $nt->getText() ) ) ) {
                        # Block link
                        if( $wgUser->isAllowed( 'block' ) )
-                               $tools[] = Linker::makeKnownLinkObj( SpecialPage::getTitleFor( 'Blockip', $nt->getDBkey() ), wfMsgHtml( 'blocklink' ) );
+                               $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Blockip', $nt->getDBkey() ), wfMsgHtml( 'blocklink' ) );
                        # Block log link
-                       $tools[] = Linker::makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), htmlspecialchars( LogPage::logName( 'block' ) ), 'type=block&page=' . $nt->getPrefixedUrl() );
+                       $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), htmlspecialchars( LogPage::logName( 'block' ) ), 'type=block&page=' . $nt->getPrefixedUrl() );
                }
                # Other logs link
-               $tools[] = Linker::makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), wfMsgHtml( 'log' ), 'user=' . $nt->getPartialUrl() );
+               $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), wfMsgHtml( 'log' ), 'user=' . $nt->getPartialUrl() );
                $ul .= ' (' . implode( ' | ', $tools ) . ')';
        }
        return $ul;
@@ -367,15 +377,9 @@ function contributionsForm( $options ) {
  * privileges. The rollback link restores the most recent version that was not
  * written by the target user.
  *
- * If the contributions page is called with the parameter &bot=1, all rollback
- * links also get that parameter. It causes the edit itself and the rollback
- * to be marked as "bot" edits. Bot edits are hidden by default from recent
- * changes, so this allows sysops to combat a busy vandal without bothering
- * other users.
- *
  * @todo This would probably look a lot nicer in a table.
  */
-function ucListEdit( $row ) {
+function ucListEdit( $sk, $row ) {
        $fname = 'ucListEdit';
        wfProfileIn( $fname );
 
@@ -388,36 +392,31 @@ function ucListEdit( $row ) {
        }
 
        $rev = new Revision( $row );
-       
+
        $page = Title::makeTitle( $row->page_namespace, $row->page_title );
-       $link = Linker::makeKnownLinkObj( $page );
+       $link = $sk->makeKnownLinkObj( $page );
        $difftext = $topmarktext = '';
        if( $row->rev_id == $row->page_latest ) {
                $topmarktext .= '<strong>' . $messages['uctop'] . '</strong>';
                if( !$row->page_is_new ) {
-                       $difftext .= '(' . Linker::makeKnownLinkObj( $page, $messages['diff'], 'diff=0' ) . ')';
+                       $difftext .= '(' . $sk->makeKnownLinkObj( $page, $messages['diff'], 'diff=0' ) . ')';
                } else {
                        $difftext .= $messages['newarticle'];
                }
 
                if( $wgUser->isAllowed( 'rollback' ) ) {
-                       $extraRollback = $wgRequest->getBool( 'bot' ) ? '&bot=1' : '';
-                       $extraRollback .= '&token=' . urlencode(
-                               $wgUser->editToken( array( $page->getPrefixedText(), $row->rev_user_text ) ) );
-                       $topmarktext .= ' ['. Linker::makeKnownLinkObj( $page,
-                               $messages['rollbacklink'],
-                               'action=rollback&from=' . urlencode( $row->rev_user_text ) . $extraRollback ) .']';
+                       $topmarktext .= ' '.$sk->generateRollback( $rev );
                }
 
        }
        if( $rev->userCan( Revision::DELETED_TEXT ) ) {
-               $difftext = '(' . Linker::makeKnownLinkObj( $page, $messages['diff'], 'diff=prev&oldid='.$row->rev_id ) . ')';
+               $difftext = '(' . $sk->makeKnownLinkObj( $page, $messages['diff'], 'diff=prev&oldid='.$row->rev_id ) . ')';
        } else {
                $difftext = '(' . $messages['diff'] . ')';
        }
-       $histlink = '(' . Linker::makeKnownLinkObj( $page, $messages['hist'], 'action=history' ) . ')';
+       $histlink='('.$sk->makeKnownLinkObj( $page, $messages['hist'], 'action=history' ) . ')';
 
-       $comment = Linker::revComment( $rev );
+       $comment = $sk->revComment( $rev );
        $d = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
        
        if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {