]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/specials/SpecialSpecialpages.php
MediaWiki 1.16.1-scripts
[autoinstallsdev/mediawiki.git] / includes / specials / SpecialSpecialpages.php
1 <?php
2 /**
3  * @file
4  * @ingroup SpecialPage
5  */
6
7 /**
8  *
9  */
10 function wfSpecialSpecialpages() {
11         global $wgOut, $wgUser, $wgMessageCache, $wgSortSpecialPages;
12
13         $wgMessageCache->loadAllMessages();
14
15         $wgOut->setRobotPolicy( 'noindex,nofollow' );  # Is this really needed?
16         $wgOut->allowClickjacking();
17         $sk = $wgUser->getSkin();
18
19         $pages = SpecialPage::getUsablePages();
20
21         if( count( $pages ) == 0 ) {
22                 # Yeah, that was pointless. Thanks for coming.
23                 return;
24         }
25
26         /** Put them into a sortable array */
27         $groups = array();
28         foreach ( $pages as $page ) {
29                 if ( $page->isListed() ) {
30                         $group = SpecialPage::getGroup( $page );
31                         if( !isset($groups[$group]) ) {
32                                 $groups[$group] = array();
33                         }
34                         $groups[$group][$page->getDescription()] = array( $page->getTitle(), $page->isRestricted() );
35                 }
36         }
37
38         /** Sort */
39         if ( $wgSortSpecialPages ) {
40                 foreach( $groups as $group => $sortedPages ) {
41                         ksort( $groups[$group] );
42                 }
43         }
44
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;
50         }
51
52         $includesRestrictedPages = false;
53         /** Now output the HTML */
54         foreach ( $groups as $group => $sortedPages ) {
55                 $middle = ceil( count($sortedPages)/2 );
56                 $total = count($sortedPages);
57                 $count = 0;
58
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 ) );
65                         if( $restricted ) {
66                                 $includesRestrictedPages = true;
67                                 $wgOut->addHTML( "<li class='mw-specialpages-page mw-specialpagerestricted'><strong>{$link}</strong></li>\n" );
68                         } else {
69                                 $wgOut->addHTML( "<li>{$link}</li>\n" );
70                         }
71
72                         # Split up the larger groups
73                         $count++;
74                         if( $total > 3 && $count == $middle ) {
75                                 $wgOut->addHTML( "</ul></td><td width='10%'></td><td width='30%' valign='top'><ul>" );
76                         }
77                 }
78                 $wgOut->addHTML( "</ul></td><td width='30%' valign='top'></td></tr></table>\n" );
79         }
80
81         if ( $includesRestrictedPages ) {
82                 $wgOut->wrapWikiMsg( "<div class=\"mw-specialpages-notes\">\n$1\n</div>", 'specialpages-note' );
83         }
84 }