67dc858296319060f7136c8b0f0c1ba2dae4ec29
[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;
13
14 $wgOut->setRobotpolicy( 'index,nofollow' );
15
16 /** Pages available to all */
17 wfSpecialSpecialpages_gen( SpecialPage::getRegularPages(), 'spheading' );
18
19 /** Restricted special pages */
20 wfSpecialSpecialpages_gen( SpecialPage::getRestrictedPages(), 'restrictedpheading' );
21 }
22
23 /**
24 * sub function generating the list of pages
25 * @param $pages the list of pages
26 * @param $heading header to be used
27 */
28 function wfSpecialSpecialpages_gen( $pages, $heading ) {
29 global $wgOut, $wgSortSpecialPages;
30
31 if( count( $pages ) == 0 ) {
32 # Yeah, that was pointless. Thanks for coming.
33 return;
34 }
35
36 /** Put them into a sortable array */
37 $sortedPages = array();
38 foreach ( $pages as $name => $page ) {
39 if ( $page->isListed() ) {
40 $sortedPages[$page->getDescription()] = $page->getTitle();
41 }
42 }
43
44 /** Sort */
45 if ( $wgSortSpecialPages ) {
46 ksort( $sortedPages );
47 }
48
49 /** Now output the HTML */
50 $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n<ul>" );
51 foreach ( $sortedPages as $desc => $title ) {
52 $link = Linker::makeKnownLinkObj( $title, $desc );
53 $wgOut->addHTML( "<li>{$link}</li>\n" );
54 }
55 $wgOut->addHTML( "</ul>\n" );
56 }
57
58 ?>