40 parent::__construct(
'Specialpages' );
47 $out->getMetadata()->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 );
79 if ( !$desc->isDisabled() ) {
80 $groups[$group][$desc->text()] = [
81 $page->getPageTitle(),
82 $page->isRestricted(),
89 foreach ( $groups as $group => $sortedPages ) {
90 ksort( $groups[$group] );
94 if ( array_key_exists(
'other', $groups ) ) {
95 $other = $groups[
'other'];
96 unset( $groups[
'other'] );
97 $groups[
'other'] = $other;
103 private function outputPageList( $groups ) {
107 $includesRestrictedPages =
false;
108 $includesCachedPages =
false;
109 foreach ( $groups as $group => $sortedPages ) {
110 foreach ( $sortedPages as $desc => [ $title, $restricted, $cached ] ) {
112 $includesCachedPages =
true;
115 $includesRestrictedPages =
true;
121 if ( $includesRestrictedPages ) {
122 $restricedMsg = $this->
msg(
'specialpages-note-restricted' );
123 if ( !$restricedMsg->isDisabled() ) {
124 $notes[] = $restricedMsg->parse();
127 if ( $includesCachedPages ) {
128 $cachedMsg = $this->
msg(
'specialpages-note-cached' );
129 if ( !$cachedMsg->isDisabled() ) {
130 $notes[] = $cachedMsg->parse();
133 if ( $notes !== [] ) {
134 $legendHeading = $this->
msg(
'specialpages-note-top' )->parse();
136 $legend = Html::rawElement(
138 [
'class' =>
'mw-changeslist-legend mw-specialpages-notes' ],
139 $legendHeading . implode(
"\n", $notes )
142 $out->addHTML( $legend );
143 $out->addModuleStyles(
'mediawiki.special.changeslist.legend' );
147 $tocData =
new TOCData();
149 foreach ( $groups as $group => $sortedPages ) {
150 if ( !str_contains( $group,
'/' ) ) {
152 $tocData->addSection(
new SectionMetadata(
155 $this->
msg(
"specialpages-group-$group" )->escaped(),
160 "mw-specialpagesgroup-$group",
161 "mw-specialpagesgroup-$group"
166 $pout =
new ParserOutput;
167 $pout->setTOCData( $tocData );
168 $pout->setOutputFlag( ParserOutputFlags::SHOW_TOC );
169 $pout->setRawText( Parser::TOC_PLACEHOLDER );
170 $out->addParserOutput( $pout );
173 foreach ( $groups as $group => $sortedPages ) {
174 if ( str_contains( $group,
'/' ) ) {
175 [ $group, $subGroup ] = explode(
'/', $group, 2 );
178 [
'class' =>
"mw-specialpagessubgroup" ],
179 $this->
msg(
"specialpages-group-$group-$subGroup" )->text()
184 [
'class' =>
"mw-specialpagesgroup",
'id' =>
"mw-specialpagesgroup-$group" ],
185 $this->
msg(
"specialpages-group-$group" )->text()
189 Html::openElement(
'div', [
'class' =>
'mw-specialpages-list' ] )
192 foreach ( $sortedPages as $desc => [ $title, $restricted, $cached ] ) {
195 $pageClasses[] =
'mw-specialpagecached';
198 $pageClasses[] =
'mw-specialpagerestricted';
202 $out->addHTML( Html::rawElement(
204 [
'class' => $pageClasses ],
209 Html::closeElement(
'ul' ) .
210 Html::closeElement(
'div' )
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.