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