3 function wfSpecialContributions( $par = "" )
5 global $wgUser, $wgOut, $wgLang, $wgRequest;
6 $fname = "wfSpecialContributions";
7 $sysop = $wgUser->isSysop();
12 $target = $wgRequest->getVal( 'target' );
14 if ( "" == $target ) {
15 $wgOut->errorpage( "notargettitle", "notargettext" );
19 # FIXME: Change from numeric offsets to date offsets
20 list( $limit, $offset ) = wfCheckLimits( 50, "" );
21 $offlimit = $limit +
$offset;
22 $querylimit = $offlimit +
1;
23 $hideminor = ($wgRequest->getVal( 'hideminor' ) ?
1 : 0);
25 $nt = Title
::newFromURL( $target );
26 $nt->setNamespace( Namespace::getUser() );
28 $sk = $wgUser->getSkin();
29 $id = User
::idFromName( $nt->getText() );
34 $ul = $sk->makeLinkObj( $nt, $nt->getText() );
36 $talk = $nt->getTalkPage();
38 $ul .= " (" . $sk->makeLinkObj( $talk, $wgLang->getNsText(Namespace::getTalk(0)) ) . ")";
41 $wgOut->setSubtitle( wfMsg( "contribsub", $ul ) );
44 $cmq = "AND cur_minor_edit=0";
45 $omq = "AND old_minor_edit=0";
46 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
47 WfMsg( "show" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
48 "&offset={$offset}&limit={$limit}&hideminor=0" );
51 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
52 WfMsg( "hide" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
53 "&offset={$offset}&limit={$limit}&hideminor=1" );
57 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new FROM cur " .
58 "WHERE cur_user_text='" . wfStrencode( $nt->getText() ) . "' {$cmq} " .
59 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
60 $res1 = wfQuery( $sql, DB_READ
, $fname );
62 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit FROM old " .
63 "WHERE old_user_text='" . wfStrencode( $nt->getText() ) . "' {$omq} " .
64 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
65 $res2 = wfQuery( $sql, DB_READ
, $fname );
67 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new FROM cur " .
68 "WHERE cur_user={$id} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
69 $res1 = wfQuery( $sql, DB_READ
, $fname );
71 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit FROM old " .
72 "WHERE old_user={$id} {$omq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
73 $res2 = wfQuery( $sql, DB_READ
, $fname );
75 $nCur = wfNumRows( $res1 );
76 $nOld = wfNumRows( $res2 );
78 $top = wfShowingResults( $offset, $limit );
79 $wgOut->addHTML( "<p>{$top}\n" );
81 $sl = wfViewPrevNext( $offset, $limit,
82 $wgLang->specialpage( "Contributions" ),
83 "hideminor={$hideminor}&target=" . wfUrlEncode( $target ),
84 ($nCur +
$nOld) <= $offlimit);
86 $shm = wfMsg( "showhideminor", $mlink );
87 $wgOut->addHTML( "<br />{$sl} ($shm)</p>\n");
90 if ( 0 == $nCur && 0 == $nOld ) {
91 $wgOut->addHTML( "\n<p>" . wfMsg( "nocontribs" ) . "</p>\n" );
94 if ( 0 != $nCur ) { $obj1 = wfFetchObject( $res1 ); }
95 if ( 0 != $nOld ) { $obj2 = wfFetchObject( $res2 ); }
97 $wgOut->addHTML( "<ul>\n" );
98 for( $n = 0; $n < $offlimit; $n++
) {
99 if ( 0 == $nCur && 0 == $nOld ) { break; }
101 if ( ( 0 == $nOld ) ||
103 ( $obj1->cur_timestamp
>= $obj2->old_timestamp
) ) ) {
104 $ns = $obj1->cur_namespace
;
105 $t = $obj1->cur_title
;
106 $ts = $obj1->cur_timestamp
;
107 $comment =$obj1->cur_comment
;
108 $me = $obj1->cur_minor_edit
;
109 $isnew = $obj1->cur_is_new
;
110 $obj1 = wfFetchObject( $res1 );
114 $ns = $obj2->old_namespace
;
115 $t = $obj2->old_title
;
116 $ts = $obj2->old_timestamp
;
117 $comment =$obj2->old_comment
;
118 $me = $obj2->old_minor_edit
;
120 $obj2 = wfFetchObject( $res2 );
126 ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, ( $me > 0), $isnew );
128 $wgOut->addHTML( "</ul>\n" );
134 Generates each row in the contributions list.
136 Contributions which are marked "top" are currently on top of the history.
137 For these contributions, a [rollback] link is shown for users with sysop
138 privileges. The rollback link restores the most recent version that was not
139 written by the target user.
141 If the contributions page is called with the parameter &bot=1, all rollback
142 links also get that parameter. It causes the edit itself and the rollback
143 to be marked as "bot" edits. Bot edits are hidden by default from recent
144 changes, so this allows sysops to combat a busy vandal without bothering
147 TODO: This would probably look a lot nicer in a table.
150 function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew )
152 global $wgLang, $wgOut, $wgUser, $wgRequest;
153 $page = Title
::makeName( $ns, $t );
154 $link = $sk->makeKnownLink( $page, "" );
158 $topmarktext .= $sk->makeKnownLink( $page, wfMsg("uctop"), "diff=0" );
160 $topmarktext .= wfMsg("newarticle");
162 $sysop = $wgUser->isSysop();
164 $extraRollback = $wgRequest->getBool( "bot" ) ?
'&bot=1' : '';
165 $target = $wgRequest->getText( 'target' );
166 $topmarktext .= " [". $sk->makeKnownLink( $page,
167 wfMsg( "rollbacklink" ),
168 "action=rollback&from=" . urlencode( $target ) . $extraRollback ) ."]";
172 $histlink="(".$sk->makeKnownLink($page,wfMsg("hist"),"action=history").")";
176 $comment="<em>(". $sk->formatComment($comment ) .")</em> ";
179 $d = $wgLang->timeanddate( $ts, true );
182 $mflag = "<strong>" . wfMsg( "minoreditletter" ) . "</strong> ";
187 $wgOut->addHTML( "<li>{$d} {$histlink} {$mflag} {$link} {$comment}{$topmarktext}</li>\n" );
190 function ucCountLink( $lim, $d )
192 global $wgUser, $wgLang, $wgRequest;
194 $target = $wgRequest->getText( 'target' );
195 $sk = $wgUser->getSkin();
196 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
197 "{$lim}", "target={$target}&days={$d}&limit={$lim}" );
201 function ucDaysLink( $lim, $d )
203 global $wgUser, $wgLang, $wgRequest;
205 $target = $wgRequest->getText( 'target' );
206 $sk = $wgUser->getSkin();
207 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
208 "{$d}", "target={$target}&days={$d}&limit={$lim}" );