use of $wgRequest
[lhc/web/wiklou.git] / includes / SpecialAllpages.php
index 8ba8225..e418756 100644 (file)
@@ -1,13 +1,14 @@
-<?
+<?php
 
 function wfSpecialAllpages( $par=NULL )
 {
-       global $from, $indexMaxperpage;
+       global $indexMaxperpage, $wgRequest;
        $indexMaxperpage = 480;
+       $from = $wgRequest->getVal( 'from' );
 
        if( $par ) {
                indexShowChunk( $par );
-       } elseif( isset( $from ) ) {
+       } elseif( !is_null( $from ) ) {
                indexShowChunk( $from );
        } else {
                indexShowToplevel();
@@ -37,13 +38,13 @@ function indexShowToplevel()
        $out = "";
        
        $sql = "SELECT COUNT(*) AS count $fromwhere";
-       $res = wfQuery( $sql, $fname );
+       $res = wfQuery( $sql, DB_READ, $fname );
        $s = wfFetchObject( $res );
        $count = $s->count;
        $sections = ceil( $count / $indexMaxperpage );
        
        $sql = "SELECT cur_title $fromwhere $order LIMIT 1";
-       $res = wfQuery( $sql, $fname );
+       $res = wfQuery( $sql, DB_READ, $fname );
        $s = wfFetchObject( $res );
        $inpoint = $s->cur_title;
        
@@ -52,7 +53,7 @@ function indexShowToplevel()
        for( $i = 1; $i < $sections; $i++ ) {
                $from = $i * $indexMaxperpage;
                $sql = "SELECT cur_title $fromwhere $order LIMIT $from,2";
-               $res = wfQuery( $sql, $fname );
+               $res = wfQuery( $sql, DB_READ, $fname );
        
                $s = wfFetchObject( $res );
                $outpoint = $s->cur_title;
@@ -66,7 +67,7 @@ function indexShowToplevel()
        
        $from = $i * $indexMaxperpage;
        $sql = "SELECT cur_title $fromwhere $order LIMIT " . ($count-1) . ",1";
-       $res = wfQuery( $sql, $fname );
+       $res = wfQuery( $sql, DB_READ, $fname );
        $s = wfFetchObject( $res );
        $outpoint = $s->cur_title;
        $out .= indexShowline( $inpoint, $outpoint );
@@ -106,16 +107,20 @@ FROM cur
 WHERE cur_namespace=0 AND cur_title >= '" . wfStrencode( $from ) . "'
 ORDER BY cur_title
 LIMIT {$indexMaxperpage}";
-       $res = wfQuery( $sql, "indexShowChunk" );
+       $res = wfQuery( $sql, DB_READ, "indexShowChunk" );
 
-       # FIXME: Dynamic column widths, backlink to main list,
-       # side links to next and previous
+# FIXME: Dynamic column widths, backlink to main list,
+# side links to next and previous
        $n = 0;
-       $out = "<table border=\"0\">\n";
+       $out = "<table border=\"0\">\n<tr>";
        while( $s = wfFetchObject( $res ) ) {
-               $out .= "<td width=\"33%\">" .
-                       $sk->makeKnownLink( $s->cur_title ) .
-                       "</td>";
+               $t = Title::makeTitle( 0, $s->cur_title );
+               if( $t ) {
+                       $link = $sk->makeKnownLinkObj( $t );
+               } else {
+                       $link = "[[" . htmlspecialchars( $s->cur_title ) . "]]";
+               }
+               $out .= "<td width=\"33%\">$link</td>";
                $n = ++$n % 3;
                if( $n == 0 ) {
                        $out .= "</tr>\n<tr>";
@@ -125,7 +130,7 @@ LIMIT {$indexMaxperpage}";
                $out .= "</tr>\n";
        }
        $out .= "</table>";
-       #return $out;
+#return $out;
        $wgOut->addHtml( $out );
 }