3 * Implements Special:Specialpages
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
25 * A special page that lists special pages
27 * @ingroup SpecialPage
29 class SpecialSpecialpages
extends UnlistedSpecialPage
{
31 function __construct() {
32 parent
::__construct( 'Specialpages' );
35 function execute( $par ) {
37 $this->outputHeader();
39 $groups = $this->getPageGroups();
41 if ( $groups === false ) {
45 $this->outputPageList( $groups );
48 private function getPageGroups() {
49 global $wgSortSpecialPages;
51 $pages = SpecialPage
::getUsablePages();
53 if( !count( $pages ) ) {
54 # Yeah, that was pointless. Thanks for coming.
58 /** Put them into a sortable array */
60 foreach ( $pages as $page ) {
61 if ( $page->isListed() ) {
62 $group = SpecialPage
::getGroup( $page );
63 if( !isset( $groups[$group] ) ) {
64 $groups[$group] = array();
66 $groups[$group][$page->getDescription()] = array( $page->getTitle(), $page->isRestricted() );
71 if ( $wgSortSpecialPages ) {
72 foreach( $groups as $group => $sortedPages ) {
73 ksort( $groups[$group] );
77 /** Always move "other" to end */
78 if( array_key_exists( 'other', $groups ) ) {
79 $other = $groups['other'];
80 unset( $groups['other'] );
81 $groups['other'] = $other;
87 private function outputPageList( $groups ) {
88 global $wgUser, $wgOut;
90 $sk = $wgUser->getSkin();
91 $includesRestrictedPages = false;
93 foreach ( $groups as $group => $sortedPages ) {
94 $middle = ceil( count( $sortedPages )/2 );
95 $total = count( $sortedPages );
98 $wgOut->wrapWikiMsg( "<h4 class=\"mw-specialpagesgroup\" id=\"mw-specialpagesgroup-$group\">$1</h4>\n", "specialpages-group-$group" );
100 Html
::openElement( 'table', array( 'style' => 'width:100%;', 'class' => 'mw-specialpages-table' ) ) ."\n" .
101 Html
::openElement( 'tr' ) . "\n" .
102 Html
::openElement( 'td', array( 'style' => 'width:30%;vertical-align:top' ) ) . "\n" .
103 Html
::openElement( 'ul' ) . "\n"
105 foreach( $sortedPages as $desc => $specialpage ) {
106 list( $title, $restricted ) = $specialpage;
107 $link = $sk->linkKnown( $title , htmlspecialchars( $desc ) );
109 $includesRestrictedPages = true;
110 $wgOut->addHTML( Html
::rawElement( 'li', array( 'class' => 'mw-specialpages-page mw-specialpagerestricted' ), Html
::rawElement( 'strong', array(), $link ) ) . "\n" );
112 $wgOut->addHTML( Html
::rawElement( 'li', array(), $link ) . "\n" );
115 # Split up the larger groups
117 if( $total > 3 && $count == $middle ) {
119 Html
::closeElement( 'ul' ) . Html
::closeElement( 'td' ) .
120 Html
::element( 'td', array( 'style' => 'width:10%' ), '' ) .
121 Html
::openElement( 'td', array( 'style' => 'width:30%' ) ) . Html
::openElement( 'ul' ) . "\n"
126 Html
::closeElement( 'ul' ) . Html
::closeElement( 'td' ) .
127 Html
::element( 'td', array( 'style' => 'width:30%' ), '' ) .
128 Html
::closeElement( 'tr' ) . Html
::closeElement( 'table' ) . "\n"
132 if ( $includesRestrictedPages ) {
133 $wgOut->wrapWikiMsg( "<div class=\"mw-specialpages-notes\">\n$1\n</div>", 'specialpages-note' );