50 parent::__construct( $name );
64 $out->allowClickjacking();
67 $from = $request->getVal(
'from',
null );
68 $to = $request->getVal(
'to',
null );
69 $namespace = $request->getInt(
'namespace' );
71 $miserMode = (bool)$this->
getConfig()->get(
'MiserMode' );
74 $hideredirects = $request->getBool(
'hideredirects',
false ) && !$miserMode;
76 $namespaces = $this->
getLanguage()->getNamespaces();
79 ( $namespace > 0 && array_key_exists( $namespace, $namespaces ) ) ?
80 $this->
msg(
'allinnamespace', str_replace(
'_',
' ', $namespaces[$namespace] ) ) :
81 $this->
msg(
'allarticles' )
83 $out->addModuleStyles(
'mediawiki.special' );
85 if ( $par !==
null ) {
86 $this->
showChunk( $namespace, $par, $to, $hideredirects );
87 } elseif ( $from !==
null && $to ===
null ) {
88 $this->
showChunk( $namespace, $from, $to, $hideredirects );
90 $this->
showToplevel( $namespace, $from, $to, $hideredirects );
103 $from =
'', $to =
'', $hideRedirects =
false
105 $miserMode = (bool)$this->
getConfig()->get(
'MiserMode' );
112 'label-message' =>
'allpagesfrom',
113 'default' => str_replace(
'_',
' ', $from ),
120 'label-message' =>
'allpagesto',
121 'default' => str_replace(
'_',
' ', $to ),
124 'type' =>
'namespaceselect',
125 'name' =>
'namespace',
127 'label-message' =>
'namespace',
129 'default' => $namespace,
133 'name' =>
'hideredirects',
134 'id' =>
'hidredirects',
135 'label-message' =>
'allpages-hide-redirects',
136 'value' => $hideRedirects,
141 unset( $formDescriptor[
'hideredirects'] );
146 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $context );
149 ->setWrapperLegendMsg(
'allpages' )
150 ->setSubmitTextMsg(
'allpagessubmit' )
152 ->displayForm(
false );
162 $namespace =
NS_MAIN, $from =
'', $to =
'', $hideredirects =
false
164 $from = Title::makeTitleSafe( $namespace, $from );
165 $to = Title::makeTitleSafe( $namespace, $to );
166 $from = ( $from && $from->isLocal() ) ? $from->getDBkey() :
null;
167 $to = ( $to && $to->isLocal() ) ? $to->getDBkey() :
null;
169 $this->
showChunk( $namespace, $from, $to, $hideredirects );
179 $namespace =
NS_MAIN, $from =
false, $to =
false, $hideredirects =
false
185 $namespaces = $this->
getContext()->getLanguage()->getNamespaces();
189 if ( !$fromList || !$toList ) {
190 $out = $this->
msg(
'allpagesbadtitle' )->parseAsBlock();
191 } elseif ( !array_key_exists( $namespace, $namespaces ) ) {
193 $out = $this->
msg(
'allpages-bad-ns', $namespace )->parse();
196 list( $namespace, $fromKey, $from ) = $fromList;
197 list( , $toKey, $to ) = $toList;
200 $filterConds = [
'page_namespace' => $namespace ];
201 if ( $hideredirects ) {
202 $filterConds[
'page_is_redirect'] = 0;
205 $conds = $filterConds;
206 $conds[] =
'page_title >= ' .
$dbr->addQuotes( $fromKey );
207 if ( $toKey !==
"" ) {
208 $conds[] =
'page_title <= ' .
$dbr->addQuotes( $toKey );
212 [
'page_namespace',
'page_title',
'page_is_redirect',
'page_id' ],
216 'ORDER BY' =>
'page_title',
217 'LIMIT' => $this->maxPerPage + 1,
218 'USE INDEX' =>
'name_title',
223 if (
$res->numRows() > 0 ) {
224 $out = Html::openElement(
'ul', [
'class' =>
'mw-allpages-chunk' ] );
226 while ( ( $n < $this->maxPerPage ) && (
$s =
$res->fetchObject() ) ) {
227 $t = Title::newFromRow(
$s );
230 (
$s->page_is_redirect ?
' class="allpagesredirect"' :
'' ) .
235 $out .=
'<li>[[' . htmlspecialchars(
$s->page_title ) .
"]]</li>\n";
239 $out .= Html::closeElement(
'ul' );
241 if (
$res->numRows() > 2 ) {
244 $out = Html::rawElement(
'div', [
'class' =>
'mw-allpages-body' ], $out );
250 if ( $fromKey !==
'' && !$this->
including() ) {
251 # Get the first title from previous chunk
252 $prevConds = $filterConds;
253 $prevConds[] =
'page_title < ' .
$dbr->addQuotes( $fromKey );
254 $prevKey =
$dbr->selectField(
259 [
'ORDER BY' =>
'page_title DESC',
'OFFSET' => $this->maxPerPage - 1 ]
262 if ( $prevKey ===
false ) {
263 # The previous chunk is not complete, need to link to the very first title
264 # available in the database
265 $prevKey =
$dbr->selectField(
270 [
'ORDER BY' =>
'page_title' ]
274 if ( $prevKey !==
false ) {
275 $prevTitle = Title::makeTitle( $namespace, $prevKey );
281 $output->addHTML( $out );
291 $query = [
'from' => $prevTitle->getText() ];
294 $query[
'namespace'] = $namespace;
297 if ( $hideredirects ) {
298 $query[
'hideredirects'] = $hideredirects;
303 $this->
msg(
'prevpage', $prevTitle->getText() )->text(),
311 if ( $n == $this->maxPerPage &&
$s =
$res->fetchObject() ) {
312 # $s is the first link of the next chunk
313 $t = Title::makeTitle( $namespace,
$s->page_title );
314 $query = [
'from' =>
$t->getText() ];
317 $query[
'namespace'] = $namespace;
320 if ( $hideredirects ) {
321 $query[
'hideredirects'] = $hideredirects;
326 $this->
msg(
'nextpage',
$t->getText() )->text(),
334 if ( count( $navLinks ) ) {
336 $pagination = Html::rawElement(
'div',
337 [
'class' =>
'mw-allpages-nav' ],
341 $output->addHTML( $pagination );
342 $out .= Html::element(
'hr' ) . $pagination;
345 $output->addHTML( $out );
355 # shortcut for common case
356 return [ $ns,
'',
'' ];
359 $t = Title::makeTitleSafe( $ns, $text );
360 if (
$t &&
$t->isLocal() ) {
361 return [
$t->getNamespace(),
$t->getDBkey(),
$t->getText() ];
366 # try again, in case the problem was an empty pagename
367 $text = preg_replace(
'/(#|$)/',
'X$1', $text );
368 $t = Title::makeTitleSafe( $ns, $text );
369 if (
$t &&
$t->isLocal() ) {
370 return [
$t->getNamespace(),
'',
'' ];
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
An IContextSource implementation which will inherit context from another source but allow individual ...
Shortcut to construct an includable special page.
Implements Special:Allpages.
int $maxPerPage
Maximum number of pages to show on single subpage.
__construct( $name='Allpages')
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.
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'.
outputHTMLForm( $namespace=NS_MAIN, $from='', $to='', $hideRedirects=false)
Outputs the HTMLForm used on this page.
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.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
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.
prefixSearchString( $search, $limit, $offset)
Perform a regular substring search for prefixSearchSubpages.
MediaWiki Linker LinkRenderer null $linkRenderer