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',
146 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $context )
148 ->setWrapperLegendMsg(
'prefixindex' )
149 ->setSubmitTextMsg(
'prefixindex-submit' );
151 return $htmlForm->prepareForm()->getHTML(
false );
160 if ( $from ===
null ) {
171 if ( !$prefixList || !$fromList ) {
172 $out = $this->
msg(
'allpagesbadtitle' )->parseAsBlock();
173 } elseif ( !array_key_exists( $namespace, $namespaces ) ) {
175 $out = $this->
msg(
'allpages-bad-ns', $namespace )->parse();
178 list( $namespace, $prefixKey, $prefix ) = $prefixList;
179 list( , $fromKey, ) = $fromList;
181 # ## @todo FIXME: Should complain if $fromNs != $namespace
183 $dbr = $this->loadBalancer->getConnectionRef( ILoadBalancer::DB_REPLICA );
186 'page_namespace' => $namespace,
187 'page_title' .
$dbr->buildLike( $prefixKey,
$dbr->anyString() ),
188 'page_title >= ' .
$dbr->addQuotes( $fromKey ),
191 if ( $this->hideRedirects ) {
192 $conds[
'page_is_redirect'] = 0;
197 [
'page_namespace',
'page_title' ],
198 LinkCache::getSelectFields()
203 'ORDER BY' =>
'page_title',
204 'LIMIT' => $this->maxPerPage + 1,
205 'USE INDEX' =>
'page_name_title',
211 if (
$res->numRows() > 0 ) {
212 $out = Html::openElement(
'ul', [
'class' =>
'mw-prefixindex-list' ] );
214 $prefixLength = strlen( $prefix );
215 foreach (
$res as $row ) {
216 if ( $n >= $this->maxPerPage ) {
220 $title = Title::newFromRow( $row );
222 $this->linkCache->addGoodLinkObjFromRow(
$title, $row );
223 $displayed =
$title->getText();
225 if ( $this->stripPrefix && $prefixLength !== strlen( $displayed ) ) {
226 $displayed = substr( $displayed, $prefixLength );
228 $link = (
$title->isRedirect() ?
'<div class="allpagesredirect">' :
'' ) .
233 (
$title->isRedirect() ?
'</div>' :
'' );
235 $out .=
"<li>$link</li>\n";
239 $out .= Html::closeElement(
'ul' );
241 if (
$res->numRows() > 2 ) {
244 $out = Html::rawElement(
'div', [
'class' =>
'mw-prefixindex-body' ], $out );
256 $output->addHTML( $out );
262 if (
$res && ( $n == $this->maxPerPage ) && $nextRow ) {
264 'from' => $nextRow->page_title,
270 if ( $namespace || $prefix ==
'' ) {
273 $query[
'namespace'] = $namespace;
278 $this->
msg(
'nextpage', str_replace(
'_',
' ', $nextRow->page_title ) )->text(),
284 $topOut .= Html::rawElement(
'div',
285 [
'class' =>
'mw-prefixindex-nav' ],
290 $out .=
"\n" . Html::element(
'hr' ) .
293 [
'class' =>
'mw-prefixindex-nav' ],
299 $output->addHTML( $topOut . $out );