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';
47 # Determines, which message describes the input field 'nsfrom', used in function namespaceForm (see superclass SpecialAllpages)
48 var $nsfromMsg='allpagesprefix';
51 * @param integer $namespace (Default NS_MAIN)
52 * @param string $from list all pages from this name (default FALSE)
54 function showChunk( $namespace = NS_MAIN
, $from, $including = false ) {
55 global $wgOut, $wgUser, $wgContLang;
57 $fname = 'indexShowChunk';
59 $sk = $wgUser->getSkin();
61 $fromTitle = Title
::newFromURL( $from );
62 if ($namespace == NS_MAIN
and $fromTitle) {
63 $namespace = $fromTitle->getNamespace();
66 $fromKey = is_null( $fromTitle ) ?
'' : $fromTitle->getDBkey();
68 $dbr =& wfGetDB( DB_SLAVE
);
70 $res = $dbr->select( 'page',
71 array( 'page_namespace', 'page_title', 'page_is_redirect' ),
73 'page_namespace' => $namespace,
74 'page_title LIKE \'' . $dbr->escapeLike( $fromKey ) .'%\''
78 'ORDER BY' => 'page_title',
79 'LIMIT' => $this->maxPerPage +
1,
80 'USE INDEX' => 'name_title',
84 ### FIXME: side link to previous
87 $out = '<table style="background: inherit;" border="0" width="100%">';
89 $namespaces = $wgContLang->getFormattedNamespaces();
90 while( ($n < $this->maxPerPage
) && ($s = $dbr->fetchObject( $res )) ) {
91 $t = Title
::makeTitle( $s->page_namespace
, $s->page_title
);
93 $link = ($s->page_is_redirect ?
'<div class="allpagesredirect">' : '' ) .
94 $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) .
95 ($s->page_is_redirect ?
'</div>' : '' );
97 $link = '[[' . htmlspecialchars( $s->page_title
) . ']]';
102 $out .= "<td>$link</td>";
108 if( ($n %
3) != 0 ) {
116 $nsForm = $this->namespaceForm ( $namespace, $from );
117 $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">';
118 $out2 .= '<tr valign="top"><td align="left">' . $nsForm;
119 $out2 .= '</td><td align="right" style="font-size: smaller; margin-bottom: 1em;">' .
120 $sk->makeKnownLink( $wgContLang->specialPage( $this->name
),
121 wfMsg ( 'allpages' ) );
122 if ( ($n == $this->maxPerPage
) && ($s = $dbr->fetchObject( $res )) ) {
123 $namespaceparam = $namespace ?
"&namespace=$namespace" : "";
124 $out2 .= " | " . $sk->makeKnownLink(
125 $wgContLang->specialPage( $this->name
),
126 wfMsg ( 'nextpage', $s->page_title
),
127 "from=" . wfUrlEncode ( $s->page_title
) . $namespaceparam );
129 $out2 .= "</td></tr></table><hr />";
132 $wgOut->addHtml( $out2 . $out );