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
|
|
|
/**
|
|
|
|
|
*
|
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 PopularPagesPage extends QueryPage {
|
|
|
|
|
|
2004-01-25 02:27:49 +00:00
|
|
|
function getName() {
|
|
|
|
|
return "Popularpages";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isExpensive() {
|
2004-12-19 08:00:50 +00:00
|
|
|
# page_counter is not indexed
|
2004-05-09 01:30:34 +00:00
|
|
|
return true;
|
2004-01-25 02:27:49 +00:00
|
|
|
}
|
2004-11-13 20:40:28 +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-07-18 08:48:43 +00:00
|
|
|
|
2004-05-09 01:30:34 +00:00
|
|
|
return
|
|
|
|
|
"SELECT 'Popularpages' as type,
|
2004-12-19 08:00:50 +00:00
|
|
|
page_namespace as namespace,
|
|
|
|
|
page_title as title,
|
|
|
|
|
page_counter as value
|
|
|
|
|
FROM $page
|
2005-01-11 18:18:16 +00:00
|
|
|
WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0";
|
2004-01-25 02:27:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatResult( $skin, $result ) {
|
2004-10-21 03:36:19 +00:00
|
|
|
global $wgLang, $wgContLang;
|
|
|
|
|
$link = $skin->makeKnownLink( $result->title, $wgContLang->convert( $result->title ) );
|
2004-05-09 01:30:34 +00:00
|
|
|
$nv = wfMsg( "nviews", $wgLang->formatNum( $result->value ) );
|
2004-01-25 02:27:49 +00:00
|
|
|
return "{$link} ({$nv})";
|
|
|
|
|
}
|
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-04-14 23:10:40 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
*/
|
|
|
|
|
function wfSpecialPopularpages() {
|
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
|
|
|
list( $limit, $offset ) = wfCheckLimits();
|
|
|
|
|
|
|
|
|
|
$ppp = new PopularPagesPage();
|
|
|
|
|
|
|
|
|
|
return $ppp->doQuery( $offset, $limit );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|