4 * @subpackage SpecialPage
7 require_once 'SpecialAllpages.php';
10 * Entry point : initialise variables and call subfunctions.
11 * @param $par String: becomes "FOO" when called like Special:Prefixindex/FOO (default NULL)
12 * @param $specialPage SpecialPage object.
14 function wfSpecialPrefixIndex( $par=NULL, $specialPage ) {
15 global $wgRequest, $wgOut, $wgContLang;
18 $from = $wgRequest->getVal( 'from' );
19 $prefix = $wgRequest->getVal( 'prefix' );
20 $namespace = $wgRequest->getInt( 'namespace' );
22 $namespaces = $wgContLang->getNamespaces();
24 $indexPage = new SpecialPrefixIndex();
26 if( !in_array($namespace, array_keys($namespaces)) )
29 $wgOut->setPagetitle( $namespace > 0 ?
30 wfMsg( 'allinnamespace', $namespaces[$namespace] ) :
31 wfMsg( 'allarticles' )
37 $indexPage->showChunk( $namespace, $par, $specialPage->including(), $from );
38 } elseif ( isset($prefix) ) {
39 $indexPage->showChunk( $namespace, $prefix, $specialPage->including(), $from );
40 } elseif ( isset($from) ) {
41 $indexPage->showChunk( $namespace, $from, $specialPage->including(), $from );
43 $wgOut->addHtml($indexPage->namespaceForm ( $namespace, null ));
47 class SpecialPrefixindex
extends SpecialAllpages
{
50 var $name='Prefixindex';
51 # Determines, which message describes the input field 'nsfrom', used in function namespaceForm (see superclass SpecialAllpages)
52 var $nsfromMsg='allpagesprefix';
55 * @param integer $namespace (Default NS_MAIN)
56 * @param string $from list all pages from this name (default FALSE)
58 function showChunk( $namespace = NS_MAIN
, $prefix, $including = false, $from = null ) {
59 global $wgOut, $wgUser, $wgContLang;
61 $fname = 'indexShowChunk';
63 $sk = $wgUser->getSkin();
65 if (!isset($from)) $from = $prefix;
67 $fromList = $this->getNamespaceKeyAndText($namespace, $from);
68 $prefixList = $this->getNamespaceKeyAndText($namespace, $prefix);
70 if ( !$prefixList ||
!$fromList ) {
71 $out = wfMsgWikiHtml( 'allpagesbadtitle' );
73 list( $namespace, $prefixKey, $prefix ) = $prefixList;
74 list( $fromNs, $fromKey, $from ) = $fromList;
76 ### FIXME: should complain if $fromNs != $namespace
78 $dbr =& wfGetDB( DB_SLAVE
);
80 $res = $dbr->select( 'page',
81 array( 'page_namespace', 'page_title', 'page_is_redirect' ),
83 'page_namespace' => $namespace,
84 'page_title LIKE \'' . $dbr->escapeLike( $prefixKey ) .'%\'',
85 'page_title >= ' . $dbr->addQuotes( $fromKey ),
89 'ORDER BY' => 'page_title',
90 'LIMIT' => $this->maxPerPage +
1,
91 'USE INDEX' => 'name_title',
95 ### FIXME: side link to previous
98 $out = '<table style="background: inherit;" border="0" width="100%">';
100 $namespaces = $wgContLang->getFormattedNamespaces();
101 while( ($n < $this->maxPerPage
) && ($s = $dbr->fetchObject( $res )) ) {
102 $t = Title
::makeTitle( $s->page_namespace
, $s->page_title
);
104 $link = ($s->page_is_redirect ?
'<div class="allpagesredirect">' : '' ) .
105 $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) .
106 ($s->page_is_redirect ?
'</div>' : '' );
108 $link = '[[' . htmlspecialchars( $s->page_title
) . ']]';
113 $out .= "<td>$link</td>";
119 if( ($n %
3) != 0 ) {
128 $nsForm = $this->namespaceForm ( $namespace, $prefix );
129 $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">';
130 $out2 .= '<tr valign="top"><td align="left">' . $nsForm;
131 $out2 .= '</td><td align="right" style="font-size: smaller; margin-bottom: 1em;">' .
132 $sk->makeKnownLink( $wgContLang->specialPage( $this->name
),
133 wfMsg ( 'allpages' ) );
134 if ( isset($dbr) && $dbr && ($n == $this->maxPerPage
) && ($s = $dbr->fetchObject( $res )) ) {
135 $namespaceparam = $namespace ?
"&namespace=$namespace" : "";
136 $out2 .= " | " . $sk->makeKnownLink(
137 $wgContLang->specialPage( $this->name
),
138 wfMsg ( 'nextpage', $s->page_title
),
139 "from=" . wfUrlEncode ( $s->page_title
) .
140 "&prefix=" . wfUrlEncode ( $prefix ) . $namespaceparam );
142 $out2 .= "</td></tr></table><hr />";
145 $wgOut->addHtml( $out2 . $out );