* Reorganised the includes directory, creating subdirectories db, parser and specials
[lhc/web/wiklou.git] / includes / specials / Specialpages.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 $sk = $wgUser->getSkin();
17
18 $pages = SpecialPage::getUsablePages();
19
20 if( count( $pages ) == 0 ) {
21 # Yeah, that was pointless. Thanks for coming.
22 return;
23 }
24
25 /** Put them into a sortable array */
26 $groups = array();
27 foreach ( $pages as $page ) {
28 if ( $page->isListed() ) {
29 $group = SpecialPage::getGroup( $page );
30 if( !isset($groups[$group]) ) {
31 $groups[$group] = array();
32 }
33 $groups[$group][$page->getDescription()] = array( $page->getTitle(), $page->isRestricted() );
34 }
35 }
36
37 /** Sort */
38 if ( $wgSortSpecialPages ) {
39 foreach( $groups as $group => $sortedPages ) {
40 ksort( $groups[$group] );
41 }
42 }
43
44 /** Always move "other" to end */
45 if( array_key_exists('other',$groups) ) {
46 $other = $groups['other'];
47 unset( $groups['other'] );
48 $groups['other'] = $other;
49 }
50
51 /** Now output the HTML */
52 foreach ( $groups as $group => $sortedPages ) {
53 $middle = ceil( count($sortedPages)/2 );
54 $total = count($sortedPages);
55 $count = 0;
56
57 $wgOut->addHTML( "<h4 class='mw-specialpagesgroup'>".wfMsgHtml("specialpages-group-$group")."</h4>\n" );
58 $wgOut->addHTML( "<table style='width: 100%;' class='mw-specialpages-table'><tr>" );
59 $wgOut->addHTML( "<td width='30%' valign='top'><ul>\n" );
60 foreach( $sortedPages as $desc => $specialpage ) {
61 list( $title, $restricted ) = $specialpage;
62 $link = $sk->makeKnownLinkObj( $title , htmlspecialchars( $desc ) );
63 if( $restricted ) {
64 $wgOut->addHTML( "<li class='mw-specialpages-page mw-specialpagerestricted'>{$link}</li>\n" );
65 } else {
66 $wgOut->addHTML( "<li>{$link}</li>\n" );
67 }
68
69 # Split up the larger groups
70 $count++;
71 if( $total > 3 && $count == $middle ) {
72 $wgOut->addHTML( "</ul></td><td width='10%'></td><td width='30%' valign='top'><ul>" );
73 }
74 }
75 $wgOut->addHTML( "</ul></td><td width='30%' valign='top'></td></tr></table>\n" );
76 }
77 $wgOut->addHTML(
78 Xml::openElement('div', array( 'class' => 'mw-specialpages-notes' )).
79 wfMsgWikiHtml('specialpages-note').
80 Xml::closeElement('div')
81 );
82 }