new wfMsg* functions to use the wgContLang object for translating content related...
[lhc/web/wiklou.git] / includes / SpecialShortpages.php
index 76e18ed..3aeaa4f 100644 (file)
@@ -1,56 +1,65 @@
-<?
-
-function wfSpecialShortpages()
-{
-       global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
-       $fname = "wfSpecialShortpages";
-
-       # Cache
-       $vsp = $wgLang->getValidSpecialPages();
-       $log = new LogPage( $vsp["Shortpages"] );
-       $log->mUpdateRecentChanges = false;
-
-       global $wgMiserMode;
-       if ( $wgMiserMode ) {
-               $log->showAsDisabledPage();
-               return;
+<?php
+/**
+ *
+ * @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";
+       }
+
+       function isExpensive() {
+               return true;
        }
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
+       function getSQL() {
+               $dbr =& wfGetDB( DB_SLAVE );
+               $cur = $dbr->tableName( 'cur' );
+               
+               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";
        }
-       if ( ! $offset ) { $offset = 0; }
-
-       $sql = "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " .
-         "WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
-         "LENGTH(cur_text) LIMIT {$offset}, {$limit}";
-       $res = wfQuery( $sql, $fname );
-
-       $top = wfShowingResults( $offset, $limit );
-       $wgOut->addHTML( "<p>{$top}\n" );
-
-       $sl = wfViewPrevNext( $offset, $limit,
-         $wgLang->specialPage( "Shortpages" ) );
-       $wgOut->addHTML( "<br>{$sl}\n" );
-
-       $sk = $wgUser->getSkin();
-       $s = "<ol start=" . ( $offset + 1 ) . ">";
-       while ( $obj = wfFetchObject( $res ) ) {
-               $nb = str_replace( "$1", $obj->len, wfMsg( "nbytes" ) );
-               $link = $sk->makeKnownLink( $obj->cur_title, "" );
-               $s .= "<li>{$link} ({$nb})</li>\n";
+       
+       function sortDescending() {
+               return false;
        }
-       wfFreeResult( $res );
-       $s .= "</ol>";
-       $wgOut->addHTML( $s );
-       $wgOut->addHTML( "<p>{$sl}\n" );
 
+       function formatResult( $skin, $result ) {
+               global $wgLang;
+               $nb = wfMsg( "nbytes", $wgLang->formatNum( $result->value ) );
+               $link = $skin->makeKnownLink( $result->title, "" );
+               return "{$link} ({$nb})";
+       }
+}
+
+/**
+ * constructor
+ */
+function wfSpecialShortpages() {
+       list( $limit, $offset ) = wfCheckLimits();
+
+       $spp = new ShortPagesPage();
 
-       # Saving cache
-       if ( $offset > 0 OR $limit < 50 ) return ; #Not suitable
-       $log->replaceContent( $s );
+       return $spp->doQuery( $offset, $limit );
 }
 
 ?>