Allow limit and offset to be restricted in subclasses of QueryPage.php
[lhc/web/wiklou.git] / includes / specialpage / QueryPage.php
index da752f6..69e1d8c 100644 (file)
@@ -70,7 +70,7 @@ abstract class QueryPage extends SpecialPage {
                                array( 'DeadendPagesPage', 'Deadendpages' ),
                                array( 'DoubleRedirectsPage', 'DoubleRedirects' ),
                                array( 'FileDuplicateSearchPage', 'FileDuplicateSearch' ),
-                               array( 'ListDuplicatedFilesPage', 'ListDuplicatedFiles'),
+                               array( 'ListDuplicatedFilesPage', 'ListDuplicatedFiles' ),
                                array( 'LinkSearchPage', 'LinkSearch' ),
                                array( 'ListredirectsPage', 'Listredirects' ),
                                array( 'LonelyPagesPage', 'Lonelypages' ),
@@ -252,6 +252,17 @@ abstract class QueryPage extends SpecialPage {
                return '';
        }
 
+       /**
+        * Outputs some kind of an informative message (via OutputPage) to let the
+        * user know that the query returned nothing and thus there's nothing to
+        * show.
+        *
+        * @since 1.26
+        */
+       protected function showEmptyText() {
+               $this->getOutput()->addWikiMsg( 'specialpage-empty' );
+       }
+
        /**
         * If using extra form wheely-dealies, return a set of parameters here
         * as an associative array. They will be encoded and added to the paging
@@ -459,6 +470,18 @@ abstract class QueryPage extends SpecialPage {
                return $this->cachedTimestamp;
        }
 
+       /**
+        * Returns limit and offset, as returned by $this->getRequest()->getLimitOffset().
+        * Subclasses may override this to further restrict or modify limit and offset.
+        *
+        * @since 1.26
+        *
+        * @return int[] list( $limit, $offset )
+        */
+       protected function getLimitOffset() {
+               return $this->getRequest()->getLimitOffset();
+       }
+
        /**
         * This is the actual workhorse. It does everything needed to make a
         * real, honest-to-gosh query page.
@@ -484,7 +507,7 @@ abstract class QueryPage extends SpecialPage {
                $out->setSyndicated( $this->isSyndicated() );
 
                if ( $this->limit == 0 && $this->offset == 0 ) {
-                       list( $this->limit, $this->offset ) = $this->getRequest()->getLimitOffset();
+                       list( $this->limit, $this->offset ) = $this->getLimitOffset();
                }
 
                // @todo Use doQuery()
@@ -546,7 +569,7 @@ abstract class QueryPage extends SpecialPage {
                        } else {
                                # No results to show, so don't bother with "showing X of Y" etc.
                                # -- just let the user know and give up now
-                               $out->addWikiMsg( 'specialpage-empty' );
+                               $this->showEmptyText();
                                $out->addHTML( Xml::closeElement( 'div' ) );
                                return;
                        }