2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-06-12 19:47:53 +00:00
|
|
|
#
|
|
|
|
|
# SpecialShortpages extends QueryPage. It is used to return the shortest
|
|
|
|
|
# pages in the database.
|
|
|
|
|
#
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-05-07 13:43:10 +00:00
|
|
|
require_once("QueryPage.php");
|
I was adding a special page (dead-end pages), and I realized that almost all
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.
2003-12-01 16:04:35 +00:00
|
|
|
|
|
|
|
|
class ShortPagesPage extends QueryPage {
|
2004-01-25 02:27:49 +00:00
|
|
|
|
|
|
|
|
function getName() {
|
|
|
|
|
return "Shortpages";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isExpensive() {
|
2004-05-09 01:30:34 +00:00
|
|
|
return true;
|
2004-01-25 02:27:49 +00:00
|
|
|
}
|
|
|
|
|
|
2004-05-09 01:30:34 +00:00
|
|
|
function getSQL() {
|
2004-07-18 08:48:43 +00:00
|
|
|
$dbr =& wfGetDB( DB_SLAVE );
|
|
|
|
|
$cur = $dbr->tableName( 'cur' );
|
|
|
|
|
|
2004-05-09 01:30:34 +00:00
|
|
|
return
|
|
|
|
|
"SELECT 'Shortpages' as type,
|
|
|
|
|
cur_namespace as namespace,
|
|
|
|
|
cur_title as title,
|
|
|
|
|
LENGTH(cur_text) AS value
|
2004-07-18 08:48:43 +00:00
|
|
|
FROM $cur
|
2004-05-09 01:30:34 +00:00
|
|
|
WHERE cur_namespace=0 AND cur_is_redirect=0";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function sortDescending() {
|
|
|
|
|
return false;
|
2004-01-25 02:27:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatResult( $skin, $result ) {
|
2004-03-06 03:03:14 +00:00
|
|
|
global $wgLang;
|
2004-05-09 01:30:34 +00:00
|
|
|
$nb = wfMsg( "nbytes", $wgLang->formatNum( $result->value ) );
|
|
|
|
|
$link = $skin->makeKnownLink( $result->title, "" );
|
2004-01-25 02:27:49 +00:00
|
|
|
return "{$link} ({$nb})";
|
|
|
|
|
}
|
I was adding a special page (dead-end pages), and I realized that almost all
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.
2003-12-01 16:04:35 +00:00
|
|
|
}
|
2003-05-16 11:19:06 +00:00
|
|
|
|
2004-06-12 19:47:53 +00:00
|
|
|
function wfSpecialShortpages() {
|
2004-01-25 02:27:49 +00:00
|
|
|
list( $limit, $offset ) = wfCheckLimits();
|
|
|
|
|
|
|
|
|
|
$spp = new ShortPagesPage();
|
|
|
|
|
|
|
|
|
|
return $spp->doQuery( $offset, $limit );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|