* Removed messages in English, they'll be inherited from the parent.
[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 extract( $dbr->tableNames( 'categorylinks', 'links', 'revision', 'page' ) );
69
70 // If target is a Category, use categorylinks and invert from and to
71 if( $nt->getNamespace() == NS_CATEGORY ) {
72 $catkey = $dbr->addQuotes( $nt->getDBKey() );
73 $sql = "SELECT page_id,page_namespace,page_title,rev_user,rev_comment," .
74 "rev_user_text,rev_timestamp,rev_minor_edit,page_is_new FROM $categorylinks, $revision, $page " .
75 "WHERE rev_timestamp > '{$cutoff}' {$cmq} AND cl_from=page_id AND cl_to=$catkey " .
76 "GROUP BY page_id,page_namespace,page_title,rev_user,rev_comment,rev_user_text," .
77 "rev_timestamp,rev_minor_edit,page_is_new ORDER BY rev_timestamp DESC LIMIT {$limit}";
78 } else {
79 $sql = "SELECT page_id,page_namespace,page_title,rev_user,rev_comment," .
80 "rev_user_text,rev_timestamp,rev_minor_edit,page_is_new FROM $links, $revision, $page " .
81 "WHERE rev_timestamp > '{$cutoff}' {$cmq} AND l_to=page_id AND l_from=$id " .
82 "GROUP BY page_id,page_namespace,page_title,rev_user,rev_comment,rev_user_text," .
83 "rev_timestamp,rev_minor_edit,page_is_new ORDER BY rev_timestamp DESC LIMIT {$limit}";
84 }
85 $res = $dbr->query( $sql, $fname );
86
87 $wgOut->addHTML("&lt; ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
88 $note = wfMsg( "rcnote", $limit, $days );
89 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
90
91 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
92 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
93 false, $mlink );
94
95 $wgOut->addHTML( $note."\n" );
96
97 $list =& new ChangesList( $sk );
98 $s = $list->beginRecentChangesList();
99 $count = $dbr->numRows( $res );
100
101 $counter = 1;
102 while ( $limit ) {
103 if ( 0 == $count ) { break; }
104 $obj = $dbr->fetchObject( $res );
105 --$count;
106
107 $rc = RecentChange::newFromCurRow( $obj );
108 $rc->counter = $counter++;
109 $s .= $list->recentChangesLine( $rc );
110 --$limit;
111 }
112 $s .= $list->endRecentChangesList();
113
114 $dbr->freeResult( $res );
115 $wgOut->addHTML( $s );
116 }
117
118 ?>