SpecialContributions: fixed style, fixed sloppy handling of empty query results,...
[mediawiki.git] / includes / SpecialSpecialpages.php
blob0b53db73c124382366f095d7486f4a1c6e6b59b9
1 <?php
2 /**
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
8 /**
11 function wfSpecialSpecialpages() {
12 global $wgOut, $wgUser, $wgAvailableRights;
14 $wgOut->setRobotpolicy( 'index,nofollow' );
15 $sk = $wgUser->getSkin();
17 # Get listable pages, in a 2-d array with the first dimension being user right
18 $pages = SpecialPage::getPages();
20 /** Pages available to all */
21 wfSpecialSpecialpages_gen($pages[''],'spheading',$sk);
23 /** Restricted special pages */
24 $rpages = array();
25 foreach($wgAvailableRights as $right) {
26 /** only show pages a user can access */
27 if( $wgUser->isAllowed($right) ) {
28 /** some rights might not have any special page associated */
29 if(isset($pages[$right])) {
30 $rpages = array_merge( $rpages, $pages[$right] );
34 wfSpecialSpecialpages_gen( $rpages, 'restrictedpheading', $sk );
37 /**
38 * sub function generating the list of pages
39 * @param $pages the list of pages
40 * @param $heading header to be used
41 * @param $sk skin object ???
43 function wfSpecialSpecialpages_gen($pages,$heading,$sk) {
44 global $wgOut, $wgSortSpecialPages;
46 if( count( $pages ) == 0 ) {
47 # Yeah, that was pointless. Thanks for coming.
48 return;
51 /** Put them into a sortable array */
52 $sortedPages = array();
53 foreach ( $pages as $name => $page ) {
54 if ( $page->isListed() ) {
55 $sortedPages[$page->getDescription()] = $page->getTitle();
59 /** Sort */
60 if ( $wgSortSpecialPages ) {
61 ksort( $sortedPages );
64 /** Now output the HTML */
65 $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n<ul>" );
66 foreach ( $sortedPages as $desc => $title ) {
67 $link = $sk->makeKnownLinkObj( $title, $desc );
68 $wgOut->addHTML( "<li>{$link}</li>\n" );
70 $wgOut->addHTML( "</ul>\n" );