3 * @addtogroup SpecialPage
7 * Entry point : initialise variables and call subfunctions.
8 * @param $par String: becomes "FOO" when called like Special:Prefixindex/FOO (default NULL)
9 * @param $specialPage SpecialPage object.
11 function wfSpecialPrefixIndex( $par=NULL, $specialPage ) {
12 global $wgRequest, $wgOut, $wgContLang;
15 $from = $wgRequest->getVal( 'from' );
16 $prefix = $wgRequest->getVal( 'prefix' );
17 $namespace = $wgRequest->getInt( 'namespace' );
19 $namespaces = $wgContLang->getNamespaces();
21 $indexPage = new SpecialPrefixIndex();
23 if( !in_array($namespace, array_keys($namespaces)) )
26 $wgOut->setPagetitle( $namespace > 0 ?
27 wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) :
28 wfMsg( 'allarticles' )
34 $indexPage->showChunk( $namespace, $par, $specialPage->including(), $from );
35 } elseif ( isset($prefix) ) {
36 $indexPage->showChunk( $namespace, $prefix, $specialPage->including(), $from );
37 } elseif ( isset($from) ) {
38 $indexPage->showChunk( $namespace, $from, $specialPage->including(), $from );
40 $wgOut->addHtml($indexPage->namespaceForm ( $namespace, null ));
44 class SpecialPrefixindex
extends SpecialAllpages
{
47 var $name='Prefixindex';
48 # Determines, which message describes the input field 'nsfrom', used in function namespaceForm (see superclass SpecialAllpages)
49 var $nsfromMsg='allpagesprefix';
52 * @param integer $namespace (Default NS_MAIN)
53 * @param string $from list all pages from this name (default FALSE)
55 function showChunk( $namespace = NS_MAIN
, $prefix, $including = false, $from = null ) {
56 global $wgOut, $wgUser, $wgContLang;
58 $fname = 'indexShowChunk';
60 $sk = $wgUser->getSkin();
62 if (!isset($from)) $from = $prefix;
64 $fromList = $this->getNamespaceKeyAndText($namespace, $from);
65 $prefixList = $this->getNamespaceKeyAndText($namespace, $prefix);
67 if ( !$prefixList ||
!$fromList ) {
68 $out = wfMsgWikiHtml( 'allpagesbadtitle' );
70 list( $namespace, $prefixKey, $prefix ) = $prefixList;
71 list( /* $fromNs */, $fromKey, $from ) = $fromList;
73 ### FIXME: should complain if $fromNs != $namespace
75 $dbr = wfGetDB( DB_SLAVE
);
77 $res = $dbr->select( 'page',
78 array( 'page_namespace', 'page_title', 'page_is_redirect' ),
80 'page_namespace' => $namespace,
81 'page_title LIKE \'' . $dbr->escapeLike( $prefixKey ) .'%\'',
82 'page_title >= ' . $dbr->addQuotes( $fromKey ),
86 'ORDER BY' => 'page_title',
87 'LIMIT' => $this->maxPerPage +
1,
88 'USE INDEX' => 'name_title',
92 ### FIXME: side link to previous
95 $out = '<table style="background: inherit;" border="0" width="100%">';
97 while( ($n < $this->maxPerPage
) && ($s = $dbr->fetchObject( $res )) ) {
98 $t = Title
::makeTitle( $s->page_namespace
, $s->page_title
);
100 $link = ($s->page_is_redirect ?
'<div class="allpagesredirect">' : '' ) .
101 $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) .
102 ($s->page_is_redirect ?
'</div>' : '' );
104 $link = '[[' . htmlspecialchars( $s->page_title
) . ']]';
109 $out .= "<td>$link</td>";
115 if( ($n %
3) != 0 ) {
124 $nsForm = $this->namespaceForm ( $namespace, $prefix );
125 $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">';
126 $out2 .= '<tr valign="top"><td align="left">' . $nsForm;
127 $out2 .= '</td><td align="right" style="font-size: smaller; margin-bottom: 1em;">' .
128 $sk->makeKnownLink( $wgContLang->specialPage( $this->name
),
129 wfMsg ( 'allpages' ) );
130 if ( isset($dbr) && $dbr && ($n == $this->maxPerPage
) && ($s = $dbr->fetchObject( $res )) ) {
131 $namespaceparam = $namespace ?
"&namespace=$namespace" : "";
132 $out2 .= " | " . $sk->makeKnownLink(
133 $wgContLang->specialPage( $this->name
),
134 wfMsg ( 'nextpage', $s->page_title
),
135 "from=" . wfUrlEncode ( $s->page_title
) .
136 "&prefix=" . wfUrlEncode ( $prefix ) . $namespaceparam );
138 $out2 .= "</td></tr></table><hr />";
141 $wgOut->addHtml( $out2 . $out );