37 parent::__construct(
'Specialpages' );
44 $out->setPreventClickjacking(
false );
45 $out->addModuleStyles(
'mediawiki.special' );
47 $groups = $this->getPageGroups();
49 if ( $groups ===
false ) {
54 $this->outputPageList( $groups );
57 private function getPageGroups() {
60 if ( $pages === [] ) {
68 foreach ( $pages as $page ) {
69 $group = $page->getFinalGroupName();
70 $groups[$group][$page->getDescription()] = [
71 $page->getPageTitle(),
72 $page->isRestricted(),
78 foreach ( $groups as $group => $sortedPages ) {
79 ksort( $groups[$group] );
83 if ( array_key_exists(
'other', $groups ) ) {
84 $other = $groups[
'other'];
85 unset( $groups[
'other'] );
86 $groups[
'other'] = $other;
92 private function outputPageList( $groups ) {
96 $includesRestrictedPages =
false;
97 $includesCachedPages =
false;
98 foreach ( $groups as $group => $sortedPages ) {
99 foreach ( $sortedPages as $desc => [
$title, $restricted, $cached ] ) {
101 $includesCachedPages =
true;
104 $includesRestrictedPages =
true;
110 if ( $includesRestrictedPages ) {
111 $restricedMsg = $this->
msg(
'specialpages-note-restricted' );
112 if ( !$restricedMsg->isDisabled() ) {
113 $notes[] = $restricedMsg->parse();
116 if ( $includesCachedPages ) {
117 $cachedMsg = $this->
msg(
'specialpages-note-cached' );
118 if ( !$cachedMsg->isDisabled() ) {
119 $notes[] = $cachedMsg->parse();
122 if ( $notes !== [] ) {
123 $legendHeading = $this->
msg(
'specialpages-note-top' )->parse();
125 $legend = Html::rawElement(
127 [
'class' => [
'mw-changeslist-legend',
'mw-collapsible',
'mw-specialpages-notes' ] ],
129 Html::rawElement(
'div', [
'class' =>
'mw-collapsible-content' ], implode(
"\n", $notes ) )
132 $out->addHTML( $legend );
133 $out->addModuleStyles(
'mediawiki.special.changeslist.legend' );
137 $tocData =
new TOCData();
139 foreach ( $groups as $group => $sortedPages ) {
140 if ( !str_contains( $group,
'/' ) ) {
142 $tocData->addSection(
new SectionMetadata(
145 $this->
msg(
"specialpages-group-$group" )->escaped(),
150 "mw-specialpagesgroup-$group",
151 "mw-specialpagesgroup-$group"
158 $pout->setOutputFlag( ParserOutputFlags::SHOW_TOC );
159 $pout->setText( Parser::TOC_PLACEHOLDER );
160 $out->addParserOutput( $pout );
163 foreach ( $groups as $group => $sortedPages ) {
164 if ( str_contains( $group,
'/' ) ) {
165 [ $group, $subGroup ] = explode(
'/', $group, 2 );
166 $out->addHTML( Html::element(
168 [
'class' =>
"mw-specialpagessubgroup" ],
169 $this->
msg(
"specialpages-group-$group-$subGroup" )->text()
172 $out->addHTML( Html::element(
174 [
'class' =>
"mw-specialpagesgroup",
'id' =>
"mw-specialpagesgroup-$group" ],
175 $this->
msg(
"specialpages-group-$group" )->text()
179 Html::openElement(
'div', [
'class' =>
'mw-specialpages-list' ] )
182 foreach ( $sortedPages as $desc => [
$title, $restricted, $cached ] ) {
185 $pageClasses[] =
'mw-specialpagecached';
188 $pageClasses[] =
'mw-specialpagerestricted';
192 $out->addHTML( Html::rawElement(
194 [
'class' => $pageClasses ],
199 Html::closeElement(
'ul' ) .
200 Html::closeElement(
'div' )
Parent class for all special pages.
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.
getUser()
Shortcut to get the User executing this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
A special page that lists special pages.
execute( $par)
Default execute method Checks user permissions.
Shortcut to construct a special page which is unlisted by default.