4 * This is to display changes made to all articles linked in an article.
7 class SpecialRecentchangeslinked
extends SpecialRecentchanges
{
9 function __construct(){
10 SpecialPage
::SpecialPage( 'Recentchangeslinked' );
13 public function getDefaultOptions() {
14 $opts = parent
::getDefaultOptions();
15 $opts->add( 'target', '' );
16 $opts->add( 'showlinkedto', false );
20 public function parseParameters( $par, FormOptions
$opts ) {
21 $opts['target'] = $par;
24 public function feedSetup(){
26 $opts = parent
::feedSetup();
27 $opts['target'] = $wgRequest->getVal( 'target' );
31 public function getFeedObject( $feedFormat ){
32 $feed = new ChangesFeed( $feedFormat, false );
33 $feedObj = $feed->getFeedObject(
34 wfMsgForContent( 'recentchangeslinked-title', $this->mTargetTitle
->getPrefixedText() ),
35 wfMsgForContent( 'recentchangeslinked' )
37 return array( $feed, $feedObj );
40 public function doMainQuery( $conds, $opts ) {
41 global $wgUser, $wgOut;
43 $title = Title
::newFromURL( $opts['target'] );
44 $showlinkedto = $opts['showlinkedto'];
45 $limit = $opts['limit'];
47 $target = $title ?
$title->getPrefixedText() : '';
48 if ( $target === '' ) {
53 $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
57 $wgOut->setPageTitle( wfMsg( 'recentchangeslinked-title', $target ) );
58 $this->mTargetTitle
= $title;
60 $dbr = wfGetDB( DB_SLAVE
, 'recentchangeslinked' );
61 $id = $title->getArticleId();
63 $tables = array( 'recentchanges' );
64 $select = array( $dbr->tableName( 'recentchanges' ) . '.*' );
65 $join_conds = array();
67 if( $title->getNamespace() == NS_CATEGORY
) {
68 $tables[] = 'categorylinks';
69 $conds['cl_to'] = $title->getDBkey();
70 $join_conds['categorylinks'] = array( 'LEFT JOIN', 'cl_from=rc_cur_id' );
73 if( $title->getNamespace() == NS_TEMPLATE
){
74 $tables[] = 'templatelinks';
75 $conds['tl_namespace'] = $title->getNamespace();
76 $conds['tl_title'] = $title->getDBkey();
77 $join_conds['templatelinks'] = array( 'LEFT JOIN', 'tl_from=rc_cur_id' );
79 $tables[] = 'pagelinks';
80 $conds['pl_namespace'] = $title->getNamespace();
81 $conds['pl_title'] = $title->getDBkey();
82 $join_conds['pagelinks'] = array( 'LEFT JOIN', 'pl_from=rc_cur_id' );
85 $tables[] = 'pagelinks';
86 $conds['pl_from'] = $id;
87 $join_conds['pagelinks'] = array( 'LEFT JOIN', 'pl_namespace = rc_namespace AND pl_title = rc_title' );
91 if( $uid = $wgUser->getId() ) {
92 $tables[] = 'watchlist';
93 $join_conds['watchlist'] = array( 'LEFT JOIN', "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace" );
94 $select[] = 'wl_user';
97 $res = $dbr->select( $tables, $select, $conds, __METHOD__
,
98 array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ), $join_conds );
100 if( $dbr->numRows( $res ) == 0 )
101 $this->mResultEmpty
= true;
106 function getExtraOptions( $opts ){
107 $opts->consumeValues( array( 'showlinkedto', 'target' ) );
108 $extraOpts = array();
109 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
110 $extraOpts['target'] = array( wfMsg( 'recentchangeslinked-page' ),
111 Xml
::input( 'target', 40, $opts['target'] ) .
112 Xml
::check( 'showlinkedto', $opts['showlinkedto'], array('id' => 'showlinkedto') ) . ' ' .
113 Xml
::label( wfMsg("recentchangeslinked-to"), 'showlinkedto' ) );
114 $extraOpts['submit'] = Xml
::submitbutton( wfMsg('allpagessubmit') );
118 function setTopText( &$out, $opts ){}
120 function setBottomText( &$out, $opts ){
121 if( $target = $opts['target'] ){
123 $out->setFeedAppendQuery( "target=" . urlencode( $target ) );
124 $out->addHTML("< ".$wgUser->getSkin()->makeLinkObj( Title
::newFromUrl( $target ), "", "redirect=no" )."<hr />\n");
126 if( isset( $this->mResultEmpty
) && $this->mResultEmpty
){
127 $out->addWikiMsg( 'recentchangeslinked-noresult' );