X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28%27votes%27%2C%20votes=%27waiting%27%29%20%7D%7D?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialRecentchangeslinked.php;h=862736d3f8b264a6c3475a321064d8125efff60e;hb=67bfdc7a68940d901e585eadd984a2074bf0216a;hp=1812eb6836f9c790eec9dcb94fc8ca7efb651f92;hpb=dc77abf2864bfd00a75c7fa5aae739fa8e4228e2;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/specials/SpecialRecentchangeslinked.php b/includes/specials/SpecialRecentchangeslinked.php
index 1812eb6836..862736d3f8 100644
--- a/includes/specials/SpecialRecentchangeslinked.php
+++ b/includes/specials/SpecialRecentchangeslinked.php
@@ -1,14 +1,36 @@
includable( true );
+ parent::__construct( 'Recentchangeslinked' );
}
public function getDefaultOptions() {
@@ -24,25 +46,23 @@ class SpecialRecentchangeslinked extends SpecialRecentchanges {
}
public function feedSetup() {
- global $wgRequest;
$opts = parent::feedSetup();
- # Feed is cached on limit,hideminor,target; other params would randomly not work
- $opts['target'] = $wgRequest->getVal( 'target' );
+ $opts['target'] = $this->getRequest()->getVal( 'target' );
return $opts;
}
public function getFeedObject( $feedFormat ){
$feed = new ChangesFeed( $feedFormat, false );
$feedObj = $feed->getFeedObject(
- wfMsgForContent( 'recentchangeslinked-title', $this->mTargetTitle->getPrefixedText() ),
- wfMsgForContent( 'recentchangeslinked' )
+ $this->msg( 'recentchangeslinked-title', $this->getTargetTitle()->getPrefixedText() )
+ ->inContentLanguage()->text(),
+ $this->msg( 'recentchangeslinked-feed' )->inContentLanguage()->text(),
+ $this->getTitle()->getFullUrl()
);
return array( $feed, $feedObj );
}
public function doMainQuery( $conds, $opts ) {
- global $wgUser, $wgOut;
-
$target = $opts['target'];
$showlinkedto = $opts['showlinkedto'];
$limit = $opts['limit'];
@@ -50,14 +70,14 @@ class SpecialRecentchangeslinked extends SpecialRecentchanges {
if ( $target === '' ) {
return false;
}
+ $outputPage = $this->getOutput();
$title = Title::newFromURL( $target );
if( !$title || $title->getInterwiki() != '' ){
- $wgOut->wrapWikiMsg( '
$1
', 'allpagesbadtitle' );
+ $outputPage->wrapWikiMsg( "\n$1\n
", 'allpagesbadtitle' );
return false;
}
- $this->mTargetTitle = $title;
- $wgOut->setPageTitle( wfMsg( 'recentchangeslinked-title', $title->getPrefixedText() ) );
+ $outputPage->setPageTitle( $this->msg( 'recentchangeslinked-title', $title->getPrefixedText() ) );
/*
* Ordinary links are in the pagelinks table, while transclusions are
@@ -69,25 +89,39 @@ class SpecialRecentchangeslinked extends SpecialRecentchanges {
*/
$dbr = wfGetDB( DB_SLAVE, 'recentchangeslinked' );
- $id = $title->getArticleId();
+ $id = $title->getArticleID();
$ns = $title->getNamespace();
$dbkey = $title->getDBkey();
$tables = array( 'recentchanges' );
$select = array( $dbr->tableName( 'recentchanges' ) . '.*' );
$join_conds = array();
+ $query_options = array();
// left join with watchlist table to highlight watched rows
- if( $uid = $wgUser->getId() ) {
+ $uid = $this->getUser()->getId();
+ if( $uid ) {
$tables[] = 'watchlist';
$select[] = 'wl_user';
$join_conds['watchlist'] = array( 'LEFT JOIN', "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace" );
}
+ if ( $this->getUser()->isAllowed( 'rollback' ) ) {
+ $tables[] = 'page';
+ $join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
+ $select[] = 'page_latest';
+ }
+ ChangeTags::modifyDisplayQuery(
+ $tables,
+ $select,
+ $conds,
+ $join_conds,
+ $query_options,
+ $opts['tagfilter']
+ );
- ChangeTags::modifyDisplayQuery( $tables, $select, $conds, $join_conds, $opts['tagfilter'] );
-
- // XXX: parent class does this, should we too?
- // wfRunHooks('SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts ) );
+ if ( !wfRunHooks( 'SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$select ) ) ) {
+ return false;
+ }
if( $ns == NS_CATEGORY && !$showlinkedto ) {
// special handling for categories
@@ -98,11 +132,14 @@ class SpecialRecentchangeslinked extends SpecialRecentchanges {
// 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 ) $link_tables[] = 'imagelinks';
+ 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
+ }
// field name prefixes for all the various tables we might want to join with
$prefix = array( 'pagelinks' => 'pl', 'templatelinks' => 'tl', 'categorylinks' => 'cl', 'imagelinks' => 'il' );
@@ -113,14 +150,20 @@ class SpecialRecentchangeslinked extends SpecialRecentchanges {
$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' ) $link_ns = NS_FILE;
- else if( $link_table == 'categorylinks' ) $link_ns = NS_CATEGORY;
- else $link_ns = 0;
+ if( $link_table == 'imagelinks' ) {
+ $link_ns = NS_FILE;
+ } elseif( $link_table == 'categorylinks' ) {
+ $link_ns = NS_CATEGORY;
+ } else {
+ $link_ns = 0;
+ }
if( $showlinkedto ) {
// find changes to pages linking to this page
if( $link_ns ) {
- if( $ns != $link_ns ) continue; // should never happen, but check anyway
+ if( $ns != $link_ns ) {
+ continue;
+ } // should never happen, but check anyway
$subconds = array( "{$pfx}_to" => $dbkey );
} else {
$subconds = array( "{$pfx}_namespace" => $ns, "{$pfx}_title" => $dbkey );
@@ -137,62 +180,100 @@ class SpecialRecentchangeslinked extends SpecialRecentchanges {
}
}
- $subsql[] = $dbr->selectSQLText(
- array_merge( $tables, array( $link_table ) ),
- $select,
+ if( $dbr->unionSupportsOrderAndLimit()) {
+ $order = array( 'ORDER BY' => 'rc_timestamp DESC' );
+ } else {
+ $order = array();
+ }
+
+ $query = $dbr->selectSQLText(
+ array_merge( $tables, array( $link_table ) ),
+ $select,
$conds + $subconds,
- __METHOD__,
- array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ),
+ __METHOD__,
+ $order + $query_options,
$join_conds + array( $link_table => array( 'INNER JOIN', $subjoin ) )
);
+
+ 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 )
+ }
+ if( count($subsql) == 1 && $dbr->unionSupportsOrderAndLimit() ) {
$sql = $subsql[0];
- else {
+ } else {
// need to resort and relimit after union
- $sql = "(" . implode( ") UNION (", $subsql ) . ") ORDER BY rc_timestamp DESC LIMIT {$limit}";
+ $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;
+ }
return $res;
}
-
+
+ /**
+ * @param $opts FormOptions
+ * @return array
+ */
function getExtraOptions( $opts ){
- $opts->consumeValues( array( 'showlinkedto', 'target' ) );
+ $opts->consumeValues( array( 'showlinkedto', 'target', 'tagfilter' ) );
$extraOpts = array();
$extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
- $extraOpts['target'] = array( wfMsg( 'recentchangeslinked-page' ),
+ $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::label( wfMsg("recentchangeslinked-to"), 'showlinkedto' ) );
+ Xml::label( $this->msg( 'recentchangeslinked-to' )->text(), 'showlinkedto' ) );
$tagFilter = ChangeTags::buildTagFilterSelector( $opts['tagfilter'] );
- if ($tagFilter)
+ if ($tagFilter) {
$extraOpts['tagfilter'] = $tagFilter;
+ }
return $extraOpts;
}
- function setTopText( OutputPage $out, FormOptions $opts ) {
- global $wgUser;
- $skin = $wgUser->getSkin();
- if( isset( $this->mTargetTitle ) && is_object( $this->mTargetTitle ) )
- $out->setSubtitle( wfMsg( 'recentchangeslinked-backlink', $skin->link( $this->mTargetTitle,
- $this->mTargetTitle->getPrefixedText(), array(), array( 'redirect' => 'no' ) ) ) );
+ /**
+ * @return Title
+ */
+ function getTargetTitle() {
+ if ( $this->rclTargetTitle === null ) {
+ $opts = $this->getOptions();
+ if ( isset( $opts['target'] ) && $opts['target'] !== '' ) {
+ $this->rclTargetTitle = Title::newFromText( $opts['target'] );
+ } else {
+ $this->rclTargetTitle = false;
+ }
+ }
+ return $this->rclTargetTitle;
+ }
+
+ function setTopText( FormOptions $opts ) {
+ $target = $this->getTargetTitle();
+ if( $target ) {
+ $this->getOutput()->addBacklinkSubtitle( $target );
+ }
}
- function setBottomText( OutputPage $out, FormOptions $opts ){
- if( isset( $this->mTargetTitle ) && is_object( $this->mTargetTitle ) ){
- global $wgUser;
- $out->setFeedAppendQuery( "target=" . urlencode( $this->mTargetTitle->getPrefixedDBkey() ) );
+ public function getFeedQuery() {
+ $target = $this->getTargetTitle();
+ if( $target ) {
+ return "target=" . urlencode( $target->getPrefixedDBkey() );
+ } else {
+ return false;
}
- if( isset( $this->mResultEmpty ) && $this->mResultEmpty ){
- $out->addWikiMsg( 'recentchangeslinked-noresult' );
+ }
+
+ function setBottomText( FormOptions $opts ) {
+ if( isset( $this->mResultEmpty ) && $this->mResultEmpty ) {
+ $this->getOutput()->addWikiMsg( 'recentchangeslinked-noresult' );
}
}
}