If local language's magicwords list is incomplete, try fetching it from the English one
[lhc/web/wiklou.git] / includes / SpecialLongpages.php
index 0ebcb7e..6139fdb 100644 (file)
@@ -1,51 +1,42 @@
-<?
+<?php
 
-function wfSpecialLongpages()
-{
-       global $wgUser, $wgOut, $wgLang, $wgTitle;
-       $fname = "wfSpecialLongpages";
-
-       # Cache
-       $vsp = $wgLang->getValidSpecialPages();
-       $log = new LogPage( $vsp["Longpages"] );
-       $log->mUpdateRecentChanges = false;
-
-       global $wgMiserMode;
-       if ( $wgMiserMode ) {
-               $log->showAsDisabledPage();
-               return;
-       }
+require_once( "QueryPage.php" );
 
-       list( $limit, $offset ) = wfCheckLimits();
+class LongPagesPage extends QueryPage {
 
-       $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) DESC LIMIT {$offset}, {$limit}";
-       $res = wfQuery( $sql, DB_READ, $fname );
-
-       $sk = $wgUser->getSkin();
+       function getName() {
+               return "Longpages";
+       }
 
-       $top = wfShowingResults( $offset, $limit );
-       $wgOut->addHTML( "<p>{$top}\n" );
+       function isExpensive() {
+               return true;
+       }
 
-       $sl = wfViewPrevNext( $offset, $limit,
-         $wgLang->specialPage( "Longpages" ) );
-       $wgOut->addHTML( "<br>{$sl}\n" );
+       function getSQL() {
+               return
+                       "SELECT 'Longpages' 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";
+       }
 
-       $s = "<ol start=" . ( $offset + 1 ) . ">";
-       while ( $obj = wfFetchObject( $res ) ) {
-               $nb = wfMsg( "nbytes", $obj->len );
-               $link = $sk->makeKnownLink( $obj->cur_title, "" );
-               $s .= "<li>{$link} ({$nb})</li>\n";
+       function formatResult( $skin, $result ) {
+               global $wgLang;
+               $nb = wfMsg( "nbytes", $wgLang->formatNum( $result->value ) );
+               $link = $skin->makeKnownLink( $result->title, "" );
+               return "{$link} ({$nb})";
        }
-       wfFreeResult( $res );
-       $s .= "</ol>";
-       $wgOut->addHTML( $s );
-       $wgOut->addHTML( "<p>{$sl}\n" );
-
-       # Saving cache
-       if ( $offset > 0 OR $limit < 50 ) return ; #Not suitable
-       $log->replaceContent( $s );
+}
+
+function wfSpecialLongpages()
+{
+    list( $limit, $offset ) = wfCheckLimits();
+
+    $lpp = new LongPagesPage( );
+    
+    $lpp->doQuery( $offset, $limit );
 }
 
 ?>