X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialWatchlist.php;h=be82afed5e1542990e710532bdecae17eecc6c1d;hb=37b73a88820fda845e73f6a03f7406bad1e1d3b6;hp=a763e8b477f5e6b682d3e299cb807f98e2b56335;hpb=840dee3ad43a33d5b97b2e1dee64d5c04e255227;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php index a763e8b477..be82afed5e 100644 --- a/includes/SpecialWatchlist.php +++ b/includes/SpecialWatchlist.php @@ -1,12 +1,22 @@ setPagetitle( wfMsg( "watchlist" ) ); @@ -15,14 +25,19 @@ function wfSpecialWatchlist() $wgOut->setRobotpolicy( "noindex,nofollow" ); $specialTitle = Title::makeTitle( NS_SPECIAL, "Watchlist" ); - + $uid = $wgUser->getID(); if( $uid == 0 ) { $wgOut->addHTML( wfMsg( "nowatchlist" ) ); return; } - global $action,$remove,$id; + # Get query variables + $days = $wgRequest->getVal( 'days' ); + $action = $wgRequest->getVal( 'action' ); + $remove = $wgRequest->getVal( 'remove' ); + $id = $wgRequest->getVal( 'id' ); + if(($action == "submit") && isset($remove) && is_array($id)) { $wgOut->addHTML( wfMsg( "removingchecked" ) ); foreach($id as $one) { @@ -51,18 +66,19 @@ function wfSpecialWatchlist() } } + $dbr =& wfGetDB( DB_SLAVE ); + extract( $dbr->tableNames( 'cur', 'watchlist', 'recentchanges' ) ); - $sql = "SELECT COUNT(*) AS n FROM watchlist WHERE wl_user=$uid"; - $res = wfQuery( $sql, DB_READ ); - $s = wfFetchObject( $res ); + $sql = "SELECT COUNT(*) AS n FROM $watchlist WHERE wl_user=$uid"; + $res = $dbr->query( $sql ); + $s = $dbr->fetchObject( $res ); $nitems = $s->n; - if($nitems == 0) { $wgOut->addHTML( wfMsg( "nowatchlist" ) ); return; } - - if ( ! isset( $days ) ) { + + if ( is_null( $days ) ) { $big = 1000; if($nitems > $big) { # Set default cutoff shorter @@ -73,54 +89,58 @@ function wfSpecialWatchlist() } else { $days = floatval($days); } - + if ( $days <= 0 ) { $docutoff = ''; $cutoff = false; $npages = wfMsg( "all" ); } else { - $docutoff = "AND cur_timestamp > '" . - ( $cutoff = wfUnix2Timestamp( time() - intval( $days * 86400 ) ) ) + $docutoff = "AND cur_timestamp > '" . + ( $cutoff = $dbr->timestamp( time() - intval( $days * 86400 ) ) ) . "'"; - $sql = "SELECT COUNT(*) AS n FROM cur WHERE cur_timestamp>'$cutoff'"; - $res = wfQuery( $sql, DB_READ ); - $s = wfFetchObject( $res ); + $sql = "SELECT COUNT(*) AS n FROM $cur WHERE cur_timestamp>'$cutoff'"; + $res = $dbr->query( $sql ); + $s = $dbr->fetchObject( $res ); $npages = $s->n; + } - + if(isset($_REQUEST['magic'])) { - $wgOut->addHTML( wfMsg( "watchlistcontains", $nitems ) . + $wgOut->addHTML( wfMsg( "watchlistcontains", $wgLang->formatNum( $nitems ) ) . "
" . wfMsg( "watcheditlist" ) . "
\n" ); - + $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... if( $cutoff && ( $nitems*1.15 > $npages ) ) { $x = "cur_timestamp"; @@ -132,15 +152,16 @@ function wfSpecialWatchlist() $z = "(wl_namespace=cur_namespace OR wl_namespace+1=cur_namespace)"; } - - $wgOut->addHTML( "" . wfMsg( "watchdetails", $nitems, $npages, $y, - $specialTitle->getURL( "magic=yes", true ) ) . "" . wfMsg( "watchnochange" ) . "
" ); return; } $sk = $wgUser->getSkin(); $s = $sk->beginRecentChangesList(); - - while ( $obj = wfFetchObject( $res ) ) { + $counter = 1; + while ( $obj = $dbr->fetchObject( $res ) ) { # Make fake RC entry $rc = RecentChange::newFromCurRow( $obj ); + $rc->counter = $counter++; $s .= $sk->recentChangesLine( $rc, true ); } $s .= $sk->endRecentChangesList(); - wfFreeResult( $res ); + $dbr->freeResult( $res ); $wgOut->addHTML( $s ); if ( $wgUseWatchlistCache ) { $wgMemc->set( $memckey, $s, $wgWLCacheTimeout); } + } function wlHoursLink( $h, $page ) { - global $wgUser, $wgLang; + global $wgUser, $wgLang, $wgContLang; $sk = $wgUser->getSkin(); $s = $sk->makeKnownLink( - $wgLang->specialPage( $page ), - $h, "days=" . ($h / 24.0) ); + $wgContLang->specialPage( $page ), + $wgLang->formatNum( $h ), + "days=" . ($h / 24.0) ); return $s; } function wlDaysLink( $d, $page ) { - global $wgUser, $wgLang; + global $wgUser, $wgLang, $wgContLang; $sk = $wgUser->getSkin(); $s = $sk->makeKnownLink( - $wgLang->specialPage( $page ), - ($d ? $d : wfMsg( "all" ) ), "days=$d" ); + $wgContLang->specialPage( $page ), + ($d ? $wgLang->formatNum( $d ) : wfMsg( "all" ) ), "days=$d" ); return $s; } -function wlCutoffLinks( $days, $limit, $page = "Watchlist" ) +function wlCutoffLinks( $days, $page = "Watchlist" ) { $hours = array( 1, 2, 6, 12 ); $days = array( 1, 3, 7 );