77d41437c5fa59a00231618138aba18c2ec4cd2e
[lhc/web/wiklou.git] / includes / SpecialPopularpages.php
1 <?php
2 /**
3 *
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 /**
9 *
10 * @package MediaWiki
11 * @subpackage SpecialPage
12 */
13 class PopularPagesPage extends QueryPage {
14
15 function getName() {
16 return "Popularpages";
17 }
18
19 function isExpensive() {
20 # page_counter is not indexed
21 return true;
22 }
23 function isSyndicated() { return false; }
24
25 function getSQL() {
26 $dbr =& wfGetDB( DB_SLAVE );
27 $page = $dbr->tableName( 'page' );
28
29 return
30 "SELECT 'Popularpages' as type,
31 page_namespace as namespace,
32 page_title as title,
33 page_counter as value
34 FROM $page
35 WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0";
36 }
37
38 function formatResult( $skin, $result ) {
39 global $wgLang, $wgContLang;
40 $title = Title::makeTitle( $result->namespace, $result->title );
41 $link = $skin->makeKnownLinkObj( $title, htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) );
42 $nv = wfMsgExt( 'nviews', array( 'parsemag', 'escape'),
43 $wgLang->formatNum( $result->value ) );
44 return wfSpecialList($link, $nv);
45 }
46 }
47
48 /**
49 * Constructor
50 */
51 function wfSpecialPopularpages() {
52 list( $limit, $offset ) = wfCheckLimits();
53
54 $ppp = new PopularPagesPage();
55
56 return $ppp->doQuery( $offset, $limit );
57 }
58
59 ?>