(bug 7098) Add an option to disable/enable sending of HTTP ETag headers,
[lhc/web/wiklou.git] / includes / SpecialSpecialpages.php
index 094ae61..6a01cd0 100644 (file)
@@ -1,55 +1,57 @@
 <?php
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
+
+/**
+ *
+ */
+function wfSpecialSpecialpages() {
+       global $wgOut, $wgUser;
+
+       $wgOut->setRobotpolicy( 'index,nofollow' );
+       $sk = $wgUser->getSkin();
+
+       /** Pages available to all */
+       wfSpecialSpecialpages_gen( SpecialPage::getRegularPages(), 'spheading', $sk );
+
+       /** Restricted special pages */
+       wfSpecialSpecialpages_gen( SpecialPage::getRestrictedPages(), 'restrictedpheading', $sk );
+}
 
-function wfSpecialSpecialpages()
-{
-       global $wgLang, $wgOut, $wgUser, $wgSpecialPages;
-       
-       $wgOut->setRobotpolicy( "index,nofollow" );
-       $sk = $wgUser->getSkin();       
-
-       # Categorise special pages
-
-       $pages = array(
-         "" => array(),
-         "sysop" => array(),
-         "developer" => array()
-       );
-
-       foreach ( $wgSpecialPages as $page ) {
-               $pages[$page->getRestriction()][$page->getName()] = $page;
+/**
+ * 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) {
+       global $wgOut, $wgSortSpecialPages;
+
+       if( count( $pages ) == 0 ) {
+               # Yeah, that was pointless. Thanks for coming.
+               return;
        }
 
-
-       # all users special pages
-       wfSpecialSpecialpages_gen($pages[""],"spheading",$sk);
-
-       # sysops only special pages
-       if ( $wgUser->isSysop() ) {
-               wfSpecialSpecialpages_gen($pages["sysop"],"sysopspheading",$sk);
+       /** Put them into a sortable array */
+       $sortedPages = array();
+       foreach ( $pages as $name => $page ) {
+               if ( $page->isListed() ) {
+                       $sortedPages[$page->getDescription()] = $page->getTitle();
+               }
        }
 
-       # developers only special pages
-       if ( $wgUser->isDeveloper() ) {
-               wfSpecialSpecialpages_gen($pages["developer"],"developerspheading",$sk);
-
+       /** Sort */
+       if ( $wgSortSpecialPages ) {
+               ksort( $sortedPages );
        }
-}
-
-# sub function generating the list of pages
-#   $pages   : the list of pages
-#   $heading : header to be used
-#   $sk      : skin object ???
 
-function wfSpecialSpecialpages_gen($pages,$heading,$sk)
-{
-       global $wgLang, $wgOut, $wgAllowSysopQueries;
-
-       $wgOut->addHTML( "<h2>" . wfMsg( $heading ) . "</h2>\n<ul>" );
-       foreach ( $pages as $name => $page ) {
-               if( !$page->isListed() ) {
-                       continue;
-               }
-               $link = $sk->makeKnownLinkObj( $page->getTitle(), $page->getDescription() );
+       /** Now output the HTML */
+       $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n<ul>" );
+       foreach ( $sortedPages as $desc => $title ) {
+               $link = $sk->makeKnownLinkObj( $title, $desc );
                $wgOut->addHTML( "<li>{$link}</li>\n" );
        }
        $wgOut->addHTML( "</ul>\n" );