diff options
Diffstat (limited to 'includes/specials/SpecialRecentchangeslinked.php')
-rw-r--r-- | includes/specials/SpecialRecentchangeslinked.php | 101 |
1 files changed, 45 insertions, 56 deletions
diff --git a/includes/specials/SpecialRecentchangeslinked.php b/includes/specials/SpecialRecentchangeslinked.php index 862736d3..a8447046 100644 --- a/includes/specials/SpecialRecentchangeslinked.php +++ b/includes/specials/SpecialRecentchangeslinked.php @@ -29,7 +29,7 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges { var $rclTargetTitle; - function __construct(){ + function __construct() { parent::__construct( 'Recentchangeslinked' ); } @@ -37,7 +37,6 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges { $opts = parent::getDefaultOptions(); $opts->add( 'target', '' ); $opts->add( 'showlinkedto', false ); - $opts->add( 'tagfilter', '' ); return $opts; } @@ -51,13 +50,13 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges { return $opts; } - public function getFeedObject( $feedFormat ){ + public function getFeedObject( $feedFormat ) { $feed = new ChangesFeed( $feedFormat, false ); $feedObj = $feed->getFeedObject( $this->msg( 'recentchangeslinked-title', $this->getTargetTitle()->getPrefixedText() ) ->inContentLanguage()->text(), $this->msg( 'recentchangeslinked-feed' )->inContentLanguage()->text(), - $this->getTitle()->getFullUrl() + $this->getTitle()->getFullURL() ); return array( $feed, $feedObj ); } @@ -72,8 +71,8 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges { } $outputPage = $this->getOutput(); $title = Title::newFromURL( $target ); - if( !$title || $title->getInterwiki() != '' ){ - $outputPage->wrapWikiMsg( "<div class=\"errorbox\">\n$1\n</div><br style=\"clear: both\" />", 'allpagesbadtitle' ); + if ( !$title || $title->getInterwiki() != '' ) { + $outputPage->wrapWikiMsg( "<div class=\"errorbox\">\n$1\n</div>", 'allpagesbadtitle' ); return false; } @@ -94,20 +93,24 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges { $dbkey = $title->getDBkey(); $tables = array( 'recentchanges' ); - $select = array( $dbr->tableName( 'recentchanges' ) . '.*' ); + $select = RecentChange::selectFields(); $join_conds = array(); $query_options = array(); // left join with watchlist table to highlight watched rows $uid = $this->getUser()->getId(); - if( $uid ) { + if ( $uid && $this->getUser()->isAllowed( 'viewmywatchlist' ) ) { $tables[] = 'watchlist'; $select[] = 'wl_user'; - $join_conds['watchlist'] = array( 'LEFT JOIN', "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace" ); + $join_conds['watchlist'] = array( 'LEFT JOIN', array( + 'wl_user' => $uid, + 'wl_title=rc_title', + 'wl_namespace=rc_namespace' + )); } if ( $this->getUser()->isAllowed( 'rollback' ) ) { $tables[] = 'page'; - $join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id'); + $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' ); $select[] = 'page_latest'; } ChangeTags::modifyDisplayQuery( @@ -123,21 +126,21 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges { return false; } - if( $ns == NS_CATEGORY && !$showlinkedto ) { + if ( $ns == NS_CATEGORY && !$showlinkedto ) { // special handling for categories - // XXX: should try to make this less klugy + // XXX: should try to make this less kludgy $link_tables = array( 'categorylinks' ); $showlinkedto = true; } else { // for now, always join on these tables; really should be configurable as in whatlinkshere $link_tables = array( 'pagelinks', 'templatelinks' ); // imagelinks only contains links to pages in NS_FILE - if( $ns == NS_FILE || !$showlinkedto ) { + if ( $ns == NS_FILE || !$showlinkedto ) { $link_tables[] = 'imagelinks'; } } - if( $id == 0 && !$showlinkedto ) { + if ( $id == 0 && !$showlinkedto ) { return false; // nonexistent pages can't link to any pages } @@ -146,22 +149,22 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges { $subsql = array(); // SELECT statements to combine with UNION - foreach( $link_tables as $link_table ) { + foreach ( $link_tables as $link_table ) { $pfx = $prefix[$link_table]; // imagelinks and categorylinks tables have no xx_namespace field, and have xx_to instead of xx_title - if( $link_table == 'imagelinks' ) { + if ( $link_table == 'imagelinks' ) { $link_ns = NS_FILE; - } elseif( $link_table == 'categorylinks' ) { + } elseif ( $link_table == 'categorylinks' ) { $link_ns = NS_CATEGORY; } else { $link_ns = 0; } - if( $showlinkedto ) { + if ( $showlinkedto ) { // find changes to pages linking to this page - if( $link_ns ) { - if( $ns != $link_ns ) { + if ( $link_ns ) { + if ( $ns != $link_ns ) { continue; } // should never happen, but check anyway $subconds = array( "{$pfx}_to" => $dbkey ); @@ -172,15 +175,15 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges { } else { // find changes to pages linked from this page $subconds = array( "{$pfx}_from" => $id ); - if( $link_table == 'imagelinks' || $link_table == 'categorylinks' ) { + if ( $link_table == 'imagelinks' || $link_table == 'categorylinks' ) { $subconds["rc_namespace"] = $link_ns; $subjoin = "rc_title = {$pfx}_to"; } else { - $subjoin = "rc_namespace = {$pfx}_namespace AND rc_title = {$pfx}_title"; + $subjoin = array( "rc_namespace = {$pfx}_namespace", "rc_title = {$pfx}_title" ); } } - if( $dbr->unionSupportsOrderAndLimit()) { + if ( $dbr->unionSupportsOrderAndLimit() ) { $order = array( 'ORDER BY' => 'rc_timestamp DESC' ); } else { $order = array(); @@ -195,26 +198,27 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges { $join_conds + array( $link_table => array( 'INNER JOIN', $subjoin ) ) ); - if( $dbr->unionSupportsOrderAndLimit()) + if ( $dbr->unionSupportsOrderAndLimit() ) { $query = $dbr->limitResult( $query, $limit ); + } $subsql[] = $query; } - if( count($subsql) == 0 ) { + if ( count( $subsql ) == 0 ) { return false; // should never happen } - if( count($subsql) == 1 && $dbr->unionSupportsOrderAndLimit() ) { + if ( count( $subsql ) == 1 && $dbr->unionSupportsOrderAndLimit() ) { $sql = $subsql[0]; } else { // need to resort and relimit after union - $sql = $dbr->unionQueries($subsql, false).' ORDER BY rc_timestamp DESC'; - $sql = $dbr->limitResult($sql, $limit, false); + $sql = $dbr->unionQueries( $subsql, false ) . ' ORDER BY rc_timestamp DESC'; + $sql = $dbr->limitResult( $sql, $limit, false ); } $res = $dbr->query( $sql, __METHOD__ ); - if( $res->numRows() == 0 ) { + if ( $res->numRows() == 0 ) { $this->mResultEmpty = true; } @@ -222,21 +226,21 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges { } /** - * @param $opts FormOptions + * Get options to be displayed in a form + * + * @param FormOptions $opts * @return array */ - function getExtraOptions( $opts ){ - $opts->consumeValues( array( 'showlinkedto', 'target', 'tagfilter' ) ); - $extraOpts = array(); - $extraOpts['namespace'] = $this->namespaceFilterForm( $opts ); + function getExtraOptions( $opts ) { + $extraOpts = parent::getExtraOptions( $opts ); + + $opts->consumeValues( array( 'showlinkedto', 'target' ) ); + $extraOpts['target'] = array( $this->msg( 'recentchangeslinked-page' )->escaped(), - Xml::input( 'target', 40, str_replace('_',' ',$opts['target']) ) . - Xml::check( 'showlinkedto', $opts['showlinkedto'], array('id' => 'showlinkedto') ) . ' ' . + Xml::input( 'target', 40, str_replace( '_', ' ', $opts['target'] ) ) . + Xml::check( 'showlinkedto', $opts['showlinkedto'], array( 'id' => 'showlinkedto' ) ) . ' ' . Xml::label( $this->msg( 'recentchangeslinked-to' )->text(), 'showlinkedto' ) ); - $tagFilter = ChangeTags::buildTagFilterSelector( $opts['tagfilter'] ); - if ($tagFilter) { - $extraOpts['tagfilter'] = $tagFilter; - } + return $extraOpts; } @@ -257,23 +261,8 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges { function setTopText( FormOptions $opts ) { $target = $this->getTargetTitle(); - if( $target ) { + if ( $target ) { $this->getOutput()->addBacklinkSubtitle( $target ); } } - - public function getFeedQuery() { - $target = $this->getTargetTitle(); - if( $target ) { - return "target=" . urlencode( $target->getPrefixedDBkey() ); - } else { - return false; - } - } - - function setBottomText( FormOptions $opts ) { - if( isset( $this->mResultEmpty ) && $this->mResultEmpty ) { - $this->getOutput()->addWikiMsg( 'recentchangeslinked-noresult' ); - } - } } |