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