getSkin(); $specialTitle = Title::makeTitle( NS_SPECIAL, 'Watchlist' ); $wgOut->setRobotPolicy( 'noindex,nofollow' ); # Anons don't get a watchlist if( $wgUser->isAnon() ) { $wgOut->setPageTitle( wfMsg( 'watchnologin' ) ); $llink = $skin->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Userlogin' ), wfMsgHtml( 'loginreqlink' ), 'returnto=' . $specialTitle->getPrefixedUrl() ); $wgOut->addHtml( wfMsgWikiHtml( 'watchlistanontext', $llink ) ); return; } else { $wgOut->setPageTitle( wfMsg( 'watchlist' ) ); $wgOut->setSubtitle( wfMsgWikiHtml( 'watchlistfor', htmlspecialchars( $wgUser->getName() ) ) ); } if( wlHandleClear( $wgOut, $wgRequest, $par ) ) { return; } $defaults = array( /* float */ 'days' => floatval( $wgUser->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */ /* bool */ 'hideOwn' => (int)$wgUser->getBoolOption( 'watchlisthideown' ), /* bool */ 'hideBots' => (int)$wgUser->getBoolOption( 'watchlisthidebots' ), /* ? */ 'namespace' => 'all', ); extract($defaults); # Extract variables from the request, falling back to user preferences or # other default values if these don't exist $prefs['days' ] = floatval( $wgUser->getOption( 'watchlistdays' ) ); $prefs['hideown' ] = $wgUser->getBoolOption( 'watchlisthideown' ); $prefs['hidebots'] = $wgUser->getBoolOption( 'watchlisthidebots' ); # Get query variables $days = $wgRequest->getVal( 'days', $prefs['days'] ); $hideOwn = $wgRequest->getBool( 'hideOwn', $prefs['hideown'] ); $hideBots = $wgRequest->getBool( 'hideBots', $prefs['hidebots'] ); # Get namespace value, if supplied, and prepare a WHERE fragment $nameSpace = $wgRequest->getIntOrNull( 'namespace' ); if( !is_null( $nameSpace ) ) { $nameSpace = intval( $nameSpace ); $nameSpaceClause = " AND rc_namespace = $nameSpace"; } else { $nameSpace = ''; $nameSpaceClause = ''; } # Watchlist editing $action = $wgRequest->getVal( 'action' ); $remove = $wgRequest->getVal( 'remove' ); $id = $wgRequest->getArray( 'id' ); $uid = $wgUser->getID(); if( $wgEnotifWatchlist && $wgRequest->getVal( 'reset' ) && $wgRequest->wasPosted() ) { $wgUser->clearAllNotifications( $uid ); } # Deleting items from watchlist if(($action == 'submit') && isset($remove) && is_array($id)) { $wgOut->addWikiText( wfMsg( 'removingchecked' ) ); $wgOut->addHTML( '
' );
foreach($id as $one) {
$t = Title::newFromURL( $one );
if( !is_null( $t ) ) {
$wl = WatchedItem::fromUserTitle( $wgUser, $t );
if( $wl->removeWatch() === false ) {
$wgOut->addHTML( wfMsg( 'couldntremove', htmlspecialchars($one) ) . "
\n" );
} else {
wfRunHooks('UnwatchArticle', array(&$wgUser, new Article($t)));
$wgOut->addHTML( '(' . htmlspecialchars($one) . ')
' );
}
} else {
$wgOut->addHTML( wfMsg( 'iteminvalidname', htmlspecialchars($one) ) . "
\n" );
}
}
$wgOut->addHTML( "
" . wfMsg( 'wldone' ) . "
\n" ); } if ( $wgUseWatchlistCache ) { $memckey = wfMemcKey( 'watchlist', 'id', $wgUser->getId() ); $cache_s = @$wgMemc->get( $memckey ); if( $cache_s ){ $wgOut->addWikiText( wfMsg('wlsaved') ); $wgOut->addHTML( $cache_s ); return; } } $dbr =& wfGetDB( DB_SLAVE ); extract( $dbr->tableNames( 'page', 'revision', 'watchlist', 'recentchanges' ) ); $sql = "SELECT COUNT(*) AS n FROM $watchlist WHERE wl_user=$uid"; $res = $dbr->query( $sql, $fname ); $s = $dbr->fetchObject( $res ); # Patch *** A1 *** (see A2 below) # adjust for page X, talk:page X, which are both stored separately, but treated together $nitems = floor($s->n / 2); # $nitems = $s->n; if($nitems == 0) { $wgOut->addWikiText( wfMsg( 'nowatchlist' ) ); return; } if( is_null($days) || !is_numeric($days) ) { $big = 1000; /* The magical big */ if($nitems > $big) { # Set default cutoff shorter $days = $defaults['days'] = (12.0 / 24.0); # 12 hours... } else { $days = $defaults['days']; # default cutoff for shortlisters } } else { $days = floatval($days); } // Dump everything here $nondefaults = array(); wfAppendToArrayIfNotDefault( 'days', $days, $defaults, $nondefaults); wfAppendToArrayIfNotDefault( 'hideOwn', (int)$hideOwn, $defaults, $nondefaults); wfAppendToArrayIfNotDefault( 'hideBots', (int)$hideBots, $defaults, $nondefaults); wfAppendToArrayIfNotDefault( 'namespace', $nameSpace, $defaults, $nondefaults ); if ( $days <= 0 ) { $docutoff = ''; $cutoff = false; $npages = wfMsg( 'watchlistall1' ); } else { $docutoff = "AND rev_timestamp > '" . ( $cutoff = $dbr->timestamp( time() - intval( $days * 86400 ) ) ) . "'"; /* $sql = "SELECT COUNT(*) AS n FROM $page, $revision WHERE rev_timestamp>'$cutoff' AND page_id=rev_page"; $res = $dbr->query( $sql, $fname ); $s = $dbr->fetchObject( $res ); $npages = $s->n; */ $npages = 40000 * $days; } /* Edit watchlist form */ if($wgRequest->getBool('edit') || $par == 'edit' ) { $wgOut->addWikiText( wfMsg( 'watchlistcontains', $wgLang->formatNum( $nitems ) ) . "\n\n" . wfMsg( 'watcheditlist' ) ); $wgOut->addHTML( '\n" ); return; } # If the watchlist is relatively short, it's simplest to zip # down its entirety and then sort the results. # If it's relatively long, it may be worth our while to zip # through the time-sorted page list checking for watched items. # Up estimate of watched items by 15% to compensate for talk pages... # Toggles $andHideOwn = $hideOwn ? "AND (rc_user <> $uid)" : ''; $andHideBots = $hideBots ? "AND (rc_bot = 0)" : ''; # Show watchlist header $header = ''; if( $wgUser->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist) { $header .= wfMsg( 'wlheader-enotif' ) . "\n"; } if ( $wgEnotifWatchlist && $wgShowUpdatedMarker ) { $header .= wfMsg( 'wlheader-showupdated' ) . "\n"; } # Toggle watchlist content (all recent edits or just the latest) if( $wgUser->getOption( 'extendwatchlist' )) { $andLatest=''; $limitWatchlist = 'LIMIT ' . intval( $wgUser->getOption( 'wllimit' ) ); } else { $andLatest= 'AND rc_this_oldid=page_latest'; $limitWatchlist = ''; } # TODO: Consider removing the third parameter $header .= wfMsgExt( 'watchdetails', array( 'parsemag' ), $wgLang->formatNum( $nitems ), $wgLang->formatNum( $npages ), '', $specialTitle->getFullUrl( 'edit=yes' ) ); $wgOut->addWikiText( $header ); if ( $wgEnotifWatchlist && $wgShowUpdatedMarker ) { $wgOut->addHTML( '' . "\n\n" ); } $sql = "SELECT rc_namespace AS page_namespace, rc_title AS page_title, rc_comment AS rev_comment, rc_cur_id AS page_id, rc_user AS rev_user, rc_user_text AS rev_user_text, rc_timestamp AS rev_timestamp, rc_minor AS rev_minor_edit, rc_this_oldid AS rev_id, rc_last_oldid, rc_id, rc_patrolled, rc_new AS page_is_new,wl_notificationtimestamp FROM $watchlist,$recentchanges,$page WHERE wl_user=$uid AND wl_namespace=rc_namespace AND wl_title=rc_title AND rc_timestamp > '$cutoff' AND rc_cur_id=page_id $andLatest $andHideOwn $andHideBots $nameSpaceClause ORDER BY rc_timestamp DESC $limitWatchlist"; $res = $dbr->query( $sql, $fname ); $numRows = $dbr->numRows( $res ); /* Start bottom header */ $wgOut->addHTML( "