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 $target = $opts['target'];
44 $showlinkedto = $opts['showlinkedto'];
45 $limit = $opts['limit'];
47 if ( $target === '' ) {
50 $title = Title
::newFromURL( $target );
51 if( !$title ||
$title->getInterwiki() != '' ){
52 $wgOut->wrapWikiMsg( '<div class="errorbox">$1</div><br clear="both" />', 'allpagesbadtitle' );
55 $this->mTargetTitle
= $title;
57 $wgOut->setPageTitle( wfMsg( 'recentchangeslinked-title', $title->getPrefixedText() ) );
59 $dbr = wfGetDB( DB_SLAVE
, 'recentchangeslinked' );
60 $id = $title->getArticleId();
62 $tables = array( 'recentchanges' );
63 $select = array( $dbr->tableName( 'recentchanges' ) . '.*' );
64 $join_conds = array();
66 if( $title->getNamespace() == NS_CATEGORY
) {
67 $tables[] = 'categorylinks';
68 $conds['cl_to'] = $title->getDBkey();
69 $join_conds['categorylinks'] = array( 'LEFT JOIN', 'cl_from=rc_cur_id' );
72 if( $title->getNamespace() == NS_TEMPLATE
){
73 $tables[] = 'templatelinks';
74 $conds['tl_namespace'] = $title->getNamespace();
75 $conds['tl_title'] = $title->getDBkey();
76 $join_conds['templatelinks'] = array( 'LEFT JOIN', 'tl_from=rc_cur_id' );
78 $tables[] = 'pagelinks';
79 $conds['pl_namespace'] = $title->getNamespace();
80 $conds['pl_title'] = $title->getDBkey();
81 $join_conds['pagelinks'] = array( 'LEFT JOIN', 'pl_from=rc_cur_id' );
84 $tables[] = 'pagelinks';
85 $conds['pl_from'] = $id;
86 $join_conds['pagelinks'] = array( 'LEFT JOIN', 'pl_namespace = rc_namespace AND pl_title = rc_title' );
90 if( $uid = $wgUser->getId() ) {
91 $tables[] = 'watchlist';
92 $join_conds['watchlist'] = array( 'LEFT JOIN', "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace" );
93 $select[] = 'wl_user';
96 $res = $dbr->select( $tables, $select, $conds, __METHOD__
,
97 array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ), $join_conds );
99 if( $dbr->numRows( $res ) == 0 )
100 $this->mResultEmpty
= true;
105 function getExtraOptions( $opts ){
106 $opts->consumeValues( array( 'showlinkedto', 'target' ) );
107 $extraOpts = array();
108 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
109 $extraOpts['target'] = array( wfMsg( 'recentchangeslinked-page' ),
110 Xml
::input( 'target', 40, str_replace('_',' ',$opts['target']) ) .
111 Xml
::check( 'showlinkedto', $opts['showlinkedto'], array('id' => 'showlinkedto') ) . ' ' .
112 Xml
::label( wfMsg("recentchangeslinked-to"), 'showlinkedto' ) );
113 $extraOpts['submit'] = Xml
::submitbutton( wfMsg('allpagessubmit') );
117 function setTopText( &$out, $opts ){}
119 function setBottomText( &$out, $opts ){
120 if( isset( $this->mTargetTitle
) && is_object( $this->mTargetTitle
) ){
122 $out->setFeedAppendQuery( "target=" . urlencode( $this->mTargetTitle
->getPrefixedDBkey() ) );
123 $out->addHTML("< ".$wgUser->getSkin()->makeLinkObj( $this->mTargetTitle
, "", "redirect=no" )."<hr />\n");
125 if( isset( $this->mResultEmpty
) && $this->mResultEmpty
){
126 $out->addWikiMsg( 'recentchangeslinked-noresult' );