MediaWiki REL1_33
SpecialSpecialpages.php
Go to the documentation of this file.
1<?php
25
32
33 function __construct() {
34 parent::__construct( 'Specialpages' );
35 }
36
37 function execute( $par ) {
38 $out = $this->getOutput();
39 $this->setHeaders();
40 $this->outputHeader();
41 $out->allowClickjacking();
42 $out->addModuleStyles( 'mediawiki.special' );
43
44 $groups = $this->getPageGroups();
45
46 if ( $groups === false ) {
47 return;
48 }
49
50 $this->addHelpLink( 'Help:Special pages' );
51 $this->outputPageList( $groups );
52 }
53
54 private function getPageGroups() {
55 $pages = MediaWikiServices::getInstance()->getSpecialPageFactory()->
56 getUsablePages( $this->getUser() );
57
58 if ( $pages === [] ) {
59 # Yeah, that was pointless. Thanks for coming.
60 return false;
61 }
62
64 $groups = [];
66 foreach ( $pages as $page ) {
67 if ( $page->isListed() ) {
68 $group = $page->getFinalGroupName();
69 if ( !isset( $groups[$group] ) ) {
70 $groups[$group] = [];
71 }
72 $groups[$group][$page->getDescription()] = [
73 $page->getPageTitle(),
74 $page->isRestricted(),
75 $page->isCached()
76 ];
77 }
78 }
79
81 foreach ( $groups as $group => $sortedPages ) {
82 ksort( $groups[$group] );
83 }
84
86 if ( array_key_exists( 'other', $groups ) ) {
87 $other = $groups['other'];
88 unset( $groups['other'] );
89 $groups['other'] = $other;
90 }
91
92 return $groups;
93 }
94
95 private function outputPageList( $groups ) {
96 $out = $this->getOutput();
97
98 $includesRestrictedPages = false;
99 $includesCachedPages = false;
100
101 foreach ( $groups as $group => $sortedPages ) {
102 if ( strpos( $group, '/' ) !== false ) {
103 list( $group, $subGroup ) = explode( '/', $group, 2 );
104 $out->wrapWikiMsg(
105 "<h3 class=\"mw-specialpagessubgroup\">$1</h3>\n",
106 "specialpages-group-$group-$subGroup"
107 );
108 } else {
109 $out->wrapWikiMsg(
110 "<h2 class=\"mw-specialpagesgroup\" id=\"mw-specialpagesgroup-$group\">$1</h2>\n",
111 "specialpages-group-$group"
112 );
113 }
114 $out->addHTML(
115 Html::openElement( 'div', [ 'class' => 'mw-specialpages-list' ] )
116 . '<ul>'
117 );
118 foreach ( $sortedPages as $desc => $specialpage ) {
119 list( $title, $restricted, $cached ) = $specialpage;
120
121 $pageClasses = [];
122 if ( $cached ) {
123 $includesCachedPages = true;
124 $pageClasses[] = 'mw-specialpagecached';
125 }
126 if ( $restricted ) {
127 $includesRestrictedPages = true;
128 $pageClasses[] = 'mw-specialpagerestricted';
129 }
130
131 $link = $this->getLinkRenderer()->makeKnownLink( $title, $desc );
132 $out->addHTML( Html::rawElement(
133 'li',
134 [ 'class' => implode( ' ', $pageClasses ) ],
135 $link
136 ) . "\n" );
137 }
138 $out->addHTML(
139 Html::closeElement( 'ul' ) .
140 Html::closeElement( 'div' )
141 );
142 }
143
144 // add legend
145 $notes = [];
146 if ( $includesRestrictedPages ) {
147 $restricedMsg = $this->msg( 'specialpages-note-restricted' );
148 if ( !$restricedMsg->isDisabled() ) {
149 $notes[] = $restricedMsg->plain();
150 }
151 }
152 if ( $includesCachedPages ) {
153 $cachedMsg = $this->msg( 'specialpages-note-cached' );
154 if ( !$cachedMsg->isDisabled() ) {
155 $notes[] = $cachedMsg->plain();
156 }
157 }
158 if ( $notes !== [] ) {
159 $out->wrapWikiMsg(
160 "<h2 class=\"mw-specialpages-note-top\">$1</h2>", 'specialpages-note-top'
161 );
162 $out->wrapWikiTextAsInterface(
163 'mw-specialpages-notes',
164 implode( "\n", $notes )
165 );
166 }
167 }
168}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
MediaWikiServices is the service locator for the application scope of MediaWiki.
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 When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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:855
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:3069