34 parent::__construct(
'Specialpages' );
41 $out->allowClickjacking();
42 $out->addModuleStyles(
'mediawiki.special' );
46 if ( $groups ===
false ) {
55 $pages = MediaWikiServices::getInstance()->getSpecialPageFactory()->
56 getUsablePages( $this->
getUser() );
58 if ( $pages === [] ) {
59 # Yeah, that was pointless. Thanks for coming.
66 foreach ( $pages as $page ) {
67 if ( $page->isListed() ) {
68 $group = $page->getFinalGroupName();
69 if ( !isset( $groups[$group] ) ) {
72 $groups[$group][$page->getDescription()] = [
73 $page->getPageTitle(),
74 $page->isRestricted(),
81 foreach ( $groups as $group => $sortedPages ) {
82 ksort( $groups[$group] );
86 if ( array_key_exists(
'other', $groups ) ) {
87 $other = $groups[
'other'];
88 unset( $groups[
'other'] );
89 $groups[
'other'] = $other;
98 $includesRestrictedPages =
false;
99 $includesCachedPages =
false;
101 foreach ( $groups as $group => $sortedPages ) {
102 if ( strpos( $group,
'/' ) !==
false ) {
103 list( $group, $subGroup ) = explode(
'/', $group, 2 );
105 "<h3 class=\"mw-specialpagessubgroup\">$1</h3>\n",
106 "specialpages-group-$group-$subGroup"
110 "<h2 class=\"mw-specialpagesgroup\" id=\"mw-specialpagesgroup-$group\">$1</h2>\n",
111 "specialpages-group-$group"
115 Html::openElement(
'div', [
'class' =>
'mw-specialpages-list' ] )
118 foreach ( $sortedPages as $desc => $specialpage ) {
119 list(
$title, $restricted, $cached ) = $specialpage;
123 $includesCachedPages =
true;
124 $pageClasses[] =
'mw-specialpagecached';
127 $includesRestrictedPages =
true;
128 $pageClasses[] =
'mw-specialpagerestricted';
132 $out->addHTML( Html::rawElement(
134 [
'class' => implode(
' ', $pageClasses ) ],
139 Html::closeElement(
'ul' ) .
140 Html::closeElement(
'div' )
146 if ( $includesRestrictedPages ) {
147 $restricedMsg = $this->
msg(
'specialpages-note-restricted' );
148 if ( !$restricedMsg->isDisabled() ) {
149 $notes[] = $restricedMsg->plain();
152 if ( $includesCachedPages ) {
153 $cachedMsg = $this->
msg(
'specialpages-note-cached' );
154 if ( !$cachedMsg->isDisabled() ) {
155 $notes[] = $cachedMsg->plain();
158 if ( $notes !== [] ) {
160 "<h2 class=\"mw-specialpages-note-top\">$1</h2>",
'specialpages-note-top'
162 $out->wrapWikiTextAsInterface(
163 'mw-specialpages-notes',
164 implode(
"\n", $notes )