00001 <?php 00010 function wfSpecialSpecialpages() { 00011 global $wgOut, $wgUser, $wgMessageCache, $wgSortSpecialPages; 00012 00013 $wgMessageCache->loadAllMessages(); 00014 00015 $wgOut->setRobotPolicy( 'noindex,nofollow' ); # Is this really needed? 00016 $sk = $wgUser->getSkin(); 00017 00018 $pages = SpecialPage::getUsablePages(); 00019 00020 if( count( $pages ) == 0 ) { 00021 # Yeah, that was pointless. Thanks for coming. 00022 return; 00023 } 00024 00026 $groups = array(); 00027 foreach ( $pages as $page ) { 00028 if ( $page->isListed() ) { 00029 $group = SpecialPage::getGroup( $page ); 00030 if( !isset($groups[$group]) ) { 00031 $groups[$group] = array(); 00032 } 00033 $groups[$group][$page->getDescription()] = array( $page->getTitle(), $page->isRestricted() ); 00034 } 00035 } 00036 00038 if ( $wgSortSpecialPages ) { 00039 foreach( $groups as $group => $sortedPages ) { 00040 ksort( $groups[$group] ); 00041 } 00042 } 00043 00045 if( array_key_exists('other',$groups) ) { 00046 $other = $groups['other']; 00047 unset( $groups['other'] ); 00048 $groups['other'] = $other; 00049 } 00050 00051 $includesRestrictedPages = false; 00053 foreach ( $groups as $group => $sortedPages ) { 00054 $middle = ceil( count($sortedPages)/2 ); 00055 $total = count($sortedPages); 00056 $count = 0; 00057 00058 $wgOut->wrapWikiMsg( "<h4 class='mw-specialpagesgroup'>$1</h4>\n", "specialpages-group-$group" ); 00059 $wgOut->addHTML( "<table style='width: 100%;' class='mw-specialpages-table'><tr>" ); 00060 $wgOut->addHTML( "<td width='30%' valign='top'><ul>\n" ); 00061 foreach( $sortedPages as $desc => $specialpage ) { 00062 list( $title, $restricted ) = $specialpage; 00063 $link = $sk->makeKnownLinkObj( $title , htmlspecialchars( $desc ) ); 00064 if( $restricted ) { 00065 $includesRestrictedPages = true; 00066 $wgOut->addHTML( "<li class='mw-specialpages-page mw-specialpagerestricted'>{$link}</li>\n" ); 00067 } else { 00068 $wgOut->addHTML( "<li>{$link}</li>\n" ); 00069 } 00070 00071 # Split up the larger groups 00072 $count++; 00073 if( $total > 3 && $count == $middle ) { 00074 $wgOut->addHTML( "</ul></td><td width='10%'></td><td width='30%' valign='top'><ul>" ); 00075 } 00076 } 00077 $wgOut->addHTML( "</ul></td><td width='30%' valign='top'></td></tr></table>\n" ); 00078 } 00079 00080 if ( $includesRestrictedPages ) { 00081 $wgOut->wrapWikiMsg( "<div class=\"mw-specialpages-notes\">\n$1\n</div>", 'specialpages-note' ); 00082 } 00083 }