Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

SpecialContributions.php

Go to the documentation of this file.
00001 <?php 00002 00003 function wfSpecialContributions( $par = "" ) 00004 { 00005 global $wgUser, $wgOut, $wgLang, $wgRequest, $wgIsPg; 00006 $fname = "wfSpecialContributions"; 00007 $sysop = $wgUser->isSysop(); 00008 00009 if( $par ) 00010 $target = $par; 00011 else 00012 $target = $wgRequest->getVal( 'target' ); 00013 00014 if ( "" == $target ) { 00015 $wgOut->errorpage( "notargettitle", "notargettext" ); 00016 return; 00017 } 00018 00019 # FIXME: Change from numeric offsets to date offsets 00020 list( $limit, $offset ) = wfCheckLimits( 50, "" ); 00021 $offlimit = $limit + $offset; 00022 $querylimit = $offlimit + 1; 00023 $hideminor = ($wgRequest->getVal( 'hideminor' ) ? 1 : 0); 00024 $sk = $wgUser->getSkin(); 00025 00026 $userCond = ""; 00027 00028 $nt = Title::newFromURL( $target ); 00029 $nt->setNamespace( Namespace::getUser() ); 00030 00031 $id = User::idFromName( $nt->getText() ); 00032 00033 if ( 0 == $id ) { 00034 $ul = $nt->getText(); 00035 } else { 00036 $ul = $sk->makeLinkObj( $nt, $nt->getText() ); 00037 $userCond = "=" . $id; 00038 } 00039 $talk = $nt->getTalkPage(); 00040 if( $talk ) 00041 $ul .= " (" . $sk->makeLinkObj( $talk, $wgLang->getNsText(Namespace::getTalk(0)) ) . ")"; 00042 else 00043 $ul .= "brrrp"; 00044 00045 if ( $target == 'newbies' ) { 00046 # View the contributions of all recently created accounts 00047 $row = wfGetArray("user",array("max(user_id) as m"),false); 00048 $userCond = ">" . ($row->m - $row->m / 100); 00049 $ul = ""; 00050 $id = 0; 00051 } 00052 00053 $wgOut->setSubtitle( wfMsg( "contribsub", $ul ) ); 00054 00055 if ( $hideminor ) { 00056 $cmq = "AND cur_minor_edit=0"; 00057 $omq = "AND old_minor_edit=0"; 00058 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ), 00059 WfMsg( "show" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) . 00060 "&offset={$offset}&limit={$limit}&hideminor=0" ); 00061 } else { 00062 $cmq = $omq = ""; 00063 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ), 00064 WfMsg( "hide" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) . 00065 "&offset={$offset}&limit={$limit}&hideminor=1" ); 00066 } 00067 00068 $oldtable=$wgIsPg?'"old"':'old'; 00069 if ( $userCond == "" ) { 00070 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM cur " . 00071 "WHERE cur_user_text='" . wfStrencode( $nt->getText() ) . "' {$cmq} " . 00072 "ORDER BY inverse_timestamp LIMIT {$querylimit}"; 00073 $res1 = wfQuery( $sql, DB_READ, $fname ); 00074 00075 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text FROM $oldtable " . 00076 "WHERE old_user_text='" . wfStrencode( $nt->getText() ) . "' {$omq} " . 00077 "ORDER BY inverse_timestamp LIMIT {$querylimit}"; 00078 $res2 = wfQuery( $sql, DB_READ, $fname ); 00079 } else { 00080 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM cur " . 00081 "WHERE cur_user {$userCond} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}"; 00082 $res1 = wfQuery( $sql, DB_READ, $fname ); 00083 00084 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text FROM $oldtable " . 00085 "WHERE old_user {$userCond} {$omq} ORDER BY inverse_timestamp LIMIT {$querylimit}"; 00086 $res2 = wfQuery( $sql, DB_READ, $fname ); 00087 } 00088 $nCur = wfNumRows( $res1 ); 00089 $nOld = wfNumRows( $res2 ); 00090 00091 $top = wfShowingResults( $offset, $limit ); 00092 $wgOut->addHTML( "<p>{$top}\n" ); 00093 00094 $sl = wfViewPrevNext( $offset, $limit, 00095 $wgLang->specialpage( "Contributions" ), 00096 "hideminor={$hideminor}&target=" . wfUrlEncode( $target ), 00097 ($nCur + $nOld) <= $offlimit); 00098 00099 $shm = wfMsg( "showhideminor", $mlink ); 00100 $wgOut->addHTML( "<br />{$sl} ($shm)</p>\n"); 00101 00102 00103 if ( 0 == $nCur && 0 == $nOld ) { 00104 $wgOut->addHTML( "\n<p>" . wfMsg( "nocontribs" ) . "</p>\n" ); 00105 return; 00106 } 00107 if ( 0 != $nCur ) { $obj1 = wfFetchObject( $res1 ); } 00108 if ( 0 != $nOld ) { $obj2 = wfFetchObject( $res2 ); } 00109 00110 $wgOut->addHTML( "<ul>\n" ); 00111 for( $n = 0; $n < $offlimit; $n++ ) { 00112 if ( 0 == $nCur && 0 == $nOld ) { break; } 00113 00114 if ( ( 0 == $nOld ) || 00115 ( ( 0 != $nCur ) && 00116 ( $obj1->cur_timestamp >= $obj2->old_timestamp ) ) ) { 00117 $ns = $obj1->cur_namespace; 00118 $t = $obj1->cur_title; 00119 $ts = $obj1->cur_timestamp; 00120 $comment =$obj1->cur_comment; 00121 $me = $obj1->cur_minor_edit; 00122 $isnew = $obj1->cur_is_new; 00123 $usertext = $obj1->cur_user_text; 00124 00125 $obj1 = wfFetchObject( $res1 ); 00126 $topmark = true; 00127 --$nCur; 00128 } else { 00129 $ns = $obj2->old_namespace; 00130 $t = $obj2->old_title; 00131 $ts = $obj2->old_timestamp; 00132 $comment =$obj2->old_comment; 00133 $me = $obj2->old_minor_edit; 00134 $usertext = $obj2->old_user_text; 00135 00136 $obj2 = wfFetchObject( $res2 ); 00137 $topmark = false; 00138 $isnew = false; 00139 --$nOld; 00140 } 00141 if( $n >= $offset ) 00142 ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, ( $me > 0), $isnew, $usertext ); 00143 } 00144 $wgOut->addHTML( "</ul>\n" ); 00145 } 00146 00147 00148 /* 00149 00150 Generates each row in the contributions list. 00151 00152 Contributions which are marked "top" are currently on top of the history. 00153 For these contributions, a [rollback] link is shown for users with sysop 00154 privileges. The rollback link restores the most recent version that was not 00155 written by the target user. 00156 00157 If the contributions page is called with the parameter &bot=1, all rollback 00158 links also get that parameter. It causes the edit itself and the rollback 00159 to be marked as "bot" edits. Bot edits are hidden by default from recent 00160 changes, so this allows sysops to combat a busy vandal without bothering 00161 other users. 00162 00163 TODO: This would probably look a lot nicer in a table. 00164 00165 */ 00166 function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew, $target ) 00167 { 00168 global $wgLang, $wgOut, $wgUser, $wgRequest; 00169 $page = Title::makeName( $ns, $t ); 00170 $link = $sk->makeKnownLink( $page, "" ); 00171 $topmarktext=""; 00172 if($topmark) { 00173 if(!$isnew) { 00174 $topmarktext .= $sk->makeKnownLink( $page, wfMsg("uctop"), "diff=0" ); 00175 } else { 00176 $topmarktext .= wfMsg("newarticle"); 00177 } 00178 $sysop = $wgUser->isSysop(); 00179 if($sysop ) { 00180 $extraRollback = $wgRequest->getBool( "bot" ) ? '&bot=1' : ''; 00181 # $target = $wgRequest->getText( 'target' ); 00182 $topmarktext .= " [". $sk->makeKnownLink( $page, 00183 wfMsg( "rollbacklink" ), 00184 "action=rollback&from=" . urlencode( $target ) . $extraRollback ) ."]"; 00185 } 00186 00187 } 00188 $histlink="(".$sk->makeKnownLink($page,wfMsg("hist"),"action=history").")"; 00189 00190 if($comment) { 00191 00192 $comment="<em>(". $sk->formatComment($comment ) .")</em> "; 00193 00194 } 00195 $d = $wgLang->timeanddate( $ts, true ); 00196 00197 if ($isminor) { 00198 $mflag = "<strong>" . wfMsg( "minoreditletter" ) . "</strong> "; 00199 } else { 00200 $mflag = ""; 00201 } 00202 00203 $wgOut->addHTML( "<li>{$d} {$histlink} {$mflag} {$link} {$comment}{$topmarktext}</li>\n" ); 00204 } 00205 00206 function ucCountLink( $lim, $d ) 00207 { 00208 global $wgUser, $wgLang, $wgRequest; 00209 00210 $target = $wgRequest->getText( 'target' ); 00211 $sk = $wgUser->getSkin(); 00212 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ), 00213 "{$lim}", "target={$target}&days={$d}&limit={$lim}" ); 00214 return $s; 00215 } 00216 00217 function ucDaysLink( $lim, $d ) 00218 { 00219 global $wgUser, $wgLang, $wgRequest; 00220 00221 $target = $wgRequest->getText( 'target' ); 00222 $sk = $wgUser->getSkin(); 00223 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ), 00224 "{$d}", "target={$target}&days={$d}&limit={$lim}" ); 00225 return $s; 00226 } 00227 ?>

Generated on Tue Jun 29 23:40:07 2004 for Mediawiki by doxygen 1.3.7