Merge "libs: Declare dynamic properties and improve doc types"
[lhc/web/wiklou.git] / includes / specials / SpecialMostimages.php
index ec89bd4..1339f4b 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 /**
+ * Implements Special:Mostimages
+ *
+ * Copyright © 2005 Ævar Arnfjörð Bjarmason
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  * You should have received a copy of the GNU General Public License along
  * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
- */
-
-/**
+ *
  * @file
  * @ingroup SpecialPage
- *
  * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
  */
 
 /**
- * implements Special:Mostimages
+ * A special page that lists most used images
+ *
  * @ingroup SpecialPage
  */
 class MostimagesPage extends ImageQueryPage {
-
-       function getName() { return 'Mostimages'; }
-       function isExpensive() { return true; }
-       function isSyndicated() { return false; }
-
-       function getSQL() {
-               $dbr = wfGetDB( DB_SLAVE );
-               $imagelinks = $dbr->tableName( 'imagelinks' );
-               return
-                       "
-                       SELECT
-                               'Mostimages' as type,
-                               " . NS_FILE . " as namespace,
-                               il_to as title,
-                               COUNT(*) as value
-                       FROM $imagelinks
-                       GROUP BY il_to
-                       HAVING COUNT(*) > 1
-                       ";
+       function __construct( $name = 'Mostimages' ) {
+               parent::__construct( $name );
        }
 
-       function getCellHtml( $row ) {
-               global $wgLang;
-               return wfMsgExt( 'nlinks',  array( 'parsemag', 'escape' ),
-                       $wgLang->formatNum( $row->value ) ) . '<br />';
+       function isExpensive() {
+               return true;
        }
 
-}
+       function isSyndicated() {
+               return false;
+       }
 
-/**
- * Constructor
- */
-function wfSpecialMostimages() {
-       list( $limit, $offset ) = wfCheckLimits();
+       function getQueryInfo() {
+               return [
+                       'tables' => [ 'imagelinks' ],
+                       'fields' => [
+                               'namespace' => NS_FILE,
+                               'title' => 'il_to',
+                               'value' => 'COUNT(*)'
+                       ],
+                       'options' => [
+                               'GROUP BY' => 'il_to',
+                               'HAVING' => 'COUNT(*) > 1'
+                       ]
+               ];
+       }
 
-       $wpp = new MostimagesPage();
+       function getCellHtml( $row ) {
+               return $this->msg( 'nimagelinks' )->numParams( $row->value )->escaped() . '<br />';
+       }
 
-       $wpp->doQuery( $offset, $limit );
+       protected function getGroupName() {
+               return 'highuse';
+       }
 }