seek() does nothing here
[mediawiki.git] / includes / SpecialSpecialpages.php
blob90ff0ed2fd01474ec9975bcbf61d84505a1c99c9
1 <?php
2 /**
4 * @addtogroup SpecialPage
5 */
7 /**
9 */
10 function wfSpecialSpecialpages() {
11 global $wgOut, $wgUser, $wgMessageCache;
13 $wgMessageCache->loadAllMessages();
15 $wgOut->setRobotpolicy( 'noindex,nofollow' ); # Is this really needed?
16 $sk = $wgUser->getSkin();
18 /** Pages available to all */
19 wfSpecialSpecialpages_gen( SpecialPage::getRegularPages(), 'spheading', $sk );
21 /** Restricted special pages */
22 wfSpecialSpecialpages_gen( SpecialPage::getRestrictedPages(), 'restrictedpheading', $sk );
25 /**
26 * sub function generating the list of pages
27 * @param $pages the list of pages
28 * @param $heading header to be used
29 * @param $sk skin object ???
31 function wfSpecialSpecialpages_gen($pages,$heading,$sk) {
32 global $wgOut, $wgSortSpecialPages;
34 if( count( $pages ) == 0 ) {
35 # Yeah, that was pointless. Thanks for coming.
36 return;
39 /** Put them into a sortable array */
40 $groups = array();
41 foreach ( $pages as $page ) {
42 if ( $page->isListed() ) {
43 $group = SpecialPage::getGroup( $page );
44 if( !isset($groups[$group]) ) {
45 $groups[$group] = array();
47 $groups[$group][$page->getDescription()] = $page->getTitle();
51 /** Sort */
52 if ( $wgSortSpecialPages ) {
53 foreach( $groups as $group => $sortedPages ) {
54 ksort( $groups[$group] );
58 /** Always move "other" to end */
59 if( array_key_exists('other',$groups) ) {
60 $other = $groups['other'];
61 unset( $groups['other'] );
62 $groups['other'] = $other;
65 /** Now output the HTML */
66 $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n" );
67 foreach ( $groups as $group => $sortedPages ) {
68 $middle = ceil( count($sortedPages)/2 );
69 $max = count($sortedPages) - 1;
70 $count = 0;
72 $wgOut->addHTML( "<h4 class='mw-specialpagesgroup'>".wfMsgHtml("specialpages-group-$group")."</h4>\n" );
73 $wgOut->addHTML( "<table style='width: 100%;' class='mw-specialpages-table'><tr>" );
74 $wgOut->addHTML( "<td width='30%' valign='top'><ul>\n" );
75 foreach ( $sortedPages as $desc => $title ) {
76 $link = $sk->makeKnownLinkObj( $title , htmlspecialchars( $desc ) );
77 $wgOut->addHTML( "<li>{$link}</li>\n" );
79 # Slit up the larger groups
80 $count++;
81 if( $max > 3 && $count == $middle && $count < $max ) {
82 $wgOut->addHTML( "</ul></td><td width='10%'></td><td width='30%' valign='top'><ul>" );
85 $wgOut->addHTML( "</ul></td><td width='30%' valign='top'></td></tr></table>\n" );