updates from the French Wikipedia's copy
[mediawiki.git] / includes / SpecialAllpages.php
blobbbd5fdc1ff280409da38391c675426dec70d03d8
1 <?
3 function wfSpecialAllpages()
5 global $from, $indexMaxperpage;
6 $indexMaxperpage = 480;
8 if( isset( $from ) ) {
9 indexShowChunk( $from );
10 } else {
11 indexShowToplevel();
15 function indexShowToplevel()
17 global $wgOut, $indexMaxperpage, $wgLang;
18 $fname = "indexShowToplevel";
20 # Cache
21 $vsp = $wgLang->getValidSpecialPages();
22 $log = new LogPage( $vsp["Allpages"] );
23 $log->mUpdateRecentChanges = false;
25 global $wgMiserMode;
26 if ( $wgMiserMode ) {
27 $log->showAsDisabledPage();
28 return;
32 # $fromwhere = "FROM cur WHERE cur_namespace=0 AND cur_is_redirect=0";
33 $fromwhere = "FROM cur WHERE cur_namespace=0";
34 $order = "ORDER BY cur_title";
35 $out = "";
37 $sql = "SELECT COUNT(*) AS count $fromwhere";
38 $res = wfQuery( $sql, $fname );
39 $s = wfFetchObject( $res );
40 $count = $s->count;
41 $sections = ceil( $count / $indexMaxperpage );
43 $sql = "SELECT cur_title $fromwhere $order LIMIT 1";
44 $res = wfQuery( $sql, $fname );
45 $s = wfFetchObject( $res );
46 $inpoint = $s->cur_title;
48 $out .= "<table>\n";
49 # There's got to be a cleaner way to do this!
50 for( $i = 1; $i < $sections; $i++ ) {
51 $from = $i * $indexMaxperpage;
52 $sql = "SELECT cur_title $fromwhere $order LIMIT $from,2";
53 $res = wfQuery( $sql, $fname );
55 $s = wfFetchObject( $res );
56 $outpoint = $s->cur_title;
57 $out .= indexShowline( $inpoint, $outpoint );
59 $s = wfFetchObject( $res );
60 $inpoint = $s->cur_title;
62 wfFreeResult( $res );
65 $from = $i * $indexMaxperpage;
66 $sql = "SELECT cur_title $fromwhere $order LIMIT " . ($count-1) . ",1";
67 $res = wfQuery( $sql, $fname );
68 $s = wfFetchObject( $res );
69 $outpoint = $s->cur_title;
70 $out .= indexShowline( $inpoint, $outpoint );
71 $out .= "</table>\n";
73 # Saving cache
74 $log->replaceContent( $out );
76 $wgOut->addHtml( $out );
79 function indexShowline( $inpoint, $outpoint )
81 global $wgOut, $wgLang, $wgUser;
82 $sk = $wgUser->getSkin();
84 # Fixme: this is ugly
85 $out = wfMsg(
86 "alphaindexline",
87 $sk->makeKnownLink( $wgLang->specialPage( "Allpages" ),
88 str_replace( "_", " ", $inpoint ),
89 "from=" . wfStrencode( $inpoint ) ) . "</td><td>",
90 "</td><td align=\"left\">" .
91 str_replace( "_", " ", $outpoint )
93 return "<tr><td align=\"right\">{$out}</td></tr>\n";
96 function indexShowChunk( $from )
98 global $wgOut, $wgUser, $indexMaxperpage;
99 $sk = $wgUser->getSkin();
101 $out = "";
102 $sql = "SELECT cur_title
103 FROM cur
104 WHERE cur_namespace=0 AND cur_title >= '" . wfStrencode( $from ) . "'
105 ORDER BY cur_title
106 LIMIT {$indexMaxperpage}";
107 $res = wfQuery( $sql, "indexShowChunk" );
109 # FIXME: Dynamic column widths, backlink to main list,
110 # side links to next and previous
111 $n = 0;
112 $out = "<table border=\"0\">\n";
113 while( $s = wfFetchObject( $res ) ) {
114 $out .= "<td width=\"33%\">" .
115 $sk->makeKnownLink( $s->cur_title ) .
116 "</td>";
117 $n = ++$n % 3;
118 if( $n == 0 ) {
119 $out .= "</tr>\n<tr>";
122 if( $n != 0 ) {
123 $out .= "</tr>\n";
125 $out .= "</table>";
126 #return $out;
127 $wgOut->addHtml( $out );