151 $fromList = $this->getNamespaceKeyAndText( $namespace, $from );
152 $prefixList = $this->getNamespaceKeyAndText( $namespace, $prefix );
153 $namespaces = $this->getContentLanguage()->getNamespaces();
157 $preparedHtmlForm = $this->namespacePrefixForm( $namespace, $prefix );
159 if ( !$prefixList || !$fromList ) {
160 $out = $this->msg(
'allpagesbadtitle' )->parseAsBlock();
161 } elseif ( !array_key_exists( $namespace, $namespaces ) ) {
163 $out = $this->msg(
'allpages-bad-ns', $namespace )->parse();
166 [ $namespace, $prefixKey, $prefix ] = $prefixList;
167 [ , $fromKey, ] = $fromList;
169 # ## @todo FIXME: Should complain if $fromNs != $namespace
171 $dbr = $this->dbProvider->getReplicaDatabase();
172 $queryBuilder = $dbr->newSelectQueryBuilder()
173 ->select( LinkCache::getSelectFields() )
176 'page_namespace' => $namespace,
180 new LikeValue( $prefixKey, $dbr->anyString() )
182 $dbr->expr(
'page_title',
'>=', $fromKey ),
184 ->orderBy(
'page_title' )
185 ->limit( $this->maxPerPage + 1 )
186 ->useIndex(
'page_name_title' );
188 if ( $this->hideRedirects ) {
189 $queryBuilder->andWhere( [
'page_is_redirect' => 0 ] );
192 $this->getHookRunner()->onSpecialPrefixIndexQuery( $preparedHtmlForm->mFieldData, $queryBuilder );
194 $res = $queryBuilder->caller( __METHOD__ )->fetchResultSet();
198 if ( $res->numRows() > 0 ) {
199 $out = Html::openElement(
'ul', [
'class' =>
'mw-prefixindex-list' ] );
201 $prefixLength = strlen( $prefix );
202 foreach ( $res as $row ) {
203 if ( $n >= $this->maxPerPage ) {
207 $title = Title::newFromRow( $row );
209 $this->linkCache->addGoodLinkObjFromRow( $title, $row );
210 $displayed = $title->getText();
212 if ( $this->stripPrefix && $prefixLength !== strlen( $displayed ) ) {
213 $displayed = substr( $displayed, $prefixLength );
215 $link = ( $title->isRedirect() ?
'<div class="allpagesredirect">' :
'' ) .
216 $this->getLinkRenderer()->makeKnownLink(
220 ( $title->isRedirect() ?
'</div>' :
'' );
222 $out .=
"<li>$link</li>\n";
226 $out .= Html::closeElement(
'ul' );
228 if ( $res->numRows() > 2 ) {
231 $out = Html::rawElement(
'div', [
'class' =>
'mw-prefixindex-body' ], $out );
238 $output = $this->getOutput();
240 if ( $this->including() ) {
243 $output->addHTML( $out );
247 $topOut = $preparedHtmlForm->getHTML(
false );
249 if ( $res && ( $n == $this->maxPerPage ) && $nextRow ) {
251 'from' => $nextRow->page_title,
253 'hideredirects' => $this->hideRedirects,
254 'stripprefix' => $this->stripPrefix,
257 if ( $namespace || $prefix ==
'' ) {
260 $query[
'namespace'] = $namespace;
263 $nextLink = $this->getLinkRenderer()->makeKnownLink(
264 $this->getPageTitle(),
265 $this->msg(
'nextpage', str_replace(
'_',
' ', $nextRow->page_title ) )->text(),
271 $topOut .= Html::rawElement(
'div',
272 [
'class' =>
'mw-prefixindex-nav' ],
280 [
'class' =>
'mw-prefixindex-nav' ],
286 $output->addHTML( $topOut . $out );