Scripts and data used for generating ZhConversion.php
[lhc/web/wiklou.git] / includes / SpecialLonelypages.php
index 35db753..64c3e00 100644 (file)
@@ -1,50 +1,53 @@
-<?
-
-function wfSpecialLonelypages()
-{
-       global $wgUser, $wgOut, $wgLang, $wgTitle;
-       $fname = "wfSpecialLonelypages";
-
-       # Cache
-       $vsp = $wgLang->getValidSpecialPages();
-       $log = new LogPage( $vsp["Lonelypages"] );
-       $log->mUpdateRecentChanges = false;
-
-       global $wgMiserMode;
-       if ( $wgMiserMode ) {
-               $log->showAsDisabledPage();
-               return;
+<?php
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
+
+/**
+ *
+ */
+require_once( "QueryPage.php" );
+
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
+class LonelyPagesPage extends PageQueryPage {
+
+       function getName() {
+               return "Lonelypages";
        }
 
-       list( $limit, $offset ) = wfCheckLimits();
-
-       $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 );
+       function sortDescending() {
+               return false;
+       }
 
-       $sk = $wgUser->getSkin();
+       function isExpensive() {
+               return true;
+       }
+       
+       function getSQL() {
+               $dbr =& wfGetDB( DB_SLAVE );
+               extract( $dbr->tableNames( 'cur', 'links' ) );
+
+               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";
+       }
+}
 
-       $top = wfShowingResults( $offset, $limit );
-       $wgOut->addHTML( "<p>{$top}\n" );
+/**
+ * Constructor
+ */
+function wfSpecialLonelypages() {
+       list( $limit, $offset ) = wfCheckLimits();
 
-       $sl = wfViewPrevNext( $offset, $limit,
-         $wgLang->specialPage( "Lonelypages" ) );
-       $wgOut->addHTML( "<br>{$sl}\n" );
+       $lpp = new LonelyPagesPage();
 
-       $s = "<ol start=" . ( $offset + 1 ) . ">";
-       while ( $obj = wfFetchObject( $res ) ) {
-               $link = $sk->makeKnownLink( $obj->cur_title, "" );
-               $s .= "<li>{$link}</li>\n";
-       }
-       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 );
+       return $lpp->doQuery( $offset, $limit );
 }
 
 ?>