* (bug 14258, 14368) Fix for subpage renames in replication environments
[lhc/web/wiklou.git] / includes / SpecialSpecialpages.php
1 <?php
2 /**
3 * @file
4 * @ingroup SpecialPage
5 */
6
7 /**
8 *
9 */
10 function wfSpecialSpecialpages() {
11 global $wgOut, $wgUser, $wgMessageCache, $wgSortSpecialPages;
12
13 $wgMessageCache->loadAllMessages();
14
15 $wgOut->setRobotpolicy( 'noindex,nofollow' ); # Is this really needed?
16 $sk = $wgUser->getSkin();
17
18 $pages = SpecialPage::getUsablePages();
19
20 if( count( $pages ) == 0 ) {
21 # Yeah, that was pointless. Thanks for coming.
22 return;
23 }
24
25 /** Put them into a sortable array */
26 $groups = array();
27 foreach ( $pages as $page ) {
28 if ( $page->isListed() ) {
29 $group = SpecialPage::getGroup( $page );
30 if( !isset($groups[$group]) ) {
31 $groups[$group] = array();
32 }
33 $groups[$group][$page->getDescription()] = array( $page->getTitle(), $page->isRestricted() );
34 }
35 }
36
37 /** Sort */
38 if ( $wgSortSpecialPages ) {
39 foreach( $groups as $group => $sortedPages ) {
40 ksort( $groups[$group] );
41 }
42 }
43
44 /** Always move "other" to end */
45 if( array_key_exists('other',$groups) ) {
46 $other = $groups['other'];
47 unset( $groups['other'] );
48 $groups['other'] = $other;
49 }
50
51 /** Now output the HTML */
52 $restrictedPages = false;
53 foreach ( $groups as $group => $sortedPages ) {
54 $wgOut->addHTML( "<h4 class='mw-specialpagesgroup'>".wfMsgHtml("specialpages-group-$group")."</h4>\n" );
55 $wgOut->addHTML( "<ul class='mw-specialpages-section'>" );
56 foreach ( $sortedPages as $desc => $specialpage ) {
57 list( $title, $restricted ) = $specialpage;
58 $link = $sk->makeKnownLinkObj( $title , htmlspecialchars( $desc ) );
59 if( $restricted ) {
60 $wgOut->addHTML( "<li class='mw-specialpages-page mw-specialpagerestricted'>{$link}</li>\n" );
61 $restrictedPages = true;
62 } else {
63 $wgOut->addHTML( "<li class='mw-specialpages-page'>{$link}</li>\n" );
64 }
65 }
66 $wgOut->addHTML( "</ul>\n" );
67 }
68 $wgOut->addHTML(
69 Xml::openElement('div', array( 'class' => 'mw-specialpages-notes' )).
70 wfMsgWikiHtml('specialpages-note').
71 Xml::closeElement('div')
72 );
73
74 }