wiki.techinc.nl/includes/SpecialRecentchangeslinked.php

106 lines
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.
*/
/**
*
*/
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 ) {
2004-04-01 12:53:01 +00:00
global $wgUser, $wgOut, $wgLang, $wgTitle, $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 = $wgRequest->getText( 'target' );
$hideminor = $wgRequest->getBool( 'hideminor' ) ? 1 : 0;
2003-04-14 23:10:40 +00:00
$wgOut->setPagetitle( wfMsg( "recentchanges" ) );
$sk = $wgUser->getSkin();
if( $par ) {
$target = $par;
}
2004-09-03 15:23:37 +00:00
if ( $target == '') {
$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();
2004-09-03 15:23:37 +00:00
$wgOut->setSubtitle( 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 ) {
2004-09-03 15:23:37 +00:00
$mlink = $sk->makeKnownLink( $wgLang->specialPage( 'Recentchangeslinked' ),
WfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
2003-04-14 23:10:40 +00:00
"&days={$days}&limit={$limit}&hideminor=0" );
} else {
$mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
WfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
2003-04-14 23:10:40 +00:00
"&days={$days}&limit={$limit}&hideminor=1" );
}
if ( $hideminor ) {
2004-09-03 15:23:37 +00:00
$cmq = 'AND cur_minor_edit=0';
} else { $cmq = ''; }
2003-04-14 23:10:40 +00:00
extract( $dbr->tableNames( 'cur', 'links' ) );
2003-04-14 23:10:40 +00:00
$sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
"cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM $links, $cur " .
"WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from=$id " .
"GROUP BY cur_id,cur_namespace,cur_title,cur_user,cur_comment,cur_user_text," .
"cur_timestamp,cur_minor_edit,cur_is_new,inverse_timestamp ORDER BY inverse_timestamp 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
$s = $sk->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::newFromCurRow( $obj );
2004-04-19 09:15:01 +00:00
$rc->counter = $counter++;
$s .= $sk->recentChangesLine( $rc );
2003-04-14 23:10:40 +00:00
--$limit;
}
$s .= $sk->endRecentChangesList();
$dbr->freeResult( $res );
2003-04-14 23:10:40 +00:00
$wgOut->addHTML( $s );
}
?>