58 $this->mName =
'Prefixindex';
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',
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
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;
196 [
'page_namespace',
'page_title' ],
202 'ORDER BY' =>
'page_title',
203 'LIMIT' => $this->maxPerPage + 1,
204 'USE INDEX' =>
'page_name_title',
210 if (
$res->numRows() > 0 ) {
213 $prefixLength = strlen( $prefix );
214 foreach (
$res as $row ) {
215 if ( $n >= $this->maxPerPage ) {
221 $this->linkCache->addGoodLinkObjFromRow(
$title, $row );
222 $displayed =
$title->getText();
224 if ( $this->stripPrefix && $prefixLength !== strlen( $displayed ) ) {
225 $displayed = substr( $displayed, $prefixLength );
227 $link = (
$title->isRedirect() ?
'<div class="allpagesredirect">' :
'' ) .
232 (
$title->isRedirect() ?
'</div>' :
'' );
234 $out .=
"<li>$link</li>\n";
240 if (
$res->numRows() > 2 ) {
243 $out =
Html::rawElement(
'div', [
'class' =>
'mw-prefixindex-body' ], $out );
255 $output->addHTML( $out );
261 if (
$res && ( $n == $this->maxPerPage ) && $nextRow ) {
263 'from' => $nextRow->page_title,
269 if ( $namespace || $prefix ==
'' ) {
272 $query[
'namespace'] = $namespace;
277 $this->
msg(
'nextpage', str_replace(
'_',
' ', $nextRow->page_title ) )->text(),
284 [
'class' =>
'mw-prefixindex-nav' ],
292 [
'class' =>
'mw-prefixindex-nav' ],
298 $output->addHTML( $topOut . $out );
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
static closeElement( $element)
Returns "</$element>".
Cache for article titles (prefixed DB keys) and ids linked from one source.
static getSelectFields()
Fields that LinkCache needs to select.
Implements Special:Allpages.
getNamespaceKeyAndText( $ns, $text)
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
getContentLanguage()
Shortcut to get content language.
including( $x=null)
Whether the special page is being evaluated via transclusion.
Implements Special:Prefixindex.
showPrefixChunk( $namespace, $prefix, $from=null)
namespacePrefixForm( $namespace=NS_MAIN, $from='')
HTML for the top form.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
ILoadBalancer $loadBalancer
__construct(ILoadBalancer $loadBalancer, LinkCache $linkCache)
$stripPrefix
Whether to remove the searched prefix from the displayed link.
execute( $par)
Entry point : initialise variables and call subfunctions.
static newFromRow( $row)
Make a Title object from a DB row.