]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/specials/SpecialFewestrevisions.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / includes / specials / SpecialFewestrevisions.php
index c265ed38618074f9c39989342aff9babbfb200ba..f20829fd644637612981df1f82b08e1cad6541fe 100644 (file)
  * @author Martin Drashkov
  */
 class FewestrevisionsPage extends QueryPage {
-
-       function getName() {
-               return 'Fewestrevisions';
+       function __construct( $name = 'Fewestrevisions' ) {
+               parent::__construct( $name );
        }
 
-       function isExpensive() {
+       public function isExpensive() {
                return true;
        }
 
@@ -41,62 +40,66 @@ class FewestrevisionsPage extends QueryPage {
                return false;
        }
 
-       function getSql() {
-               $dbr = wfGetDB( DB_SLAVE );
-               list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' );
-
-               return "SELECT 'Fewestrevisions' as type,
-                               page_namespace as namespace,
-                               page_title as title,
-                               page_is_redirect as redirect,
-                               COUNT(*) as value
-                       FROM $revision
-                       JOIN $page ON page_id = rev_page
-                       WHERE page_namespace = " . NS_MAIN . "
-                       GROUP BY page_namespace, page_title, page_is_redirect
-                       HAVING COUNT(*) > 1";
-                       // ^^^ This was probably here to weed out redirects.
-                       // Since we mark them as such now, it might be
-                       // useful to remove this. People _do_ create pages
-                       // and never revise them, they aren't necessarily
-                       // redirects.
+       public function getQueryInfo() {
+               return [
+                       'tables' => [ 'revision', 'page' ],
+                       'fields' => [
+                               'namespace' => 'page_namespace',
+                               'title' => 'page_title',
+                               'value' => 'COUNT(*)',
+                               'redirect' => 'page_is_redirect'
+                       ],
+                       'conds' => [
+                               'page_namespace' => MWNamespace::getContentNamespaces(),
+                               'page_id = rev_page' ],
+                       'options' => [
+                               'GROUP BY' => [ 'page_namespace', 'page_title', 'page_is_redirect' ]
+                       ]
+               ];
        }
 
        function sortDescending() {
                return false;
        }
 
+       /**
+        * @param Skin $skin
+        * @param object $result Database row
+        * @return string
+        */
        function formatResult( $skin, $result ) {
-               global $wgLang, $wgContLang;
+               global $wgContLang;
 
                $nt = Title::makeTitleSafe( $result->namespace, $result->title );
-               if( !$nt ) {
-                       return '<!-- bad title -->';
+               if ( !$nt ) {
+                       return Html::element(
+                               'span',
+                               [ 'class' => 'mw-invalidtitle' ],
+                               Linker::getInvalidTitleDescription(
+                                       $this->getContext(),
+                                       $result->namespace,
+                                       $result->title
+                               )
+                       );
                }
-
+               $linkRenderer = $this->getLinkRenderer();
                $text = $wgContLang->convert( $nt->getPrefixedText() );
+               $plink = $linkRenderer->makeLink( $nt, $text );
 
-               $plink = $skin->linkKnown(
-                       $nt,
-                       $text
-               );
-
-               $nl = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape' ),
-                       $wgLang->formatNum( $result->value ) );
-               $redirect = $result->redirect ? ' - ' . wfMsgHtml( 'isredirect' ) : '';
-               $nlink = $skin->linkKnown(
+               $nl = $this->msg( 'nrevisions' )->numParams( $result->value )->text();
+               $redirect = isset( $result->redirect ) && $result->redirect ?
+                       ' - ' . $this->msg( 'isredirect' )->escaped() : '';
+               $nlink = $linkRenderer->makeKnownLink(
                        $nt,
                        $nl,
-                       array(),
-                       array( 'action' => 'history' )
+                       [],
+                       [ 'action' => 'history' ]
                ) . $redirect;
 
-               return wfSpecialList( $plink, $nlink );
+               return $this->getLanguage()->specialList( $plink, $nlink );
        }
-}
 
-function wfSpecialFewestrevisions() {
-       list( $limit, $offset ) = wfCheckLimits();
-       $frp = new FewestrevisionsPage();
-       $frp->doQuery( $offset, $limit );
+       protected function getGroupName() {
+               return 'maintenance';
+       }
 }