fixed Uncategorizedcategories caching
[lhc/web/wiklou.git] / includes / SpecialRecentchanges.php
index ccabbb9..8ad4899 100644 (file)
@@ -15,7 +15,7 @@ require_once( 'Revision.php' );
 /**
  * Constructor
  */
-function wfSpecialRecentchanges( $par ) {
+function wfSpecialRecentchanges( $par, $specialPage ) {
        global $wgUser, $wgOut, $wgLang, $wgContLang, $wgTitle, $wgMemc, $wgDBname;
        global $wgRequest, $wgSitename, $wgLanguageCode, $wgContLanguageCode;
        global $wgFeedClasses, $wgUseRCPatrol;
@@ -34,7 +34,7 @@ function wfSpecialRecentchanges( $par ) {
        /* bool */ 'hideliu' => false,
        /* bool */ 'hidepatrolled' => false,
        /* text */ 'from' => '',
-       /* text */ 'namespace' => '',
+       /* text */ 'namespace' => null,
        /* bool */ 'invert' => false,
        );
 
@@ -43,16 +43,13 @@ function wfSpecialRecentchanges( $par ) {
 
        $days = $wgUser->getOption( 'rcdays' );
        if ( !$days ) { $days = $defaults['days']; }
+       $days = $wgRequest->getInt( 'days', $days );
 
        $limit = $wgUser->getOption( 'rclimit' );
        if ( !$limit ) { $limit = $defaults['limit']; }
 
-       
-       $days = $wgRequest->getInt( 'days', $defaults['days'] );
-
        #       list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
-       $limit = $wgRequest->getInt( 'limit', $defaults['limit'] );
-       if ( $limit < 0 || $limit > 5000 ) $limit = $defaults['limit'];
+       $limit = $wgRequest->getInt( 'limit', $limit );
 
        /* order of selection: url > preferences > default */
        $hideminor = $wgRequest->getBool( 'hideminor', $wgUser->getOption( 'hideminor') ? true : $defaults['hideminor'] );      
@@ -67,7 +64,7 @@ function wfSpecialRecentchanges( $par ) {
 
        } else {
 
-               $namespace = $wgRequest->getVal( 'namespace', $defaults['namespace'] );
+               $namespace = $wgRequest->getIntOrNull( 'namespace' );
                $invert = $wgRequest->getBool( 'invert', $defaults['invert'] );
                $hidebots = $wgRequest->getBool( 'hidebots', $defaults['hidebots'] );
                $hideliu = $wgRequest->getBool( 'hideliu', $defaults['hideliu'] );
@@ -77,15 +74,31 @@ function wfSpecialRecentchanges( $par ) {
                # Get query parameters from path
                if( $par ) {
                        $bits = preg_split( '/\s*,\s*/', trim( $par ) );
-                       if( in_array( 'hidebots', $bits ) ) $hidebots = 1;
-                       if( in_array( 'bots', $bits ) ) $hidebots = 0;
-                       if( in_array( 'hideminor', $bits ) ) $hideminor = 1;
-                       if( in_array( 'minor', $bits ) ) $hideminor = 0;
-                       if( in_array( 'hideliu', $bits) ) $hideliu = 1;
-                       if( in_array( 'hidepatrolled', $bits) ) $hidepatrolled = 1;
+                       foreach ( $bits as $bit ) {
+                               if ( 'hidebots' == $bit ) $hidebots = 1;
+                               if ( 'bots' == $bit ) $hidebots = 0;
+                               if ( 'hideminor' == $bit ) $hideminor = 1;
+                               if ( 'minor' == $bit ) $hideminor = 0;
+                               if ( 'hideliu' == $bit ) $hideliu = 1;
+                               if ( 'hidepatrolled' == $bit ) $hidepatrolled = 1;
+
+                               if ( is_numeric( $bit ) ) {
+                                       $limit = $bit;
+                               }
+
+                               if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
+                                       $limit = $m[1];
+                               }
+
+                               if ( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
+                                       $days = $m[1];
+                               }
+                       }
                }
        }
 
+       if ( $limit < 0 || $limit > 5000 ) $limit = $defaults['limit'];
+
 
        # Database connection and caching
        $dbr =& wfGetDB( DB_SLAVE );
@@ -118,7 +131,7 @@ function wfSpecialRecentchanges( $par ) {
        $hidem .= $hidebots ? ' AND rc_bot=0' : '';
        $hidem .= $hideliu ? ' AND rc_user=0' : '';
        $hidem .= $hidepatrolled ? ' AND rc_patrolled=0' : '';
-       $hidem .= $namespace === '' ?  ''       :' AND rc_namespace' . ($invert ? '!=' : '=') . $namespace;
+       $hidem .= is_null( $namespace ) ?  ''   : ' AND rc_namespace' . ($invert ? '!=' : '=') . $namespace;
 
        // This is the big thing!
 
@@ -157,24 +170,26 @@ function wfSpecialRecentchanges( $par ) {
                # Web output...
 
                // Output header
-               $wgOut->addWikiText( wfMsgForContent( "recentchangestext" ) );
-       
-               // Dump everything here
-               $nondefaults = array();
-       
-               appendToArrayIfNotDefault( 'days', $days, $defaults, $nondefaults);
-               appendToArrayIfNotDefault( 'limit', $limit , $defaults, $nondefaults);
-               appendToArrayIfNotDefault( 'hideminor', $hideminor, $defaults, $nondefaults);
-               appendToArrayIfNotDefault( 'hidebots', $hidebots, $defaults, $nondefaults);
-               appendToArrayIfNotDefault( 'hideliu', $hideliu, $defaults, $nondefaults);
-               appendToArrayIfNotDefault( 'hidepatrolled', $hidepatrolled, $defaults, $nondefaults);
-               appendToArrayIfNotDefault( 'from', $from, $defaults, $nondefaults);
-               appendToArrayIfNotDefault( 'namespace', $namespace, $defaults, $nondefaults);
-               appendToArrayIfNotDefault( 'invert', $invert, $defaults, $nondefaults);
-       
-               // Add end of the texts
-               $wgOut->addHTML( '<div class="rcoptions">' . rcOptionsPanel( $defaults, $nondefaults ) );
-               $wgOut->addHTML( namespaceForm( $namespace, $invert, $nondefaults) . '</div>');
+               if ( !$specialPage->including() ) {
+                       $wgOut->addWikiText( wfMsgForContent( "recentchangestext" ) );
+               
+                       // Dump everything here
+                       $nondefaults = array();
+               
+                       appendToArrayIfNotDefault( 'days', $days, $defaults, $nondefaults);
+                       appendToArrayIfNotDefault( 'limit', $limit , $defaults, $nondefaults);
+                       appendToArrayIfNotDefault( 'hideminor', $hideminor, $defaults, $nondefaults);
+                       appendToArrayIfNotDefault( 'hidebots', $hidebots, $defaults, $nondefaults);
+                       appendToArrayIfNotDefault( 'hideliu', $hideliu, $defaults, $nondefaults);
+                       appendToArrayIfNotDefault( 'hidepatrolled', $hidepatrolled, $defaults, $nondefaults);
+                       appendToArrayIfNotDefault( 'from', $from, $defaults, $nondefaults);
+                       appendToArrayIfNotDefault( 'namespace', $namespace, $defaults, $nondefaults);
+                       appendToArrayIfNotDefault( 'invert', $invert, $defaults, $nondefaults);
+
+                       // Add end of the texts
+                       $wgOut->addHTML( '<div class="rcoptions">' . rcOptionsPanel( $defaults, $nondefaults ) );
+                       $wgOut->addHTML( rcNamespaceForm( $namespace, $invert, $nondefaults) . '</div>');
+               }
 
                // And now for the content
                $sk = $wgUser->getSkin();
@@ -193,7 +208,6 @@ function wfSpecialRecentchanges( $par ) {
                                $rc->counter = $counter++;
 
                                if ($wgShowUpdatedMarker
-                                       && $wgUser->getOption( 'showupdated' )
                                        && !empty( $obj->wl_notificationtimestamp )
                                        && ($obj->rc_timestamp >= $obj->wl_notificationtimestamp)) {
                                                $rc->notificationtimestamp = true;
@@ -440,7 +454,7 @@ function rcOptionsPanel( $defaults, $nondefaults ) {
  *
  * @return string
  */
-function namespaceForm ( $namespace, $invert, $nondefaults ) {
+function rcNamespaceForm ( $namespace, $invert, $nondefaults ) {
        global $wgContLang, $wgScript;
        $t = Title::makeTitle( NS_SPECIAL, 'Recentchanges' );
 
@@ -469,12 +483,10 @@ function namespaceForm ( $namespace, $invert, $nondefaults ) {
        
        $out .= '<input type="hidden" name="title" value="'.$t->getPrefixedText().'" />';
        $out .= "
-<table id='nsselect' class='recentchanges'>
-       <tr>
-               <td align='right'><label for='nsselectbox'>" . wfMsg('namespace') . "</label></td>
-               <td align='left'>$namespaceselect $submitbutton $invertbox <label for='nsinvert'>" . wfMsg('invert') . "</label></td>
-       </tr>
-       </table>";
+<div id='nsselect' class='recentchanges'>
+       <label for='nsselectbox'>" . wfMsg('namespace') . "</label>
+       $namespaceselect $submitbutton $invertbox <label for='nsinvert'>" . wfMsg('invert') . "</label>
+</div>";
        $out .= '</form></div>';
        return $out;
 }