don't parse blank ISBNs
[lhc/web/wiklou.git] / includes / SpecialWatchlist.php
index d3d833b..5e4ffa9 100644 (file)
@@ -1,12 +1,22 @@
 <?php
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
+
+/**
+ *
+ */
 require_once( "SpecialRecentchanges.php" );
 require_once( "WatchedItem.php" );
 
-function wfSpecialWatchlist()
-{
-       global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc;
+/**
+ * constructor
+ */
+function wfSpecialWatchlist() {
+       global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgRequest;
        global $wgUseWatchlistCache, $wgWLCacheTimeout, $wgDBname;
-       global $days, $limit, $target; # From query string
        $fname = "wfSpecialWatchlist";
 
        $wgOut->setPagetitle( wfMsg( "watchlist" ) );
@@ -22,7 +32,12 @@ function wfSpecialWatchlist()
                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) {
@@ -62,8 +77,8 @@ function wfSpecialWatchlist()
         $wgOut->addHTML( wfMsg( "nowatchlist" ) );
         return;
        }
-
-       if ( ! isset( $days ) ) {
+       
+       if ( is_null( $days ) ) {
                $big = 1000;
                if($nitems > $big) {
                        # Set default cutoff shorter
@@ -81,7 +96,7 @@ function wfSpecialWatchlist()
                $npages = wfMsg( "all" );
        } else {
                $docutoff = "AND cur_timestamp > '" .
-                 ( $cutoff = wfUnix2Timestamp( time() - intval( $days * 86400 ) ) )
+                 ( $cutoff = $dbr->timestamp( time() - intval( $days * 86400 ) ) )
                  . "'";
                $sql = "SELECT COUNT(*) AS n FROM $cur WHERE cur_timestamp>'$cutoff'";
                $res = $dbr->query( $sql );
@@ -100,7 +115,6 @@ function wfSpecialWatchlist()
                        "<ul>\n" );
                $sql = "SELECT wl_namespace,wl_title FROM $watchlist WHERE wl_user=$uid";
                $res = $dbr->query( $sql );
-               global $wgUser, $wgLang;
                $sk = $wgUser->getSkin();
                while( $s = $dbr->fetchObject( $res ) ) {
                        $t = Title::makeTitle( $s->wl_namespace, $s->wl_title );
@@ -156,18 +170,18 @@ function wfSpecialWatchlist()
 
 
        $res = $dbr->query( $sql, $fname );
-
+       $numRows = $dbr->numRows( $res );
        if($days >= 1)
-               $note = wfMsg( "rcnote", $wgLang->formatNum( $limit ), $wgLang->formatNum( $days ) );
+               $note = wfMsg( "rcnote", $wgLang->formatNum( $numRows ), $wgLang->formatNum( $days ) );
        elseif($days > 0)
-               $note = wfMsg( "wlnote", $wgLang->formatNum( $limit ), $wgLang->formatNum( round($days*24) ) );
+               $note = wfMsg( "wlnote", $wgLang->formatNum( $numRows ), $wgLang->formatNum( round($days*24) ) );
        else
                $note = "";
        $wgOut->addHTML( "\n<hr />\n{$note}\n<br />" );
-       $note = wlCutoffLinks( $days, $limit );
+       $note = wlCutoffLinks( $days );
        $wgOut->addHTML( "{$note}\n" );
 
-       if ( $dbr->numRows( $res ) == 0 ) {
+       if ( $numRows == 0 ) {
                $wgOut->addHTML( "<p><i>" . wfMsg( "watchnochange" ) . "</i></p>" );
                return;
        }
@@ -213,7 +227,7 @@ function wlDaysLink( $d, $page ) {
        return $s;
 }
 
-function wlCutoffLinks( $days, $limit, $page = "Watchlist" )
+function wlCutoffLinks( $days, $page = "Watchlist" )
 {
        $hours = array( 1, 2, 6, 12 );
        $days = array( 1, 3, 7 );