Allow QueryPage subclasses to use a different "no results" message than "specialpage...
authorJack Phoenix <jack@countervandalism.net>
Wed, 29 Apr 2015 00:16:38 +0000 (03:16 +0300)
committerJack Phoenix <jack@countervandalism.net>
Sat, 2 May 2015 23:18:43 +0000 (02:18 +0300)
Child classes wishing to show a different message, such as wikiHow's
NewArticleBoost extension, need to override showEmptyText() to display
their custom message via the appropriate OutputPage method(s).

Change-Id: If488e2c81b225eb651e52bcca0fea08b8e685286

includes/specialpage/QueryPage.php

index da752f6..92409cd 100644 (file)
@@ -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
@@ -546,7 +557,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;
                        }