MediaWiki  REL1_22
SpecialPopularpages.php
Go to the documentation of this file.
00001 <?php
00029 class PopularPagesPage extends QueryPage {
00030     function __construct( $name = 'Popularpages' ) {
00031         parent::__construct( $name );
00032     }
00033 
00034     function isExpensive() {
00035         # page_counter is not indexed
00036         return true;
00037     }
00038 
00039     function isSyndicated() {
00040         return false;
00041     }
00042 
00043     function getQueryInfo() {
00044         return array(
00045             'tables' => array( 'page' ),
00046             'fields' => array(
00047                 'namespace' => 'page_namespace',
00048                 'title' => 'page_title',
00049                 'value' => 'page_counter' ),
00050             'conds' => array(
00051                 'page_is_redirect' => 0,
00052                 'page_namespace' => MWNamespace::getContentNamespaces()
00053             )
00054         );
00055     }
00056 
00062     function formatResult( $skin, $result ) {
00063         global $wgContLang;
00064 
00065         $title = Title::makeTitleSafe( $result->namespace, $result->title );
00066         if ( !$title ) {
00067             return Html::element(
00068                 'span',
00069                 array( 'class' => 'mw-invalidtitle' ),
00070                 Linker::getInvalidTitleDescription(
00071                     $this->getContext(),
00072                     $result->namespace,
00073                     $result->title )
00074             );
00075         }
00076 
00077         $link = Linker::linkKnown(
00078             $title,
00079             htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) )
00080         );
00081         $nv = $this->msg( 'nviews' )->numParams( $result->value )->escaped();
00082 
00083         return $this->getLanguage()->specialList( $link, $nv );
00084     }
00085 
00086     protected function getGroupName() {
00087         return 'wiki';
00088     }
00089 }