4 * @subpackage SpecialPage
8 * Entry point : initialise variables and call subfunctions.
9 * @param string $par Becomes "FOO" when called like Special:Prefixindex/FOO (default NULL)
12 require_once 'SpecialAllpages.php';
14 function wfSpecialPrefixIndex( $par=NULL, $specialPage ) {
15 global $wgRequest, $wgOut, $wgContLang;
18 $from = $wgRequest->getVal( 'from' );
19 $namespace = $wgRequest->getInt( 'namespace' );
21 $namespaces = $wgContLang->getNamespaces();
23 $indexPage = new SpecialPrefixIndex();
25 if( !in_array($namespace, array_keys($namespaces)) )
28 $wgOut->setPagetitle( $namespace > 0 ?
29 wfMsg( 'allinnamespace', $namespaces[$namespace] ) :
30 wfMsg( 'allarticles' )
35 $indexPage->showChunk( $namespace, $par, $specialPage->including() );
36 } elseif ( isset($from) ) {
37 $indexPage->showChunk( $namespace, $from, $specialPage->including() );
39 $wgOut->addHtml($indexPage->namespaceForm ( $namespace, $from ));
43 class SpecialPrefixindex
extends SpecialAllpages
{
46 var $name='Prefixindex';
49 * @param integer $namespace (Default NS_MAIN)
50 * @param string $from list all pages from this name (default FALSE)
52 function showChunk( $namespace = NS_MAIN
, $from, $including = false ) {
53 global $wgOut, $wgUser, $wgContLang;
55 $fname = 'indexShowChunk';
57 $sk = $wgUser->getSkin();
59 $fromTitle = Title
::newFromURL( $from );
60 if ($namespace == NS_MAIN
and $fromTitle) {
61 $namespace = $fromTitle->getNamespace();
64 $fromKey = is_null( $fromTitle ) ?
'' : $fromTitle->getDBkey();
66 $dbr =& wfGetDB( DB_SLAVE
);
68 $res = $dbr->select( 'page',
69 array( 'page_namespace', 'page_title', 'page_is_redirect' ),
71 'page_namespace' => $namespace,
72 'page_title LIKE \'' . $dbr->escapeLike( $fromKey ) .'%\''
76 'ORDER BY' => 'page_title',
77 'LIMIT' => $this->maxPerPage +
1,
78 'USE INDEX' => 'name_title',
82 ### FIXME: side link to previous
85 $out = '<table style="background: inherit;" border="0" width="100%">';
87 $namespaces = $wgContLang->getFormattedNamespaces();
88 while( ($n < $this->maxPerPage
) && ($s = $dbr->fetchObject( $res )) ) {
89 $t = Title
::makeTitle( $s->page_namespace
, $s->page_title
);
91 $link = ($s->page_is_redirect ?
'<div class="allpagesredirect">' : '' ) .
92 $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) .
93 ($s->page_is_redirect ?
'</div>' : '' );
95 $link = '[[' . htmlspecialchars( $s->page_title
) . ']]';
100 $out .= "<td>$link</td>";
106 if( ($n %
3) != 0 ) {
114 $nsForm = $this->namespaceForm ( $namespace, $from );
115 $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">';
116 $out2 .= '<tr valign="top"><td align="left">' . $nsForm;
117 $out2 .= '</td><td align="right" style="font-size: smaller; margin-bottom: 1em;">' .
118 $sk->makeKnownLink( $wgContLang->specialPage( $this->name
),
119 wfMsg ( 'allpages' ) );
120 if ( ($n == $this->maxPerPage
) && ($s = $dbr->fetchObject( $res )) ) {
121 $namespaceparam = $namespace ?
"&namespace=$namespace" : "";
122 $out2 .= " | " . $sk->makeKnownLink(
123 $wgContLang->specialPage( $this->name
),
124 wfMsg ( 'nextpage', $s->page_title
),
125 "from=" . wfUrlEncode ( $s->page_title
) . $namespaceparam );
127 $out2 .= "</td></tr></table><hr />";
130 $wgOut->addHtml( $out2 . $out );