43 parent::__construct(
'Specialpages' );
50 $out->setPreventClickjacking(
false );
51 $out->addModuleStyles(
'mediawiki.special' );
53 $groups = $this->getPageGroups();
55 if ( $groups ===
false ) {
60 $this->outputPageList( $groups );
63 private function getPageGroups() {
66 if ( $pages === [] ) {
74 foreach ( $pages as $page ) {
75 $group = $page->getFinalGroupName();
76 $desc = $page->getDescription();
78 if ( is_string( $desc ) ) {
79 wfDeprecated(
"string return from {$page->getName()}::getDescription()",
'1.41' );
80 $desc = (
new RawMessage(
'$1' ) )->rawParams( $desc );
82 $groups[$group][$desc->text()] = [
83 $page->getPageTitle(),
84 $page->isRestricted(),
90 foreach ( $groups as $group => $sortedPages ) {
91 ksort( $groups[$group] );
95 if ( array_key_exists(
'other', $groups ) ) {
96 $other = $groups[
'other'];
97 unset( $groups[
'other'] );
98 $groups[
'other'] = $other;
104 private function outputPageList( $groups ) {
108 $includesRestrictedPages =
false;
109 $includesCachedPages =
false;
110 foreach ( $groups as $group => $sortedPages ) {
111 foreach ( $sortedPages as $desc => [ $title, $restricted, $cached ] ) {
113 $includesCachedPages =
true;
116 $includesRestrictedPages =
true;
122 if ( $includesRestrictedPages ) {
123 $restricedMsg = $this->
msg(
'specialpages-note-restricted' );
124 if ( !$restricedMsg->isDisabled() ) {
125 $notes[] = $restricedMsg->parse();
128 if ( $includesCachedPages ) {
129 $cachedMsg = $this->
msg(
'specialpages-note-cached' );
130 if ( !$cachedMsg->isDisabled() ) {
131 $notes[] = $cachedMsg->parse();
134 if ( $notes !== [] ) {
135 $legendHeading = $this->
msg(
'specialpages-note-top' )->parse();
137 $legend = Html::rawElement(
139 [
'class' =>
'mw-changeslist-legend mw-specialpages-notes' ],
140 $legendHeading . implode(
"\n", $notes )
143 $out->addHTML( $legend );
144 $out->addModuleStyles(
'mediawiki.special.changeslist.legend' );
148 $tocData =
new TOCData();
150 foreach ( $groups as $group => $sortedPages ) {
151 if ( !str_contains( $group,
'/' ) ) {
153 $tocData->addSection(
new SectionMetadata(
156 $this->
msg(
"specialpages-group-$group" )->escaped(),
161 "mw-specialpagesgroup-$group",
162 "mw-specialpagesgroup-$group"
167 $pout =
new ParserOutput;
168 $pout->setTOCData( $tocData );
169 $pout->setOutputFlag( ParserOutputFlags::SHOW_TOC );
170 $pout->setRawText( Parser::TOC_PLACEHOLDER );
171 $out->addParserOutput( $pout );
174 foreach ( $groups as $group => $sortedPages ) {
175 if ( str_contains( $group,
'/' ) ) {
176 [ $group, $subGroup ] = explode(
'/', $group, 2 );
179 [
'class' =>
"mw-specialpagessubgroup" ],
180 $this->
msg(
"specialpages-group-$group-$subGroup" )->text()
185 [
'class' =>
"mw-specialpagesgroup",
'id' =>
"mw-specialpagesgroup-$group" ],
186 $this->
msg(
"specialpages-group-$group" )->text()
190 Html::openElement(
'div', [
'class' =>
'mw-specialpages-list' ] )
193 foreach ( $sortedPages as $desc => [ $title, $restricted, $cached ] ) {
196 $pageClasses[] =
'mw-specialpagecached';
199 $pageClasses[] =
'mw-specialpagerestricted';
203 $out->addHTML( Html::rawElement(
205 [
'class' => $pageClasses ],
210 Html::closeElement(
'ul' ) .
211 Html::closeElement(
'div' )
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.