2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
*
|
2004-09-03 23:00:01 +00:00
|
|
|
* @package MediaWiki
|
|
|
|
|
* @subpackage SpecialPage
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-02 23:28:24 +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
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* SpecialShortpages extends QueryPage. It is used to return the shortest
|
|
|
|
|
* pages in the database.
|
2004-09-03 23:00:01 +00:00
|
|
|
* @package MediaWiki
|
|
|
|
|
* @subpackage SpecialPage
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
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";
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-12 11:51:02 +00:00
|
|
|
/**
|
|
|
|
|
* This query is indexed as of 1.5
|
|
|
|
|
*/
|
2004-01-25 02:27:49 +00:00
|
|
|
function isExpensive() {
|
2005-11-12 23:00:02 +00:00
|
|
|
return true;
|
2005-03-12 11:51:02 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-03-12 11:51:02 +00:00
|
|
|
function isSyndicated() {
|
|
|
|
|
return false;
|
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 );
|
2004-12-19 08:00:50 +00:00
|
|
|
$page = $dbr->tableName( 'page' );
|
2004-10-03 10:42:02 +00:00
|
|
|
$name = $dbr->addQuotes( $this->getName() );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2004-05-09 01:30:34 +00:00
|
|
|
return
|
2004-10-03 10:42:02 +00:00
|
|
|
"SELECT $name as type,
|
2005-10-21 02:06:22 +00:00
|
|
|
page_namespace as namespace,
|
2004-12-19 08:00:50 +00:00
|
|
|
page_title as title,
|
2005-03-12 11:51:02 +00:00
|
|
|
page_len AS value
|
2005-10-17 17:30:10 +00:00
|
|
|
FROM $page FORCE INDEX (page_len)
|
2005-03-12 11:51:02 +00:00
|
|
|
WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0";
|
2004-05-09 01:30:34 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2004-05-09 01:30:34 +00:00
|
|
|
function sortDescending() {
|
|
|
|
|
return false;
|
2004-01-25 02:27:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatResult( $skin, $result ) {
|
2004-10-21 03:36:19 +00:00
|
|
|
global $wgLang, $wgContLang;
|
2006-01-15 14:06:29 +00:00
|
|
|
$nb = htmlspecialchars( wfMsg( 'nbytes', $wgLang->formatNum( $result->value ) ) );
|
2005-03-12 11:51:02 +00:00
|
|
|
$title = Title::makeTitle( $result->namespace, $result->title );
|
2005-09-13 17:02:43 +00:00
|
|
|
$link = $skin->makeKnownLinkObj( $title, htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) );
|
2006-01-15 20:34:25 +00:00
|
|
|
$histlink = $skin->makeKnownLinkObj( $title, wfMsgHtml('hist'), 'action=history' );
|
2006-01-15 14:06:29 +00:00
|
|
|
return "({$histlink}) $link ({$nb})";
|
2004-01-25 02:27:49 +00:00
|
|
|
}
|
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-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* constructor
|
|
|
|
|
*/
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|