MediaWiki  REL1_21
SpecialFewestrevisions.php
Go to the documentation of this file.
00001 <?php
00030 class FewestrevisionsPage extends QueryPage {
00031 
00032         function __construct( $name = 'Fewestrevisions' ) {
00033                 parent::__construct( $name );
00034         }
00035 
00036         function isExpensive() {
00037                 return true;
00038         }
00039 
00040         function isSyndicated() {
00041                 return false;
00042         }
00043 
00044         function getQueryInfo() {
00045                 return array (
00046                         'tables' => array ( 'revision', 'page' ),
00047                         'fields' => array ( 'namespace' => 'page_namespace',
00048                                         'title' => 'page_title',
00049                                         'value' => 'COUNT(*)',
00050                                         'redirect' => 'page_is_redirect' ),
00051                         'conds' => array ( 'page_namespace' => MWNamespace::getContentNamespaces(),
00052                                         'page_id = rev_page' ),
00053                         'options' => array ( 'HAVING' => 'COUNT(*) > 1',
00054                         // ^^^ This was probably here to weed out redirects.
00055                         // Since we mark them as such now, it might be
00056                         // useful to remove this. People _do_ create pages
00057                         // and never revise them, they aren't necessarily
00058                         // redirects.
00059                         'GROUP BY' => array( 'page_namespace', 'page_title', 'page_is_redirect' ) )
00060                 );
00061         }
00062 
00063         function sortDescending() {
00064                 return false;
00065         }
00066 
00072         function formatResult( $skin, $result ) {
00073                 global $wgContLang;
00074 
00075                 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
00076                 if( !$nt ) {
00077                         return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ),
00078                                 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
00079                 }
00080 
00081                 $text = htmlspecialchars( $wgContLang->convert( $nt->getPrefixedText() ) );
00082                 $plink = Linker::linkKnown( $nt, $text );
00083 
00084                 $nl = $this->msg( 'nrevisions' )->numParams( $result->value )->escaped();
00085                 $redirect = isset( $result->redirect ) && $result->redirect ?
00086                         ' - ' . $this->msg( 'isredirect' )->escaped() : '';
00087                 $nlink = Linker::linkKnown(
00088                         $nt,
00089                         $nl,
00090                         array(),
00091                         array( 'action' => 'history' )
00092                 ) . $redirect;
00093 
00094                 return $this->getLanguage()->specialList( $plink, $nlink );
00095         }
00096 
00097         protected function getGroupName() {
00098                 return 'maintenance';
00099         }
00100 }