finally found the reason for the li bug, top a now in skin
[lhc/web/wiklou.git] / includes / SpecialContributions.php
index a68c7c2..ad9b5ac 100644 (file)
@@ -9,7 +9,7 @@ function wfSpecialContributions( $par = "" )
        if( $par )
                $target = $par;
        else
-               $target = $wgResult->getVal( 'target' );
+               $target = $wgRequest->getVal( 'target' );
 
        if ( "" == $target ) {
                $wgOut->errorpage( "notargettitle", "notargettext" );
@@ -54,7 +54,7 @@ function wfSpecialContributions( $par = "" )
        }
 
        if ( 0 == $id ) {
-               $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit FROM cur " .
+               $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new FROM cur " .
                  "WHERE cur_user_text='" . wfStrencode( $nt->getText() ) . "' {$cmq} " .
                  "ORDER BY inverse_timestamp LIMIT {$querylimit}";
                $res1 = wfQuery( $sql, DB_READ, $fname );
@@ -64,7 +64,7 @@ function wfSpecialContributions( $par = "" )
                  "ORDER BY inverse_timestamp LIMIT {$querylimit}";
                $res2 = wfQuery( $sql, DB_READ, $fname );
        } else {
-               $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit FROM cur " .
+               $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new FROM cur " .
                  "WHERE cur_user={$id} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
                $res1 = wfQuery( $sql, DB_READ, $fname );
 
@@ -84,8 +84,8 @@ function wfSpecialContributions( $par = "" )
          ($nCur + $nOld) <= $offlimit);
 
         $shm = wfMsg( "showhideminor", $mlink );
-       $wgOut->addHTML( "<br>{$sl} ($shm) \n");
-       
+       $wgOut->addHTML( "<br />{$sl} ($shm)</p>\n");
+
 
        if ( 0 == $nCur && 0 == $nOld ) {
                $wgOut->addHTML( "\n<p>" . wfMsg( "nocontribs" ) . "</p>\n" );
@@ -106,9 +106,9 @@ function wfSpecialContributions( $par = "" )
                        $ts = $obj1->cur_timestamp;
                        $comment =$obj1->cur_comment;
                        $me = $obj1->cur_minor_edit;
-
+                       $isnew = $obj1->cur_is_new;
                        $obj1 = wfFetchObject( $res1 );
-                       $topmark = true;                        
+                       $topmark = true;
                        --$nCur;
                } else {
                        $ns = $obj2->old_namespace;
@@ -119,46 +119,79 @@ function wfSpecialContributions( $par = "" )
 
                        $obj2 = wfFetchObject( $res2 );
                        $topmark = false;
+                       $isnew = false;
                        --$nOld;
                }
                if( $n >= $offset )
-                       ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, ( $me > 0) );
+                       ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, ( $me > 0), $isnew );
        }
        $wgOut->addHTML( "</ul>\n" );
 }
 
-function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor )
+
+/*
+
+Generates each row in the contributions list.
+
+Contributions which are marked "top" are currently on top of the history.
+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 )
 {
-       global $wgLang, $wgOut, $wgUser, $target;
+       global $wgLang, $wgOut, $wgUser, $wgRequest;
        $page = Title::makeName( $ns, $t );
        $link = $sk->makeKnownLink( $page, "" );
-       $topmarktext = $topmark ? wfMsg ( "uctop" ) : "";
-       $sysop = $wgUser->isSysop();
+       $topmarktext="";
+       if($topmark) {
+               if(!$isnew) {
+                       $topmarktext .= $sk->makeKnownLink( $page, wfMsg("uctop"), "diff=0" );
+               } else {
+                       $topmarktext .= wfMsg("newarticle");
+               }
+               $sysop = $wgUser->isSysop();
+               if($sysop ) {
+                       $extraRollback = $wgRequest->getBool( "bot" ) ? '&bot=1' : '';
+                       $target = $wgRequest->getText( 'target' );
+                       $topmarktext .= " [". $sk->makeKnownLink( $page,
+                       wfMsg( "rollbacklink" ),
+                       "action=rollback&from=" . urlencode( $target ) . $extraRollback ) ."]";
+               }
 
-       $extraRollback = $_REQUEST['bot'] ? '&bot=1' : '';      
-       if($sysop && $topmark ) {
-               $topmarktext .= " [". $sk->makeKnownLink( $page,
-                 wfMsg( "rollbacklink" ), 
-                 "action=rollback&from=" . urlencode( $target ) . $extraRollback ) ."]";
        }
+       $histlink="(".$sk->makeKnownLink($page,wfMsg("hist"),"action=history").")";
+
        if($comment) {
-       
-               $comment="<em>(". htmlspecialchars( $comment ) .")</em> ";
-       
+
+               $comment="<em>(". $sk->formatComment($comment ) .")</em> ";
+
        }
        $d = $wgLang->timeanddate( $ts, true );
 
-        if ($isminor) {
-          $mflag = "<strong>" . wfMsg( "minoreditletter" ) . "</strong> ";
-        }
+       if ($isminor) {
+               $mflag = "<strong>" . wfMsg( "minoreditletter" ) . "</strong> ";
+       } else {
+               $mflag = "";
+       }
 
-       $wgOut->addHTML( "<li>{$d} {$mflag}{$link} {$comment}{$topmarktext}</li>\n" );
+       $wgOut->addHTML( "<li>{$d} {$histlink} {$mflag} {$link} {$comment}{$topmarktext}</li>\n" );
 }
 
 function ucCountLink( $lim, $d )
 {
-       global $wgUser, $wgLang, $target;
+       global $wgUser, $wgLang, $wgRequest;
 
+       $target = $wgRequest->getText( 'target' );
        $sk = $wgUser->getSkin();
        $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
          "{$lim}", "target={$target}&days={$d}&limit={$lim}" );
@@ -167,8 +200,9 @@ function ucCountLink( $lim, $d )
 
 function ucDaysLink( $lim, $d )
 {
-       global $wgUser, $wgLang, $target;
+       global $wgUser, $wgLang, $wgRequest;
 
+       $target = $wgRequest->getText( 'target' );
        $sk = $wgUser->getSkin();
        $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
          "{$d}", "target={$target}&days={$d}&limit={$lim}" );