Lazy initialisation of wgProxyList, no flip required
[lhc/web/wiklou.git] / includes / SpecialContributions.php
index cf4b3bc..00864da 100644 (file)
 <?php
 /**
- *
  * @package MediaWiki
  * @subpackage SpecialPage
  */
 
+/** @package MediaWiki */
+class contribs_finder {
+       var $username, $offset, $limit, $namespace;
+       var $dbr;
+
+       function contribs_finder($username) {
+               $this->username = $username;
+               $this->namespace = false;
+               $this->dbr =& wfGetDB(DB_SLAVE);
+       }
+
+       function set_namespace($ns) {
+               $this->namespace = $ns;
+       }
+
+       function set_limit($limit) {
+               $this->limit = $limit;
+       }
+
+       function set_offset($offset) {
+               $this->offset = $offset;
+       }
+
+       function get_edit_limit($dir) {
+               list($index, $usercond) = $this->get_user_cond();
+               $nscond = $this->get_namespace_cond();
+               $use_index = $this->dbr->useIndexClause($index);
+               extract($this->dbr->tableNames('revision', 'page'));
+               $sql =  "SELECT rev_timestamp " .
+                       " FROM $page,$revision $use_index " .
+                       " WHERE rev_page=page_id AND $usercond $nscond" .
+                       " ORDER BY rev_timestamp $dir LIMIT 1";
+
+               $res = $this->dbr->query($sql, "contribs_finder::get_edit_limit");
+               while ($o = $this->dbr->fetchObject($res))
+                       $row = $o;
+               return $row->rev_timestamp;
+       }
+
+       function get_edit_limits() {
+               return array(
+                       $this->get_edit_limit("ASC"),
+                       $this->get_edit_limit("DESC")
+               );
+       }
+
+       function get_user_cond() {
+               $condition = '';
+
+               if ($this->username == 'newbies') {
+                       $max = $this->dbr->selectField('user', 'max(user_id)', false, 'make_sql');
+                       $condition = '>' . (int)($max - $max / 100);
+               }
+
+               if ($condition == '') {
+                       $condition = ' rev_user_text=' . $this->dbr->addQuotes($this->username);
+                       $index = 'usertext_timestamp';
+               } else {
+                       $condition = ' rev_user '.$condition ;
+                       $index = 'user_timestamp';
+               }
+               return array($index, $condition);
+       }
+
+       function get_namespace_cond() {
+               if ($this->namespace !== false)
+                       return ' AND page_namespace = ' . (int)$this->namespace;
+               return '';
+       }
+
+       function get_previous_offset_for_paging() {
+               list($index, $usercond) = $this->get_user_cond();
+               $nscond = $this->get_namespace_cond();
+
+               $use_index = $this->dbr->useIndexClause($index);
+               extract($this->dbr->tableNames('page', 'revision'));
+
+               $sql =  "SELECT rev_timestamp FROM $page, $revision $use_index " .
+                       "WHERE page_id = rev_page AND rev_timestamp > '" . $this->offset . "' AND " .
+                       "rev_user_text = " . $this->dbr->addQuotes($this->username)
+                       . $nscond;
+               $sql .= " ORDER BY rev_timestamp ASC";
+               $sql = $this->dbr->limitResult($sql, $this->limit, 0);
+               $res = $this->dbr->query($sql);
+               $rows = array();
+               while ($obj = $this->dbr->fetchObject($res))
+                       $rows[] = $obj;
+               $this->dbr->freeResult($res);
+               return $rows[count($rows) - 1]->rev_timestamp;
+       }
+
+       function get_first_offset_for_paging() {
+               list($index, $usercond) = $this->get_user_cond();
+               $use_index = $this->dbr->useIndexClause($index);
+               extract($this->dbr->tableNames('page', 'revision'));
+               $nscond = $this->get_namespace_cond();
+               $sql =  "SELECT rev_timestamp FROM $page, $revision $use_index " .
+                       "WHERE page_id = rev_page AND " .
+                       "rev_user_text = " . $this->dbr->addQuotes($this->username)
+                       . $nscond;
+               $sql .= " ORDER BY rev_timestamp ASC";
+               $sql = $this->dbr->limitResult($sql, $this->limit, 0);
+               $res = $this->dbr->query($sql);
+               $rows = array();
+               while ($obj = $this->dbr->fetchObject($res))
+                       $rows[] = $obj;
+               $this->dbr->freeResult($res);
+               return $rows[count($rows) - 1]->rev_timestamp;
+       }
+
+       /* private */ function make_sql() {
+               $userCond = $condition = $index = $offsetQuery = $limitQuery = "";
+
+               extract($this->dbr->tableNames('page', 'revision'));
+               list($index, $userCond) = $this->get_user_cond();
+
+               $limitQuery = 'LIMIT '.$this->limit;
+               if ($this->offset)
+                       $offsetQuery = "AND rev_timestamp <= '{$this->offset}'";
+
+               $nscond = $this->get_namespace_cond();
+               $use_index = $this->dbr->useIndexClause($index);
+               $sql = "SELECT
+                       page_namespace,page_title,page_is_new,page_latest,
+                       rev_id,rev_timestamp,rev_comment,rev_minor_edit,rev_user_text,
+                       rev_deleted
+                       FROM $page,$revision $use_index
+                       WHERE page_id=rev_page AND $userCond $nscond $offsetQuery
+                       ORDER BY rev_timestamp DESC";
+               $sql = $this->dbr->limitResult($sql, $this->limit, 0);
+               return $sql;
+       }
+
+       function find() {
+               $contribs = array();
+               $res = $this->dbr->query($this->make_sql(), 'contribs_finder::find');
+               while ($c = $this->dbr->fetchObject($res))
+                       $contribs[] = $c;
+               $this->dbr->freeResult($res);
+               return $contribs;
+       }
+};
+
 /**
  * Special page "user contributions".
  * Shows a list of the contributions of a user.
  * @return     none
  * @param      string  $par    (optional) user name of the user for which to show the contributions
  */
-function wfSpecialContributions( $par = '' ) {
-       global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest;
+function wfSpecialContributions( $par = null ) {
+       global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest, $wgTitle,
+              $wgScript;
        $fname = 'wfSpecialContributions';
 
-       if( $par )
-               $target = $par;
-       else
-               $target = $wgRequest->getVal( 'target' );
+       $target = isset($par) ? $par : $wgRequest->getVal( 'target' );
+       if (!strlen($target)) {
+               $wgOut->errorpage('notargettitle', 'notargettext');
+               return;
+       }
 
-       if ( '' == $target ) {
+       $nt = Title::newFromURL( $target );
+       if (!$nt) {
                $wgOut->errorpage( 'notargettitle', 'notargettext' );
                return;
        }
+       $nt =& Title::makeTitle(NS_USER, $nt->getDBkey());
 
-       # FIXME: Change from numeric offsets to date offsets
-       list( $limit, $offset ) = wfCheckLimits( 50, '' );
-       $offlimit = $limit + $offset;
-       $querylimit = $offlimit + 1;
-       $hideminor = ($wgRequest->getVal( 'hideminor' ) ? 1 : 0);
-       $sk = $wgUser->getSkin();
-       $dbr =& wfGetDB( DB_SLAVE );
-       $userCond = "";
-       $namespace = $wgRequest->getVal( 'namespace', '' );
-       if( $namespace != '' ) {
-               $namespace = IntVal( $namespace );
-       } else {
-               $namespace = NULL;
+       list( $limit, $offset) = wfCheckLimits();
+       $offset = $wgRequest->getVal('offset');
+       /* Offset must be an integral. */
+       if (!strlen($offset) || !preg_match('/^[0-9]+$/', $offset))
+               $offset = 0;
+
+       $title = Title::makeTitle(NS_SPECIAL, 'Contributions');
+       $urlbits = 'target=' . wfUrlEncode($target);
+       $myurl = $title->escapeLocalURL($urlbits);
+
+       $finder = new contribs_finder(($target == 'newbies') ? 'newbies' : $nt->getText());
+
+       $finder->set_limit($limit);
+       $finder->set_offset($offset);
+
+       $nsurl = $xnsurl = '';
+       if (($ns = $wgRequest->getVal('namespace', null)) !== null && $ns !== '') {
+               $nsurl = '&namespace='.$ns;
+               $xnsurl = htmlspecialchars($nsurl);
+               $finder->set_namespace($ns);
        }
 
-       $nt = Title::newFromURL( $target );
-       if ( !$nt ) {
-               $wgOut->errorpage( 'notargettitle', 'notargettext' );
+       $boturl = '';
+       if ($wgUser->isAllowed('rollback') && $wgRequest->getBool( 'bot' ))
+               $boturl = '&amp;bot=1';
+
+       if ($wgRequest->getText('go') == 'prev') {
+               $prevts = $finder->get_previous_offset_for_paging();
+               $prevurl = $title->getLocalURL($urlbits . "&offset=$prevts&limit=$limit$nsurl$boturl");
+               $wgOut->redirect($prevurl);
                return;
        }
-       $nt =& Title::makeTitle( NS_USER, $nt->getDBkey() );
 
-       $id = User::idFromName( $nt->getText() );
+       if ($wgRequest->getText('go') == 'first' && $target != 'newbies') {
+                $prevts = $finder->get_first_offset_for_paging();
+               $prevurl = $title->getLocalURL($urlbits . "&offset=$prevts&limit=$limit$nsurl$boturl");
+               $wgOut->redirect($prevurl);
+               return;
+       }
+
+       $sk = $wgUser->getSkin();
+
+       $id = User::idFromName($nt->getText());
 
        if ( 0 == $id ) {
                $ul = $nt->getText();
@@ -58,140 +224,104 @@ function wfSpecialContributions( $par = '' ) {
        }
        $talk = $nt->getTalkPage();
        if( $talk ) {
-               $ul .= ' (' . $sk->makeLinkObj( $talk, $wgLang->getNsText(Namespace::getTalk(0)) ) . ')';
+               $ul .= ' (' . $sk->makeLinkObj( $talk, $wgLang->getNsText( NS_TALK ) ) . ')';
        }
 
+       if ($target == 'newbies') {
+               $ul = wfMsg ('newbies');
+       }
 
-       if ( $target == 'newbies' ) {
-               # View the contributions of all recently created accounts
-               $max = $dbr->selectField( 'user', 'max(user_id)', false, $fname );
-               $userCond = '>' . ($max - $max / 100);
-               $ul = wfMsg ( 'newbies' );
-               $id = 0;
+       $wgOut->setSubtitle( wfMsgHtml( 'contribsub', $ul ) );
+
+       wfRunHooks('SpecialContributionsBeforeMainOutput', $id );
+
+       $arr =  $wgContLang->getFormattedNamespaces();
+       $nsform = "<form method='get' action=\"$wgScript\">\n";
+       $nsform .= wfElement('input', array(
+                       'name' => 'title',
+                       'type' => 'hidden',
+                       'value' => $wgTitle->getPrefixedText()));
+       $nsform .= wfElement('input', array(
+                       'name' => 'offset',
+                       'type' => 'hidden',
+                       'value' => $offset));
+       $nsform .= wfElement('input', array(
+                       'name' => 'limit',
+                       'type' => 'hidden',
+                       'value' => $limit));
+       $nsform .= wfElement('input', array(
+                       'name' => 'target',
+                       'type' => 'hidden',
+                       'value' => $target));
+       $nsform .= '<p>';
+       $nsform .= wfMsgHtml('namespace');
+
+       $nsform .= HTMLnamespaceselector( $ns, '' );
+
+       $nsform .= wfElement('input', array(
+                       'type' => 'submit',
+                       'value' => wfMsg('allpagessubmit')));
+       $nsform .= "</p></form>\n";
+
+       $wgOut->addHTML($nsform);
+
+       $contribsPage = Title::makeTitle( NS_SPECIAL, 'Contributions' );
+       $contribs = $finder->find();
+
+       if (count($contribs) == 0) {
+               $wgOut->addWikiText( wfMsg( 'nocontribs' ) );
+               return;
        }
 
-       $wgOut->setSubtitle( wfMsg( 'contribsub', $ul ) );
+       list($early, $late) = $finder->get_edit_limits();
+       $lastts = count($contribs) ? $contribs[count($contribs) - 1]->rev_timestamp : 0;
+       $atstart = (!count($contribs) || $late == $contribs[0]->rev_timestamp);
+       $atend = (!count($contribs) || $early == $lastts);
+
+       $lasturl = $wgTitle->escapeLocalURL("action=history&limit={$limit}");
+
+       $firsttext = wfMsgHtml('histfirst');
+       $lasttext = wfMsgHtml('histlast');
 
-       if ( $hideminor ) {
-               $cmq = 'AND cur_minor_edit=0';
-               $omq = 'AND old_minor_edit=0';
-               $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
-                 WfMsg( 'show' ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
-                 "&offset={$offset}&limit={$limit}&hideminor=0&namespace={$namespace}" );
+       $prevtext = wfMsg('prevn', $limit);
+       if ($atstart) {
+               $lastlink = $lasttext;
+               $prevlink = $prevtext;
        } else {
-               $cmq = $omq = '';
-               $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Contributions" ),
-                 WfMsg( 'hide' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
-                 "&offset={$offset}&limit={$limit}&hideminor=1&namespace={$namespace}" );
+               $lastlink = "<a href=\"$myurl&amp;limit=$limit$xnsurl$boturl\">$lasttext</a>";
+               $prevlink = "<a href=\"$myurl&amp;offset=$offset&amp;limit=$limit$xnsurl$boturl&amp;go=prev\">$prevtext</a>";
        }
-       
-       if( !is_null($namespace) ) {
-               $cmq .= " AND cur_namespace = {$namespace}";
-               $omq .= " AND old_namespace = {$namespace}";
-       }
-       
-       extract( $dbr->tableNames( 'old', 'cur' ) );
-       if ( $userCond == '' ) {
-               # We may have to force the index, as some options will cause
-               # MySQL to incorrectly pick eg the namespace index.
-               list( $useIndex, $tailOpts ) = $dbr->makeSelectOptions( array(
-                       'USE INDEX' => 'usertext_timestamp',
-                       'LIMIT' => $querylimit ) );
-               
-               $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur $useIndex " .
-                 "WHERE cur_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$cmq} " .
-                 "ORDER BY inverse_timestamp $tailOpts";
-               $res1 = $dbr->query( $sql, $fname );
-
-               $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old $useIndex " .
-                 "WHERE old_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$omq} " .
-                 "ORDER BY inverse_timestamp $tailOpts";
-               $res2 = $dbr->query( $sql, $fname );
+
+       $nexttext = wfMsg('nextn', $limit);
+       if ($atend) {
+               $firstlink = $firsttext;
+               $nextlink = $nexttext;
        } else {
-               list( $useIndex, $tailOpts ) = $dbr->makeSelectOptions( array(
-                       'USE INDEX' => 'user_timestamp',
-                       'LIMIT' => $querylimit ) );
-               
-               $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur $useIndex " .
-                 "WHERE cur_user {$userCond} {$cmq} ORDER BY inverse_timestamp $tailOpts";
-               $res1 = $dbr->query( $sql, $fname );
-
-               $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old $useIndex " .
-                 "WHERE old_user {$userCond} {$omq} ORDER BY inverse_timestamp $tailOpts";
-               $res2 = $dbr->query( $sql, $fname );
+               $firstlink = "<a href=\"$myurl&amp;limit=$limit$xnsurl$boturl&amp;go=first\">$firsttext</a>";
+               $nextlink = "<a href=\"$myurl&amp;offset=$lastts&amp;limit=$limit$xnsurl$boturl\">$nexttext</a>";
        }
-       $nCur = $dbr->numRows( $res1 );
-       $nOld = $dbr->numRows( $res2 );
-
-       $wgOut->addHTML( namespaceForm( $target, $hideminor, $namespace ) );
+        if ($target == 'newbies') {
+            $firstlast ="($lastlink)";
+        } else {
+            $firstlast = "($lastlink | $firstlink)";
+        }
 
-       $top = wfShowingResults( $offset, $limit );
-       $wgOut->addHTML( "<p>{$top}\n" );
+       $urls = array();
+       foreach (array(20, 50, 100, 250, 500) as $num)
+               $urls[] = "<a href=\"$myurl&amp;offset=$offset&amp;limit={$num}$xnsurl$boturl\">".$wgLang->formatNum($num)."</a>";
+       $bits = implode($urls, ' | ');
 
-       $sl = wfViewPrevNext( $offset, $limit,
-         $wgContLang->specialpage( 'Contributions' ),
-         "hideminor={$hideminor}&namespace={$namespace}&target=" . wfUrlEncode( $target ),
-         ($nCur + $nOld) <= $offlimit);
+       $prevnextbits = $firstlast .' '. wfMsgHtml('viewprevnext', $prevlink, $nextlink, $bits);
 
-        $shm = wfMsg( 'showhideminor', $mlink );
-       $wgOut->addHTML( "<br />{$sl} ($shm)</p>\n");
-
-
-       if ( 0 == $nCur && 0 == $nOld ) {
-               $wgOut->addHTML( "\n<p>" . wfMsg( 'nocontribs' ) . "</p>\n" );
-               return;
-       }
-       if ( 0 != $nCur ) { $obj1 = $dbr->fetchObject( $res1 ); }
-       if ( 0 != $nOld ) { $obj2 = $dbr->fetchObject( $res2 ); }
+       $wgOut->addHTML( "<p>{$prevnextbits}</p>\n");
 
        $wgOut->addHTML( "<ul>\n" );
-       for( $n = 0; $n < $offlimit; $n++ ) {
-               if ( 0 == $nCur && 0 == $nOld ) { break; }
-
-               if ( ( 0 == $nOld ) ||
-                 ( ( 0 != $nCur ) &&
-                 ( $obj1->cur_timestamp >= $obj2->old_timestamp ) ) ) {
-                       $ns = $obj1->cur_namespace;
-                       $t = $obj1->cur_title;
-                       $ts = $obj1->cur_timestamp;
-                       $comment =$obj1->cur_comment;
-                       $me = $obj1->cur_minor_edit;
-                       $isnew = $obj1->cur_is_new;
-                       $usertext = $obj1->cur_user_text;
-
-                       $obj1 = $dbr->fetchObject( $res1 );
-                       $topmark = true;
-                       $oldid = false;
-                       --$nCur;
-               } else {
-                       $ns = $obj2->old_namespace;
-                       $t = $obj2->old_title;
-                       $ts = $obj2->old_timestamp;
-                       $comment =$obj2->old_comment;
-                       $me = $obj2->old_minor_edit;
-                       $usertext = $obj2->old_user_text;
-                       $oldid = $obj2->old_id;
-
-                       $obj2 = $dbr->fetchObject( $res2 );
-                       $topmark = false;
-                       $isnew = false;
-                       --$nOld;
-               }
-               if( $n >= $offset )
-                       ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, ( $me > 0), $isnew, $usertext, $oldid );
-       }
-       $wgOut->addHTML( "</ul>\n" );
 
-       # Validations
-       global $wgUseValidation;
-       if( $wgUseValidation ) {
-               require_once( 'SpecialValidate.php' );
-               $val = new Validation ;
-               $val = $val->countUserValidations ( $id ) ;
-               $wgOut->addHTML( wfMsg ( 'val_user_validations', $val ) );
-       }
+       foreach ($contribs as $contrib)
+               $wgOut->addHTML(ucListEdit($sk, $contrib));
 
-       $wgOut->addHTML( "<br />{$sl} ($shm)</p>\n");
+       $wgOut->addHTML( "</ul>\n" );
+       $wgOut->addHTML( "<p>{$prevnextbits}</p>\n");
 }
 
 
@@ -202,19 +332,19 @@ function wfSpecialContributions( $par = '' ) {
  * For these contributions, a [rollback] link is shown for users with sysop
  * 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( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew, $target, $oldid ) {
+function ucListEdit( $sk, $row ) {
        $fname = 'ucListEdit';
        wfProfileIn( $fname );
-       
+
        global $wgLang, $wgOut, $wgUser, $wgRequest;
        static $messages;
        if( !isset( $messages ) ) {
@@ -222,107 +352,51 @@ function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew, $t
                        $messages[$msg] = wfMsg( $msg );
                }
        }
-       
-       $page =& Title::makeTitle( $ns, $t );
+
+       $page =& Title::makeTitle( $row->page_namespace, $row->page_title );
        $link = $sk->makeKnownLinkObj( $page, '' );
        $difftext = $topmarktext = '';
-       if($topmark) {
+       if( $row->rev_id == $row->page_latest ) {
                $topmarktext .= '<strong>' . $messages['uctop'] . '</strong>';
-               if(!$isnew) {
-                       $difftext .= $sk->makeKnownLinkObj( $page, '(' . $messages['diff'] . ')', 'diff=0' );
+               if( !$row->page_is_new ) {
+                       $difftext .= '(' . $sk->makeKnownLinkObj( $page, $messages['diff'], 'diff=0' ) . ')';
                } else {
                        $difftext .= $messages['newarticle'];
                }
-               
+
                if( $wgUser->isAllowed('rollback') ) {
                        $extraRollback = $wgRequest->getBool( 'bot' ) ? '&bot=1' : '';
-                       # $target = $wgRequest->getText( 'target' );
+                       $extraRollback .= '&token=' . urlencode(
+                               $wgUser->editToken( array( $page->getPrefixedText(), $row->rev_user_text ) ) );
                        $topmarktext .= ' ['. $sk->makeKnownLinkObj( $page,
                                $messages['rollbacklink'],
-                               'action=rollback&from=' . urlencode( $target ) . $extraRollback ) .']';
+                               'action=rollback&from=' . urlencode( $row->rev_user_text ) . $extraRollback ) .']';
                }
 
        }
-       if ( $oldid ) {
-               $difftext= $sk->makeKnownLinkObj( $page, '(' . $messages['diff'].')', 'diff=prev&oldid='.$oldid );
-       } 
+       if( $row->rev_deleted && !$wgUser->isAllowed( 'undelete' ) ) {
+               $difftext = '(' . $messages['diff'] . ')';
+       } else {
+               $difftext = '(' . $sk->makeKnownLinkObj( $page, $messages['diff'], 'diff=prev&oldid='.$row->rev_id ) . ')';
+       }
        $histlink='('.$sk->makeKnownLinkObj( $page, $messages['hist'], 'action=history' ) . ')';
 
-       if( $comment ) {
-               $comment = '<em>(' . $sk->formatComment( $comment, $page ) . ')</em> ';
-       }
-       $d = $wgLang->timeanddate( $ts, true );
+       $comment = $sk->commentBlock( $row->rev_comment, $page );
+       $d = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->rev_timestamp), true );
 
-       if ($isminor) {
+       if( $row->rev_minor_edit ) {
                $mflag = '<span class="minor">' . $messages['minoreditletter'] . '</span> ';
        } else {
                $mflag = '';
        }
 
-       $wgOut->addHTML( "<li>{$d} {$histlink} {$difftext} {$mflag} {$link} {$comment} {$topmarktext}</li>\n" );
+       $ret = "{$d} {$histlink} {$difftext} {$mflag} {$link} {$comment} {$topmarktext}";
+       if( $row->rev_deleted ) {
+               $ret = '<span class="deleted">' . $ret . '</span> ' . htmlspecialchars( wfMsg( 'deletedrev' ) );
+       }
+       $ret = "<li>$ret</li>\n";
        wfProfileOut( $fname );
+       return $ret;
 }
 
-/**
- *
- */
-function ucCountLink( $lim, $d ) {
-       global $wgUser, $wgContLang, $wgRequest;
-
-       $target = $wgRequest->getText( 'target' );
-       $sk = $wgUser->getSkin();
-       $s = $sk->makeKnownLink( $wgContLang->specialPage( "Contributions" ),
-         "{$lim}", "target={$target}&days={$d}&limit={$lim}" );
-       return $s;
-}
-
-/**
- *
- */
-function ucDaysLink( $lim, $d ) {
-       global $wgUser, $wgContLang, $wgRequest;
-
-       $target = $wgRequest->getText( 'target' );
-       $sk = $wgUser->getSkin();
-       $s = $sk->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
-         "{$d}", "target={$target}&days={$d}&limit={$lim}" );
-       return $s;
-}
-
-/**
- * Generates a form used to restrict display of contributions
- * to a specific namespace
- *
- * @return     none
- * @param      string  $target target user to show contributions for
- * @param      string  $hideminor whether minor contributions are hidden
- * @param      string  $namespace currently selected namespace, NULL for show all
- */
-function namespaceForm ( $target, $hideminor, $namespace ) {
-       global $wgContLang, $wgScript;
-
-       $namespaceselect = '<form><select name="namespace">';
-       $namespaceselect .= '<option value="" '.(is_null($namespace) ? ' selected="selected"' : '').'>'.wfMsg( 'all' ).'</option>';
-       $arr = $wgContLang->getNamespaces();
-       foreach( array_keys( $arr ) as $i ) {
-               if( $i < 0 ) {
-                       continue;
-               }
-               $namespacename = str_replace ( "_", " ", $arr[$i] );
-               $n = ($i == 0) ? wfMsg ( 'articlenamespace' ) : $namespacename;
-               $sel = ($i === $namespace) ? ' selected="selected"' : '';
-               $namespaceselect .= "<option value='{$i}'{$sel}>{$n}</option>";
-       }
-       $namespaceselect .= '</select>';
-
-       $submitbutton = '<input type="submit" value="' . wfMsg( 'allpagessubmit' ) . '" />';
-
-       $out = "<div class='namespaceselector'><form method='get' action='{$wgScript}'>";
-       $out .= '<input type="hidden" name="title" value="'.$wgContLang->specialpage( 'Contributions' ).'" />';
-       $out .= '<input type="hidden" name="target" value="'.htmlspecialchars( $target ).'" />';
-       $out .= '<input type="hidden" name="hideminor" value="'.$hideminor.'" />';      
-       $out .= wfMsg ( 'allpagesformtext2', $namespaceselect, $submitbutton );
-       $out .= '</form></div>';
-       return $out;
-}
 ?>