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