4 * @addtogroup SpecialPage
8 * implements Special:Popularpages
9 * @addtogroup SpecialPage
11 class PopularPagesPage
extends QueryPage
{
14 return "Popularpages";
17 function isExpensive() {
18 # page_counter is not indexed
21 function isSyndicated() { return false; }
24 $dbr = wfGetDB( DB_SLAVE
);
25 $page = $dbr->tableName( 'page' );
28 "SELECT 'Popularpages' as type,
29 page_namespace as namespace,
34 "WHERE page_is_redirect=0 AND page_namespace";
36 global $wgContentNamespaces;
37 if( empty( $wgContentNamespaces ) ) {
38 $where .= '='.NS_MAIN
;
39 } else if( count( $wgContentNamespaces ) > 1 ) {
40 $where .= ' in (' . implode( ', ', $wgContentNamespaces ) . ')';
42 $where .= '='.$wgContentNamespaces[0];
45 return $query . $where;
48 function formatResult( $skin, $result ) {
49 global $wgLang, $wgContLang;
50 $title = Title
::makeTitle( $result->namespace, $result->title
);
51 $link = $skin->makeKnownLinkObj( $title, htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) );
52 $nv = wfMsgExt( 'nviews', array( 'parsemag', 'escape'),
53 $wgLang->formatNum( $result->value
) );
54 return wfSpecialList($link, $nv);
61 function wfSpecialPopularpages() {
62 list( $limit, $offset ) = wfCheckLimits();
64 $ppp = new PopularPagesPage();
66 return $ppp->doQuery( $offset, $limit );