Making INNER JOIN implicit
[lhc/web/wiklou.git] / includes / SpecialSpecialpages.php
index b23d036..b3a5520 100644 (file)
@@ -12,17 +12,14 @@ function wfSpecialSpecialpages() {
 
        $wgMessageCache->loadAllMessages();
 
-       $wgOut->setRobotpolicy( 'index,nofollow' );
+       $wgOut->setRobotpolicy( 'noindex,nofollow' );  # Is this really needed?
        $sk = $wgUser->getSkin();
 
        /** Pages available to all */
-       wfSpecialSpecialpages_gen( SpecialPage::getRegularPages(), 'spheading', $sk, false );
+       wfSpecialSpecialpages_gen( SpecialPage::getRegularPages(), 'spheading', $sk );
 
        /** Restricted special pages */
-       wfSpecialSpecialpages_gen( SpecialPage::getRestrictedPages(), 'restrictedpheading', $sk, false );
-       
-       /** Restricted logs */
-       wfSpecialSpecialpages_gen( SpecialPage::getRestrictedLogs(), 'restrictedlheading', $sk, true );
+       wfSpecialSpecialpages_gen( SpecialPage::getRestrictedPages(), 'restrictedpheading', $sk );
 }
 
 /**
@@ -30,10 +27,9 @@ function wfSpecialSpecialpages() {
  * @param $pages the list of pages
  * @param $heading header to be used
  * @param $sk skin object ???
- * @param $islog, is this for a list of log types?
  */
-function wfSpecialSpecialpages_gen( $pages, $heading, $sk, $islog=false ) {
-       global $wgOut, $wgUser, $wgSortSpecialPages;
+function wfSpecialSpecialpages_gen($pages,$heading,$sk) {
+       global $wgOut, $wgSortSpecialPages;
 
        if( count( $pages ) == 0 ) {
                # Yeah, that was pointless. Thanks for coming.
@@ -41,29 +37,51 @@ function wfSpecialSpecialpages_gen( $pages, $heading, $sk, $islog=false ) {
        }
 
        /** Put them into a sortable array */
-       $sortedPages = array();
-       if( $islog ) {
-               $sortedPages = $pages;
-       } else {
-               foreach ( $pages as $page ) {
-                       if ( $page->isListed() ) {
-                               $sortedPages[$page->getDescription()] = $page->getTitle();
+       $groups = array();
+       foreach ( $pages as $page ) {
+               if ( $page->isListed() ) {
+                       $group = SpecialPage::getGroup( $page );
+                       if( !isset($groups[$group]) ) {
+                               $groups[$group] = array();
                        }
+                       $groups[$group][$page->getDescription()] = $page->getTitle();
                }
        }
 
        /** Sort */
        if ( $wgSortSpecialPages ) {
-               ksort( $sortedPages );
+               foreach( $groups as $group => $sortedPages ) {
+                       ksort( $groups[$group] );
+               }
        }
 
-       /** Now output the HTML */
-       $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n<ul>" );
-       foreach ( $sortedPages as $desc => $title ) {
-               $link = $sk->makeKnownLinkObj( $title , htmlspecialchars( $desc ) );
-               $wgOut->addHTML( "<li>{$link}</li>\n" );
+       /** Always move "other" to end */
+       if( array_key_exists('other',$groups) ) {
+               $other = $groups['other'];
+               unset( $groups['other'] );
+               $groups['other'] = $other;
        }
-       $wgOut->addHTML( "</ul>\n" );
-}
 
+       /** Now output the HTML */
+       $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n" );
+       foreach ( $groups as $group => $sortedPages ) {
+               $middle = ceil( count($sortedPages)/2 );
+               $total = count($sortedPages);
+               $count = 0;
+
+               $wgOut->addHTML( "<h4 class='mw-specialpagesgroup'>".wfMsgHtml("specialpages-group-$group")."</h4>\n" );
+               $wgOut->addHTML( "<table style='width: 100%;' class='mw-specialpages-table'><tr>" );
+               $wgOut->addHTML( "<td width='30%' valign='top'><ul>\n" );
+               foreach ( $sortedPages as $desc => $title ) {
+                       $link = $sk->makeKnownLinkObj( $title , htmlspecialchars( $desc ) );
+                       $wgOut->addHTML( "<li>{$link}</li>\n" );
 
+                       # Slit up the larger groups
+                       $count++;
+                       if( $total > 3 && $count == $middle ) {
+                               $wgOut->addHTML( "</ul></td><td width='10%'></td><td width='30%' valign='top'><ul>" );
+                       }
+               }
+               $wgOut->addHTML( "</ul></td><td width='30%' valign='top'></td></tr></table>\n" );
+       }
+}