4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * http://www.gnu.org/copyleft/gpl.html
22 * @ingroup SpecialPage
25 function wfSpecialSpecialpages() {
26 global $wgOut, $wgUser, $wgMessageCache, $wgSortSpecialPages;
28 $wgMessageCache->loadAllMessages();
30 $wgOut->setRobotPolicy( 'noindex,nofollow' ); # Is this really needed?
31 $sk = $wgUser->getSkin();
33 $pages = SpecialPage
::getUsablePages();
35 if( count( $pages ) == 0 ) {
36 # Yeah, that was pointless. Thanks for coming.
40 /** Put them into a sortable array */
42 foreach ( $pages as $page ) {
43 if ( $page->isListed() ) {
44 $group = SpecialPage
::getGroup( $page );
45 if( !isset($groups[$group]) ) {
46 $groups[$group] = array();
48 $groups[$group][$page->getDescription()] = array( $page->getTitle(), $page->isRestricted() );
53 if ( $wgSortSpecialPages ) {
54 foreach( $groups as $group => $sortedPages ) {
55 ksort( $groups[$group] );
59 /** Always move "other" to end */
60 if( array_key_exists('other',$groups) ) {
61 $other = $groups['other'];
62 unset( $groups['other'] );
63 $groups['other'] = $other;
66 $includesRestrictedPages = false;
67 /** Now output the HTML */
68 foreach ( $groups as $group => $sortedPages ) {
69 $middle = ceil( count($sortedPages)/2 );
70 $total = count($sortedPages);
73 $wgOut->wrapWikiMsg( "<h4 class=\"mw-specialpagesgroup\" id=\"mw-specialpagesgroup-$group\">$1</h4>\n", "specialpages-group-$group" );
74 $wgOut->addHTML( "<table style='width: 100%;' class='mw-specialpages-table'><tr>" );
75 $wgOut->addHTML( "<td width='30%' valign='top'><ul>\n" );
76 foreach( $sortedPages as $desc => $specialpage ) {
77 list( $title, $restricted ) = $specialpage;
78 $link = $sk->linkKnown( $title , htmlspecialchars( $desc ) );
80 $includesRestrictedPages = true;
81 $wgOut->addHTML( "<li class='mw-specialpages-page mw-specialpagerestricted'><strong>{$link}</strong></li>\n" );
83 $wgOut->addHTML( "<li>{$link}</li>\n" );
86 # Split up the larger groups
88 if( $total > 3 && $count == $middle ) {
89 $wgOut->addHTML( "</ul></td><td width='10%'></td><td width='30%' valign='top'><ul>" );
92 $wgOut->addHTML( "</ul></td><td width='30%' valign='top'></td></tr></table>\n" );
95 if ( $includesRestrictedPages ) {
96 $wgOut->wrapWikiMsg( "<div class=\"mw-specialpages-notes\">\n$1\n</div>", 'specialpages-note' );