Start migrating wfCheckLimits to WebRequest::getLimitOffset()
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 23 Aug 2004 02:19:02 +0000 (02:19 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 23 Aug 2004 02:19:02 +0000 (02:19 +0000)
includes/GlobalFunctions.php
includes/WebRequest.php

index 606b98f..a544971 100644 (file)
@@ -452,20 +452,8 @@ function wfClientAcceptsGzip() {
 
 # Yay, more global functions!
 function wfCheckLimits( $deflimit = 50, $optionname = 'rclimit' ) {
-       global $wgUser, $wgRequest;
-
-       $limit = $wgRequest->getInt( 'limit', 0 );
-       if( $limit < 0 ) $limit = 0;
-       if( ( $limit == 0 ) && ( $optionname != '' ) ) {
-               $limit = (int)$wgUser->getOption( $optionname );
-       }
-       if( $limit <= 0 ) $limit = $deflimit;
-       if( $limit > 5000 ) $limit = 5000; # We have *some* limits...
-
-       $offset = $wgRequest->getInt( 'offset', 0 );
-       if( $offset < 0 ) $offset = 0;
-
-       return array( $limit, $offset );
+       global $wgRequest;
+       return $wgRequest->getLimitOffset( $deflimit, $optionname );
 }
 
 # Escapes the given text so that it may be output using addWikiText()
index a069ee7..841ce29 100644 (file)
@@ -145,6 +145,22 @@ class WebRequest {
                return htmlspecialchars( $this->appendQuery( $query ) );
        }
        
+       function getLimitOffset( $deflimit = 50, $optionname = 'rclimit' ) {
+               global $wgUser;
+       
+               $limit = $this->getInt( 'limit', 0 );
+               if( $limit < 0 ) $limit = 0;
+               if( ( $limit == 0 ) && ( $optionname != '' ) ) {
+                       $limit = (int)$wgUser->getOption( $optionname );
+               }
+               if( $limit <= 0 ) $limit = $deflimit;
+               if( $limit > 5000 ) $limit = 5000; # We have *some* limits...
+       
+               $offset = $this->getInt( 'offset', 0 );
+               if( $offset < 0 ) $offset = 0;
+       
+               return array( $limit, $offset );
+       }
 }
 
 ?>