BUG#1402 Make link color of tab subject page link on talk page indicate whether artic...
[lhc/web/wiklou.git] / includes / SpecialRecentchangeslinked.php
1 <?php
2 /**
3 * This is to display changes made to all articles linked in an article.
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 /**
9 *
10 */
11 require_once( 'SpecialRecentchanges.php' );
12
13 /**
14 * Entrypoint
15 * @param string $par parent page we will look at
16 */
17 function wfSpecialRecentchangeslinked( $par = NULL ) {
18 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgTitle, $wgRequest;
19 $fname = 'wfSpecialRecentchangeslinked';
20
21 $days = $wgRequest->getInt( 'days' );
22 $target = $wgRequest->getText( 'target' );
23 $hideminor = $wgRequest->getBool( 'hideminor' ) ? 1 : 0;
24
25 $wgOut->setPagetitle( wfMsg( "recentchanges" ) );
26 $sk = $wgUser->getSkin();
27
28 if( $par ) {
29 $target = $par;
30 }
31 if ( $target == '') {
32 $wgOut->errorpage( 'notargettitle', 'notargettext' );
33 return;
34 }
35 $nt = Title::newFromURL( $target );
36 if( !$nt ) {
37 $wgOut->errorpage( 'notargettitle', 'notargettext' );
38 return;
39 }
40 $id = $nt->getArticleId();
41
42 $wgOut->setSubtitle( wfMsg( 'rclsub', $nt->getPrefixedText() ) );
43
44 if ( ! $days ) {
45 $days = $wgUser->getOption( 'rcdays' );
46 if ( ! $days ) { $days = 7; }
47 }
48 $days = (int)$days;
49 list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
50
51 $dbr =& wfGetDB( DB_SLAVE );
52 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
53
54 $hideminor = ($hideminor ? 1 : 0);
55 if ( $hideminor ) {
56 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
57 WfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
58 "&days={$days}&limit={$limit}&hideminor=0" );
59 } else {
60 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
61 WfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
62 "&days={$days}&limit={$limit}&hideminor=1" );
63 }
64 if ( $hideminor ) {
65 $cmq = 'AND rev_minor_edit=0';
66 } else { $cmq = ''; }
67
68 // If target is a Category, use categorylinks and invert from and to
69 if( $nt->getNamespace() == NS_CATEGORY ) {
70 $catkey = $dbr->addQuotes( $nt->getDBKey() );
71 $sql = "SELECT page_id,page_namespace,page_title,rev_user,rev_comment," .
72 "rev_user_text,rev_timestamp,rev_minor_edit,page_is_new FROM $categorylinks, $revision, $page " .
73 "WHERE rev_timestamp > '{$cutoff}' {$cmq} AND cl_from=page_id AND cl_to=$catkey " .
74 "GROUP BY page_id,page_namespace,page_title,rev_user,rev_comment,rev_user_text," .
75 "rev_timestamp,rev_minor_edit,page_is_new,inverse_timestamp ORDER BY inverse_timestamp LIMIT {$limit}";
76 } else {
77 $sql = "SELECT page_id,page_namespace,page_title,rev_user,rev_comment," .
78 "rev_user_text,rev_timestamp,rev_minor_edit,page_is_new FROM $links, $revision, $page " .
79 "WHERE rev_timestamp > '{$cutoff}' {$cmq} AND l_to=page_id AND l_from=$id " .
80 "GROUP BY page_id,page_namespace,page_title,rev_user,rev_comment,rev_user_text," .
81 "rev_timestamp,rev_minor_edit,page_is_new,inverse_timestamp ORDER BY inverse_timestamp LIMIT {$limit}";
82 }
83 $res = $dbr->query( $sql, $fname );
84
85 $wgOut->addHTML("&lt; ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
86 $note = wfMsg( "rcnote", $limit, $days );
87 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
88
89 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
90 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
91 false, $mlink );
92
93 $wgOut->addHTML( $note."\n" );
94
95 $list =& new ChangesList( $sk );
96 $s = $list->beginRecentChangesList();
97 $count = $dbr->numRows( $res );
98
99 $counter = 1;
100 while ( $limit ) {
101 if ( 0 == $count ) { break; }
102 $obj = $dbr->fetchObject( $res );
103 --$count;
104
105 $rc = RecentChange::newFromCurRow( $obj );
106 $rc->counter = $counter++;
107 $s .= $list->recentChangesLine( $rc );
108 --$limit;
109 }
110 $s .= $list->endRecentChangesList();
111
112 $dbr->freeResult( $res );
113 $wgOut->addHTML( $s );
114 }
115
116 ?>