doc fix
[lhc/web/wiklou.git] / includes / SpecialWatchlist.php
index 60a4a72..dc1277a 100644 (file)
@@ -9,10 +9,11 @@
  *
  */
 require_once( 'SpecialRecentchanges.php' );
-require_once( 'WatchedItem.php' );
 
 /**
- * constructor
+ * Constructor
+ * @todo Document $par parameter.
+ * @param $par String: FIXME
  */
 function wfSpecialWatchlist( $par ) {
        global $wgUser, $wgOut, $wgLang, $wgMemc, $wgRequest, $wgContLang;
@@ -39,9 +40,9 @@ function wfSpecialWatchlist( $par ) {
 
        $defaults = array(
        /* float */ 'days' => floatval( $wgUser->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */
-       /* bool  */ 'hideOwn' => $wgUser->getBoolOption( 'watchlisthideown' ),
-       /* bool  */ 'hideBots' => $wgUser->getBoolOption( 'watchlisthidebots' ),
-                               'namespace' => 'all',
+       /* bool  */ 'hideOwn' => (int)$wgUser->getBoolOption( 'watchlisthideown' ),
+       /* bool  */ 'hideBots' => (int)$wgUser->getBoolOption( 'watchlisthidebots' ),
+       /* ?     */ 'namespace' => 'all',
        );
 
        extract($defaults);
@@ -88,13 +89,14 @@ function wfSpecialWatchlist( $par ) {
                                if( $wl->removeWatch() === false ) {
                                        $wgOut->addHTML( "<br />\n" . wfMsg( 'couldntremove', htmlspecialchars($one) ) );
                                } else {
+                                       wfRunHooks('UnwatchArticle', array(&$wgUser, new Article($t)));
                                        $wgOut->addHTML( ' (' . htmlspecialchars($one) . ')' );
                                }
                        } else {
                                $wgOut->addHTML( "<br />\n" . wfMsg( 'iteminvalidname', htmlspecialchars($one) ) );
                        }
                }
-               $wgOut->addHTML( "done.</p>\n" );
+               $wgOut->addHTML( "<br />\n" . wfMsg( 'wldone' ) . "</p>\n" );
        }
 
        if ( $wgUseWatchlistCache ) {
@@ -259,6 +261,15 @@ function wfSpecialWatchlist( $par ) {
                $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 .= wfMsg( 'watchdetails', $wgLang->formatNum( $nitems ),
                $wgLang->formatNum( $npages ), '',
@@ -280,7 +291,7 @@ function wfSpecialWatchlist( $par ) {
          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_last_oldid, rc_id, rc_patrolled,
          rc_new AS page_is_new,wl_notificationtimestamp
          FROM $watchlist,$recentchanges,$page
          WHERE wl_user=$uid
@@ -288,10 +299,12 @@ function wfSpecialWatchlist( $par ) {
          AND wl_title=rc_title
          AND rc_timestamp > '$cutoff'
          AND rc_cur_id=page_id
+         $andLatest
          $andHideOwn
          $andHideBots
          $nameSpaceClause
-         ORDER BY rc_timestamp DESC";
+         ORDER BY rc_timestamp DESC
+         $limitWatchlist";
 
        $res = $dbr->query( $sql, $fname );
        $numRows = $dbr->numRows( $res );
@@ -301,7 +314,7 @@ function wfSpecialWatchlist( $par ) {
 
        if($days >= 1)
                $wgOut->addWikiText( wfMsg( 'rcnote', $wgLang->formatNum( $numRows ),
-                       $wgLang->formatNum( $days ) ) . '<br />' , false );
+                       $wgLang->formatNum( $days ), $wgLang->timeAndDate( wfTimestampNow(), true ) ) . '<br />' , false );
        elseif($days > 0)
                $wgOut->addWikiText( wfMsg( 'wlnote', $wgLang->formatNum( $numRows ),
                        $wgLang->formatNum( round($days*24) ) ) . '<br />' , false );
@@ -329,12 +342,12 @@ function wfSpecialWatchlist( $par ) {
        # Form for namespace filtering
        $thisAction = $thisTitle->escapeLocalUrl();
        $nsForm  = "<form method=\"post\" action=\"{$thisAction}\">\n";
-       $nsForm .= "<label for=\"namespace\">" . wfMsg( 'namespace' ) . "</label> ";
+       $nsForm .= "<label for=\"namespace\">" . wfMsgExt( 'namespace', array( 'parseinline') ) . "</label> ";
        $nsForm .= HTMLnamespaceselector( $nameSpace, '' ) . "\n";
        $nsForm .= ( $hideOwn ? "<input type=\"hidden\" name=\"hideown\" value=\"1\" />\n" : "" );
        $nsForm .= ( $hideBots ? "<input type=\"hidden\" name=\"hidebots\" value=\"1\" />\n" : "" );
        $nsForm .= "<input type=\"hidden\" name=\"days\" value=\"" . $days . "\" />\n";
-       $nsForm .= "<input type=\"submit\" name=\"submit\" value=\"" . wfMsgHtml( 'allpagessubmit' ) . "\" />\n";
+       $nsForm .= "<input type=\"submit\" name=\"submit\" value=\"" . wfMsgExt( 'allpagessubmit', array( 'escape') ) . "\" />\n";
        $nsForm .= "</form>\n";
        $wgOut->addHTML( $nsForm );
 
@@ -405,6 +418,9 @@ function wlDaysLink( $d, $page, $options = array() ) {
        return $s;
 }
 
+/**
+ * Returns html
+ */
 function wlCutoffLinks( $days, $page = 'Watchlist', $options = array() ) {
        $hours = array( 1, 2, 6, 12 );
        $days = array( 1, 3, 7 );
@@ -417,7 +433,8 @@ function wlCutoffLinks( $days, $page = 'Watchlist', $options = array() ) {
        foreach( $days as $d ) {
                $days[$i++] = wlDaysLink( $d, $page, $options );
        }
-       return wfMsg ('wlshowlast',
+       return wfMsgExt('wlshowlast',
+               array('parseinline', 'replaceafter'),
                implode(' | ', $hours),
                implode(' | ', $days),
                wlDaysLink( 0, $page, $options ) );