Re-establishing validation feature (the beginnings)
[lhc/web/wiklou.git] / includes / SpecialSpecialpages.php
index 91e6163..677ed31 100644 (file)
@@ -1,43 +1,74 @@
 <?php
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
 
-function wfSpecialSpecialpages()
-{
-       global $wgLang, $wgOut, $wgUser;
+/**
+ *
+ */
+function wfSpecialSpecialpages() {
+       global $wgLang, $wgOut, $wgUser, $wgAvailableRights;
        
-       # sub function generating the list of pages
-       #   $SP      : the list of pages
-       #   $heading : header to be used
-       #   $sk      : skin object ???
+       $wgOut->setRobotpolicy( 'index,nofollow' );
+       $sk = $wgUser->getSkin();       
        
-       function wfSpecialSpecialpages_gen($SP,$heading,$sk)
-       {
-               global $wgLang, $wgOut;
-
-               $wgOut->addHTML( "<h2>" . wfMsg( $heading ) . "</h2>\n<ul>" );
-               foreach ( $SP as $name => $desc ) {
-                       if ( "" == $desc ) { continue; }
-                       $link = $sk->makeKnownLink( $wgLang->specialPage( $name ), $desc );
-                       $wgOut->addHTML( "<li>{$link}</li>\n" );
+       # Get listable pages
+       $pages = SpecialPage::getPages();
+
+       /** pages available to all */
+       wfSpecialSpecialpages_gen($pages[''],'spheading',$sk);
+
+       /** show pages splitted by user rights */
+       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])) {
+                       wfSpecialSpecialpages_gen($pages[$right], $right.'pheading', $sk);
+                       }
                }
-               $wgOut->addHTML( "</ul>\n" );
+       
        }
 
-       $wgOut->setRobotpolicy( "index,nofollow" );
-       $sk = $wgUser->getSkin();       
-
+/** FIXME : spheading, sysopspheading, developerspheading need to be removed
+from language files [av] */
+/**
        # all users special pages
-       wfSpecialSpecialpages_gen($wgLang->getValidSpecialPages(),"spheading",$sk);
+       wfSpecialSpecialpages_gen($pages[''],'spheading',$sk);
 
        # sysops only special pages
        if ( $wgUser->isSysop() ) {
-               wfSpecialSpecialpages_gen($wgLang->getSysopSpecialPages(),"sysopspheading",$sk);
+               wfSpecialSpecialpages_gen($pages['sysop'],'sysopspheading',$sk);
        }
 
        # developers only special pages
        if ( $wgUser->isDeveloper() ) {
-               wfSpecialSpecialpages_gen($wgLang->getDeveloperSpecialPages(),"developerspheading",$sk);
+               wfSpecialSpecialpages_gen($pages['developer'],'developerspheading',$sk);
 
        }
+*/
+}
+
+/**
+ * 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 $wgLang, $wgOut;
+
+       $wgOut->addHTML( '<h2>' . wfMsg( $heading ) . "</h2>\n<ul>" );
+       foreach ( $pages as $name => $page ) {
+               if( !$page->isListed() ) {
+                       continue;
+               }
+               $link = $sk->makeKnownLinkObj( $page->getTitle(), $page->getDescription() );
+               $wgOut->addHTML( "<li>{$link}</li>\n" );
+       }
+       $wgOut->addHTML( "</ul>\n" );
 }
 
 ?>