61 $out->addModuleStyles(
'mediawiki.special' );
65 $from = $request->getVal(
'from',
'' );
66 $prefix = $request->getVal(
'prefix',
'' );
67 $ns = $request->getIntOrNull(
'namespace' );
68 $namespace = (int)$ns;
// if no namespace given, use 0 (NS_MAIN). 69 $this->hideRedirects = $request->getBool(
'hideredirects', $this->hideRedirects );
70 $this->stripPrefix = $request->getBool(
'stripprefix', $this->stripPrefix );
73 $out->setPageTitleMsg(
74 ( $namespace > 0 && array_key_exists( $namespace, $namespaces ) )
75 ? $this->
msg(
'prefixindex-namespace' )->plaintextParams(
76 str_replace(
'_',
' ', $namespaces[$namespace] )
78 : $this->
msg(
'prefixindex' )
84 } elseif ( $prefix !=
'' ) {
86 } elseif ( $from !=
'' && $ns ===
null ) {
87// For back-compat with Special:Allpages 88// Don't do this if namespace is passed, so paging works when doing NS views. 92// T29864: if transcluded, show all pages instead of the form. 93if ( $this->
including() || $showme !=
'' || $ns !==
null ) {
155 $fromList = $this->getNamespaceKeyAndText( $namespace, $from );
156 $prefixList = $this->getNamespaceKeyAndText( $namespace, $prefix );
157 $namespaces = $this->getContentLanguage()->getNamespaces();
161 $preparedHtmlForm = $this->namespacePrefixForm( $namespace, $prefix );
163if ( !$prefixList || !$fromList ) {
164 $out = $this->msg(
'allpagesbadtitle' )->parseAsBlock();
165 } elseif ( !array_key_exists( $namespace, $namespaces ) ) {
166// Show errormessage and reset to NS_MAIN 167 $out = $this->msg(
'allpages-bad-ns', $namespace )->parse();
170 [ $namespace, $prefixKey, $prefix ] = $prefixList;
171 [
/* $fromNS */, $fromKey, ] = $fromList;
173 # ## @todo FIXME: Should complain if $fromNs != $namespace 175 $dbr = $this->dbProvider->getReplicaDatabase();
176 $queryBuiler = $dbr->newSelectQueryBuilder()
177 ->select( LinkCache::getSelectFields() )
180'page_namespace' => $namespace,
184newLikeValue( $prefixKey, $dbr->anyString() )
186 $dbr->expr(
'page_title',
'>=', $fromKey ),
188 ->orderBy(
'page_title' )
189 ->limit( $this->maxPerPage + 1 )
190 ->useIndex(
'page_name_title' );
192if ( $this->hideRedirects ) {
193 $queryBuiler->andWhere( [
'page_is_redirect' => 0 ] );
196 $this->getHookRunner()->onSpecialPrefixIndexQuery( $preparedHtmlForm->mFieldData, $queryBuiler );
198 $res = $queryBuiler->caller( __METHOD__ )->fetchResultSet();
200// @todo FIXME: Side link to previous 202if ( $res->numRows() > 0 ) {
203 $out = Html::openElement(
'ul', [
'class' =>
'mw-prefixindex-list' ] );
205 $prefixLength = strlen( $prefix );
206foreach ( $res as $row ) {
207if ( $n >= $this->maxPerPage ) {
211 $title = Title::newFromRow( $row );
212// Make sure it gets into LinkCache 213 $this->linkCache->addGoodLinkObjFromRow( $title, $row );
214 $displayed = $title->getText();
215// Try not to generate unclickable links 216if ( $this->stripPrefix && $prefixLength !== strlen( $displayed ) ) {
217 $displayed = substr( $displayed, $prefixLength );
219 $link = ( $title->isRedirect() ?
'<div class="allpagesredirect">' :
'' ) .
220 $this->getLinkRenderer()->makeKnownLink(
224 ( $title->isRedirect() ?
'</div>' :
'' );
226 $out .=
"<li>$link</li>\n";
230 $out .= Html::closeElement(
'ul' );
232if ( $res->numRows() > 2 ) {
233// Only apply CSS column styles if there are more than 2 entries. 234// Otherwise, rendering is broken as "mw-prefixindex-body"'s CSS column count is 3. 235 $out = Html::rawElement(
'div', [
'class' =>
'mw-prefixindex-body' ], $out );
242 $output = $this->getOutput();
244if ( $this->including() ) {
245// We don't show the nav-links and the form when included in other 246// pages, so let's just finish here. 247 $output->addHTML( $out );
251 $topOut = $preparedHtmlForm->getHTML(
false );
253if ( $res && ( $n == $this->maxPerPage ) && $nextRow ) {
255'from' => $nextRow->page_title,
257'hideredirects' => $this->hideRedirects,
258'stripprefix' => $this->stripPrefix,
261if ( $namespace || $prefix ==
'' ) {
262// Keep the namespace even if it's 0 for empty prefixes. 263// This tells us we're not just a holdover from old links. 264 $query[
'namespace'] = $namespace;
267 $nextLink = $this->getLinkRenderer()->makeKnownLink(
268 $this->getPageTitle(),
269 $this->msg(
'nextpage', str_replace(
'_',
' ', $nextRow->page_title ) )->text(),
274// Link shown at the top of the page below the form 275 $topOut .= Html::rawElement(
'div',
276 [
'class' =>
'mw-prefixindex-nav' ],
280// Link shown at the footer 284 [
'class' =>
'mw-prefixindex-nav' ],
290 $output->addHTML( $topOut . $out );