r35670 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35669‎ | r35670 | r35671 >
Date:04:27, 1 June 2008
Author:dantman
Status:old
Tags:
Comment:
Changing the UI for [[Special:Specialpages]].
* 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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)
  • /trunk/phase3/includes/SpecialSpecialpages.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/skins/common/shared.css (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/shared.css
@@ -236,11 +236,54 @@
237237
238238 /* Special:SpecialPages styling */
239239 h4.mw-specialpagesgroup {
 240+ padding: 2px;
240241 background-color: #dcdcdc;
241 - padding: 2px;
242 - margin: .3em 0em 0em 0em;
 242+ margin: .3em 0em 0em;
 243+ clear: both;
243244 }
 245+.mw-specialpages-section {
 246+ display: block;
 247+ width: 100%;
 248+ clear: both;
 249+}
 250+/*.mw-specialpages-column {
 251+ margin: 0em 0em .5em;
 252+ float: left;
 253+}*/
 254+.mw-specialpages-page {
 255+ float: left;
 256+ width: 275px;
 257+ margin: 0em .3em .3em;
 258+}
244259
 260+.mw-specialpagerestricted {
 261+ font-weight: bold;
 262+}
 263+
 264+/*.mw-restrictedicon {
 265+ position: relative;
 266+ top: -5px;
 267+ font-style: italic;
 268+ color: #777777;
 269+float: right;
 270+ font-size: .75em;
 271+}*/
 272+.mw-specialpages-notes {
 273+ clear: both;
 274+}
 275+/*.mw-specialpagenotes {
 276+ clear: both;
 277+}*/
 278+/*.mw-specialpagenote {
 279+ display: block;
 280+}
 281+.mw-specialpagenote-symbol {
 282+ float: left;
 283+}
 284+.mw-specialpagenote-text {
 285+ font-style: italic;
 286+}*/
 287+
245288 #shared-image-dup, #shared-image-conflict {
246289 font-style: italic;
247290 }
Index: trunk/phase3/includes/SpecialSpecialpages.php
@@ -8,34 +8,20 @@
99 *
1010 */
1111 function wfSpecialSpecialpages() {
12 - global $wgOut, $wgUser, $wgMessageCache;
 12+ global $wgOut, $wgUser, $wgMessageCache, $wgSortSpecialPages;
1313
1414 $wgMessageCache->loadAllMessages();
1515
1616 $wgOut->setRobotpolicy( 'noindex,nofollow' ); # Is this really needed?
1717 $sk = $wgUser->getSkin();
1818
19 - /** Pages available to all */
20 - wfSpecialSpecialpages_gen( SpecialPage::getRegularPages(), 'spheading', $sk );
21 -
22 - /** Restricted special pages */
23 - wfSpecialSpecialpages_gen( SpecialPage::getRestrictedPages(), 'restrictedpheading', $sk );
24 -}
25 -
26 -/**
27 - * sub function generating the list of pages
28 - * @param $pages the list of pages
29 - * @param $heading header to be used
30 - * @param $sk skin object ???
31 - */
32 -function wfSpecialSpecialpages_gen($pages,$heading,$sk) {
33 - global $wgOut, $wgSortSpecialPages;
34 -
 19+ $pages = SpecialPage::getUsablePages();
 20+
3521 if( count( $pages ) == 0 ) {
3622 # Yeah, that was pointless. Thanks for coming.
3723 return;
3824 }
39 -
 25+
4026 /** Put them into a sortable array */
4127 $groups = array();
4228 foreach ( $pages as $page ) {
@@ -44,44 +30,45 @@
4531 if( !isset($groups[$group]) ) {
4632 $groups[$group] = array();
4733 }
48 - $groups[$group][$page->getDescription()] = $page->getTitle();
 34+ $groups[$group][$page->getDescription()] = array( $page->getTitle(), $page->isRestricted() );
4935 }
5036 }
51 -
 37+
5238 /** Sort */
5339 if ( $wgSortSpecialPages ) {
5440 foreach( $groups as $group => $sortedPages ) {
5541 ksort( $groups[$group] );
5642 }
5743 }
58 -
 44+
5945 /** Always move "other" to end */
6046 if( array_key_exists('other',$groups) ) {
6147 $other = $groups['other'];
6248 unset( $groups['other'] );
6349 $groups['other'] = $other;
6450 }
65 -
 51+
6652 /** Now output the HTML */
67 - $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n" );
 53+ $restrictedPages = false;
6854 foreach ( $groups as $group => $sortedPages ) {
69 - $middle = ceil( count($sortedPages)/2 );
70 - $total = count($sortedPages);
71 - $count = 0;
72 -
7355 $wgOut->addHTML( "<h4 class='mw-specialpagesgroup'>".wfMsgHtml("specialpages-group-$group")."</h4>\n" );
74 - $wgOut->addHTML( "<table style='width: 100%;' class='mw-specialpages-table'><tr>" );
75 - $wgOut->addHTML( "<td width='30%' valign='top'><ul>\n" );
76 - foreach ( $sortedPages as $desc => $title ) {
 56+ $wgOut->addHTML( "<ul class='mw-specialpages-section'>" );
 57+ foreach ( $sortedPages as $desc => $specialpage ) {
 58+ list( $title, $restricted ) = $specialpage;
7759 $link = $sk->makeKnownLinkObj( $title , htmlspecialchars( $desc ) );
78 - $wgOut->addHTML( "<li>{$link}</li>\n" );
79 -
80 - # Slit up the larger groups
81 - $count++;
82 - if( $total > 3 && $count == $middle ) {
83 - $wgOut->addHTML( "</ul></td><td width='10%'></td><td width='30%' valign='top'><ul>" );
 60+ if( $restricted ) {
 61+ $wgOut->addHTML( "<li class='mw-specialpages-page mw-specialpagerestricted'>{$link}</li>\n" );
 62+ $restrictedPages = true;
 63+ } else {
 64+ $wgOut->addHTML( "<li class='mw-specialpages-page'>{$link}</li>\n" );
8465 }
8566 }
86 - $wgOut->addHTML( "</ul></td><td width='30%' valign='top'></td></tr></table>\n" );
 67+ $wgOut->addHTML( "</ul>\n" );
8768 }
88 -}
 69+ $wgOut->addHTML(
 70+ Xml::openElement('div', array( 'class' => 'mw-specialpages-notes' )).
 71+ wfMsgWikiHtml('specialpages-note').
 72+ Xml::closeElement('div')
 73+ );
 74+
 75+}
\ No newline at end of file
Index: trunk/phase3/includes/SpecialPage.php
@@ -375,6 +375,32 @@
376376 }
377377
378378 /**
 379+ * Return categorised listable special pages which are available
 380+ * for the current user, and everyone.
 381+ * @static
 382+ */
 383+ static function getUsablePages() {
 384+ global $wgUser;
 385+ if ( !self::$mListInitialised ) {
 386+ self::initList();
 387+ }
 388+ $pages = array();
 389+
 390+ foreach ( self::$mList as $name => $rec ) {
 391+ $page = self::getPage( $name );
 392+ if ( $page->isListed()
 393+ && (
 394+ !$page->isRestricted()
 395+ || $page->userCanExecute( $wgUser )
 396+ )
 397+ ) {
 398+ $pages[$name] = $page;
 399+ }
 400+ }
 401+ return $pages;
 402+ }
 403+
 404+ /**
379405 * Return categorised listable special pages for all users
380406 * @static
381407 */
@@ -409,8 +435,8 @@
410436 $page = self::getPage( $name );
411437 if (
412438 $page->isListed()
413 - and $page->isRestricted()
414 - and $page->userCanExecute( $wgUser )
 439+ && $page->isRestricted()
 440+ && $page->userCanExecute( $wgUser )
415441 ) {
416442 $pages[$name] = $page;
417443 }
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -3392,6 +3392,7 @@
33933393 'fileduplicatesearch-result-n' => 'The file "$1" has {{PLURAL:$2|1 identical duplication|$2 identical duplications}}.',
33943394
33953395 # Special:SpecialPages
 3396+'specialpages-note' => "<hr>\n* <span class=\"mw-specialpagerestricted\">Highlighted</span> special pages are restricted.",
33963397 'specialpages-group-maintenance' => 'Maintenance reports',
33973398 'specialpages-group-other' => 'Other special pages',
33983399 'specialpages-group-login' => 'Login / sign up',
Index: trunk/phase3/RELEASE-NOTES
@@ -128,6 +128,9 @@
129129 'import-upload' instead of 'upload'
130130 * Add information about user group membership to Special:Preferences
131131 * (bug 14146) Wrap usage section on imagepages into <div>s.
 132+* New layout for Special:Specialpages. Restricted pages are marked but not separated
 133+ from other pages in their group. And the page uses css rather than tables to create
 134+ a column layout which grades well in all sizes of browsers.
132135
133136 === Bug fixes in 1.13 ===
134137

Follow-up revisions

RevisionCommit summaryAuthorDate
r35679Per r35670: Bump $wgStyleVersionialex16:13, 1 June 2008

Status & tagging log