MediaWiki  1.30.0
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() {
53  $pages = SpecialPageFactory::getUsablePages( $this->getUser() );
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 }
SpecialPage\msg
msg( $key)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:746
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:675
UnlistedSpecialPage
Shortcut to construct a special page which is unlisted by default.
Definition: UnlistedSpecialPage.php:29
captcha-old.count
count
Definition: captcha-old.py:249
SpecialSpecialpages\__construct
__construct()
Definition: SpecialSpecialpages.php:31
SpecialPageFactory\getUsablePages
static getUsablePages(User $user=null)
Return categorised listable special pages which are available for the current user,...
Definition: SpecialPageFactory.php:431
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
SpecialSpecialpages\getPageGroups
getPageGroups()
Definition: SpecialSpecialpages.php:52
Html\closeElement
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:309
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:785
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:932
SpecialSpecialpages\outputPageList
outputPageList( $groups)
Definition: SpecialSpecialpages.php:92
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:484
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:685
SpecialSpecialpages
A special page that lists special pages.
Definition: SpecialSpecialpages.php:29
list
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
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:860
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Html\openElement
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:251
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2981
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:583
$out
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:781
SpecialSpecialpages\execute
execute( $par)
Default execute method Checks user permissions.
Definition: SpecialSpecialpages.php:35