Is there any documentation on using the QueryPage class in an extension? I'd like to create a special page with the QueryPage features but am running into problems "hooking it up" to run. I don't see any QueryPage docs on mediawiki.org or meta. (Or is there a more modern way to get a paging Special Page?)
First I defined my subclass of QueryPage with some dummy methods:
class MyQueryPageClassName extends QueryPage { function getName() { return 'My Query Page'; } function getSQL() { return "select 1 as 'test'"; } function formatResult() { return 'dummy result'; } }
Then I hooked up my page with:
$wgHooks['wgQueryPages'][] = 'wfMyQueryPages'; function wfMtQueryPages(&$wgQueryPages) { $wgQueryPages[] = array('MyQueryPageClassName', 'MyQueryPage'); return true; }
At this point, the special page does not exist on the wiki. What else needs to be done to make this work?
I looked at SpecialPopularpages.php and see a global function wfSpecialPopularpages() at the end that looks necessary, but I don't see anything that calls it in the code. How does this really work? I created my own version but nothing seems to call it.
/** * Constructor */ function wfMyQueryPage() { list( $limit, $offset ) = wfCheckLimits(); $ppp = new MyQueryPageClassName(); return $ppp->doQuery( $offset, $limit ); }
Any help appreciated.
Thanks, DanB
On Mon, Dec 5, 2011 at 6:21 PM, Daniel Barrett danb@vistaprint.com wrote:
class MyQueryPageClassName extends QueryPage { function getName() { return 'My Query Page'; } function getSQL() { return "select 1 as 'test'"; }
getSQL() ?!?
I looked at SpecialPopularpages.php and see a global function wfSpecialPopularpages() at the end that looks necessary, but I don't see anything that calls it in the code. How does this really work? I created my own version but nothing seems to call it.
wfSpecialPopularpages() ?!? Are you sure you're looking at a recent version of MediaWiki?
Roan
Roan Kattouw asks:
getSQL() ?!? wfSpecialPopularpages() ?!? Are you sure you're looking at a recent version of MediaWiki?
Yes, version 1.17.1: https://svn.wikimedia.org/viewvc/mediawiki/tags/REL1_17_1/phase3/includes/sp...
I see these functions are gone in 1.18.0, and I'm happy to do things the "right way"... so is there any documentation on using the QueryPage class within an extension? Or an example that's outside of the core?
Thanks, DanB
On Mon, Dec 5, 2011 at 8:16 PM, Daniel Barrett danb@vistaprint.com wrote:
I see these functions are gone in 1.18.0, and I'm happy to do things the "right way"... so is there any documentation on using the QueryPage class within an extension? Or an example that's outside of the core?
Not really, but you should be able to create a QueryPage subclass in an extension, set $wgSpecialPages['specialpagename'] = 'SpecialPageClass'; , add to $wgQueryPages (I forget the exact format there), and you should be all set.
Roan
Can someone who has actually done this before write some documentation? :D
you should be able to create a QueryPage subclass in an extension, set $wgSpecialPages['specialpagename'] = 'SpecialPageClass'; , add to $wgQueryPages (I forget the exact format there), and you should be all set.
Thanks. I tried that, and when I added the $wgSpecialPages line, I got an error that MyQueryPage::isListed() was undefined. (This is a SpecialPage method.)
Subclassing QueryPage doesn't seem to be enough, since QueryPage is not a subclass of SpecialPage. This is where I got confused about how QueryPage and SpecialPage somehow get related.
DanB
On Mon, Dec 5, 2011 at 8:29 PM, Daniel Barrett danb@vistaprint.com wrote:
you should be able to create a QueryPage subclass in an extension, set $wgSpecialPages['specialpagename'] = 'SpecialPageClass'; , add to $wgQueryPages (I forget the exact format there), and you should be all set.
Thanks. I tried that, and when I added the $wgSpecialPages line, I got an error that MyQueryPage::isListed() was undefined. (This is a SpecialPage method.)
Subclassing QueryPage doesn't seem to be enough, since QueryPage is not a subclass of SpecialPage. This is where I got confused about how QueryPage and SpecialPage somehow get related.
That's why you should use 1.18.0, where all of this was fixed and QueryPage does actually subclass SpecialPage :)
Roan
wikitech-l@lists.wikimedia.org