77 $out->addModuleStyles(
'mediawiki.special' );
81 $from = $request->getVal(
'from',
'' );
82 $prefix = $request->getVal(
'prefix',
'' );
83 $ns = $request->getIntOrNull(
'namespace' );
84 $namespace = (int)$ns;
85 $this->hideRedirects = $request->getBool(
'hideredirects', $this->hideRedirects );
86 $this->stripPrefix = $request->getBool(
'stripprefix', $this->stripPrefix );
89 $out->setPageTitleMsg(
90 ( $namespace > 0 && array_key_exists( $namespace, $namespaces ) )
91 ? $this->
msg(
'prefixindex-namespace' )->plaintextParams(
92 str_replace(
'_',
' ', $namespaces[$namespace] )
94 : $this->
msg(
'prefixindex' )
98 if ( $par !==
null ) {
100 } elseif ( $prefix !=
'' ) {
102 } elseif ( $from !=
'' && $ns ===
null ) {
109 if ( $this->
including() || $showme !=
'' || $ns !==
null ) {
169 if ( $from ===
null ) {
173 $fromList = $this->getNamespaceKeyAndText( $namespace, $from );
174 $prefixList = $this->getNamespaceKeyAndText( $namespace, $prefix );
175 $namespaces = $this->getContentLanguage()->getNamespaces();
179 $preparedHtmlForm = $this->namespacePrefixForm( $namespace, $prefix );
181 if ( !$prefixList || !$fromList ) {
182 $out = $this->msg(
'allpagesbadtitle' )->parseAsBlock();
183 } elseif ( !array_key_exists( $namespace, $namespaces ) ) {
185 $out = $this->msg(
'allpages-bad-ns', $namespace )->parse();
188 [ $namespace, $prefixKey, $prefix ] = $prefixList;
189 [ , $fromKey, ] = $fromList;
191 # ## @todo FIXME: Should complain if $fromNs != $namespace
193 $dbr = $this->dbProvider->getReplicaDatabase();
194 $queryBuiler = $dbr->newSelectQueryBuilder()
195 ->select( LinkCache::getSelectFields() )
198 'page_namespace' => $namespace,
202 new LikeValue( $prefixKey, $dbr->anyString() )
204 $dbr->expr(
'page_title',
'>=', $fromKey ),
206 ->orderBy(
'page_title' )
207 ->limit( $this->maxPerPage + 1 )
208 ->useIndex(
'page_name_title' );
210 if ( $this->hideRedirects ) {
211 $queryBuiler->andWhere( [
'page_is_redirect' => 0 ] );
214 $this->getHookRunner()->onSpecialPrefixIndexQuery( $preparedHtmlForm->mFieldData, $queryBuiler );
216 $res = $queryBuiler->caller( __METHOD__ )->fetchResultSet();
220 if ( $res->numRows() > 0 ) {
221 $out = Html::openElement(
'ul', [
'class' =>
'mw-prefixindex-list' ] );
223 $prefixLength = strlen( $prefix );
224 foreach ( $res as $row ) {
225 if ( $n >= $this->maxPerPage ) {
229 $title = Title::newFromRow( $row );
231 $this->linkCache->addGoodLinkObjFromRow( $title, $row );
232 $displayed = $title->getText();
234 if ( $this->stripPrefix && $prefixLength !== strlen( $displayed ) ) {
235 $displayed = substr( $displayed, $prefixLength );
237 $link = ( $title->isRedirect() ?
'<div class="allpagesredirect">' :
'' ) .
238 $this->getLinkRenderer()->makeKnownLink(
242 ( $title->isRedirect() ?
'</div>' :
'' );
244 $out .=
"<li>$link</li>\n";
248 $out .= Html::closeElement(
'ul' );
250 if ( $res->numRows() > 2 ) {
253 $out = Html::rawElement(
'div', [
'class' =>
'mw-prefixindex-body' ], $out );
260 $output = $this->getOutput();
262 if ( $this->including() ) {
265 $output->addHTML( $out );
269 $topOut = $preparedHtmlForm->getHTML(
false );
271 if ( $res && ( $n == $this->maxPerPage ) && $nextRow ) {
273 'from' => $nextRow->page_title,
275 'hideredirects' => $this->hideRedirects,
276 'stripprefix' => $this->stripPrefix,
279 if ( $namespace || $prefix ==
'' ) {
282 $query[
'namespace'] = $namespace;
285 $nextLink = $this->getLinkRenderer()->makeKnownLink(
286 $this->getPageTitle(),
287 $this->msg(
'nextpage', str_replace(
'_',
' ', $nextRow->page_title ) )->text(),
293 $topOut .= Html::rawElement(
'div',
294 [
'class' =>
'mw-prefixindex-nav' ],
302 [
'class' =>
'mw-prefixindex-nav' ],
308 $output->addHTML( $topOut . $out );