From 6d9cc5fb78f36921c5299e026e9dadd56115ca65 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Sun, 1 Jun 2008 04:27:47 +0000 Subject: [PATCH] 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. --- RELEASE-NOTES | 3 ++ includes/SpecialPage.php | 30 ++++++++++++++- includes/SpecialSpecialpages.php | 63 ++++++++++++------------------- languages/messages/MessagesEn.php | 1 + skins/common/shared.css | 47 ++++++++++++++++++++++- 5 files changed, 102 insertions(+), 42 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8fee2e04f9..3950f1da20 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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
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 === diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 7cb791abcd..d558e8e2ac 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -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; } diff --git a/includes/SpecialSpecialpages.php b/includes/SpecialSpecialpages.php index 34095dfb1f..3179577245 100644 --- a/includes/SpecialSpecialpages.php +++ b/includes/SpecialSpecialpages.php @@ -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( '

' . wfMsgHtml( $heading ) . "

\n" ); + $restrictedPages = false; foreach ( $groups as $group => $sortedPages ) { - $middle = ceil( count($sortedPages)/2 ); - $total = count($sortedPages); - $count = 0; - $wgOut->addHTML( "

".wfMsgHtml("specialpages-group-$group")."

\n" ); - $wgOut->addHTML( "" ); - $wgOut->addHTML( "
    \n" ); - foreach ( $sortedPages as $desc => $title ) { + $wgOut->addHTML( "
      " ); + foreach ( $sortedPages as $desc => $specialpage ) { + list( $title, $restricted ) = $specialpage; $link = $sk->makeKnownLinkObj( $title , htmlspecialchars( $desc ) ); - $wgOut->addHTML( "
    • {$link}
    • \n" ); - - # Slit up the larger groups - $count++; - if( $total > 3 && $count == $middle ) { - $wgOut->addHTML( "
    " ); + if( $restricted ) { + $wgOut->addHTML( "
  • {$link}
  • \n" ); + $restrictedPages = true; + } else { + $wgOut->addHTML( "
  • {$link}
  • \n" ); } } - $wgOut->addHTML( "
\n" ); + $wgOut->addHTML( "\n" ); } -} + $wgOut->addHTML( + Xml::openElement('div', array( 'class' => 'mw-specialpages-notes' )). + wfMsgWikiHtml('specialpages-note'). + Xml::closeElement('div') + ); + +} \ No newline at end of file diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index b543461502..4de79b7862 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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' => "
\n* Highlighted special pages are restricted.", 'specialpages-group-maintenance' => 'Maintenance reports', 'specialpages-group-other' => 'Other special pages', 'specialpages-group-login' => 'Login / sign up', diff --git a/skins/common/shared.css b/skins/common/shared.css index 5aa8bfec33..d9cea3f625 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -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; } -- 2.20.1