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 ) {
171 $fromList = $this->getNamespaceKeyAndText( $namespace, $from );
172 $prefixList = $this->getNamespaceKeyAndText( $namespace, $prefix );
173 $namespaces = $this->getContentLanguage()->getNamespaces();
177 $preparedHtmlForm = $this->namespacePrefixForm( $namespace, $prefix );
179 if ( !$prefixList || !$fromList ) {
180 $out = $this->msg(
'allpagesbadtitle' )->parseAsBlock();
181 } elseif ( !array_key_exists( $namespace, $namespaces ) ) {
183 $out = $this->msg(
'allpages-bad-ns', $namespace )->parse();
186 [ $namespace, $prefixKey, $prefix ] = $prefixList;
187 [ , $fromKey, ] = $fromList;
189 # ## @todo FIXME: Should complain if $fromNs != $namespace
191 $dbr = $this->dbProvider->getReplicaDatabase();
192 $queryBuiler = $dbr->newSelectQueryBuilder()
193 ->select( LinkCache::getSelectFields() )
196 'page_namespace' => $namespace,
200 new LikeValue( $prefixKey, $dbr->anyString() )
202 $dbr->expr(
'page_title',
'>=', $fromKey ),
204 ->orderBy(
'page_title' )
205 ->limit( $this->maxPerPage + 1 )
206 ->useIndex(
'page_name_title' );
208 if ( $this->hideRedirects ) {
209 $queryBuiler->andWhere( [
'page_is_redirect' => 0 ] );
212 $this->getHookRunner()->onSpecialPrefixIndexQuery( $preparedHtmlForm->mFieldData, $queryBuiler );
214 $res = $queryBuiler->caller( __METHOD__ )->fetchResultSet();
218 if ( $res->numRows() > 0 ) {
219 $out = Html::openElement(
'ul', [
'class' =>
'mw-prefixindex-list' ] );
221 $prefixLength = strlen( $prefix );
222 foreach ( $res as $row ) {
223 if ( $n >= $this->maxPerPage ) {
227 $title = Title::newFromRow( $row );
229 $this->linkCache->addGoodLinkObjFromRow( $title, $row );
230 $displayed = $title->getText();
232 if ( $this->stripPrefix && $prefixLength !== strlen( $displayed ) ) {
233 $displayed = substr( $displayed, $prefixLength );
235 $link = ( $title->isRedirect() ?
'<div class="allpagesredirect">' :
'' ) .
236 $this->getLinkRenderer()->makeKnownLink(
240 ( $title->isRedirect() ?
'</div>' :
'' );
242 $out .=
"<li>$link</li>\n";
246 $out .= Html::closeElement(
'ul' );
248 if ( $res->numRows() > 2 ) {
251 $out = Html::rawElement(
'div', [
'class' =>
'mw-prefixindex-body' ], $out );
258 $output = $this->getOutput();
260 if ( $this->including() ) {
263 $output->addHTML( $out );
267 $topOut = $preparedHtmlForm->getHTML(
false );
269 if ( $res && ( $n == $this->maxPerPage ) && $nextRow ) {
271 'from' => $nextRow->page_title,
273 'hideredirects' => $this->hideRedirects,
274 'stripprefix' => $this->stripPrefix,
277 if ( $namespace || $prefix ==
'' ) {
280 $query[
'namespace'] = $namespace;
283 $nextLink = $this->getLinkRenderer()->makeKnownLink(
284 $this->getPageTitle(),
285 $this->msg(
'nextpage', str_replace(
'_',
' ', $nextRow->page_title ) )->text(),
291 $topOut .= Html::rawElement(
'div',
292 [
'class' =>
'mw-prefixindex-nav' ],
300 [
'class' =>
'mw-prefixindex-nav' ],
306 $output->addHTML( $topOut . $out );