76 $out->addModuleStyles(
'mediawiki.special' );
80 $from = $request->getVal(
'from',
'' );
81 $prefix = $request->getVal(
'prefix',
'' );
82 $ns = $request->getIntOrNull(
'namespace' );
83 $namespace = (int)$ns;
84 $this->hideRedirects = $request->getBool(
'hideredirects', $this->hideRedirects );
85 $this->stripPrefix = $request->getBool(
'stripprefix', $this->stripPrefix );
88 $out->setPageTitleMsg(
89 ( $namespace > 0 && array_key_exists( $namespace, $namespaces ) )
90 ? $this->
msg(
'prefixindex-namespace' )->plaintextParams(
91 str_replace(
'_',
' ', $namespaces[$namespace] )
93 : $this->
msg(
'prefixindex' )
97 if ( $par !==
null ) {
99 } elseif ( $prefix !=
'' ) {
101 } elseif ( $from !=
'' && $ns ===
null ) {
108 if ( $this->
including() || $showme !=
'' || $ns !==
null ) {
124 'label-message' =>
'allpagesprefix',
129 'default' => str_replace(
'_',
' ', $from ),
132 'type' =>
'namespaceselect',
133 'name' =>
'namespace',
135 'label-message' =>
'namespace',
137 'default' => $namespace,
140 'class' => HTMLCheckField::class,
141 'name' =>
'hideredirects',
142 'label-message' =>
'allpages-hide-redirects',
145 'class' => HTMLCheckField::class,
146 'name' =>
'stripprefix',
147 'label-message' =>
'prefixindex-strip',
150 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() )
153 ->setWrapperLegendMsg(
'prefixindex' )
154 ->setSubmitTextMsg(
'prefixindex-submit' );
156 return $htmlForm->prepareForm()->getHTML(
false );
165 if ( $from ===
null ) {
176 if ( !$prefixList || !$fromList ) {
177 $out = $this->
msg(
'allpagesbadtitle' )->parseAsBlock();
178 } elseif ( !array_key_exists( $namespace, $namespaces ) ) {
180 $out = $this->
msg(
'allpages-bad-ns', $namespace )->parse();
183 [ $namespace, $prefixKey, $prefix ] = $prefixList;
184 [ , $fromKey, ] = $fromList;
186 # ## @todo FIXME: Should complain if $fromNs != $namespace
188 $dbr = $this->dbProvider->getReplicaDatabase();
189 $queryBuiler = $dbr->newSelectQueryBuilder()
190 ->select( LinkCache::getSelectFields() )
193 'page_namespace' => $namespace,
194 'page_title' . $dbr->buildLike( $prefixKey, $dbr->anyString() ),
195 'page_title >= ' . $dbr->addQuotes( $fromKey ),
197 ->orderBy(
'page_title' )
198 ->limit( $this->maxPerPage + 1 )
199 ->useIndex(
'page_name_title' );
201 if ( $this->hideRedirects ) {
202 $queryBuiler->andWhere( [
'page_is_redirect' => 0 ] );
205 $res = $queryBuiler->caller( __METHOD__ )->fetchResultSet();
209 if ( $res->numRows() > 0 ) {
210 $out = Html::openElement(
'ul', [
'class' =>
'mw-prefixindex-list' ] );
212 $prefixLength = strlen( $prefix );
213 foreach ( $res as $row ) {
214 if ( $n >= $this->maxPerPage ) {
218 $title = Title::newFromRow( $row );
220 $this->linkCache->addGoodLinkObjFromRow( $title, $row );
221 $displayed = $title->getText();
223 if ( $this->stripPrefix && $prefixLength !== strlen( $displayed ) ) {
224 $displayed = substr( $displayed, $prefixLength );
226 $link = ( $title->isRedirect() ?
'<div class="allpagesredirect">' :
'' ) .
231 ( $title->isRedirect() ?
'</div>' :
'' );
233 $out .=
"<li>$link</li>\n";
237 $out .= Html::closeElement(
'ul' );
239 if ( $res->numRows() > 2 ) {
242 $out = Html::rawElement(
'div', [
'class' =>
'mw-prefixindex-body' ], $out );
254 $output->addHTML( $out );
260 if ( $res && ( $n == $this->maxPerPage ) && $nextRow ) {
262 'from' => $nextRow->page_title,
268 if ( $namespace || $prefix ==
'' ) {
271 $query[
'namespace'] = $namespace;
276 $this->
msg(
'nextpage', str_replace(
'_',
' ', $nextRow->page_title ) )->text(),
282 $topOut .= Html::rawElement(
'div',
283 [
'class' =>
'mw-prefixindex-nav' ],
288 $out .=
"\n" . Html::element(
'hr' ) .
291 [
'class' =>
'mw-prefixindex-nav' ],
297 $output->addHTML( $topOut . $out );