Changing the UI for [[Special:Specialpages]].
authorDaniel Friesen <dantman@users.mediawiki.org>
Sun, 1 Jun 2008 04:27:47 +0000 (04:27 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Sun, 1 Jun 2008 04:27:47 +0000 (04:27 +0000)
* Restricted pages are now with the normal pages (Special pages of a group are grouped together rather than split up on whether they are restricted or not [which does not matter to the user since they can use the page anyways])
* Restricted pages are still marked so the user can identify them. (CSS Class allows this behavior to be customized, default is to bold the link)
* New layout change. Rather than a poor table based column layout, using a dynamic CSS based one. This one uses floats and list items. With CSS disabled you get a single list. In 800x640px you get 2 columns, in 1042x860px you still get two columns, and in large screens like my 1280x1240px you get 3 columns. (770px width and below you get a single column) so this scales well no matter what screen size you have.

RELEASE-NOTES
includes/SpecialPage.php
includes/SpecialSpecialpages.php
languages/messages/MessagesEn.php
skins/common/shared.css

index 8fee2e0..3950f1d 100644 (file)
@@ -128,6 +128,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   'import-upload' instead of 'upload'
 * Add information about user group membership to Special:Preferences
 * (bug 14146) Wrap usage section on imagepages into <div>s.
+* New layout for Special:Specialpages. Restricted pages are marked but not separated
+  from other pages in their group. And the page uses css rather than tables to create
+  a column layout which grades well in all sizes of browsers.
 
 === Bug fixes in 1.13 ===
 
index 7cb791a..d558e8e 100644 (file)
@@ -374,6 +374,32 @@ class SpecialPage
                }
        }
 
+       /**
+        * Return categorised listable special pages which are available
+        * for the current user, and everyone.
+        * @static
+        */
+       static function getUsablePages() {
+               global $wgUser;
+               if ( !self::$mListInitialised ) {
+                       self::initList();
+               }
+               $pages = array();
+
+               foreach ( self::$mList as $name => $rec ) {
+                       $page = self::getPage( $name );
+                       if ( $page->isListed()
+                               && (
+                                       !$page->isRestricted()
+                                       || $page->userCanExecute( $wgUser )
+                               )
+                       ) {
+                               $pages[$name] = $page;
+                       }
+               }
+               return $pages;
+       }
+
        /**
         * Return categorised listable special pages for all users
         * @static
@@ -409,8 +435,8 @@ class SpecialPage
                        $page = self::getPage( $name );
                        if (
                                $page->isListed()
-                               and $page->isRestricted()
-                               and $page->userCanExecute( $wgUser )
+                               && $page->isRestricted()
+                               && $page->userCanExecute( $wgUser )
                        ) {
                                $pages[$name] = $page;
                        }
index 34095df..3179577 100644 (file)
@@ -8,34 +8,20 @@
  *
  */
 function wfSpecialSpecialpages() {
-       global $wgOut, $wgUser, $wgMessageCache;
+       global $wgOut, $wgUser, $wgMessageCache, $wgSortSpecialPages;
 
        $wgMessageCache->loadAllMessages();
 
        $wgOut->setRobotpolicy( 'noindex,nofollow' );  # Is this really needed?
        $sk = $wgUser->getSkin();
 
-       /** Pages available to all */
-       wfSpecialSpecialpages_gen( SpecialPage::getRegularPages(), 'spheading', $sk );
-
-       /** Restricted special pages */
-       wfSpecialSpecialpages_gen( SpecialPage::getRestrictedPages(), 'restrictedpheading', $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 $wgOut, $wgSortSpecialPages;
-
+       $pages = SpecialPage::getUsablePages();
+       
        if( count( $pages ) == 0 ) {
                # Yeah, that was pointless. Thanks for coming.
                return;
        }
-
+       
        /** Put them into a sortable array */
        $groups = array();
        foreach ( $pages as $page ) {
@@ -44,44 +30,45 @@ function wfSpecialSpecialpages_gen($pages,$heading,$sk) {
                        if( !isset($groups[$group]) ) {
                                $groups[$group] = array();
                        }
-                       $groups[$group][$page->getDescription()] = $page->getTitle();
+                       $groups[$group][$page->getDescription()] = array( $page->getTitle(), $page->isRestricted() );
                }
        }
-
+       
        /** Sort */
        if ( $wgSortSpecialPages ) {
                foreach( $groups as $group => $sortedPages ) {
                        ksort( $groups[$group] );
                }
        }
-
+       
        /** Always move "other" to end */
        if( array_key_exists('other',$groups) ) {
                $other = $groups['other'];
                unset( $groups['other'] );
                $groups['other'] = $other;
        }
-
+       
        /** Now output the HTML */
-       $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n" );
+       $restrictedPages = false;
        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 ) {
+               $wgOut->addHTML( "<ul class='mw-specialpages-section'>" );
+               foreach ( $sortedPages as $desc => $specialpage ) {
+                       list( $title, $restricted ) = $specialpage;
                        $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>" );
+                       if( $restricted ) {
+                               $wgOut->addHTML( "<li class='mw-specialpages-page mw-specialpagerestricted'>{$link}</li>\n" );
+                               $restrictedPages = true;
+                       } else {
+                               $wgOut->addHTML( "<li class='mw-specialpages-page'>{$link}</li>\n" );
                        }
                }
-               $wgOut->addHTML( "</ul></td><td width='30%' valign='top'></td></tr></table>\n" );
+               $wgOut->addHTML( "</ul>\n" );
        }
-}
+       $wgOut->addHTML(
+               Xml::openElement('div', array( 'class' => 'mw-specialpages-notes' )).
+               wfMsgWikiHtml('specialpages-note').
+               Xml::closeElement('div')
+       );
+       
+}
\ No newline at end of file
index b543461..4de79b7 100644 (file)
@@ -3392,6 +3392,7 @@ Enter the filename without the "{{ns:image}}:" prefix.',
 'fileduplicatesearch-result-n' => 'The file "$1" has {{PLURAL:$2|1 identical duplication|$2 identical duplications}}.',
 
 # Special:SpecialPages
+'specialpages-note'              => "<hr>\n* <span class=\"mw-specialpagerestricted\">Highlighted</span> special pages are restricted.",
 'specialpages-group-maintenance' => 'Maintenance reports',
 'specialpages-group-other'       => 'Other special pages',
 'specialpages-group-login'       => 'Login / sign up',
index 5aa8bfe..d9cea3f 100644 (file)
@@ -236,11 +236,54 @@ table.mw-listgrouprights-table td, table.mw-listgrouprights-table th {
 
 /* Special:SpecialPages styling */
 h4.mw-specialpagesgroup {
-       background-color: #dcdcdc;
        padding: 2px;
-       margin: .3em 0em 0em 0em;
+       background-color: #dcdcdc;
+       margin: .3em 0em 0em;
+       clear: both;
+}
+.mw-specialpages-section {
+       display: block;
+       width: 100%;
+       clear: both;
+}
+/*.mw-specialpages-column {
+       margin: 0em 0em .5em;
+       float: left;
+}*/
+.mw-specialpages-page {
+       float: left;
+       width: 275px;
+       margin: 0em .3em .3em;
 }
 
+.mw-specialpagerestricted {
+       font-weight: bold;
+}
+
+/*.mw-restrictedicon {
+       position: relative;
+       top: -5px;
+       font-style: italic;
+       color: #777777;
+float: right;
+       font-size: .75em;
+}*/
+.mw-specialpages-notes {
+       clear: both;
+}
+/*.mw-specialpagenotes {
+       clear: both;
+}*/
+/*.mw-specialpagenote {
+       display: block;
+}
+.mw-specialpagenote-symbol {
+       float: left;
+}
+.mw-specialpagenote-text {
+       font-style: italic;
+}*/
+
 #shared-image-dup, #shared-image-conflict {
        font-style: italic;
 }