75 $out->addModuleStyles(
'mediawiki.special' );
79 $from = $request->getVal(
'from',
'' );
80 $prefix = $request->getVal(
'prefix',
'' );
81 $ns = $request->getIntOrNull(
'namespace' );
82 $namespace = (int)$ns;
83 $this->hideRedirects = $request->getBool(
'hideredirects', $this->hideRedirects );
84 $this->stripPrefix = $request->getBool(
'stripprefix', $this->stripPrefix );
87 $out->setPageTitleMsg(
88 ( $namespace > 0 && array_key_exists( $namespace, $namespaces ) )
89 ? $this->
msg(
'prefixindex-namespace' )->plaintextParams(
90 str_replace(
'_',
' ', $namespaces[$namespace] )
92 : $this->
msg(
'prefixindex' )
96 if ( $par !==
null ) {
98 } elseif ( $prefix !=
'' ) {
100 } elseif ( $from !=
'' && $ns ===
null ) {
107 if ( $this->
including() || $showme !=
'' || $ns !==
null ) {
169 $fromList = $this->getNamespaceKeyAndText( $namespace, $from );
170 $prefixList = $this->getNamespaceKeyAndText( $namespace, $prefix );
171 $namespaces = $this->getContentLanguage()->getNamespaces();
175 $preparedHtmlForm = $this->namespacePrefixForm( $namespace, $prefix );
177 if ( !$prefixList || !$fromList ) {
178 $out = $this->msg(
'allpagesbadtitle' )->parseAsBlock();
179 } elseif ( !array_key_exists( $namespace, $namespaces ) ) {
181 $out = $this->msg(
'allpages-bad-ns', $namespace )->parse();
184 [ $namespace, $prefixKey, $prefix ] = $prefixList;
185 [ , $fromKey, ] = $fromList;
187 # ## @todo FIXME: Should complain if $fromNs != $namespace
189 $dbr = $this->dbProvider->getReplicaDatabase();
190 $queryBuiler = $dbr->newSelectQueryBuilder()
191 ->select( LinkCache::getSelectFields() )
194 'page_namespace' => $namespace,
198 new LikeValue( $prefixKey, $dbr->anyString() )
200 $dbr->expr(
'page_title',
'>=', $fromKey ),
202 ->orderBy(
'page_title' )
203 ->limit( $this->maxPerPage + 1 )
204 ->useIndex(
'page_name_title' );
206 if ( $this->hideRedirects ) {
207 $queryBuiler->andWhere( [
'page_is_redirect' => 0 ] );
210 $this->getHookRunner()->onSpecialPrefixIndexQuery( $preparedHtmlForm->mFieldData, $queryBuiler );
212 $res = $queryBuiler->caller( __METHOD__ )->fetchResultSet();
216 if ( $res->numRows() > 0 ) {
217 $out = Html::openElement(
'ul', [
'class' =>
'mw-prefixindex-list' ] );
219 $prefixLength = strlen( $prefix );
220 foreach ( $res as $row ) {
221 if ( $n >= $this->maxPerPage ) {
225 $title = Title::newFromRow( $row );
227 $this->linkCache->addGoodLinkObjFromRow( $title, $row );
228 $displayed = $title->getText();
230 if ( $this->stripPrefix && $prefixLength !== strlen( $displayed ) ) {
231 $displayed = substr( $displayed, $prefixLength );
233 $link = ( $title->isRedirect() ?
'<div class="allpagesredirect">' :
'' ) .
234 $this->getLinkRenderer()->makeKnownLink(
238 ( $title->isRedirect() ?
'</div>' :
'' );
240 $out .=
"<li>$link</li>\n";
244 $out .= Html::closeElement(
'ul' );
246 if ( $res->numRows() > 2 ) {
249 $out = Html::rawElement(
'div', [
'class' =>
'mw-prefixindex-body' ], $out );
256 $output = $this->getOutput();
258 if ( $this->including() ) {
261 $output->addHTML( $out );
265 $topOut = $preparedHtmlForm->getHTML(
false );
267 if ( $res && ( $n == $this->maxPerPage ) && $nextRow ) {
269 'from' => $nextRow->page_title,
271 'hideredirects' => $this->hideRedirects,
272 'stripprefix' => $this->stripPrefix,
275 if ( $namespace || $prefix ==
'' ) {
278 $query[
'namespace'] = $namespace;
281 $nextLink = $this->getLinkRenderer()->makeKnownLink(
282 $this->getPageTitle(),
283 $this->msg(
'nextpage', str_replace(
'_',
' ', $nextRow->page_title ) )->text(),
289 $topOut .= Html::rawElement(
'div',
290 [
'class' =>
'mw-prefixindex-nav' ],
298 [
'class' =>
'mw-prefixindex-nav' ],
304 $output->addHTML( $topOut . $out );