Re-establishing validation feature (the beginnings)
[lhc/web/wiklou.git] / includes / SpecialShortpages.php
index c3eafc4..70ca503 100644 (file)
@@ -1,29 +1,50 @@
 <?php
-#
-# SpecialShortpages extends QueryPage. It is used to return the shortest
-# pages in the database.
-#
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
 
+/**
+ *
+ */
 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 true;
+               return false;
+       }
+       
+       function isSyndicated() {
+               return false;
        }
 
        function getSQL() {
+               $dbr =& wfGetDB( DB_SLAVE );
+               $page = $dbr->tableName( 'page' );
+               $name = $dbr->addQuotes( $this->getName() );
+               
                return
-                       "SELECT 'Shortpages' as type,
-                                       cur_namespace as namespace,
-                               cur_title as title,
-                               LENGTH(cur_text) AS value
-                       FROM cur
-                       WHERE cur_namespace=0 AND cur_is_redirect=0";
+                       "SELECT $name as type,
+                                       page_namespace as namespace,
+                               page_title as title,
+                               page_len AS value
+                       FROM $page
+                       WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0";
        }
        
        function sortDescending() {
@@ -31,13 +52,17 @@ class ShortPagesPage extends QueryPage {
        }
 
        function formatResult( $skin, $result ) {
-               global $wgLang;
-               $nb = wfMsg( "nbytes", $wgLang->formatNum( $result->value ) );
-               $link = $skin->makeKnownLink( $result->title, "" );
+               global $wgLang, $wgContLang;
+               $nb = htmlspecialchars( wfMsg( "nbytes", $wgLang->formatNum( $result->value ) ) );
+               $title = Title::makeTitle( $result->namespace, $result->title );
+               $link = $skin->makeKnownLinkObj( $title, $wgContLang->convert( $title->getPrefixedText() ) );
                return "{$link} ({$nb})";
        }
 }
 
+/**
+ * constructor
+ */
 function wfSpecialShortpages() {
        list( $limit, $offset ) = wfCheckLimits();