MediaWiki  1.23.15
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->outputPageList( $groups );
49  }
50 
51  private function getPageGroups() {
52  global $wgSortSpecialPages;
53 
54  $pages = SpecialPageFactory::getUsablePages( $this->getUser() );
55 
56  if ( !count( $pages ) ) {
57  # Yeah, that was pointless. Thanks for coming.
58  return false;
59  }
60 
62  $groups = array();
64  foreach ( $pages as $page ) {
65  if ( $page->isListed() ) {
66  $group = $page->getFinalGroupName();
67  if ( !isset( $groups[$group] ) ) {
68  $groups[$group] = array();
69  }
70  $groups[$group][$page->getDescription()] = array(
71  $page->getPageTitle(),
72  $page->isRestricted(),
73  $page->isCached()
74  );
75  }
76  }
77 
79  if ( $wgSortSpecialPages ) {
80  foreach ( $groups as $group => $sortedPages ) {
81  ksort( $groups[$group] );
82  }
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  $total = count( $sortedPages );
103  $middle = ceil( $total / 2 );
104  $count = 0;
105 
106  $out->wrapWikiMsg(
107  "<h2 class=\"mw-specialpagesgroup\" id=\"mw-specialpagesgroup-$group\">$1</h2>\n",
108  "specialpages-group-$group"
109  );
110  $out->addHTML(
112  'table',
113  array( 'style' => 'width:100%;', 'class' => 'mw-specialpages-table' )
114  ) . "\n" .
115  Html::openElement( 'tr' ) . "\n" .
116  Html::openElement( 'td', array( 'style' => 'width:30%;vertical-align:top' ) ) . "\n" .
117  Html::openElement( 'ul' ) . "\n"
118  );
119  foreach ( $sortedPages as $desc => $specialpage ) {
120  list( $title, $restricted, $cached ) = $specialpage;
121 
122  $pageClasses = array();
123  if ( $cached ) {
124  $includesCachedPages = true;
125  $pageClasses[] = 'mw-specialpagecached';
126  }
127  if ( $restricted ) {
128  $includesRestrictedPages = true;
129  $pageClasses[] = 'mw-specialpagerestricted';
130  }
131 
132  $link = Linker::linkKnown( $title, htmlspecialchars( $desc ) );
133  $out->addHTML( Html::rawElement(
134  'li',
135  array( 'class' => implode( ' ', $pageClasses ) ),
136  $link
137  ) . "\n" );
138 
139  # Split up the larger groups
140  $count++;
141  if ( $total > 3 && $count == $middle ) {
142  $out->addHTML(
143  Html::closeElement( 'ul' ) . Html::closeElement( 'td' ) .
144  Html::element( 'td', array( 'style' => 'width:10%' ), '' ) .
145  Html::openElement( 'td', array( 'style' => 'width:30%' ) ) . Html::openElement( 'ul' ) . "\n"
146  );
147  }
148  }
149  $out->addHTML(
150  Html::closeElement( 'ul' ) . Html::closeElement( 'td' ) .
151  Html::element( 'td', array( 'style' => 'width:30%' ), '' ) .
152  Html::closeElement( 'tr' ) . Html::closeElement( 'table' ) . "\n"
153  );
154  }
155 
156  if ( $includesRestrictedPages || $includesCachedPages ) {
157  $out->wrapWikiMsg( "<h2 class=\"mw-specialpages-note-top\">$1</h2>", 'specialpages-note-top' );
158  $out->wrapWikiMsg( "<div class=\"mw-specialpages-notes\">\n$1\n</div>", 'specialpages-note' );
159  }
160  }
161 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:535
UnlistedSpecialPage
Shortcut to construct a special page which is unlisted by default.
Definition: UnlistedSpecialPage.php:29
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:368
$link
set to $title object and return false for a match for latest after cache objects are set use the ContentHandler facility to handle CSS and JavaScript for highlighting & $link
Definition: hooks.txt:2160
Linker\linkKnown
static linkKnown( $target, $html=null, $customAttribs=array(), $query=array(), $options=array( 'known', 'noclasses'))
Identical to link(), except $options defaults to 'known'.
Definition: Linker.php:264
SpecialSpecialpages\getPageGroups
getPageGroups()
Definition: SpecialSpecialpages.php:51
Html\closeElement
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:218
Html\openElement
static openElement( $element, $attribs=array())
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:159
$total
$total
Definition: Utf8Test.php:92
$out
$out
Definition: UtfNormalGenerate.php:167
Html\element
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:141
SpecialSpecialpages\outputPageList
outputPageList( $groups)
Definition: SpecialSpecialpages.php:95
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:352
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:545
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
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
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
$count
$count
Definition: UtfNormalTest2.php:96
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\rawElement
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
Definition: Html.php:121
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:443
SpecialSpecialpages\execute
execute( $par)
Default execute method Checks user permissions, calls the function given in mFunction.
Definition: SpecialSpecialpages.php:35