55 $out->addModuleStyles(
'mediawiki.special' );
59 $from = $request->getVal(
'from',
'' );
60 $prefix = $request->getVal(
'prefix',
'' );
61 $ns = $request->getIntOrNull(
'namespace' );
62 $namespace = (int)$ns;
63 $this->hideRedirects = $request->getBool(
'hideredirects', $this->hideRedirects );
64 $this->stripPrefix = $request->getBool(
'stripprefix', $this->stripPrefix );
66 $namespaces = MediaWikiServices::getInstance()->getContentLanguage()->getNamespaces();
68 ( $namespace > 0 && array_key_exists( $namespace, $namespaces ) )
69 ? $this->
msg(
'prefixindex-namespace', str_replace(
'_',
' ', $namespaces[$namespace] ) )
70 : $this->
msg(
'prefixindex' )
74 if ( $par !==
null ) {
76 } elseif ( $prefix !=
'' ) {
78 } elseif ( $from !=
'' && $ns ===
null ) {
85 if ( $this->
including() || $showme !=
'' || $ns !==
null ) {
144 if ( $from ===
null ) {
150 $namespaces = MediaWikiServices::getInstance()->getContentLanguage()->getNamespaces();
155 if ( !$prefixList || !$fromList ) {
156 $out = $this->
msg(
'allpagesbadtitle' )->parseAsBlock();
157 } elseif ( !array_key_exists( $namespace, $namespaces ) ) {
159 $out = $this->
msg(
'allpages-bad-ns', $namespace )->parse();
162 list( $namespace, $prefixKey, $prefix ) = $prefixList;
163 list( , $fromKey, ) = $fromList;
165 # ## @todo FIXME: Should complain if $fromNs != $namespace
170 'page_namespace' => $namespace,
171 'page_title' .
$dbr->buildLike( $prefixKey,
$dbr->anyString() ),
172 'page_title >= ' .
$dbr->addQuotes( $fromKey ),
175 if ( $this->hideRedirects ) {
176 $conds[
'page_is_redirect'] = 0;
181 [
'page_namespace',
'page_title' ],
182 LinkCache::getSelectFields()
187 'ORDER BY' =>
'page_title',
188 'LIMIT' => $this->maxPerPage + 1,
189 'USE INDEX' =>
'name_title',
195 if (
$res->numRows() > 0 ) {
196 $out = Html::openElement(
'ul', [
'class' =>
'mw-prefixindex-list' ] );
197 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
199 $prefixLength = strlen( $prefix );
200 foreach (
$res as $row ) {
201 if ( $n >= $this->maxPerPage ) {
205 $title = Title::newFromRow( $row );
207 $linkCache->addGoodLinkObjFromRow(
$title, $row );
208 $displayed =
$title->getText();
210 if ( $this->stripPrefix && $prefixLength !== strlen( $displayed ) ) {
211 $displayed = substr( $displayed, $prefixLength );
213 $link = (
$title->isRedirect() ?
'<div class="allpagesredirect">' :
'' ) .
218 (
$title->isRedirect() ?
'</div>' :
'' );
220 $out .=
"<li>$link</li>\n";
224 $out .= Html::closeElement(
'ul' );
226 if (
$res->numRows() > 2 ) {
229 $out = Html::rawElement(
'div', [
'class' =>
'mw-prefixindex-body' ], $out );
241 $output->addHTML( $out );
247 if (
$res && ( $n == $this->maxPerPage ) && $nextRow ) {
249 'from' => $nextRow->page_title,
255 if ( $namespace || $prefix ==
'' ) {
258 $query[
'namespace'] = $namespace;
263 $this->
msg(
'nextpage', str_replace(
'_',
' ', $nextRow->page_title ) )->text(),
269 $topOut .= Html::rawElement(
'div',
270 [
'class' =>
'mw-prefixindex-nav' ],
275 $out .=
"\n" . Html::element(
'hr' ) .
278 [
'class' =>
'mw-prefixindex-nav' ],
284 $output->addHTML( $topOut . $out );