* Remove deprecated $wgOnlySysopsCanPatrol references; use User::isAllowed( 'patrol...
[lhc/web/wiklou.git] / includes / SpecialShortpages.php
index 2cb6c37..5d748c2 100644 (file)
@@ -1,32 +1,70 @@
 <?php
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
 
-include_once("QueryPage.php");
+/**
+ *
+ */
+require_once("QueryPage.php");
 
+/**
+ * SpecialShortpages extends QueryPage. It is used to return the shortest
+ * pages in the database.
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
 class ShortPagesPage extends QueryPage {
 
        function getName() {
                return "Shortpages";
        }
 
+       /**
+        * This query is indexed as of 1.5
+        */
        function isExpensive() {
-               return 1;
+               return true;
        }
 
-       function getSQL( $offset, $limit ) {
-               return "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " .
-                 "WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY len " .
-                 "LIMIT {$offset}, {$limit}";
+       function isSyndicated() {
+               return false;
+       }
+
+       function getSQL() {
+               $dbr =& wfGetDB( DB_SLAVE );
+               $page = $dbr->tableName( 'page' );
+               $name = $dbr->addQuotes( $this->getName() );
+
+               return
+                       "SELECT $name as type,
+                               page_namespace as namespace,
+                               page_title as title,
+                               page_len AS value
+                       FROM $page FORCE INDEX (page_len)
+                       WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0";
+       }
+
+       function sortDescending() {
+               return false;
        }
 
        function formatResult( $skin, $result ) {
-               $nb = wfMsg( "nbytes", $result->len );
-               $link = $skin->makeKnownLink( $result->cur_title, "" );
-               return "{$link} ({$nb})";
+               global $wgLang, $wgContLang;
+               $nb = htmlspecialchars( wfMsg( 'nbytes', $wgLang->formatNum( $result->value ) ) );
+               $title = Title::makeTitle( $result->namespace, $result->title );
+               $link = $skin->makeKnownLinkObj( $title, htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) );
+               $histlink = $skin->makeKnownLinkObj( $title, wfMsgHtml('hist'), 'action=history' );
+               return "({$histlink}) $link ({$nb})";
        }
 }
 
-function wfSpecialShortpages()
-{
+/**
+ * constructor
+ */
+function wfSpecialShortpages() {
        list( $limit, $offset ) = wfCheckLimits();
 
        $spp = new ShortPagesPage();