Deprecating ; reordering the special pages array (whose the special page list is...
[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 # Get listable pages, in a 2-d array with the first dimension being user right
18 $pages = SpecialPage::getPages();
19
20 /** Pages available to all */
21 wfSpecialSpecialpages_gen($pages[''],'spheading',$sk);
22
23 /** Restricted special pages */
24 $rpages = array();
25 foreach ( $pages['restricted'] as $name => $page ) {
26 if( $wgUser->isAllowed( $page->getRestriction() ) ) {
27 $rpages[$name] = $page;
28 }
29 }
30 wfSpecialSpecialpages_gen( $rpages, 'restrictedpheading', $sk );
31 }
32
33 /**
34 * sub function generating the list of pages
35 * @param $pages the list of pages
36 * @param $heading header to be used
37 * @param $sk skin object ???
38 */
39 function wfSpecialSpecialpages_gen($pages,$heading,$sk) {
40 global $wgOut, $wgSortSpecialPages;
41
42 if( count( $pages ) == 0 ) {
43 # Yeah, that was pointless. Thanks for coming.
44 return;
45 }
46
47 /** Put them into a sortable array */
48 $sortedPages = array();
49 foreach ( $pages as $name => $page ) {
50 if ( $page->isListed() ) {
51 $sortedPages[$page->getDescription()] = $page->getTitle();
52 }
53 }
54
55 /** Sort */
56 if ( $wgSortSpecialPages ) {
57 ksort( $sortedPages );
58 }
59
60 /** Now output the HTML */
61 $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n<ul>" );
62 foreach ( $sortedPages as $desc => $title ) {
63 $link = $sk->makeKnownLinkObj( $title, $desc );
64 $wgOut->addHTML( "<li>{$link}</li>\n" );
65 }
66 $wgOut->addHTML( "</ul>\n" );
67 }
68
69 ?>