40 parent::__construct(
'Specialpages' );
47 $out->setPreventClickjacking(
false );
48 $out->addModuleStyles(
'mediawiki.special' );
50 $groups = $this->getPageGroups();
52 if ( $groups ===
false ) {
57 $this->outputPageList( $groups );
60 private function getPageGroups() {
63 if ( $pages === [] ) {
70 foreach ( $pages as $page ) {
71 $group = $page->getFinalGroupName();
72 $desc = $page->getDescription();
74 if ( is_string( $desc ) ) {
75 wfDeprecated(
"string return from {$page->getName()}::getDescription()",
'1.41' );
76 $desc = (
new RawMessage(
'$1' ) )->rawParams( $desc );
78 $groups[$group][$desc->text()] = [
79 $page->getPageTitle(),
80 $page->isRestricted(),
86 foreach ( $groups as $group => $sortedPages ) {
87 ksort( $groups[$group] );
91 if ( array_key_exists(
'other', $groups ) ) {
92 $other = $groups[
'other'];
93 unset( $groups[
'other'] );
94 $groups[
'other'] = $other;
100 private function outputPageList( $groups ) {
104 $includesRestrictedPages =
false;
105 $includesCachedPages =
false;
106 foreach ( $groups as $group => $sortedPages ) {
107 foreach ( $sortedPages as $desc => [ $title, $restricted, $cached ] ) {
109 $includesCachedPages =
true;
112 $includesRestrictedPages =
true;
118 if ( $includesRestrictedPages ) {
119 $restricedMsg = $this->
msg(
'specialpages-note-restricted' );
120 if ( !$restricedMsg->isDisabled() ) {
121 $notes[] = $restricedMsg->parse();
124 if ( $includesCachedPages ) {
125 $cachedMsg = $this->
msg(
'specialpages-note-cached' );
126 if ( !$cachedMsg->isDisabled() ) {
127 $notes[] = $cachedMsg->parse();
130 if ( $notes !== [] ) {
131 $legendHeading = $this->
msg(
'specialpages-note-top' )->parse();
133 $legend = Html::rawElement(
135 [
'class' =>
'mw-changeslist-legend mw-specialpages-notes' ],
136 $legendHeading . implode(
"\n", $notes )
139 $out->addHTML( $legend );
140 $out->addModuleStyles(
'mediawiki.special.changeslist.legend' );
144 $tocData =
new TOCData();
146 foreach ( $groups as $group => $sortedPages ) {
147 if ( !str_contains( $group,
'/' ) ) {
149 $tocData->addSection(
new SectionMetadata(
152 $this->
msg(
"specialpages-group-$group" )->escaped(),
157 "mw-specialpagesgroup-$group",
158 "mw-specialpagesgroup-$group"
163 $pout =
new ParserOutput;
164 $pout->setTOCData( $tocData );
165 $pout->setOutputFlag( ParserOutputFlags::SHOW_TOC );
166 $pout->setRawText( Parser::TOC_PLACEHOLDER );
167 $out->addParserOutput( $pout );
170 foreach ( $groups as $group => $sortedPages ) {
171 if ( str_contains( $group,
'/' ) ) {
172 [ $group, $subGroup ] = explode(
'/', $group, 2 );
175 [
'class' =>
"mw-specialpagessubgroup" ],
176 $this->
msg(
"specialpages-group-$group-$subGroup" )->text()
181 [
'class' =>
"mw-specialpagesgroup",
'id' =>
"mw-specialpagesgroup-$group" ],
182 $this->
msg(
"specialpages-group-$group" )->text()
186 Html::openElement(
'div', [
'class' =>
'mw-specialpages-list' ] )
189 foreach ( $sortedPages as $desc => [ $title, $restricted, $cached ] ) {
192 $pageClasses[] =
'mw-specialpagecached';
195 $pageClasses[] =
'mw-specialpagerestricted';
199 $out->addHTML( Html::rawElement(
201 [
'class' => $pageClasses ],
206 Html::closeElement(
'ul' ) .
207 Html::closeElement(
'div' )
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.