more specific error message, using WikiError, if user trys to create account with...
[mediawiki.git] / includes / specials / SpecialPopularpages.php
blob88b90bc384e1d73c0caf029e0e69e58a05a729a9
1 <?php
2 /**
3 * @file
4 * @ingroup SpecialPage
5 */
7 /**
8 * implements Special:Popularpages
9 * @ingroup SpecialPage
11 class PopularPagesPage extends QueryPage {
13 function getName() {
14 return "Popularpages";
17 function isExpensive() {
18 # page_counter is not indexed
19 return true;
21 function isSyndicated() { return false; }
23 function getSQL() {
24 $dbr = wfGetDB( DB_SLAVE );
25 $page = $dbr->tableName( 'page' );
27 $query =
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 =
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 ) . ')';
41 } else {
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->linkKnown(
52 $title,
53 htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) )
55 $nv = wfMsgExt(
56 'nviews',
57 array( 'parsemag', 'escape'),
58 $wgLang->formatNum( $result->value )
60 return wfSpecialList($link, $nv);
64 /**
65 * Constructor
67 function wfSpecialPopularpages() {
68 list( $limit, $offset ) = wfCheckLimits();
70 $ppp = new PopularPagesPage();
72 return $ppp->doQuery( $offset, $limit );