New global config setting $wgMaxTocLevel: Maximum indent level of toc.
[lhc/web/wiklou.git] / includes / SpecialRecentchangeslinked.php
1 <?php
2 require_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 $dbr =& wfGetDB( DB_SLAVE );
55 extract( $dbr->tableNames( 'cur', 'links' ) );
56
57 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
58 "cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM $links, $cur " .
59 "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from=$id " .
60 "GROUP BY cur_id ORDER BY inverse_timestamp LIMIT {$limit}";
61 $res = $dbr->query( $sql, $fname );
62
63 $wgOut->addHTML("&lt; ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
64 $note = wfMsg( "rcnote", $limit, $days );
65 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
66
67 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
68 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
69 false, $mlink );
70
71 $wgOut->addHTML( "{$note}\n" );
72
73 $s = $sk->beginRecentChangesList();
74 $count = $dbr->numRows( $res );
75
76 $counter = 1;
77 while ( $limit ) {
78 if ( 0 == $count ) { break; }
79 $obj = $dbr->fetchObject( $res );
80 --$count;
81
82 $rc = RecentChange::newFromCurRow( $obj );
83 $rc->counter = $counter++;
84 $s .= $sk->recentChangesLine( $rc );
85 --$limit;
86 }
87 $s .= $sk->endRecentChangesList();
88
89 $dbr->freeResult( $res );
90 $wgOut->addHTML( $s );
91 }
92
93 ?>