wiki.techinc.nl/includes/SpecialRecentchangeslinked.php

159 lines
4.3 KiB
PHP
Raw Normal View History

<?php
/**
2004-09-03 15:23:37 +00:00
* This is to display changes made to all articles linked in an article.
* @package MediaWiki
* @subpackage SpecialPage
*/
/**
*
*/
2004-09-03 15:23:37 +00:00
require_once( 'SpecialRecentchanges.php' );
2003-04-14 23:10:40 +00:00
/**
2004-09-03 15:23:37 +00:00
* Entrypoint
* @param string $par parent page we will look at
*/
function wfSpecialRecentchangeslinked( $par = NULL ) {
2005-12-04 18:27:59 +00:00
global $wgUser, $wgOut, $wgContLang, $wgRequest;
2004-09-03 15:23:37 +00:00
$fname = 'wfSpecialRecentchangeslinked';
2003-04-14 23:10:40 +00:00
2004-04-01 12:53:01 +00:00
$days = $wgRequest->getInt( 'days' );
$target = isset($par) ? $par : $wgRequest->getText( 'target' );
2004-04-01 12:53:01 +00:00
$hideminor = $wgRequest->getBool( 'hideminor' ) ? 1 : 0;
$wgOut->setPagetitle( wfMsg( 'recentchangeslinked' ) );
2003-04-14 23:10:40 +00:00
$sk = $wgUser->getSkin();
if (is_null($target)) {
2004-09-03 15:23:37 +00:00
$wgOut->errorpage( 'notargettitle', 'notargettext' );
2003-04-14 23:10:40 +00:00
return;
}
$nt = Title::newFromURL( $target );
if( !$nt ) {
2004-09-03 15:23:37 +00:00
$wgOut->errorpage( 'notargettitle', 'notargettext' );
return;
}
$id = $nt->getArticleId();
$wgOut->setSubtitle( htmlspecialchars( wfMsg( 'rclsub', $nt->getPrefixedText() ) ) );
2003-04-14 23:10:40 +00:00
if ( ! $days ) {
2004-09-03 15:23:37 +00:00
$days = $wgUser->getOption( 'rcdays' );
2003-04-14 23:10:40 +00:00
if ( ! $days ) { $days = 7; }
}
$days = (int)$days;
2004-09-03 15:23:37 +00:00
list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
$dbr =& wfGetDB( DB_SLAVE );
$cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
2003-04-14 23:10:40 +00:00
$hideminor = ($hideminor ? 1 : 0);
2003-04-14 23:10:40 +00:00
if ( $hideminor ) {
$mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
2005-08-16 21:02:15 +00:00
wfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
2003-04-14 23:10:40 +00:00
"&days={$days}&limit={$limit}&hideminor=0" );
} else {
$mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
2005-08-16 21:02:15 +00:00
wfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
2003-04-14 23:10:40 +00:00
"&days={$days}&limit={$limit}&hideminor=1" );
}
if ( $hideminor ) {
$cmq = 'AND rc_minor=0';
2004-09-03 15:23:37 +00:00
} else { $cmq = ''; }
2003-04-14 23:10:40 +00:00
extract( $dbr->tableNames( 'recentchanges', 'categorylinks', 'pagelinks', 'revision', 'page' ) );
2005-02-08 20:46:22 +00:00
// If target is a Category, use categorylinks and invert from and to
if( $nt->getNamespace() == NS_CATEGORY ) {
$catkey = $dbr->addQuotes( $nt->getDBKey() );
$sql = "SELECT /* wfSpecialRecentchangeslinked */
rc_id,
rc_cur_id,
rc_namespace,
rc_title,
rc_this_oldid,
rc_last_oldid,
rc_user,
rc_comment,
rc_user_text,
rc_timestamp,
rc_minor,
rc_new,
rc_patrolled,
rc_type
FROM $categorylinks, $recentchanges
WHERE rc_timestamp > '{$cutoff}'
{$cmq}
AND cl_from=rc_cur_id
AND cl_to=$catkey
GROUP BY rc_cur_id,rc_namespace,rc_title,
rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,
rc_new
ORDER BY rc_timestamp DESC
LIMIT {$limit};
";
} else {
$sql =
"SELECT /* wfSpecialRecentchangeslinked */
rc_id,
rc_cur_id,
rc_namespace,
rc_title,
rc_user,
rc_comment,
rc_user_text,
rc_this_oldid,
rc_last_oldid,
rc_timestamp,
rc_minor,
rc_new,
rc_patrolled,
rc_type
FROM $pagelinks, $recentchanges
WHERE rc_timestamp > '{$cutoff}'
{$cmq}
AND pl_namespace=rc_namespace
AND pl_title=rc_title
AND pl_from=$id
GROUP BY rc_cur_id,rc_namespace,rc_title,
rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,
rc_new
ORDER BY rc_timestamp DESC
LIMIT {$limit}";
}
$res = $dbr->query( $sql, $fname );
2003-04-14 23:10:40 +00:00
2004-05-06 15:30:05 +00:00
$wgOut->addHTML("&lt; ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
$note = wfMsg( "rcnote", $limit, $days );
$wgOut->addHTML( "<hr />\n{$note}\n<br />" );
2003-04-14 23:10:40 +00:00
$note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
"target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
false, $mlink );
2004-09-03 15:23:37 +00:00
$wgOut->addHTML( $note."\n" );
2003-04-14 23:10:40 +00:00
$list = ChangesList::newFromUser( $wgUser );
$s = $list->beginRecentChangesList();
$count = $dbr->numRows( $res );
2004-04-19 09:15:01 +00:00
$counter = 1;
2003-04-14 23:10:40 +00:00
while ( $limit ) {
if ( 0 == $count ) { break; }
$obj = $dbr->fetchObject( $res );
2003-04-14 23:10:40 +00:00
--$count;
$rc = RecentChange::newFromRow( $obj );
2004-04-19 09:15:01 +00:00
$rc->counter = $counter++;
$s .= $list->recentChangesLine( $rc );
2003-04-14 23:10:40 +00:00
--$limit;
}
$s .= $list->endRecentChangesList();
2003-04-14 23:10:40 +00:00
$dbr->freeResult( $res );
2003-04-14 23:10:40 +00:00
$wgOut->addHTML( $s );
}
?>