Reverting new Special:SpecialPages layout: Problems in RTL wikis in Firefox (didn...
[lhc/web/wiklou.git] / includes / 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()] = $page->getTitle();
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 /** Now output the HTML */
53 $restrictedPages = false;
54 foreach ( $groups as $group => $sortedPages ) {
55 $middle = ceil( count($sortedPages)/2 );
56 $total = count($sortedPages);
57 $count = 0;
58
59 $wgOut->addHTML( "<h4 class='mw-specialpagesgroup'>".wfMsgHtml("specialpages-group-$group")."</h4>\n" );
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->makeKnownLinkObj( $title , htmlspecialchars( $desc ) );
65 if( $restricted ) {
66 $wgOut->addHTML( "<li class='mw-specialpages-page mw-specialpagerestricted'>{$link}</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 $wgOut->addHTML(
80 Xml::openElement('div', array( 'class' => 'mw-specialpages-notes' )).
81 wfMsgWikiHtml('specialpages-note').
82 Xml::closeElement('div')
83 );
84 }