72 $out->addModuleStyles(
'mediawiki.special' );
76 $from = $request->getVal(
'from',
'' );
77 $prefix = $request->getVal(
'prefix',
'' );
78 $ns = $request->getIntOrNull(
'namespace' );
79 $namespace = (int)$ns;
80 $this->hideRedirects = $request->getBool(
'hideredirects', $this->hideRedirects );
81 $this->stripPrefix = $request->getBool(
'stripprefix', $this->stripPrefix );
85 ( $namespace > 0 && array_key_exists( $namespace, $namespaces ) )
86 ? $this->
msg(
'prefixindex-namespace', str_replace(
'_',
' ', $namespaces[$namespace] ) )
87 : $this->
msg(
'prefixindex' )
91 if ( $par !==
null ) {
93 } elseif ( $prefix !=
'' ) {
95 } elseif ( $from !=
'' && $ns ===
null ) {
102 if ( $this->
including() || $showme !=
'' || $ns !==
null ) {
118 'label-message' =>
'allpagesprefix',
123 'default' => str_replace(
'_',
' ', $from ),
126 'type' =>
'namespaceselect',
127 'name' =>
'namespace',
129 'label-message' =>
'namespace',
131 'default' => $namespace,
134 'class' => HTMLCheckField::class,
135 'name' =>
'hideredirects',
136 'label-message' =>
'allpages-hide-redirects',
139 'class' => HTMLCheckField::class,
140 'name' =>
'stripprefix',
141 'label-message' =>
'prefixindex-strip',
144 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() )
147 ->setWrapperLegendMsg(
'prefixindex' )
148 ->setSubmitTextMsg(
'prefixindex-submit' );
150 return $htmlForm->prepareForm()->getHTML(
false );
159 if ( $from ===
null ) {
170 if ( !$prefixList || !$fromList ) {
171 $out = $this->
msg(
'allpagesbadtitle' )->parseAsBlock();
172 } elseif ( !array_key_exists( $namespace, $namespaces ) ) {
174 $out = $this->
msg(
'allpages-bad-ns', $namespace )->parse();
177 list( $namespace, $prefixKey, $prefix ) = $prefixList;
178 list( , $fromKey, ) = $fromList;
180 # ## @todo FIXME: Should complain if $fromNs != $namespace
182 $dbr = $this->loadBalancer->getConnectionRef( ILoadBalancer::DB_REPLICA );
185 'page_namespace' => $namespace,
186 'page_title' .
$dbr->buildLike( $prefixKey,
$dbr->anyString() ),
187 'page_title >= ' .
$dbr->addQuotes( $fromKey ),
190 if ( $this->hideRedirects ) {
191 $conds[
'page_is_redirect'] = 0;
195 LinkCache::getSelectFields(),
199 'ORDER BY' =>
'page_title',
200 'LIMIT' => $this->maxPerPage + 1,
201 'USE INDEX' =>
'page_name_title',
207 if (
$res->numRows() > 0 ) {
208 $out = Html::openElement(
'ul', [
'class' =>
'mw-prefixindex-list' ] );
210 $prefixLength = strlen( $prefix );
211 foreach (
$res as $row ) {
212 if ( $n >= $this->maxPerPage ) {
216 $title = Title::newFromRow( $row );
218 $this->linkCache->addGoodLinkObjFromRow(
$title, $row );
219 $displayed =
$title->getText();
221 if ( $this->stripPrefix && $prefixLength !== strlen( $displayed ) ) {
222 $displayed = substr( $displayed, $prefixLength );
224 $link = (
$title->isRedirect() ?
'<div class="allpagesredirect">' :
'' ) .
229 (
$title->isRedirect() ?
'</div>' :
'' );
231 $out .=
"<li>$link</li>\n";
235 $out .= Html::closeElement(
'ul' );
237 if (
$res->numRows() > 2 ) {
240 $out = Html::rawElement(
'div', [
'class' =>
'mw-prefixindex-body' ], $out );
252 $output->addHTML( $out );
258 if (
$res && ( $n == $this->maxPerPage ) && $nextRow ) {
260 'from' => $nextRow->page_title,
266 if ( $namespace || $prefix ==
'' ) {
269 $query[
'namespace'] = $namespace;
274 $this->
msg(
'nextpage', str_replace(
'_',
' ', $nextRow->page_title ) )->text(),
280 $topOut .= Html::rawElement(
'div',
281 [
'class' =>
'mw-prefixindex-nav' ],
286 $out .=
"\n" . Html::element(
'hr' ) .
289 [
'class' =>
'mw-prefixindex-nav' ],
295 $output->addHTML( $topOut . $out );