the special query pages were pretty much identical. I copy-and-pasted one to make the one I was working on, and I realized that that was Wrong. So, I took the common elements and made them into a class, QueryPage.php. Then, I derived each of the existing special pages from QueryPage, and overrode places where they differed. This is a Recipe pattern, btw, for those of you following along at home. Anyways, the upshot is that the query pages are a lot shorter, with just the essentials that make them different from other query pages, and there's one place to make big UI changes for all queries.
37 lines
770 B
PHP
37 lines
770 B
PHP
<?
|
|
|
|
include_once("QueryPage.php");
|
|
|
|
class ShortPagesPage extends QueryPage {
|
|
|
|
function getName() {
|
|
return "Shortpages";
|
|
}
|
|
|
|
function isExpensive() {
|
|
return 1;
|
|
}
|
|
|
|
function getSQL( $offset, $limit ) {
|
|
return "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " .
|
|
"WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
|
|
"LENGTH(cur_text) LIMIT {$offset}, {$limit}";
|
|
}
|
|
|
|
function formatResult( $skin, $result ) {
|
|
$nb = wfMsg( "nbytes", $result->len );
|
|
$link = $skin->makeKnownLink( $result->cur_title, "" );
|
|
return "{$link} ({$nb})";
|
|
}
|
|
}
|
|
|
|
function wfSpecialShortpages()
|
|
{
|
|
list( $limit, $offset ) = wfCheckLimits();
|
|
|
|
$spp = new ShortPagesPage();
|
|
|
|
return $spp->doQuery( $offset, $limit );
|
|
}
|
|
|
|
?>
|