* API: result data generation cleanup, minor cleaning
[mediawiki.git] / includes / SpecialSpecialpages.php
blob6a01cd082988ec9e6c4a9eb0d6dce412c8eb7559
1 <?php
2 /**
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
8 /**
11 function wfSpecialSpecialpages() {
12 global $wgOut, $wgUser;
14 $wgOut->setRobotpolicy( 'index,nofollow' );
15 $sk = $wgUser->getSkin();
17 /** Pages available to all */
18 wfSpecialSpecialpages_gen( SpecialPage::getRegularPages(), 'spheading', $sk );
20 /** Restricted special pages */
21 wfSpecialSpecialpages_gen( SpecialPage::getRestrictedPages(), 'restrictedpheading', $sk );
24 /**
25 * sub function generating the list of pages
26 * @param $pages the list of pages
27 * @param $heading header to be used
28 * @param $sk skin object ???
30 function wfSpecialSpecialpages_gen($pages,$heading,$sk) {
31 global $wgOut, $wgSortSpecialPages;
33 if( count( $pages ) == 0 ) {
34 # Yeah, that was pointless. Thanks for coming.
35 return;
38 /** Put them into a sortable array */
39 $sortedPages = array();
40 foreach ( $pages as $name => $page ) {
41 if ( $page->isListed() ) {
42 $sortedPages[$page->getDescription()] = $page->getTitle();
46 /** Sort */
47 if ( $wgSortSpecialPages ) {
48 ksort( $sortedPages );
51 /** Now output the HTML */
52 $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n<ul>" );
53 foreach ( $sortedPages as $desc => $title ) {
54 $link = $sk->makeKnownLinkObj( $title, $desc );
55 $wgOut->addHTML( "<li>{$link}</li>\n" );
57 $wgOut->addHTML( "</ul>\n" );