* replace use of deprecated makeKnownLinkObj() by linkKnown() in core special pages
[lhc/web/wiklou.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 $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 $includesRestrictedPages = false;
52 /** Now output the HTML */
53 foreach ( $groups as $group => $sortedPages ) {
54 $middle = ceil( count($sortedPages)/2 );
55 $total = count($sortedPages);
56 $count = 0;
57
58 $wgOut->wrapWikiMsg( "<h4 class=\"mw-specialpagesgroup\" id=\"mw-specialpagesgroup-$group\">$1</h4>\n", "specialpages-group-$group" );
59 $wgOut->addHTML( "<table style='width: 100%;' class='mw-specialpages-table'><tr>" );
60 $wgOut->addHTML( "<td width='30%' valign='top'><ul>\n" );
61 foreach( $sortedPages as $desc => $specialpage ) {
62 list( $title, $restricted ) = $specialpage;
63 $link = $sk->linkKnown( $title , htmlspecialchars( $desc ) );
64 if( $restricted ) {
65 $includesRestrictedPages = true;
66 $wgOut->addHTML( "<li class='mw-specialpages-page mw-specialpagerestricted'><strong>{$link}</strong></li>\n" );
67 } else {
68 $wgOut->addHTML( "<li>{$link}</li>\n" );
69 }
70
71 # Split up the larger groups
72 $count++;
73 if( $total > 3 && $count == $middle ) {
74 $wgOut->addHTML( "</ul></td><td width='10%'></td><td width='30%' valign='top'><ul>" );
75 }
76 }
77 $wgOut->addHTML( "</ul></td><td width='30%' valign='top'></td></tr></table>\n" );
78 }
79
80 if ( $includesRestrictedPages ) {
81 $wgOut->wrapWikiMsg( "<div class=\"mw-specialpages-notes\">\n$1\n</div>", 'specialpages-note' );
82 }
83 }