Correction to r31475 -- works with PHP 5.1 now.
[mediawiki.git] / includes / SpecialSpecialpages.php
blob4ea956b899e147e8594fc365a82e29a4ae2d582d
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 $sortedPages = array();
41 foreach ( $pages as $page ) {
42 if ( $page->isListed() ) {
43 $sortedPages[$page->getDescription()] = $page->getTitle();
47 /** Sort */
48 if ( $wgSortSpecialPages ) {
49 ksort( $sortedPages );
52 /** Now output the HTML */
53 $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n<ul>" );
54 foreach ( $sortedPages as $desc => $title ) {
55 $link = $sk->makeKnownLinkObj( $title , htmlspecialchars( $desc ) );
56 $wgOut->addHTML( "<li>{$link}</li>\n" );
58 $wgOut->addHTML( "</ul>\n" );