isExpensive get default value
[lhc/web/wiklou.git] / includes / SpecialAllpages.php
index 2e01937..ccac741 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();
@@ -51,7 +52,7 @@ function indexShowToplevel()
        # There's got to be a cleaner way to do this!
        for( $i = 1; $i < $sections; $i++ ) {
                $from = $i * $indexMaxperpage;
-               $sql = "SELECT cur_title $fromwhere $order LIMIT $from,2";
+               $sql = "SELECT cur_title $fromwhere $order ".wfLimitResult(2,$from);
                $res = wfQuery( $sql, DB_READ, $fname );
        
                $s = wfFetchObject( $res );
@@ -65,7 +66,7 @@ function indexShowToplevel()
        }
        
        $from = $i * $indexMaxperpage;
-       $sql = "SELECT cur_title $fromwhere $order LIMIT " . ($count-1) . ",1";
+       $sql = "SELECT cur_title $fromwhere $order ".wfLimitResult(1,$count-1);
        $res = wfQuery( $sql, DB_READ, $fname );
        $s = wfFetchObject( $res );
        $outpoint = $s->cur_title;
@@ -108,24 +109,31 @@ ORDER BY cur_title
 LIMIT {$indexMaxperpage}";
        $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";
        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 ) . "]]";
+               }
+               if( $n == 0 ) {
+                       $out .= "<tr>\n";
+               }
+               $out .= "<td width=\"33%\">$link</td>";
                $n = ++$n % 3;
                if( $n == 0 ) {
-                       $out .= "</tr>\n<tr>";
+                       $out .= "</tr>\n";
                }
        }
        if( $n != 0 ) {
                $out .= "</tr>\n";
        }
        $out .= "</table>";
-       #return $out;
+#return $out;
        $wgOut->addHtml( $out );
 }