Refactored parser output handling slightly, and added a hook function, to allow exten...
[lhc/web/wiklou.git] / includes / SpecialSpecialpages.php
1 <?php
2 /**
3 *
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 /**
9 *
10 */
11 function wfSpecialSpecialpages() {
12 global $wgOut, $wgUser;
13
14 $wgOut->setRobotpolicy( 'index,nofollow' );
15 $sk = $wgUser->getSkin();
16
17 /** Pages available to all */
18 wfSpecialSpecialpages_gen( SpecialPage::getRegularPages(), 'spheading', $sk );
19
20 /** Restricted special pages */
21 wfSpecialSpecialpages_gen( SpecialPage::getRestrictedPages(), 'restrictedpheading', $sk );
22 }
23
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 ???
29 */
30 function wfSpecialSpecialpages_gen($pages,$heading,$sk) {
31 global $wgOut, $wgSortSpecialPages;
32
33 if( count( $pages ) == 0 ) {
34 # Yeah, that was pointless. Thanks for coming.
35 return;
36 }
37
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();
43 }
44 }
45
46 /** Sort */
47 if ( $wgSortSpecialPages ) {
48 ksort( $sortedPages );
49 }
50
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" );
56 }
57 $wgOut->addHTML( "</ul>\n" );
58 }
59
60 ?>