typo
[lhc/web/wiklou.git] / includes / SpecialLonelypages.php
index ab7f937..ebb4f0b 100644 (file)
@@ -1,55 +1,30 @@
-<?
+<?php
 
-function wfSpecialLonelypages()
-{
-       global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
-       $fname = "wfSpecialLonelypages";
+require_once( "QueryPage.php" );
 
-       # Cache
-       $vsp = $wgLang->getValidSpecialPages();
-       $log = new LogPage( $vsp["Lonelypages"] );
-       $log->mUpdateRecentChanges = false;
-
-       global $wgMiserMode;
-       if ( $wgMiserMode ) {
-               $log->showAsDisabledPage();
-               return;
+class LonelyPagesPage extends PageQueryPage {
+       
+       function getName() {
+               return "Lonelypages";
        }
-
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
+       
+       function isExpensive() {
+               return true;
        }
-       if ( ! $offset ) { $offset = 0; }
-
-       $sql = "SELECT cur_title FROM cur LEFT JOIN links ON " .
-         "cur_id=l_to WHERE l_to IS NULL AND cur_namespace=0 AND " .
-         "cur_is_redirect=0 ORDER BY cur_title LIMIT {$offset}, {$limit}";
-       $res = wfQuery( $sql, $fname );
-
-       $sk = $wgUser->getSkin();
-
-       $top = wfShowingResults( $offset, $limit );
-       $wgOut->addHTML( "<p>{$top}\n" );
-
-       $sl = wfViewPrevNext( $offset, $limit,
-         $wgLang->specialPage( "Lonelypages" ) );
-       $wgOut->addHTML( "<br>{$sl}\n" );
-
-       $s = "<ol start=" . ( $offset + 1 ) . ">";
-       while ( $obj = wfFetchObject( $res ) ) {
-               $link = $sk->makeKnownLink( $obj->cur_title, "" );
-               $s .= "<li>{$link}</li>\n";
+       
+       function getSQL() {
+               return "SELECT 'Lonelypages' as type, cur_namespace AS namespace, cur_title AS title, cur_title AS value " .
+                       "FROM cur LEFT JOIN links ON cur_id=l_to ".
+                       "WHERE l_to IS NULL AND cur_namespace=0 AND cur_is_redirect=0";
        }
-       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 wfSpecialLonelypages() {
+       list( $limit, $offset ) = wfCheckLimits();
+       
+       $lpp = new LonelyPagesPage();
+       
+       return $lpp->doQuery( $offset, $limit );
 }
 
 ?>