63 parent::__construct(
'Allpages' );
65 $services = MediaWikiServices::getInstance();
66 $this->loadBalancer =
$loadBalancer ?? $services->getDBLoadBalancer();
81 $out->allowClickjacking();
84 $from = $request->getVal(
'from',
null );
85 $to = $request->getVal(
'to',
null );
86 $namespace = $request->getInt(
'namespace' );
88 $miserMode = (bool)$this->
getConfig()->get(
'MiserMode' );
91 $hideredirects = $request->getBool(
'hideredirects',
false ) && !$miserMode;
93 $namespaces = $this->
getLanguage()->getNamespaces();
96 ( $namespace > 0 && array_key_exists( $namespace, $namespaces ) ) ?
97 $this->
msg(
'allinnamespace', str_replace(
'_',
' ', $namespaces[$namespace] ) ) :
98 $this->
msg(
'allarticles' )
100 $out->addModuleStyles(
'mediawiki.special' );
102 if ( $par !==
null ) {
103 $this->
showChunk( $namespace, $par, $to, $hideredirects );
104 } elseif ( $from !==
null && $to ===
null ) {
105 $this->
showChunk( $namespace, $from, $to, $hideredirects );
107 $this->
showToplevel( $namespace, $from, $to, $hideredirects );
120 $from =
'', $to =
'', $hideRedirects =
false
122 $miserMode = (bool)$this->
getConfig()->get(
'MiserMode' );
129 'label-message' =>
'allpagesfrom',
130 'default' => str_replace(
'_',
' ', $from ),
137 'label-message' =>
'allpagesto',
138 'default' => str_replace(
'_',
' ', $to ),
141 'type' =>
'namespaceselect',
142 'name' =>
'namespace',
144 'label-message' =>
'namespace',
146 'default' => $namespace,
150 'name' =>
'hideredirects',
151 'id' =>
'hidredirects',
152 'label-message' =>
'allpages-hide-redirects',
153 'value' => $hideRedirects,
158 unset( $formDescriptor[
'hideredirects'] );
163 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $context );
166 ->setWrapperLegendMsg(
'allpages' )
167 ->setSubmitTextMsg(
'allpagessubmit' )
169 ->displayForm(
false );
179 $namespace =
NS_MAIN, $from =
'', $to =
'', $hideredirects =
false
181 $from = Title::makeTitleSafe( $namespace, $from );
182 $to = Title::makeTitleSafe( $namespace, $to );
183 $from = ( $from && $from->isLocal() ) ? $from->getDBkey() :
null;
184 $to = ( $to && $to->isLocal() ) ? $to->getDBkey() :
null;
186 $this->
showChunk( $namespace, $from, $to, $hideredirects );
196 $namespace =
NS_MAIN, $from =
false, $to =
false, $hideredirects =
false
202 $namespaces = $this->
getContext()->getLanguage()->getNamespaces();
206 if ( !$fromList || !$toList ) {
207 $out = $this->
msg(
'allpagesbadtitle' )->parseAsBlock();
208 } elseif ( !array_key_exists( $namespace, $namespaces ) ) {
210 $out = $this->
msg(
'allpages-bad-ns', $namespace )->parse();
213 list( $namespace, $fromKey, $from ) = $fromList;
214 list( , $toKey, $to ) = $toList;
216 $dbr = $this->loadBalancer->getConnectionRef( ILoadBalancer::DB_REPLICA );
217 $filterConds = [
'page_namespace' => $namespace ];
218 if ( $hideredirects ) {
219 $filterConds[
'page_is_redirect'] = 0;
222 $conds = $filterConds;
223 $conds[] =
'page_title >= ' .
$dbr->addQuotes( $fromKey );
224 if ( $toKey !==
"" ) {
225 $conds[] =
'page_title <= ' .
$dbr->addQuotes( $toKey );
228 [
'page_namespace',
'page_title',
'page_is_redirect',
'page_id' ],
232 'ORDER BY' =>
'page_title',
233 'LIMIT' => $this->maxPerPage + 1,
234 'USE INDEX' =>
'page_name_title',
239 if (
$res->numRows() > 0 ) {
240 $out = Html::openElement(
'ul', [
'class' =>
'mw-allpages-chunk' ] );
242 while ( ( $n < $this->maxPerPage ) && (
$s =
$res->fetchObject() ) ) {
243 $t = Title::newFromRow(
$s );
246 (
$s->page_is_redirect ?
' class="allpagesredirect"' :
'' ) .
251 $out .=
'<li>[[' . htmlspecialchars(
$s->page_title ) .
"]]</li>\n";
255 $out .= Html::closeElement(
'ul' );
257 if (
$res->numRows() > 2 ) {
260 $out = Html::rawElement(
'div', [
'class' =>
'mw-allpages-body' ], $out );
266 if ( $fromKey !==
'' && !$this->
including() ) {
267 # Get the first title from previous chunk
268 $prevConds = $filterConds;
269 $prevConds[] =
'page_title < ' .
$dbr->addQuotes( $fromKey );
270 $prevKey =
$dbr->selectField(
275 [
'ORDER BY' =>
'page_title DESC',
'OFFSET' => $this->maxPerPage - 1 ]
278 if ( $prevKey ===
false ) {
279 # The previous chunk is not complete, need to link to the very first title
280 # available in the database
281 $prevKey =
$dbr->selectField(
286 [
'ORDER BY' =>
'page_title' ]
290 if ( $prevKey !==
false ) {
291 $prevTitle = Title::makeTitle( $namespace, $prevKey );
297 $output->addHTML( $out );
307 $query = [
'from' => $prevTitle->getText() ];
310 $query[
'namespace'] = $namespace;
313 if ( $hideredirects ) {
314 $query[
'hideredirects'] = $hideredirects;
319 $this->
msg(
'prevpage', $prevTitle->getText() )->text(),
327 if ( $n == $this->maxPerPage &&
$s =
$res->fetchObject() ) {
328 # $s is the first link of the next chunk
329 $t = Title::makeTitle( $namespace,
$s->page_title );
330 $query = [
'from' =>
$t->getText() ];
333 $query[
'namespace'] = $namespace;
336 if ( $hideredirects ) {
337 $query[
'hideredirects'] = $hideredirects;
342 $this->
msg(
'nextpage',
$t->getText() )->text(),
350 if ( count( $navLinks ) ) {
352 $pagination = Html::rawElement(
'div',
353 [
'class' =>
'mw-allpages-nav' ],
357 $output->addHTML( $pagination );
358 $out .= Html::element(
'hr' ) . $pagination;
361 $output->addHTML( $out );
371 # shortcut for common case
372 return [ $ns,
'',
'' ];
375 $t = Title::makeTitleSafe( $ns, $text );
376 if (
$t &&
$t->isLocal() ) {
377 return [
$t->getNamespace(),
$t->getDBkey(),
$t->getText() ];
382 # try again, in case the problem was an empty pagename
383 $text = preg_replace(
'/(#|$)/',
'X$1', $text );
384 $t = Title::makeTitleSafe( $ns, $text );
385 if (
$t &&
$t->isLocal() ) {
386 return [
$t->getNamespace(),
'',
'' ];
401 return $this->
prefixSearchString( $search, $limit, $offset, $this->searchEngineFactory );
An IContextSource implementation which will inherit context from another source but allow individual ...
Shortcut to construct an includable special page.
Factory class for SearchEngine.
Implements Special:Allpages.
int $maxPerPage
Maximum number of pages to show on single subpage.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
showToplevel( $namespace=NS_MAIN, $from='', $to='', $hideredirects=false)
execute( $par)
Entry point : initialise variables and call subfunctions.
ILoadBalancer $loadBalancer
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
showChunk( $namespace=NS_MAIN, $from=false, $to=false, $hideredirects=false)
string $nsfromMsg
Determines, which message describes the input field 'nsfrom'.
__construct(ILoadBalancer $loadBalancer=null, SearchEngineFactory $searchEngineFactory=null)
outputHTMLForm( $namespace=NS_MAIN, $from='', $to='', $hideRedirects=false)
Outputs the HTMLForm used on this page.
SearchEngineFactory $searchEngineFactory
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.
LinkRenderer null $linkRenderer
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
prefixSearchString( $search, $limit, $offset, SearchEngineFactory $searchEngineFactory=null)
Perform a regular substring search for prefixSearchSubpages.
getPageTitle( $subpage=false)
Get a self-referential title object.
getLanguage()
Shortcut to get user's language.
including( $x=null)
Whether the special page is being evaluated via transclusion.
foreach( $mmfl['setupFiles'] as $fileName) if($queue) if(empty( $mmfl['quiet'])) $s