2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
*
|
2004-09-03 23:00:01 +00:00
|
|
|
* @package MediaWiki
|
|
|
|
|
* @subpackage SpecialPage
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function wfSpecialSpecialpages() {
|
2004-10-24 19:14:48 +00:00
|
|
|
global $wgLang, $wgOut, $wgUser, $wgAvailableRights;
|
2004-03-14 01:44:17 +00:00
|
|
|
|
2004-09-17 23:25:35 +00:00
|
|
|
$wgOut->setRobotpolicy( 'index,nofollow' );
|
2004-03-14 01:44:17 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
2004-05-20 14:13:03 +00:00
|
|
|
|
2005-03-20 02:37:08 +00:00
|
|
|
# Get listable pages, in a 2-d array with the first dimension being user right
|
2004-05-20 14:13:03 +00:00
|
|
|
$pages = SpecialPage::getPages();
|
2004-05-15 03:36:39 +00:00
|
|
|
|
2005-03-20 02:37:08 +00:00
|
|
|
/** Pages available to all */
|
2004-10-24 19:14:48 +00:00
|
|
|
wfSpecialSpecialpages_gen($pages[''],'spheading',$sk);
|
|
|
|
|
|
2005-03-20 02:37:08 +00:00
|
|
|
/** Restricted special pages */
|
|
|
|
|
$rpages = array();
|
2004-10-24 19:14:48 +00:00
|
|
|
foreach($wgAvailableRights as $right) {
|
|
|
|
|
/** only show pages a user can access */
|
|
|
|
|
if( $wgUser->isAllowed($right) ) {
|
|
|
|
|
/** some rights might not have any special page associated */
|
|
|
|
|
if(isset($pages[$right])) {
|
2005-03-20 02:37:08 +00:00
|
|
|
$rpages = array_merge( $rpages, $pages[$right] );
|
2004-10-24 19:14:48 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-05-15 03:36:39 +00:00
|
|
|
}
|
2005-03-20 02:37:08 +00:00
|
|
|
wfSpecialSpecialpages_gen( $rpages, 'restrictedpheading', $sk );
|
2004-05-15 03:36:39 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* sub function generating the list of pages
|
|
|
|
|
* @param $pages the list of pages
|
|
|
|
|
* @param $heading header to be used
|
|
|
|
|
* @param $sk skin object ???
|
|
|
|
|
*/
|
|
|
|
|
function wfSpecialSpecialpages_gen($pages,$heading,$sk) {
|
2005-03-20 02:53:23 +00:00
|
|
|
global $wgLang, $wgOut, $wgSortSpecialPages;
|
2004-05-15 03:36:39 +00:00
|
|
|
|
2005-05-02 12:17:28 +00:00
|
|
|
if( count( $pages ) == 0 ) {
|
|
|
|
|
# Yeah, that was pointless. Thanks for coming.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-20 02:37:08 +00:00
|
|
|
/** Put them into a sortable array */
|
|
|
|
|
$sortedPages = array();
|
2004-05-15 03:36:39 +00:00
|
|
|
foreach ( $pages as $name => $page ) {
|
2005-03-20 02:37:08 +00:00
|
|
|
if ( $page->isListed() ) {
|
|
|
|
|
$sortedPages[$page->getDescription()] = $page->getTitle();
|
2004-05-15 03:36:39 +00:00
|
|
|
}
|
2005-03-20 02:37:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Sort */
|
2005-03-20 02:53:23 +00:00
|
|
|
if ( $wgSortSpecialPages ) {
|
|
|
|
|
ksort( $sortedPages );
|
|
|
|
|
}
|
2005-03-20 02:37:08 +00:00
|
|
|
|
|
|
|
|
/** Now output the HTML */
|
|
|
|
|
$wgOut->addHTML( '<h2>' . wfMsg( $heading ) . "</h2>\n<ul>" );
|
|
|
|
|
foreach ( $sortedPages as $desc => $title ) {
|
|
|
|
|
$link = $sk->makeKnownLinkObj( $title, $desc );
|
2004-05-15 03:36:39 +00:00
|
|
|
$wgOut->addHTML( "<li>{$link}</li>\n" );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2004-05-15 03:36:39 +00:00
|
|
|
$wgOut->addHTML( "</ul>\n" );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|