2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2003-07-02 06:22:03 +00:00
|
|
|
function wfSpecialAllpages( $par=NULL )
|
2003-04-14 23:10:40 +00:00
|
|
|
{
|
2004-07-10 03:09:26 +00:00
|
|
|
global $indexMaxperpage, $wgRequest;
|
2003-04-14 23:10:40 +00:00
|
|
|
$indexMaxperpage = 480;
|
2004-04-01 12:53:01 +00:00
|
|
|
$from = $wgRequest->getVal( 'from' );
|
2004-08-13 00:56:03 +00:00
|
|
|
$namespace = $wgRequest->getVal( 'namespace' );
|
|
|
|
|
if ( is_null($namespace) ) { $namespace = 0; }
|
|
|
|
|
|
2003-07-02 06:22:03 +00:00
|
|
|
if( $par ) {
|
2004-08-13 00:56:03 +00:00
|
|
|
indexShowChunk( $par, $namespace );
|
2004-04-01 12:53:01 +00:00
|
|
|
} elseif( !is_null( $from ) ) {
|
2004-08-13 00:56:03 +00:00
|
|
|
indexShowChunk( $from, $namespace );
|
2003-04-14 23:10:40 +00:00
|
|
|
} else {
|
|
|
|
|
indexShowToplevel();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function indexShowToplevel()
|
|
|
|
|
{
|
2003-05-16 11:19:06 +00:00
|
|
|
global $wgOut, $indexMaxperpage, $wgLang;
|
2003-04-14 23:10:40 +00:00
|
|
|
$fname = "indexShowToplevel";
|
2003-05-16 11:19:06 +00:00
|
|
|
|
|
|
|
|
# Cache
|
|
|
|
|
$vsp = $wgLang->getValidSpecialPages();
|
|
|
|
|
$log = new LogPage( $vsp["Allpages"] );
|
|
|
|
|
$log->mUpdateRecentChanges = false;
|
|
|
|
|
|
|
|
|
|
global $wgMiserMode;
|
|
|
|
|
if ( $wgMiserMode ) {
|
|
|
|
|
$log->showAsDisabledPage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2004-08-13 00:56:03 +00:00
|
|
|
|
2004-07-18 08:48:43 +00:00
|
|
|
$dbr =& wfGetDB( DB_SLAVE );
|
|
|
|
|
$cur = $dbr->tableName( 'cur' );
|
|
|
|
|
$fromwhere = "FROM $cur WHERE cur_namespace=0";
|
|
|
|
|
$order = 'ORDER BY cur_title';
|
2003-04-14 23:10:40 +00:00
|
|
|
$out = "";
|
2004-07-18 08:48:43 +00:00
|
|
|
$where = array( 'cur_namespace' => 0 );
|
2004-07-08 16:50:22 +00:00
|
|
|
|
2004-07-18 08:48:43 +00:00
|
|
|
$count = $dbr->selectField( 'cur', 'COUNT(*)', $where, $fname );
|
2003-04-14 23:10:40 +00:00
|
|
|
$sections = ceil( $count / $indexMaxperpage );
|
2004-07-18 08:48:43 +00:00
|
|
|
$inpoint = $dbr->selectField( 'cur', 'cur_title', $where, $fname, $order );
|
2004-08-13 00:56:03 +00:00
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
$out .= "<table>\n";
|
|
|
|
|
# There's got to be a cleaner way to do this!
|
|
|
|
|
for( $i = 1; $i < $sections; $i++ ) {
|
|
|
|
|
$from = $i * $indexMaxperpage;
|
2004-08-10 13:58:55 +00:00
|
|
|
$sql = "SELECT cur_title $fromwhere $order ".$dbr->limitResult(2,$from);
|
2004-07-18 08:48:43 +00:00
|
|
|
$res = $dbr->query( $sql, $fname );
|
2004-07-08 16:50:22 +00:00
|
|
|
|
2004-07-18 08:48:43 +00:00
|
|
|
$s = $dbr->fetchObject( $res );
|
2003-04-14 23:10:40 +00:00
|
|
|
$outpoint = $s->cur_title;
|
|
|
|
|
$out .= indexShowline( $inpoint, $outpoint );
|
2004-07-08 16:50:22 +00:00
|
|
|
|
2004-07-18 08:48:43 +00:00
|
|
|
$s = $dbr->fetchObject( $res );
|
2003-04-14 23:10:40 +00:00
|
|
|
$inpoint = $s->cur_title;
|
2004-07-08 16:50:22 +00:00
|
|
|
|
2004-07-18 08:48:43 +00:00
|
|
|
$dbr->freeResult( $res );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2004-07-08 16:50:22 +00:00
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
$from = $i * $indexMaxperpage;
|
2004-06-11 16:37:15 +00:00
|
|
|
$sql = "SELECT cur_title $fromwhere $order ".wfLimitResult(1,$count-1);
|
2004-07-18 08:48:43 +00:00
|
|
|
$res = $dbr->query( $sql, $fname );
|
|
|
|
|
$s = $dbr->fetchObject( $res );
|
2003-04-14 23:10:40 +00:00
|
|
|
$outpoint = $s->cur_title;
|
|
|
|
|
$out .= indexShowline( $inpoint, $outpoint );
|
|
|
|
|
$out .= "</table>\n";
|
2003-05-16 11:19:06 +00:00
|
|
|
|
|
|
|
|
# Saving cache
|
|
|
|
|
$log->replaceContent( $out );
|
2004-07-08 16:50:22 +00:00
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
$wgOut->addHtml( $out );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function indexShowline( $inpoint, $outpoint )
|
|
|
|
|
{
|
|
|
|
|
global $wgOut, $wgLang, $wgUser;
|
|
|
|
|
$sk = $wgUser->getSkin();
|
2004-07-18 08:48:43 +00:00
|
|
|
$dbr =& wfGetDB( DB_SLAVE );
|
2003-04-14 23:10:40 +00:00
|
|
|
|
|
|
|
|
# Fixme: this is ugly
|
|
|
|
|
$out = wfMsg(
|
|
|
|
|
"alphaindexline",
|
|
|
|
|
$sk->makeKnownLink( $wgLang->specialPage( "Allpages" ),
|
|
|
|
|
str_replace( "_", " ", $inpoint ),
|
2004-07-18 08:48:43 +00:00
|
|
|
"from=" . $dbr->strencode( $inpoint ) ) . "</td><td>",
|
2003-04-14 23:10:40 +00:00
|
|
|
"</td><td align=\"left\">" .
|
|
|
|
|
str_replace( "_", " ", $outpoint )
|
|
|
|
|
);
|
|
|
|
|
return "<tr><td align=\"right\">{$out}</td></tr>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-13 00:56:03 +00:00
|
|
|
function indexShowChunk( $from, $namespace = 0 )
|
2003-04-14 23:10:40 +00:00
|
|
|
{
|
2004-07-08 16:50:22 +00:00
|
|
|
global $wgOut, $wgUser, $indexMaxperpage, $wgLang;
|
2003-04-14 23:10:40 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
2004-07-08 16:50:22 +00:00
|
|
|
$maxPlusOne = $indexMaxperpage + 1;
|
2004-08-13 00:56:03 +00:00
|
|
|
$namespacee = intval($namespace);
|
2004-07-08 16:50:22 +00:00
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
$out = "";
|
2004-07-18 08:48:43 +00:00
|
|
|
$dbr =& wfGetDB( DB_SLAVE );
|
|
|
|
|
$cur = $dbr->tableName( 'cur' );
|
2004-08-13 00:56:03 +00:00
|
|
|
$sql = "SELECT cur_title FROM $cur WHERE cur_namespace=$namespacee AND cur_title >= '"
|
2004-07-18 08:48:43 +00:00
|
|
|
. $dbr->strencode( $from ) . "' ORDER BY cur_title LIMIT " . $maxPlusOne;
|
|
|
|
|
$res = $dbr->query( $sql, "indexShowChunk" );
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-07-08 16:50:22 +00:00
|
|
|
### FIXME: side link to previous
|
|
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
$n = 0;
|
2004-07-08 16:50:22 +00:00
|
|
|
$out = "<table border=\"0\" width=\"100%\">\n";
|
2004-07-18 08:48:43 +00:00
|
|
|
while( ($n < $indexMaxperpage) && ($s = $dbr->fetchObject( $res )) ) {
|
2004-08-13 00:56:03 +00:00
|
|
|
$t = Title::makeTitle( $namespacee, $s->cur_title );
|
2003-11-12 10:21:28 +00:00
|
|
|
if( $t ) {
|
|
|
|
|
$link = $sk->makeKnownLinkObj( $t );
|
|
|
|
|
} else {
|
|
|
|
|
$link = "[[" . htmlspecialchars( $s->cur_title ) . "]]";
|
|
|
|
|
}
|
2004-07-08 16:50:22 +00:00
|
|
|
if( $n % 3 == 0 ) {
|
2004-04-09 08:27:00 +00:00
|
|
|
$out .= "<tr>\n";
|
|
|
|
|
}
|
2004-07-08 16:50:22 +00:00
|
|
|
$out .= "<td>$link</td>";
|
|
|
|
|
$n++;
|
|
|
|
|
if( $n % 3 == 0 ) {
|
2004-04-09 08:27:00 +00:00
|
|
|
$out .= "</tr>\n";
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-07-08 16:50:22 +00:00
|
|
|
if( ($n % 3) != 0 ) {
|
2003-04-14 23:10:40 +00:00
|
|
|
$out .= "</tr>\n";
|
|
|
|
|
}
|
|
|
|
|
$out .= "</table>";
|
2004-07-08 16:50:22 +00:00
|
|
|
|
|
|
|
|
$out2 = "<div style='text-align: right; font-size: smaller; margin-bottom: 1em;'>" .
|
|
|
|
|
$sk->makeKnownLink( $wgLang->specialPage( "Allpages" ),
|
|
|
|
|
wfMsg ( 'allpages' ) );
|
2004-07-18 08:48:43 +00:00
|
|
|
if ( ($n == $indexMaxperpage) && ($s = $dbr->fetchObject( $res )) ) {
|
2004-07-08 16:50:22 +00:00
|
|
|
$out2 .= " | " . $sk->makeKnownLink(
|
|
|
|
|
$wgLang->specialPage( "Allpages" ),
|
|
|
|
|
wfMsg ( 'nextpage', $s->cur_title ),
|
2004-07-18 08:48:43 +00:00
|
|
|
"from=" . $dbr->strencode( $s->cur_title ) );
|
2004-07-08 16:50:22 +00:00
|
|
|
}
|
|
|
|
|
$out2 .= "</div>";
|
|
|
|
|
|
|
|
|
|
$wgOut->addHtml( $out2 . $out );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|