8c2f3ff974290f80ec35c2654f5e4713ce782244
[lhc/web/wiklou.git] / includes / SpecialRecentchangeslinked.php
1 <?php
2 include_once( "SpecialRecentchanges.php" );
3
4 function wfSpecialRecentchangeslinked( $par = NULL )
5 {
6 global $wgUser, $wgOut, $wgLang, $wgTitle, $wgRequest;
7 $fname = "wfSpecialRecentchangeslinked";
8
9 $days = $wgRequest->getInt( 'days' );
10 $target = $wgRequest->getText( 'target' );
11 $hideminor = $wgRequest->getBool( 'hideminor' ) ? 1 : 0;
12
13 $wgOut->setPagetitle( wfMsg( "recentchanges" ) );
14 $sk = $wgUser->getSkin();
15
16 if( $par ) {
17 $target = $par;
18 }
19 if ( "" == $target ) {
20 $wgOut->errorpage( "notargettitle", "notargettext" );
21 return;
22 }
23 $nt = Title::newFromURL( $target );
24 if( !$nt ) {
25 $wgOut->errorpage( "notargettitle", "notargettext" );
26 return;
27 }
28 $id = $nt->getArticleId();
29
30 $wgOut->setSubtitle( wfMsg( "rclsub", $nt->getPrefixedText() ) );
31
32 if ( ! $days ) {
33 $days = $wgUser->getOption( "rcdays" );
34 if ( ! $days ) { $days = 7; }
35 }
36 $days = (int)$days;
37 list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
38 $cutoff = wfUnix2Timestamp( time() - ( $days * 86400 ) );
39
40 $hideminor = ($hideminor ? 1 : 0);
41 if ( $hideminor ) {
42 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
43 WfMsg( "show" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
44 "&days={$days}&limit={$limit}&hideminor=0" );
45 } else {
46 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
47 WfMsg( "hide" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
48 "&days={$days}&limit={$limit}&hideminor=1" );
49 }
50 if ( $hideminor ) {
51 $cmq = "AND cur_minor_edit=0";
52 } else { $cmq = ""; }
53
54 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
55 "cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM links, cur " .
56 "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from=$id " .
57 "GROUP BY cur_id ORDER BY inverse_timestamp LIMIT {$limit}";
58 $res = wfQuery( $sql, DB_READ, $fname );
59
60 $wgOut->addHTML("&lt; ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
61 $note = wfMsg( "rcnote", $limit, $days );
62 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
63
64 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
65 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
66 false, $mlink );
67
68 $wgOut->addHTML( "{$note}\n" );
69
70 $s = $sk->beginRecentChangesList();
71 $count = wfNumRows( $res );
72
73 $counter = 1;
74 while ( $limit ) {
75 if ( 0 == $count ) { break; }
76 $obj = wfFetchObject( $res );
77 --$count;
78
79 $rc = RecentChange::newFromCurRow( $obj );
80 $rc->counter = $counter++;
81 $s .= $sk->recentChangesLine( $rc );
82 --$limit;
83 }
84 $s .= $sk->endRecentChangesList();
85
86 wfFreeResult( $res );
87 $wgOut->addHTML( $s );
88 }
89
90 ?>