MediaWiki REL1_31
SpecialSpecialpages.php
Go to the documentation of this file.
1<?php
30
31 function __construct() {
32 parent::__construct( 'Specialpages' );
33 }
34
35 function execute( $par ) {
36 $out = $this->getOutput();
37 $this->setHeaders();
38 $this->outputHeader();
39 $out->allowClickjacking();
40 $out->addModuleStyles( 'mediawiki.special' );
41
42 $groups = $this->getPageGroups();
43
44 if ( $groups === false ) {
45 return;
46 }
47
48 $this->addHelpLink( 'Help:Special pages' );
49 $this->outputPageList( $groups );
50 }
51
52 private function getPageGroups() {
54
55 if ( !count( $pages ) ) {
56 # Yeah, that was pointless. Thanks for coming.
57 return false;
58 }
59
61 $groups = [];
63 foreach ( $pages as $page ) {
64 if ( $page->isListed() ) {
65 $group = $page->getFinalGroupName();
66 if ( !isset( $groups[$group] ) ) {
67 $groups[$group] = [];
68 }
69 $groups[$group][$page->getDescription()] = [
70 $page->getPageTitle(),
71 $page->isRestricted(),
72 $page->isCached()
73 ];
74 }
75 }
76
78 foreach ( $groups as $group => $sortedPages ) {
79 ksort( $groups[$group] );
80 }
81
83 if ( array_key_exists( 'other', $groups ) ) {
84 $other = $groups['other'];
85 unset( $groups['other'] );
86 $groups['other'] = $other;
87 }
88
89 return $groups;
90 }
91
92 private function outputPageList( $groups ) {
93 $out = $this->getOutput();
94
95 $includesRestrictedPages = false;
96 $includesCachedPages = false;
97
98 foreach ( $groups as $group => $sortedPages ) {
99 $out->wrapWikiMsg(
100 "<h2 class=\"mw-specialpagesgroup\" id=\"mw-specialpagesgroup-$group\">$1</h2>\n",
101 "specialpages-group-$group"
102 );
103 $out->addHTML(
104 Html::openElement( 'div', [ 'class' => 'mw-specialpages-list' ] )
105 . '<ul>'
106 );
107 foreach ( $sortedPages as $desc => $specialpage ) {
108 list( $title, $restricted, $cached ) = $specialpage;
109
110 $pageClasses = [];
111 if ( $cached ) {
112 $includesCachedPages = true;
113 $pageClasses[] = 'mw-specialpagecached';
114 }
115 if ( $restricted ) {
116 $includesRestrictedPages = true;
117 $pageClasses[] = 'mw-specialpagerestricted';
118 }
119
120 $link = $this->getLinkRenderer()->makeKnownLink( $title, $desc );
121 $out->addHTML( Html::rawElement(
122 'li',
123 [ 'class' => implode( ' ', $pageClasses ) ],
124 $link
125 ) . "\n" );
126 }
127 $out->addHTML(
128 Html::closeElement( 'ul' ) .
129 Html::closeElement( 'div' )
130 );
131 }
132
133 // add legend
134 $notes = [];
135 if ( $includesRestrictedPages ) {
136 $restricedMsg = $this->msg( 'specialpages-note-restricted' );
137 if ( !$restricedMsg->isDisabled() ) {
138 $notes[] = $restricedMsg->plain();
139 }
140 }
141 if ( $includesCachedPages ) {
142 $cachedMsg = $this->msg( 'specialpages-note-cached' );
143 if ( !$cachedMsg->isDisabled() ) {
144 $notes[] = $cachedMsg->plain();
145 }
146 }
147 if ( $notes !== [] ) {
148 $out->wrapWikiMsg(
149 "<h2 class=\"mw-specialpages-note-top\">$1</h2>", 'specialpages-note-top'
150 );
151 $out->addWikiText(
152 "<div class=\"mw-specialpages-notes\">\n" .
153 implode( "\n", $notes ) .
154 "\n</div>"
155 );
156 }
157 }
158}
static getUsablePages(User $user=null)
Return categorised listable special pages which are available for the current user,...
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)
Wrapper around wfMessage that sets the current context.
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.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:864
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:3021