10 function wfSpecialSpecialpages() {
11 global $wgOut, $wgUser, $wgMessageCache, $wgSortSpecialPages;
13 $wgMessageCache->loadAllMessages();
15 $wgOut->setRobotPolicy( 'noindex,nofollow' ); # Is this really needed?
16 $wgOut->allowClickjacking();
17 $sk = $wgUser->getSkin();
19 $pages = SpecialPage::getUsablePages();
21 if( count( $pages ) == 0 ) {
22 # Yeah, that was pointless. Thanks for coming.
26 /** Put them into a sortable array */
28 foreach ( $pages as $page ) {
29 if ( $page->isListed() ) {
30 $group = SpecialPage::getGroup( $page );
31 if( !isset($groups[$group]) ) {
32 $groups[$group] = array();
34 $groups[$group][$page->getDescription()] = array( $page->getTitle(), $page->isRestricted() );
39 if ( $wgSortSpecialPages ) {
40 foreach( $groups as $group => $sortedPages ) {
41 ksort( $groups[$group] );
45 /** Always move "other" to end */
46 if( array_key_exists('other',$groups) ) {
47 $other = $groups['other'];
48 unset( $groups['other'] );
49 $groups['other'] = $other;
52 $includesRestrictedPages = false;
53 /** Now output the HTML */
54 foreach ( $groups as $group => $sortedPages ) {
55 $middle = ceil( count($sortedPages)/2 );
56 $total = count($sortedPages);
59 $wgOut->wrapWikiMsg( "<h4 class=\"mw-specialpagesgroup\" id=\"mw-specialpagesgroup-$group\">$1</h4>\n", "specialpages-group-$group" );
60 $wgOut->addHTML( "<table style='width: 100%;' class='mw-specialpages-table'><tr>" );
61 $wgOut->addHTML( "<td width='30%' valign='top'><ul>\n" );
62 foreach( $sortedPages as $desc => $specialpage ) {
63 list( $title, $restricted ) = $specialpage;
64 $link = $sk->linkKnown( $title , htmlspecialchars( $desc ) );
66 $includesRestrictedPages = true;
67 $wgOut->addHTML( "<li class='mw-specialpages-page mw-specialpagerestricted'><strong>{$link}</strong></li>\n" );
69 $wgOut->addHTML( "<li>{$link}</li>\n" );
72 # Split up the larger groups
74 if( $total > 3 && $count == $middle ) {
75 $wgOut->addHTML( "</ul></td><td width='10%'></td><td width='30%' valign='top'><ul>" );
78 $wgOut->addHTML( "</ul></td><td width='30%' valign='top'></td></tr></table>\n" );
81 if ( $includesRestrictedPages ) {
82 $wgOut->wrapWikiMsg( "<div class=\"mw-specialpages-notes\">\n$1\n</div>", 'specialpages-note' );